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

Define SideNav items with a tree structure #141

Merged
merged 17 commits into from
Nov 22, 2017

Conversation

cjcenizal
Copy link
Contributor

@cjcenizal cjcenizal commented Nov 12, 2017

While I was playing with this, the static behavior of the carets felt weird. I'd click on an item to open it, and the caret felt redundant once it was opened. I wonder if we even need the caret? Is it there to communicate to users that something expands? If so, do we need to communicate that?

To-do:

  • Document isInline prop on flex components
  • Discuss "open parent" visual style with designers
  • Fix left padding of individual items so that focus state doesn't look odd

@bevacqua
Copy link
Contributor

Would be nice if we started pasting screenshots of the PR to get a glimpse of what's implemented/changed. Think you could do that here? 😅

@cjcenizal
Copy link
Contributor Author

@bevacqua Yep! I was going to add a gif once this was ready for review. Sorry, I should have added a WIP tag.

@cjcenizal
Copy link
Contributor Author

cjcenizal commented Nov 14, 2017

@snide @gjones @Adrian-J @formgeist @bevacqua This is ready for your review! I suggest checking out this branch and playing with it in the browser to get a feel for the interaction.

The side nav in the docs themselves is also worth trying out because, due to a quirk in the implementation, the subsections of each page aren't registered until after that page has been visited. Which means that each section initially doesn't show a caret, but does show a caret after you visit that page. To be honest, I didn't miss the caret. What do y'all think?

@Adrian-J
Copy link

@cjcenizal looks great. only comment, can the expanded version push the rest down instead of up?

@formgeist
Copy link
Contributor

Does it have to be font-weight: 500; on selected state? It feels a little weird to me when the letter-spacing jumps around because it adds additional weight for each click. I tested it out locally I thought it was more "calm" when it was just regular all the way.

@cjcenizal
Copy link
Contributor Author

Thanks @Adrian-J that "pushing up" is a side-effect because this example is at the bottom of the page. So it's making the page taller and Chrome will "stick" you to the bottom of the page as the page expands. So long story short... yes, it's already pushing the rest down as you would expect.

@formgeist I'll leave that one to @snide.

@gjones
Copy link
Contributor

gjones commented Nov 14, 2017

Something does feel a little off to me with that caret, I think it's because I would expect it to be the arrowRight icon and then transition to arrowDown when the sub menu is expanded. I also think that it should live maybe 4 or 6 pixels to the right of the word rather than as far away as it is now. Sorry I haven't taken too long to think this over, these are just my immediate thoughts, feel free to disregard.

So something like below (excuse the hasty, gross designs)

screen shot 2017-11-14 at 11 17 53

becomes

screen shot 2017-11-14 at 11 19 01

Also, I should add, I wouldn't be opposed to the carets being light grey and only appearing on hover.

@Adrian-J
Copy link

@cjcenizal makes sense. One more thing I haven't noticed before, I think the 2nd level vertical line should be left-aligned with the 1st level title. Looks cleaner that way.

@cjcenizal
Copy link
Contributor Author

cjcenizal commented Nov 14, 2017

@Adrian-J It's funny you mention that because I actually had the same thought and tried it out:

When I looked at it originally it felt weird to me, but now looking at it again I kind of like it. I'll let you and Dave hash it out.

@Adrian-J
Copy link

@cjcenizal I like this version much better. Great job!

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

Minor stuff. Feel free to merge whenever.

I do think it's really weird to see the carets in the docs only after you've clicked them. Can fix later, but if that happened in a prod scenario I'd think it was kind of busted.

margin-bottom: $euiSizeS;
padding: 0;
padding-left: $euiSizeS; /* 1 */
margin-left: -$euiSizeS; /* 1 */
Copy link
Contributor

Choose a reason for hiding this comment

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

