Skip to content

[Page layouts] Updates to [EuiSideNav] - #4488

Merged
cchaos merged 17 commits into
elastic:masterfrom
cchaos:page_layouts/side_nav
Feb 17, 2021
Merged

cchaos merged 17 commits into
elastic:masterfrom
cchaos:page_layouts/side_nav

Conversation

@cchaos

@cchaos cchaos commented Feb 4, 2021 •

Copy link
Copy Markdown
Contributor

This PR is mostly backlog fixes and a couple prop additions

1. Fixed nested indicator when item is the last one

The left side indicator used to extend too far down. Now it will stop at the last child.

image

2. Re-arranging text color styles for easier className overrides

Fixes #2380

When passing a custom className to the nav item to change the text color, where the class was applied and where the styles were applied would not allow this. Now the CSS applies the color at the EuiSideNavItem level so that the button inherits.

So doing something like this

.customItemClass {
  color: red;
}

Results in:

image

3. Added a truncate prop that can be applied to the whole EuiSideNav or an individual item

Fixes #4264

It is on by default and includes innerText for titles when truncation is on.

image

4. Added disabled state to items and fixed up some other interaction state styles

Before, if you tried to add disabled to a particular nav item, it would not get respected. It was not passed down to the actual button and so never actually disabled anything.

Now, it's passed down to the right component and has styles applied.

image

5. Added an emphasize prop to side nav items that adds a background and bolds the button

This enhancement came mainly from Cloud but is also a possible enhancement for any side nav items that are rendered "dynamically" or for any other reason that a consumer might want to emphasize a certain section.

Screen Shot 2021-02-04 at 16 03 18 PM

6. Consolidating some prop types

The prop types for this component are a bit screwy. See #4487. But also, the allowed props on individual items passed as an object to EuiSideNav are not the same as ones for EuiSideNavItem. It gets all very complicated, but I tried to reduce some of the duplication by extending each other. I still think it could be further cleaned up but I'm not enough familiar with the generic types. This is also why no playground was added.

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs and playground toggles
  • Added documentation
  • Checked Code Sandbox works for the any docs examples
  • Added or updated jest tests
  • [ ] Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine

Copy link
Copy Markdown
Contributor

@kibanamachine

Copy link
Copy Markdown
Contributor

Comment on lines +5 to +6
// Redoing this mixin mainly to remove the letter-spacing
@mixin euiFont {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just noticed this when I'd toggle between clickable and not-clickable, the letter-spacing would change because there was still a missing Amsterdam override to remove it from this mixin.

@cchaos
cchaos marked this pull request as ready for review February 4, 2021 22:46
@kibanamachine

Copy link
Copy Markdown
Contributor

@cchaos
cchaos requested review from thompsongl and removed request for chandlerprall February 8, 2021 20:47
@kibanamachine

Copy link
Copy Markdown
Contributor

@thompsongl

Copy link
Copy Markdown
Contributor

But also, the allowed props on individual items passed as an object to EuiSideNav are not the same as ones for EuiSideNavItem. It gets all very complicated ...

Clarifying: the two sets of props should be the same, or they are intentionally different and you're simply explaining the complication?

@cchaos

cchaos commented Feb 16, 2021

Copy link
Copy Markdown
Contributor Author

The two sets of props are currently intentionally different. Being that EuiSideNavItem is technically an internal-only component right now since the larger EuiSideNav component handles all the logic like nesting. Could they be more uniform? Probably. Is it necessary? Not sure. But it makes it hard to do any testing at the EuiSideNavItem level in the docs themselves.

@thompsongl

Copy link
Copy Markdown
Contributor

Got it. I think the refactor you made is a good step, and I don't see a lot of additional available gain from a TS point of view.
Resolving #4129 will be helpful to consumers

@thompsongl

Copy link
Copy Markdown
Contributor

jenkins test this

Error: Timed out waiting for: http-get://localhost:9999

@thompsongl thompsongl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code changes LGTM
Just a couple small things

children: ReactNode;
}
export type RenderItem<T> = (
// argument is the set of extra component props + GuaranteedRenderItemProps

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// argument is the set of extra component props + GuaranteedRenderItemProps
// argument is the set of extra component props + SideNavItemButtonProps

Comment thread src/components/side_nav/index.ts Outdated
Comment on lines +20 to +21
export { EuiSideNav } from './side_nav';
export { EuiSideNavItem } from './side_nav_item';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Export prop types, also?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's where it all gets confusing because on the next line, the actual item props get exported from a specific types file. But we don't export EuiSideNavItem any higher than this (and I think I could actually remove this since it was originally added when I attempted to add a playground). So I'm just going to remove this export but I did add the props for the EuiSideNav

@kibanamachine

Copy link
Copy Markdown
Contributor

Comment thread src/components/side_nav/_variables.scss Resolved

@elizabetdev elizabetdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested in Chrome, Safari, Edge, and Firefox.

I found that the side nav items don't have enough contrast in dark mode. All the rest looks good.

Screenshot 2021-02-16 at 21 06 10

@cchaos
cchaos requested a review from elizabetdev February 16, 2021 23:24
@kibanamachine

Copy link
Copy Markdown
Contributor

@elizabetdev elizabetdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I tested again in Chrome, Edge, Firefox, Safari, and I also looked at the code.

LGTM! 🎉

@cchaos
cchaos merged commit 3b94a1b into elastic:master Feb 17, 2021
@cchaos
cchaos deleted the page_layouts/side_nav branch February 17, 2021 15:29
anuragxxd added a commit to anuragxxd/eui that referenced this pull request Feb 17, 2021
[Page layouts] Updates to [EuiSideNav] (elastic#4488)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[EuiSideNav] Allow text wrapping [EuiSideNav] Hard to customize

4 participants