Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add args to tree #1112

Merged
merged 20 commits into from
Feb 5, 2020
Merged

Add args to tree #1112

merged 20 commits into from
Feb 5, 2020

Conversation

RobbieTheWagner
Copy link
Member

Rebasing seemed hard, so opening a new PR

Rebasing seemed hard, so opening a new PR
Co-Authored-By: Jerry Nummi <jnummi@gmail.com>
This was referenced Dec 19, 2019
@RobbieTheWagner
Copy link
Member Author

@chancancode @nummi there were a lot of conflicts since the big PR was merged, so I cherry picked our commits into this new PR. Please take a look!

app/controllers/component-tree.js Outdated Show resolved Hide resolved
app/helpers/component-argument.js Outdated Show resolved Hide resolved
app/styles/component_tree.scss Show resolved Hide resolved
app/styles/component_tree.scss Show resolved Hide resolved
app/templates/components/component-tree-item.hbs Outdated Show resolved Hide resolved
app/templates/components/component-tree-item.hbs Outdated Show resolved Hide resolved
app/templates/components/component-tree-item.hbs Outdated Show resolved Hide resolved
app/templates/components/component-tree-item.hbs Outdated Show resolved Hide resolved
app/templates/components/component-tree-item.hbs Outdated Show resolved Hide resolved
@chancancode
Copy link
Member

chancancode commented Dec 19, 2019

I left some review comments, but I think the main issue is still the horizontal scrolling CSS issues? (scrolling breaks the row highlight/closing tag/buttons)

See https://discordapp.com/channels/480462759797063690/486243207072710656/654839741384228888

RobbieTheWagner and others added 3 commits December 19, 2019 18:01
Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>
Co-Authored-By: Jerry Nummi <jnummi@gmail.com>
@nummi
Copy link
Collaborator

nummi commented Dec 20, 2019

I left some review comments, but I think the main issue is still the horizontal scrolling CSS issues?

I don't know if we'll fix this before the next release. It has been an issue for a while and I'm afraid the fix will require some big changes to the markup and/or the CSS.

@chancancode
Copy link
Member

@nummi I don't think the problem is specific to our setup here, you can reproduce it with a pretty minimal html/css file:

<style>
.scrollable {
  overflow: scroll;
  width: 100%;
  height: 100%;
}

.row {
  background-color: lightgrey;
  height: 50px;
}

.row:nth-child(2n) {
  background-color: lightslategrey;
}
</style>

<div class="scrollable">
  <div class="row"></div><div class="row"></div><div class="row"></div><div class="row"></div><div class="row"></div><div class="row"></div><div class="row"></div><div class="row"></div><div class="row"></div><div class="row"></div>

  <div class="row" style="width: 5000px"></div>

  <div class="row"></div><div class="row"></div><div class="row"></div><div class="row"></div><div class="row"></div><div class="row"></div><div class="row"></div><div class="row"></div><div class="row"></div><div class="row"></div>
</div>

I think we may have to switch to flexbox, or perhaps there is some other CSS Trick™ that would make it work here, but I'm pretty sure we can make something work. Since it's a pretty major new feature, it's okay for it to take a bit longer (the 3.13.0 release already went out yesterday, so it's not a blocker), but we should find a way to introduce it without introducing a regression.

@RobbieTheWagner
Copy link
Member Author

@chancancode I was talking to @nummi earlier and I think we should move the action icons into the object inspector. That would solve the issue of them being off the screen.

@RobbieTheWagner
Copy link
Member Author

@chancancode I believe I resolved all the things you requested. Mind taking another look? I think we should get this in, and then have @nummi help us move the icons to the object inspector, so people do not have to scroll to see them.

@nummi
Copy link
Collaborator

nummi commented Jan 8, 2020

image

@nummi
Copy link
Collaborator

nummi commented Jan 9, 2020

2020-01-09 12 53 50

@RobbieTheWagner
Copy link
Member Author

Nice work @nummi!

@nummi
Copy link
Collaborator

nummi commented Jan 9, 2020

#1129

nummi and others added 3 commits January 11, 2020 19:25
* Fix component list overflow background color

* Gradient on component-tree-item actions
Copy link
Collaborator

@nummi nummi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from my end. UI works well on light and dark modes; scrolling issue is fixed; args in Glimmer components and no args on classic.

Copy link
Member

@chancancode chancancode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good! A few more things to fix then I think we are golden