This trick messes up your focus state width. Use a calc width calc(100% + #{$euiSizeS}) and add your negative margin back to adjust it. Essentially you want the right hand line to carry straight across the entire side.

image


export default () => (
<EuiFlexGroup useSpan>
<EuiFlexItem useSpan>This a span within a span</EuiFlexItem>
Copy link
Contributor

Choose a reason for hiding this comment

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

Any time you'd mix spans and divs? If not, should this just be on EuiFlexGroup and not the items itself? Not a blocker, just if it's easy it's probably easier to consume.

Maybe give a better example of why you'd want to use spans? I assume it's because you want to sit within a button rather than KeyboardAccessible? Maybe show the example inside of a button then to illustrate that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any time you'd mix spans and divs?

Good question, but I'm not sure to be honest. Since I can't say one way or the other I think I should assume there's a good use case I'm just not aware of. We can find a way to lock it down later if people find this un-ergonomic.

Maybe give a better example of why you'd want to use spans?

Good call, I'll put it inside a button to make this clearer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, makes sense.

}

&.euiSideNavItem--parent.euiSideNavItem-isSelected {
color: $euiColorFullShade;
&.euiSideNavItemButton-isOpenable {
background: svg-load('../src/components/icon/assets/arrow_down.svg') center right no-repeat;
Copy link
Contributor

Choose a reason for hiding this comment

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

If possible, I'd instead use EuiIcon instead of this hacky CSS solution. That way it can be colored (it should probably be subdued). Right now this breaks in dark mode because it's hard coded.

Don't want to hamper your PR, so if you merge it as is, just make an issue to cover it. We can figure it out later.

@snide
Copy link
Contributor

snide commented Nov 14, 2017

@cjcenizal Don't forget to update the changelog before you merge this.

return {
...section,
};
});
Copy link
Contributor

Choose a reason for hiding this comment

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

tiny stylistic proposal:

=> ({ ...section })

name: subSection.name,
onClick: this.onClickLink.bind(this, subSection.id),
}));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

#nicohat -- could lose the mutable var by turning this into a function that takes subSections and guards on it being falsy

name: subSection.name,
onClick: this.onClickLink.bind(this, subSection.id),
}));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

(and benefit from it here as well)

justifyContent,
useSpan,
...rest,
}) => {
Copy link
Contributor

@zinckiwi zinckiwi Nov 15, 2017

Choose a reason for hiding this comment

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

Rather than useSpan which seems overly prescriptive, could I suggest component: Component = 'div' and return <Component ... />? Could easily propType it to oneOf(['div', 'span']) to lock it down to those two.

Edit: to clarify, usage would be <FlexGroup component='span' /> instead of <FlexGroup useSpan />

@cjcenizal cjcenizal force-pushed the improvement/side-nav-interface branch from 75e0b1b to 0195fae Compare November 16, 2017 19:33
@cjcenizal
Copy link
Contributor Author

@snide I updated the changelog, thanks for the reminder. @zinckiwi I addressed your comments, could you take another look?

CHANGELOG.md Outdated
@@ -1,8 +1,13 @@
# [`master`](https://github.com/elastic/eui/tree/master)

- `<EuiFlexItem>` now accepts integers between 1 and 10 for the `grow` prop. [(#144)](https://github.com/elastic/eui/pull/144)
- `<EuiFlexItem>` and `<EuiFlexGrow>` now accept a `component` prop which you can set to `span` or `div`. [(#141)](https://github.com/elastic/eui/pull/141)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps an indication as to the default (which therefore shouldn't be explicitly specified)?

@zinckiwi
Copy link
Contributor

LGTM aside from one very minor comment about the changelog entry!

@cjcenizal
Copy link
Contributor Author

Thanks @zinckiwi !

@cjcenizal cjcenizal merged commit 0c9b8ce into elastic:master Nov 22, 2017
@cjcenizal cjcenizal deleted the improvement/side-nav-interface branch November 22, 2017 20:33
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.

7 participants