Repository navigation
Closed
Description
Wiki Doc for How to Write Styles with Emotion
Completed
- Accordion (
EuiAccordionconvert Sass to Emotion CSS #5826) @1Copenut - Bottom bar @breehall [Emotion] Convert
EuiBottomBarto Emotion #5823 - Flex @constancecchen [Emotion] Convert EuiFlexGroup, EuiFlexItem, and EuiFlexGrid #6270
- Flyout @breehall [Emotion] Convert
EuiFlyout#6213 - Horizontal rule ([EuiHorizontalRule] convert horizontal rule to emotion #5815)
- Page @cchaos
- Page header @cchaos
- Panel @cchaos [Emotion] Convert EuiPanel #5891
- Popover @cchaos [EuiPopover and parts] Converted to Emotion #5977
- Spacer ([EuiSpacer] Converts
EuiSpacerto Emotion #5812) - Button
- Facet @miukimiu ([Emotion] Convert
EuiFacetButtonandEuiFacetGroup#5878) - Link ([Emotion] Convert EuiLink #5856) @MichaelMarcialis
- Pagination [EuiPagination & Co.] Convert to Emotion styling #6109
- Tabs [Emotion] EuiTabs #6311
- Aspect ratio ([EuiAspectRatio] Remove sass and replace with inline styles #5818)
- Avatar ([CSS-in-JS] Convert
EuiAvatar#5670) - Badge ([Emotion] Convert EuiBadge #6224, [Emotion] Convert EuiBadgeGroup, EuiBetaBadge, and EuiNotificationBadge #6258)
- Callout @cchaos [Emotion] Convert EuiCallOut #5870
- Card [EuiCard & friends] Convert to Emotion #6110
- Comment list @miukimiu ([EuiComment] Add
"custom"option toEuiComment.typeand more enhancements #5692) - Description list @breehall [Emotion] Convert EuiDescriptionList #5971
- Health @constancecchen [Emotion] Convert EuiHealth #5832
- Icons @miukimiu [Emotion] Convert
EuiIcon#5967 - Token @miukimiu [Emotion] Convert EuiToken #6067
- Image @miukimiu [Emotion] Convert
EuiImage#5969 - List group @miukimiu [Emotion] Convert
EuiListGroup#6207 - Loading @cchaos [Emotion] Convert the rest of the Loading components #5845
- Progress @constancecchen [Emotion] Convert EuiProgress #5986
- Range sliders @miukimiu [Feature Branch] Convert EuiRange sliders to Emotion and more enhancements #6092
- Stat @constancecchen [Emotion] Convert EuiStat #5968
- Text @constancecchen [Emotion] Convert EuiText, EuiTextAlign, and EuiTextColor #5895
- Title @constancecchen [Emotion] Convert EuiTitle #5842
- Toast [EuiToast & Co.] Convert to function component, Emotion styling #6068
- Tooltip [EuiToolTip] Convert to Emotion styling #6104
- Tour [EuiTour] Convert to Emotion styling #6087
- Code @miukimiu [Emotion] Convert
EuiCodeandEuiCodeBlock#6263 - [Emotion] EuiModal #6403 @miukimiu ([Emotion] Convert
EuiModal#6321)
Utilities
- Accessibility
- Beacon @miukimiu ([Emotion] Converted EuiBeacon #5814)
- CSS utility classes [Emotion] Convert global
classNameutilities #6124 - Error boundary [CSS-in-JS] Convert
EuiErrorBoundary#6053 - Highlight and mark ([CSS-in-JS] Convert
EuiMark#4575) - Overlay mask [EuiOverlayMask] Convert to Emotion; remove
onClickprop #6090 - Portal [Emotion] Convert
EuiPortal#6075 - Text diff [CSS-in-JS] Convert
EuiTextDiff#6056
## Partially complete
- [x] https://github.com/elastic/eui/issues/6388
- [ ] https://github.com/elastic/eui/issues/6653
- [ ] #6386
- [ ] #6408
- [ ] https://github.com/elastic/eui/issues/6406
## Display
- [ ] #6404
- [ ] #6397
- [ ] #6396
## Navigation
- [ ] #6389
- [ ] #6392
- [ ] #6393
- [ ] #6412
- [ ] #6416
- [ ] #6401
- [x] #6413
- [x] #6418
## Layout
- [ ] #6417
- [ ] https://github.com/elastic/eui/issues/6405
## Tables
- [ ] #6415
- [ ] #6387
## Forms
- [x] https://github.com/elastic/eui/issues/6398
- [ ] https://github.com/elastic/eui/issues/6410
- [ ] https://github.com/elastic/eui/issues/6411
- [ ] https://github.com/elastic/eui/issues/6391
- [ ] https://github.com/elastic/eui/issues/6390
- [ ] #6400
## Low priority (3rd party components or components that may move out of EUI)
- [ ] #6395
- [ ] #6402
- [ ] #6394
- [ ] #6414
Reacted by Caroline Horn, Andrea Del Rio, Chandler Prall, Christopher Chiche and Pedro Rodriguez Alia
Activity
breehall commentedon Apr 7, 2022
Component Conversion Process
Converting the Sass styles to Emotion
1. New file structure
src/components/{component}), create a new file for Emotion styling. Files should follow the{component}.styles.tsnaming structure (i.eavatar.styles.ts). In this file, convert the existing Sass styles to Emotion. For detailed information on converting styles, formatting styles, and creating style helpers, see writing styles with Emotion. For more detailed conversion checklist see comment below.{component}.tsx). ImportuseEuiTheme()from the services directory and configure the component to use Emotion styling.Example
<Insertion>component shenanigans. These snapshots should be addressed by one of the following options:mount()torender()mount()tomount().render()2a. Convert & Remove Sass component styles
{component}.styles.tssrc/components/{component}). This should include the stylesheets and the_index.scssfile found in the component folder. Insrc/components/index.scss, remove the import for the component Sass module2b. Update style props types by removing
classNameMaps where possibleSee #5889 for examples.
If the modifier piece of the class name
--{modifier}is the same string as the possible prop values, switch to applying the modifier piece of the class name directly as they key. Remove the manual maps of property value to class name maps and change the array of values as an exported arrayas const.Example:
Becomes:
If they don't match completely 1:1, you will need to keep the map, but remove the
euiComponentName--part of the value and still apply the className directly in the function:2c. Removing vs. keeping
classNamesIn the above scenarios, removing the
--modifier classNames/maps may be a perfectly valid choice as well to clean up our classNames logic. Be sure to search through Kibana first for the modifier(s) classes:[data]attribute instead that consumers can target instead of a class.NOTE: Generally, do not remove the top level className (e.g.
.euiComponent) or child element classNames (e.g..euiComponent__child). These classes serve as useful hooks/markers for consumers to use (both for CSS overrides and test selectors).3. Move and remove style Amsterdam overrides (if present)
Check
src/themes/amsterdam/overridesfor component style overrides. If overrides are present:src/themes/amsterdam/overrides/. The file will be named_{component}.scss.{component}.styles.tsfilesrc/themes/amsterdam/overrides/_index.scss, remove the component Sass module import4. Update component tests
{component}.test.tsx) to use theshouldRenderCustomStylesutility:Example
5. Remove styling variables used by the EUI documentation site (if present)
.jsonfiles by running the commandyarn compile-scss6. Deprecate any component-specific mixins
@warnmessage within theglobal_styling/mixins/{component name}.scssfile providing a recommendation if possibleExample if the recommendation is to use the actual React component
7. Update the documentation site playground (if using
withEuiThemeHOC)withEuiTheme()trueas the second argument topropUtilityForPlayground8. Changelog
Be sure to add the following header:
If any Sass variables or mixins were removed, append them to the line item use a semi-colon separator
cchaos commentedon Apr 7, 2022
EDIT: We've moved this conversion checklist to our GitHub PR template instead. See #6294
cchaos commentedon Apr 19, 2022
Add sass variable overrides to theme
Add sass variable overrides to theme
Add sass variable overrides to theme
cee-chen commentedon Sep 12, 2024
2.5 years later - all EUI components have been converted!! 🚀 🥲