app/controllers/component-tree.js Outdated Show resolved Hide resolved
{{if @item.isComponent "component-tree-item--component"}}
{{if @item.hasInstance "component-tree-item--has-instance"}}
{{if @item.isSelected "component-tree-item--selected"}}
{{if @item.isHighlighted "component-tree-item--highlighted"}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this removed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I could tell that was being used for the hover state. See: https://github.com/emberjs/ember-inspector/pull/1129/files#diff-cbd2aa0d940eef1f44430e6ca030fbd9L8

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the original PR: #984

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Yeah that changed in Octane. It is now used to highlight the "currently previewing component". IMO the previous behavior is not that useful, since you can already see the parent/child relationship from the nesting.

There are two ways to "preview" a component, by hovering the rows in the component tree or by using the "live inspection" feature and hover over the DOM elements on the page:

highlight

Using CSS hover state only solves the first part and I think we still need this for the latter.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooooh. I see. I'll have to revert that.

app/templates/components/component-tree-item.hbs Outdated Show resolved Hide resolved
@chancancode
Copy link
Member

args in Glimmer components and no args on classic

@nummi are you testing both on the same app? I think we expect args to show up for both, assuming you have a recent enough version of ember-source. So if it's not showing up for classic components, there may be a bug.

@nummi
Copy link
Collaborator

nummi commented Jan 16, 2020

@nummi are you testing both on the same app? I think we expect args to show up for both, assuming you have a recent enough version of ember-source. So if it's not showing up for classic components, there may be a bug.

I am not. The classic app I tested in is deprecations.emberjs.com and the Glimmer app is ember-source: 3.15.0

RobbieTheWagner and others added 2 commits January 16, 2020 16:09
Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>
Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>
@chancancode
Copy link
Member

chancancode commented Jan 16, 2020

@nummi 👌 that's fine then. if you have any classic components in the 3.15 app, they would/should also show up with args.

Another thing I noticed is sometimes the strings passed to the components can be very long (like an entire blog post). Do we want to come up with a reasonable limit and truncate the rest with ...? (The component-argument can handle this pretty naturally.)

@RobbieTheWagner
Copy link
Member Author

@chancancode coming up with a limit sounds good.

@nummi
Copy link
Collaborator

nummi commented Jan 17, 2020

#1135

@chancancode
Copy link
Member

@chancancode coming up with a limit sounds good.

Feel free to steal this:

function truncate(str, limit = 20, rest = "...") {
  if (str.length <= limit) {
    return str;
  }

  if (rest.length >= limit) {
    throw new Error("rest cannot be longer than limit");
  }

  let parts = str.split(/(\s+|\b)/); // split by whitespace or word boundaries
  let selected = []; // the parts to keep
  let targetLength = limit - rest.length; // leave room for the "..."
  let currentLength = 0;

  while (true) {
    let candidate = parts.shift();

    if ((currentLength + candidate.length) <= targetLength) {
      selected.push(candidate);
      currentLength += candidate.length;
    } else {
      if (currentLength === 0) {
        // We have no choice but to break in the middle of a long word
        selected.push(candidate.slice(0, targetLength));
      }

      break;
    }
  }

  selected.push(rest);

  return selected.join("")
}

It ensures the resulting string (including the "..." if added) is shorter than the given limit, but try to break at word boundaries or whitespaces when possible:

> truncate("It ensures the resulting string (including the \"...\" if added) is shorter than the given limit, but try to break at word boundaries or whitespaces when possible:", 999)
"It ensures the resulting string (including the "..." if added) is shorter than the given limit, but try to break at word boundaries or whitespaces when possible:"

> truncate("It ensures the resulting string (including the \"...\" if added) is shorter than the given limit, but try to break at word boundaries or whitespaces when possible:", 100)
"It ensures the resulting string (including the "..." if added) is shorter than the given limit, ..."

> truncate("It ensures the resulting string (including the \"...\" if added) is shorter than the given limit, but try to break at word boundaries or whitespaces when possible:", 50)
"It ensures the resulting string (including the ..."

> truncate("It ensures the resulting string (including the \"...\" if added) is shorter than the given limit, but try to break at word boundaries or whitespaces when possible:", 20)
"It ensures the ..."

> truncate("It ensures the resulting string (including the \"...\" if added) is shorter than the given limit, but try to break at word boundaries or whitespaces when possible:", 10)
"It ..."

With this style the truncation, I find that 20 seems to be a pretty reasonable default (it will often be much shorter than that depending the length of the word that happen to sit at the boundary).

@nummi
Copy link
Collaborator

nummi commented Jan 17, 2020

Any chance we could use an ellipsis in place of three periods? "…"

With a monospaced font:
three periods: ...
ellipsis:

@chancancode
Copy link
Member

chancancode commented Jan 17, 2020

Sounds good to me. The algorithm should work just as well

nummi and others added 2 commits January 17, 2020 11:32
* Bring back hover highlight in component tree

* Update comment in app/styles/component_tree.scss

Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>

Co-authored-by: Godfrey Chan <godfreykfc@gmail.com>
@RobbieTheWagner
Copy link
Member Author

@chancancode I just pushed up the truncate and the adding quotes you requested. I was unable to test out the positional params because it seems like the renderNode is coming back with named args only, not positional ones, even when I use {{set-body-class this.theme}}

@chancancode chancancode merged commit f5e05a4 into master Feb 5, 2020
@chancancode chancancode deleted the add-args-2 branch February 5, 2020 00:22
nummi added a commit to nummi/ember-inspector that referenced this pull request Apr 1, 2020
* Add args to tree

Rebasing seemed hard, so opening a new PR

* Adjust component tree colors

Co-Authored-By: Jerry Nummi <jnummi@gmail.com>

* Update app/helpers/component-argument.js

Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>

* Remove at-token

Co-Authored-By: Jerry Nummi <jnummi@gmail.com>

* Use suggested class ifs

* Apply changes based on feedback

* Fix lint

* Fix component list overflow (emberjs#1129)

* Fix component list overflow background color

* Gradient on component-tree-item actions

* Update app/controllers/component-tree.js

Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>

* Update app/templates/components/component-tree-item.hbs

Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>

* Bring back hover highlight in component tree (emberjs#1135)

* Bring back hover highlight in component tree

* Update comment in app/styles/component_tree.scss

Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>

Co-authored-by: Godfrey Chan <godfreykfc@gmail.com>

* Truncate, add quotes

* Update truncate.js

Co-authored-by: Jerry Nummi <nummi@users.noreply.github.com>
Co-authored-by: Godfrey Chan <godfreykfc@gmail.com>
nummi added a commit to nummi/ember-inspector that referenced this pull request Apr 5, 2020
* Add args to tree

Rebasing seemed hard, so opening a new PR

* Adjust component tree colors

Co-Authored-By: Jerry Nummi <jnummi@gmail.com>

* Update app/helpers/component-argument.js

Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>

* Remove at-token

Co-Authored-By: Jerry Nummi <jnummi@gmail.com>

* Use suggested class ifs

* Apply changes based on feedback

* Fix lint

* Fix component list overflow (emberjs#1129)

* Fix component list overflow background color

* Gradient on component-tree-item actions

* Update app/controllers/component-tree.js

Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>

* Update app/templates/components/component-tree-item.hbs

Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>

* Bring back hover highlight in component tree (emberjs#1135)

* Bring back hover highlight in component tree

* Update comment in app/styles/component_tree.scss

Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>

Co-authored-by: Godfrey Chan <godfreykfc@gmail.com>

* Truncate, add quotes

* Update truncate.js

Co-authored-by: Jerry Nummi <nummi@users.noreply.github.com>
Co-authored-by: Godfrey Chan <godfreykfc@gmail.com>
patricklx pushed a commit to patricklx/ember-inspector that referenced this pull request Sep 19, 2022
* Add args to tree

Rebasing seemed hard, so opening a new PR

* Adjust component tree colors

Co-Authored-By: Jerry Nummi <jnummi@gmail.com>

* Update app/helpers/component-argument.js

Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>

* Remove at-token

Co-Authored-By: Jerry Nummi <jnummi@gmail.com>

* Use suggested class ifs

* Apply changes based on feedback

* Fix lint

* Fix component list overflow (emberjs#1129)

* Fix component list overflow background color

* Gradient on component-tree-item actions

* Update app/controllers/component-tree.js

Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>

* Update app/templates/components/component-tree-item.hbs

Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>

* Bring back hover highlight in component tree (emberjs#1135)

* Bring back hover highlight in component tree

* Update comment in app/styles/component_tree.scss

Co-Authored-By: Godfrey Chan <godfreykfc@gmail.com>

Co-authored-by: Godfrey Chan <godfreykfc@gmail.com>

* Truncate, add quotes

* Update truncate.js

Co-authored-by: Jerry Nummi <nummi@users.noreply.github.com>
Co-authored-by: Godfrey Chan <godfreykfc@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants