[EuiProvider] Detect OS/system light vs darkmode as a default#8026
[EuiProvider] Detect OS/system light vs darkmode as a default#8026cee-chen merged 10 commits intoelastic:mainfrom
Conversation
7cf8edd to
77e870c
Compare
- doesn't have dynamic listening as a result, but oh well, that's how storybook's UI behaves so we might as well match it
…g from system setting
- due to previous legacy theme font changes
… prop - not really sure what either of these are doing, i'm guessing it's legacy code from before React context was more widely used
77e870c to
b7be6d8
Compare
|
I think this is a tremendous and much needed improvement. This wouldn't be breaking change, correct? I think we currently require a colorMode prop of either If that is the case, I see no reason why we couldn't proceed with this PR. Directionally, it's where we're headed with Kibana and moving this logic to EUI lets us take advantage of this in all of our products. |
No, we do not require the
Not a breaking change, correct. If consumers continue to not pass |
|
@JasonStoltz did you mean to approve this, by the way? 👀 |
packages/eui/src-docs/src/components/with_theme/theme_context.tsx
Outdated
Show resolved
Hide resolved
| * Setup theme based on current light/dark theme | ||
| */ | ||
| const isDarkTheme = themeContext.theme.includes('dark'); | ||
| const isDarkTheme = useEuiTheme().colorMode === 'DARK'; |
There was a problem hiding this comment.
Yay for being able to reuse things! 👏
💚 Build Succeeded
History
|
`v95.11.0`⏩`v95.12.0-backport.0` > [!note] > A few fun highlights from this release: > - Content within `EuiDataGrid`, `EuiBasicTable`, and `EuiInMemoryTable`, when manually selected/highlighted by users, should now more cleanly copy and paste into various spreadsheet apps > - `EuiProvider` will now detect the user's system-level dark or light mode and default to that if no `colorMode` prop is passed manually _[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.12.0`](https://github.com/elastic/eui/releases/v95.12.0) - Enhanced `EuiDataGrid` and `EuiBasic/InMemoryTable` to clean content newlines/tabs when users copy and paste from their tabular data ([#8019](elastic/eui#8019)) - Updated `EuiResizableButton` with a new `accountForScrollbars` prop ([#8021](elastic/eui#8021)) - Updated `EuiProvider` to inherit from the user's OS/system light/dark mode setting if a `colorMode` prop has not been passed ([#8026](elastic/eui#8026)) **Bug fixes** - Fixed `EuiDatePicker`'s `onClear` button to not appear when the input is `disabled` ([#8020](elastic/eui#8020)) - Fixed several `EuiDataGrid` row height bugs: ([#8025](elastic/eui#8025)) - Fixed row heights not recalculating when `rowHeightOptions.lineHeight`, `gridStyles.fontSize`, or `gridStyles.cellPadding` changed - Fixed incorrect height calculations for `rowHeightOptions.rowHeights` with `lineCount`s - Fixed control column content to align better with multi-line row heights, as well as custom line-heights ## [`v95.12.0-backport.0`](https://github.com/elastic/eui/releases/v95.12.0-backport.0) **This is a backport release only intended for use by Kibana.** **Bug fixes** - Fixed `EuiProvider`'s system color mode detection causing errors during server-side rendering ([#8040](elastic/eui#8040)) - Fixed an `EuiDataGrid` rendering bug that was causing bouncing scrollbar issues ([#8041](elastic/eui#8041))
`v95.11.0`⏩`v95.12.0-backport.0` > [!note] > A few fun highlights from this release: > - Content within `EuiDataGrid`, `EuiBasicTable`, and `EuiInMemoryTable`, when manually selected/highlighted by users, should now more cleanly copy and paste into various spreadsheet apps > - `EuiProvider` will now detect the user's system-level dark or light mode and default to that if no `colorMode` prop is passed manually _[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.12.0`](https://github.com/elastic/eui/releases/v95.12.0) - Enhanced `EuiDataGrid` and `EuiBasic/InMemoryTable` to clean content newlines/tabs when users copy and paste from their tabular data ([elastic#8019](elastic/eui#8019)) - Updated `EuiResizableButton` with a new `accountForScrollbars` prop ([elastic#8021](elastic/eui#8021)) - Updated `EuiProvider` to inherit from the user's OS/system light/dark mode setting if a `colorMode` prop has not been passed ([elastic#8026](elastic/eui#8026)) **Bug fixes** - Fixed `EuiDatePicker`'s `onClear` button to not appear when the input is `disabled` ([elastic#8020](elastic/eui#8020)) - Fixed several `EuiDataGrid` row height bugs: ([elastic#8025](elastic/eui#8025)) - Fixed row heights not recalculating when `rowHeightOptions.lineHeight`, `gridStyles.fontSize`, or `gridStyles.cellPadding` changed - Fixed incorrect height calculations for `rowHeightOptions.rowHeights` with `lineCount`s - Fixed control column content to align better with multi-line row heights, as well as custom line-heights ## [`v95.12.0-backport.0`](https://github.com/elastic/eui/releases/v95.12.0-backport.0) **This is a backport release only intended for use by Kibana.** **Bug fixes** - Fixed `EuiProvider`'s system color mode detection causing errors during server-side rendering ([elastic#8040](elastic/eui#8040)) - Fixed an `EuiDataGrid` rendering bug that was causing bouncing scrollbar issues ([elastic#8041](elastic/eui#8041)) (cherry picked from commit 8a89c85)
Summary
Nobody asked for this, but I thought I'd do it anyway! 🤠
EUI's theme/
colorModecurrently defaults to light mode. I've added a new provider that detects the current system light/dark mode setting and if no consumercolorModeprop has been set/overridden, will automatically default to the OS/system setting.There's also a few src-docs cleanup in here (tagged as such in individual commits), and I'll shortly be doing another pass of our various docs that remove/deprecate all references to Sass setup.
QA
General checklist
@defaultif default values are missing)and playground togglesand cypress tests