-
Notifications
You must be signed in to change notification settings - Fork 844
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
Moving EuiBreadcrumb styles to Emotion. #5934
Moving EuiBreadcrumb styles to Emotion. #5934
Conversation
* Adding basic Emotion styles for links and content. * Adding the truncated link and content styles to Emotion. * Added all rules to Emotion. Testing for visual regression. * Fixed the focus halo for overflow:hidden declarations. * Removed breadcrumb overrides from Amsterdam theme. * Added last styles for individual truncated content. * Final Emotion style updates and a11y QA testing complete. * Updating snapshot tests for breadcrumb Emotion styles.
Preview documentation changes for this PR: https://eui.elastic.co/pr_5934/ |
Hey, sorry, not the PageHeader breadcrumbs, the EuiHeaderBreadcrumbs as seen on this page: https://eui.elastic.co/pr_5934/#/layout/header |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5934/ |
* Removing first group of SCSS files ahead of Amsterdam overrides. * Moving Amsterdam overrides to Emotion. * Added majority of the header breadcrumb styles. * Header styles are now contained, not casting into regular breadcrumbs. * Last color and bgColor styles added. * Removed Amsterdam SCSS overrides file. * Updating Jest snapshots for Emotion. * Adding CHANGELOG, final mobile styles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left one comment about the reasoning for having a new prop. LMK what you think.
} | ||
} | ||
`, | ||
isHeaderBreadcrumb: css` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The EuiHeaderBreadcrumbs
didn't have an easy way to cast styles into child elements, so I added a headerBreadcrumb
boolean prop so we could target header breadcrumbs.
I don't think this will be a breaking change because I passed the headerBreadcrumb
prop into the EUIHeaderBreadcrumbs
component, so it'll get picked up automatically and cast the new styles. If the reviewers feel this will be a breaking change, I'm happy to refactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Not a breaking change! I ended up following this pattern and adding another
isNested
prop (used for breadcrumbs within the collapsed popover - e50a5f9). It's much cleaner to handle this logic via JS rather than nested CSS. -
I'm not 100% on this but I'm not a super huge fan of the
headerBreadcrumb
/isHeaderBreadcrumb
var name. It feels super duper specific when there's arguably a use case for the visual style outside ofEuiHeader
. I'm wondering if a prop name likeisBadge
orisChevron
would be more descriptive. @1Copenut @miukimiu any thoughts here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on board for a more descriptive prop name. I used isHeaderBreadcrumb
purely because it fit with the presentation naming / spaces in EUI. I agree that it could be improved on if these styles can exist outside EuiHeader
. Great call!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's now a boolean flag, so super easy to see the visual effect on the playground!
It's just kind of a question of intention in visual language, I suppose. If we're OK with the chevron effect being used in places other than EuiHeader, then it makes sense to name it more generically. If it's only supposed to be used by EuiHeader, then it makes sense to be more specific and document it as such. I don't know for sure though, hence why I'm tagging in our designers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an excellent way to visualize and document the conditional styling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The EuiHeaderBreadcrumb was added by @cchaos and because she didn't add the styles directly in EuiBreadcrumb I'm assuming she intentionally only wanted those styles to appear for EuiHeader.
But that's my assumption... Caroline is back on Monday so I guess we can wait and she let us know. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, agreed. I want to note that we could move the styles to src/components/header/header_breadcrumbs
instead of remaining in src/components/breadcrumb
, but there are a few (minor) disadvantages to doing so vs keeping all the styles in breadcrumb.styles.ts
:
- CSS selector nesting: we would have to do
[class*="euiBreadcrumb"] { ... } // header-specific styles/overrides
[class*="euiBreadcrumb__content"] { ... } // header-specific styles/overrides
Which, if consumers wanted to override those overrides, they would have to do so either via !important
or their own nested selector. Not a huge deal, but IIRC we were trying to flatten nested selectors as part of the Emotion conversion.
- Developer styling - if I were trying to write new styles for header breadcrumbs and some parent CSS in
EuiBreadcrumb
was messing with that or causing unexpected effects, it might not be 100% clear where the parent breadcrumb styles live or are coming from (vs being able to skim all styles at once in one file). Again, not a huge or impossible ordeal to surmount.
We can definitely wait for Caroline to get back for clarity. In the interim I pushed up 6051809 to hide the new internal props from the props table, and renamed them more specifically/added comments as to their internal nature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I look at it is that no matter how we obfuscate the new prop, consumers can still use EuiHeaderBreadcrumbs anywhere they want. In this PR, the only header-specific styles applied to EuiBreadcrumbs is to enforce truncation and spacing when within the context of EuiHeader. If a consumer wants the look of EuiHeaderBreadcrumbs outside of EuiHeader, they'll most likely be fighting with these extra styles.
Therefore, I suggest keeping this new prop visible to all consumers so they can attain this look anywhere. But I think the name isInEuiHeader
is a bit awkward and a pattern we haven't established. I would consider naming it something that points to the purpose of the style and make it an enum, maybe something like type: 'page' | 'application'
. And commenting that there should really only be on application
style breadcrumb per view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, yes, isInEuiHeader
is overly explicit/awkward and is only what I would have named it if we weren't going to publicly expose the prop. I like the type
prop instead for helping designate the purpose!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preview documentation changes for this PR: https://eui.elastic.co/pr_5934/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logical CSS properties pass
src/components/header/header_breadcrumbs/header_breadcrumbs.styles.ts
Outdated
Show resolved
Hide resolved
src/components/header/header_breadcrumbs/header_breadcrumbs.styles.ts
Outdated
Show resolved
Hide resolved
I'll get these values converted to |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5934/ |
+ clarify prop documentation + simplify style declaration
Preview documentation changes for this PR: https://eui.elastic.co/pr_5934/ |
- for easier dev readability and testing + remove unnecessary classNames modifiers - they're not used in Kibana anywhere
- pass `maxWidth` to text truncation util - instead of using `> a` or `> span` selectors, just set the styles directly on the content child + use JS to conditionally skip the last breadcrumb - remove `isTruncated` on parent li, it's no longer needed
- they're already handled in the content CSS and incidentally also in EuiLink styles
- apply nested CSS to .euiBreadcrumb__content directly instead of using nested selectors - use a nested object and conditional JS logic (vs first/only/last-child) to flatten and DRY out CSS
- Remove unnecessary `--collapsed` modifier class - DRY out `<li>` and `__content` logic/styles by reusing the `EuiBreadcrumb` and `EuiBreadcrumbContent` components, passing props/overrides as necessary - Allow any children as `EuiBreadcrumb` child to support this behavior/the popover - Pass EuiBreadcrumbContent in at the EuiBreadcrumbs level as a result
- in favor of JS logic instead
- remove unnecessary `--truncate` modifier - not used in Kibana
+ update snapshots
- For easier dev readability / testing + microperf optimization onWindowResize: move declaration to useEffect so it's only declared every time `responsive` changes instead of on every rerender + remove unnecessary conditional around state setter, React already does its own optimization around values that stay the same
- Move to separate util for easier reading / testing - Memoize both limitBreadcrumb and breadcrumb mapping so arrays aren't being traversed on every rerender - refactor: instead of potentially rendering a bunch of hidden breadcrumb elements that never get displayed, splice the breadcrumbs array first, insert a custom object that signifies the EuiBreadcrumbCollapsed button, and then have the element traversal map handle conditionally rendering the collapse button in-place
@1Copenut The component split was super helpful in mentally organizing and cleaning up a lot of the nested styles. I should have pushed almost all of the refactors I wanted to make (see previous comment about |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5934/ |
- rename both props to be more specific, since they're now internal only / used for a specific purpose - move both props to an underscore prefixed type and modify props table and playground to not display them
Preview documentation changes for this PR: https://eui.elastic.co/pr_5934/ |
- This may be useful to other consumers where their last breadcrumb is not the current page + tweak styling to show color difference for both `span`s and `a` tags - using JS `color` props instead of CSS + fix `color` prop being passed to underlying span tags
- the `<li>` parent still needs an overflow hidden as it turns out - the last breadcrumb also still needs text truncation styles, it's just max-width should be set ot none
Preview documentation changes for this PR: https://eui.elastic.co/pr_5934/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preview documentation changes for this PR: https://eui.elastic.co/pr_5934/ |
Summary
Moved the
EuiBreadcrumb
to Emotion CSS-in-JS. @cchaos mentioned to split the PR for breadcrumbs and page header breadcrumbs. I'll review this before moving the PR out of draft, but it appears the core breadcrumb CSS was transferring to the page header. I couldn't see any visual differences between my local server and the published version.Checklist
Added documentationUpdated the Figma library counterpart