-
Notifications
You must be signed in to change notification settings - Fork 841
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
[Emotion] Convert EuiColorPalettePicker and EuiColorPaletteDisplay #7854
[Emotion] Convert EuiColorPalettePicker and EuiColorPaletteDisplay #7854
Conversation
aa4f13a
to
a5ff8f6
Compare
import { CommonProps } from '../../common'; | ||
import { EuiSpacer } from '../../spacer'; | ||
import { EuiText } from '../../text'; | ||
import { EuiSuperSelect, type EuiSuperSelectProps } from '../../form'; |
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.
This is weird: Changing the import like this results in the props not being passed along to the Storybook controls table 🤯 Only the ones manually defined as args
are added but they lose their docgenInfo because it's not actually resolved.
Maybe it's the level of abstraction also here. '../../form'
adds one more export file that the import goes through to resolve 🤔 But changing the path for it in /form/index
to /super_select/super_select
does not work. 🤷♀️
I saw this comment and can also reproduce this: The props are properly resolved when declaring components with function
instead of const
🙈
Digging a bit further and seeing this issue, I can also confirm that this is also true in this case:
// does not work
export const SomeComponent: FunctionComponent<Props> = ({
propA,
propB,
...rest
}) => {}
// does work
export const SomeComponent = ({
propA,
propB,
...rest
}: Props) => {}
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.
whoaaa what the heck. I changed the import path to forms/super_select
and it started working again :| NO idea why. What on earth. I left a comment so hopefully that helps at least??
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.
Yeah I think for now that's fine. 👍 Eventually I guess we might need to look at this limitation around resolving types that we keep running into with Storybook, or rather react-docgen-typescript
🫣
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.
Because React is not an ESM package, if using React.memo
or React.ReactNode
, etc., in the file, the TypeScript compiler used by react-docgen-typescript
cannot recognize the type.
An easy solution is to replace the import: import React from 'react'
with import * as React from 'react'
.
The final solution is to replace the use of react-docgen-typescript
with withDefaultConfig(parserOpts)
by:
- import { withDefaultConfig } from 'react-docgen-typescript';
+ import { withCompilerOptions } from 'react-docgen-typescript';
import { defaultOptions } from 'react-docgen-typescript/lib/parser';
- withDefaultConfig(parserOpts).parseWithProgramProvider
+ withCompilerOptions(
+ /* tsconfig compilerOptions */
+ {
+ ...defaultOptions,
+ /* Either of these two is useful */
+ esModuleInterop: true,
+ allowSyntheticDefaultImports: true,
+ },
+ /* your parserOpts */
+ parserOpts
+ ).parseWithProgramProvider
packages/eui/src/components/color_picker/color_palette_display/color_palette_display.styles.ts
Show resolved
Hide resolved
.../eui/src/components/color_picker/color_palette_display/color_palette_display_fixed.styles.ts
Show resolved
Hide resolved
38b92ac
to
2e46b04
Compare
- doesn't need CSS at all! whoa!
- convert Enzyme to RTL + snapshot the popover
- remove need for passing a size to by simply using the `inherit` CSS property - remove mixin - ignore light/dark arg, appears to be unused
- remove modifier maps, no Kibana usages - remove Sass variables - remove unnecessary nested bleed area height CSS by inheriting `height: 100%` from the parent
- can be a static const, no EUI variables being used - switch to position inset of height/width for simplicity - it's unclear if the 1px offset/workaround is due to an actual EUI var so I'm leaving it as a static 1px
e1feba7
to
29a4697
Compare
Preview staging links for this PR:
|
💚 Build Succeeded
History
|
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.
🚢 🐈⬛ Looking good to me!
Thanks Lene!! |
`v95.2.0`⏩`v95.3.0` _[Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_ --- ## [`v95.3.0`](https://github.com/elastic/eui/releases/v95.3.0) - Updated `EuiThemeProvider`s to allow modifying/setting custom `breakpoint`s in nested usage (as opposed to only at the top `EuiProvider` level) ([#7862](elastic/eui#7862)) **Bug fixes** - Fixed a Chrome/Edge CSS `mask-image` bug that was affecting scroll overflow shadow utilties ([#7855](elastic/eui#7855)) **CSS-in-JS conversions** - Converted `EuiColorPicker` to Emotion; Removed `$euiColorPickerWidth` ([#7845](elastic/eui#7845)) - Converted `EuiColorPickerSwatch` to Emotion ([#7853](elastic/eui#7853)) - Converted `EuiColorPalettePicker` and `EuiColorPaletteDisplay` to Emotion ([#7854](elastic/eui#7854)) - Removed `$euiColorPaletteDisplaySizes` - Removed `@mixin euiColorPaletteInnerBorder` - Removed `$euiColorPickerValueRange0`, `$euiColorPickerValueRange1`, `$euiColorPickerSaturationRange0`, `$euiColorPickerSaturationRange1`, and `$euiColorPickerIndicatorSize` ([#7859](elastic/eui#7859)) **Accessibility** - Updated the `aria-label` attribute for the `EuiFilePicker` remove file button ([#7860](elastic/eui#7860)) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
`v95.2.0`⏩`v95.3.0` _[Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_ --- - Updated `EuiThemeProvider`s to allow modifying/setting custom `breakpoint`s in nested usage (as opposed to only at the top `EuiProvider` level) ([elastic#7862](elastic/eui#7862)) **Bug fixes** - Fixed a Chrome/Edge CSS `mask-image` bug that was affecting scroll overflow shadow utilties ([elastic#7855](elastic/eui#7855)) **CSS-in-JS conversions** - Converted `EuiColorPicker` to Emotion; Removed `$euiColorPickerWidth` ([elastic#7845](elastic/eui#7845)) - Converted `EuiColorPickerSwatch` to Emotion ([elastic#7853](elastic/eui#7853)) - Converted `EuiColorPalettePicker` and `EuiColorPaletteDisplay` to Emotion ([elastic#7854](elastic/eui#7854)) - Removed `$euiColorPaletteDisplaySizes` - Removed `@mixin euiColorPaletteInnerBorder` - Removed `$euiColorPickerValueRange0`, `$euiColorPickerValueRange1`, `$euiColorPickerSaturationRange0`, `$euiColorPickerSaturationRange1`, and `$euiColorPickerIndicatorSize` ([elastic#7859](elastic/eui#7859)) **Accessibility** - Updated the `aria-label` attribute for the `EuiFilePicker` remove file button ([elastic#7860](elastic/eui#7860)) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Summary
Note
This PR merges into a feature branch.
I recommend code reviewing by commit for this PR!
QA
The below links should look the same as before with no UI/visual regressions:
General checklist
- [ ] Checked for accessibility including keyboard-only and screenreader modesand cypress tests- [ ] If applicable, added the breaking change issue label (and filled out the breaking change checklist)Emotion checklist
General
className(s)
read as expected in snapshots and browsers[ ] Checked component playgroundNo playgroundUnit tests
shouldRenderCustomStyles()
test was added and passes with parent component and any nestedchildProps
(e.g.tooltipProps
)Sass/Emotion conversion process
$euiSize
toeuiTheme.size.base
)or convertedcomponent-specific Sass vars/mixins to exported JS versionssrc/components/index.scss
[ ] Ranyarn compile-scss
to update var/mixin JSON files[ ] Simplifiedcalc()
tomathWithUnits
if possible (if mixing different unit types, this may not be possible)[ ] Deleted anysrc/amsterdam/overrides/{component}.scss
files (styles within should have been converted to the baseline Emotion styles)[ ] Added an@warn
deprecation message within theglobal_styling/mixins/{component}.scss
fileCSS tech debt
[ ] Wrapped all animations or transitions ineuiCanAnimate
[ ] Usedgap
property to add margin between items if using flex-inline
and-block
logical properties (check inline styles as well as CSS)DOM Cleanup
euiComponent
,euiComponent__child
).euiColorPaletteDisplay--[size]
- no usagesKibana due diligence
{euiComponent}-
(case sensitive) to check for usage of modifier classes - None[ ] If usage exists, consider converting to adata
attribute so that consumers still have something to hook into**/target, **/*.snap, **/*.storyshot
for less noise) foreui{Component}
(case sensitive) to find:euiBadge
class on a div instead of simply using theEuiBadge
component) - NoneThere's a single custom CSS
euiColorPaletteDisplay
override, but it shouldn't be impacted by this PRExtras/nice-to-have
[ ] Optional component/code cleanup: consider splitting up the component into multiple children if it's overly verbose or difficult to reason about[ ] Documentation pass[ ] Check for issues in the backlog that could be a quick fix for that component