From 3902751fdb90e6aadbe22bb9f01eac02cd799851 Mon Sep 17 00:00:00 2001
From: Cee Chen
Date: Wed, 18 Sep 2024 15:23:33 -0700
Subject: [PATCH 1/9] Update getting started docs to remove references to
`.css` files and migration
+ remove `colorMode` docs in anticipation of automatic system color mode logic, and link to EuiProvider props instead
---
.../guidelines/getting_started/_app_setup.tsx | 71 +++++++------------
.../docs/01_guidelines/getting_started.mdx | 16 +----
wiki/consuming-eui/README.md | 5 +-
3 files changed, 31 insertions(+), 61 deletions(-)
diff --git a/packages/eui/src-docs/src/views/guidelines/getting_started/_app_setup.tsx b/packages/eui/src-docs/src/views/guidelines/getting_started/_app_setup.tsx
index cce01cad10e..9ad5022204e 100644
--- a/packages/eui/src-docs/src/views/guidelines/getting_started/_app_setup.tsx
+++ b/packages/eui/src-docs/src/views/guidelines/getting_started/_app_setup.tsx
@@ -1,71 +1,52 @@
-import React, { FunctionComponent } from 'react';
+import React from 'react';
import { Link } from 'react-router-dom';
import {
EuiCodeBlock,
- useEuiTheme,
EuiCode,
EuiSpacer,
EuiText,
- EuiCallOut,
+ EuiLink,
} from '../../../../../src';
-type AppSetup = {};
-
-export const AppSetup: FunctionComponent = ({}) => {
- const { colorMode } = useEuiTheme();
+export const AppSetup = () => {
+ return (
+ <>
+
+
+ EUI uses CSS-in-JS (specifically{' '}
+
+ Emotion
+
+ ) for its styles and theming. As such, we require an{' '}
+ {''} wrapper around your application
+ in order for various theme-related UI & UX (such as dark/light mode
+ switching) to work as expected.
+
- While EUI is in the process of converting from a Sass based theme to
- CSS-in-JS via Emotion. We require that both the{' '}
-
- EuiProvider
- {' '}
- and the compiled CSS (or raw Sass) files be imported
- during this transition.
-
-
-
-
-
-
-
- EUI provides a general context provider to handle global aspects like
- light and dark theme. You can import these default themes through
- their respective compiled CSS files. Use the{' '}
- .min.css file extension for the minified version.
-
-
-
-
- {appSetup}
+
- For the dark theme, you can swap the words light{' '}
- for dark.
For more configuration options of the provider, see the{' '}
- EuiProvider documentation.
+
+ EuiProvider documentation
+
+ .
>
diff --git a/packages/website/docs/01_guidelines/getting_started.mdx b/packages/website/docs/01_guidelines/getting_started.mdx
index 75caebef0d6..e40b4f48a3c 100644
--- a/packages/website/docs/01_guidelines/getting_started.mdx
+++ b/packages/website/docs/01_guidelines/getting_started.mdx
@@ -44,24 +44,15 @@ You can read more about other ways to consume EUI in our wiki.
## Setting up your application
-:::warning
-While EUI is in the process of converting from a Sass based theme to CSS-in-JS via Emotion. We require that both
-the [EuiProvider](https://eui.elastic.co/#/utilities/provider) **and** the compiled CSS (or raw Sass) files be imported
-during this transition.
-:::
-
-
-EUI provides a general context provider to handle global aspects like light and dark theme. You can import these
-default themes through their respective compiled CSS files. Use the `.min.css` file extension for the minified version.
+EUI uses CSS-in-JS (specifically [Emotion](https://emotion.sh)) for its styles and theming. As such, we require an `` wrapper around your application in order for various theme-related UI & UX (such as dark/light mode switching) to work as expected.
```jsx
import React from 'react';
-import '@elastic/eui/dist/eui_theme_light.css';
import { EuiProvider, EuiText } from '@elastic/eui';
const MyApp = () => (
-
+
Hello World!
);
@@ -69,9 +60,8 @@ const MyApp = () => (
export default MyApp;
```
-For the dark theme, you can swap the words `light` for `dark`.
For more configuration options of the provider, see the
-[EuiProvider documentation](https://eui.elastic.co/#/utilities/provider).
+[**EuiProvider** documentation](https://eui.elastic.co/#/utilities/provider).
## Styling your application
diff --git a/wiki/consuming-eui/README.md b/wiki/consuming-eui/README.md
index 9e0e275a97d..6bc0430d971 100644
--- a/wiki/consuming-eui/README.md
+++ b/wiki/consuming-eui/README.md
@@ -51,16 +51,15 @@ import { findByTestSubject, render, screen } from '@elastic/eui/lib/test/rtl'; /
### Theming
-As of April 2022 EUI is in the process of [migrating to Emotion JS for the CSS and theming layer](https://github.com/elastic/eui/issues/3912). While EUI is in the process of this conversion, we require that both the EuiProvider and the compiled CSS (or raw Sass) files be imported during this transition.
+EUI uses CSS-in-JS (specifically [Emotion](https://emotion.sh)) for its styles and theming. As such, we require an `` wrapper around your application in order for various theme-related UI & UX (such as dark/light mode switching) to work as expected.
```jsx
import React from 'react';
-import '@elastic/eui/dist/eui_theme_light.css';
import { EuiProvider, EuiText } from '@elastic/eui';
const MyApp = () => (
-
+
-
- Keep an eye out for this language selector that will allow you
- to view the syntax for either the Sass or CSS-in-JS (Emotion)
- theming mechanisms.
-
-
-
-
-
-
-
-
-
-
- {showSass ? (
- <>
-
-
-
This will require style, css, postcss, and sass loaders.
-
-
-
-
-
- >
- ) : (
- <>
-
-
-
- As long as you have wrapped your application with{' '}
-
- EuiProvider
-
- , you have access to the JS theme tokens via{' '}
- useEuiTheme() and Emotion's{' '}
- css prop.
-
-
-
-
-
-
- >
- )}
-
- );
-};
diff --git a/packages/eui/src-docs/src/views/guidelines/getting_started/getting_started.js b/packages/eui/src-docs/src/views/guidelines/getting_started/getting_started.js
index 88c48d5e53f..1c51cf5e126 100644
--- a/packages/eui/src-docs/src/views/guidelines/getting_started/getting_started.js
+++ b/packages/eui/src-docs/src/views/guidelines/getting_started/getting_started.js
@@ -1,12 +1,19 @@
import React from 'react';
import { Link } from 'react-router-dom';
-import { EuiCodeBlock, EuiCode, EuiText, EuiSpacer } from '../../../../../src';
+import {
+ EuiCodeBlock,
+ EuiCode,
+ EuiText,
+ EuiSpacer,
+ EuiPanel,
+} from '../../../../../src';
import { AppSetup } from './_app_setup';
-import { Tokens } from './_tokens';
import { Customizing } from './_customizing';
import { ThemeNotice } from '../../../views/theme/_components/_theme_notice.tsx';
+import { GuideSectionExampleCode } from '../../../components/guide_section/guide_section_parts/guide_section_code';
+const consumingSource = require('!!raw-loader!../../theme/consuming');
import { euiProviderComponentDefaultsSnippet } from '../../provider/provider_component_defaults';
export const GettingStarted = {
@@ -72,18 +79,23 @@ export const GettingStarted = {
<>
- To build your custom components using EUI theme variables,
- functions, and mixins, you will need to consume them through one
- of the Sass,{' '}
- Emotion, or{' '}
-
- JSON import
- {' '}
- methods.
+ You can build custom components using EUI's theme tokens, consumed
+ via useEuiTheme(). The below example uses
+ Emotion's css prop, but any CSS-in-JS library
+ should be able to interpolate the JS variables.
+
+
+ For more ways to consume EUI's theme, see the{' '}
+
+ EuiThemeProvider documentation
+
+ .
-
+
+
+
diff --git a/packages/eui/src-docs/src/views/theme/consuming.tsx b/packages/eui/src-docs/src/views/theme/consuming.tsx
index 44bb1cd7971..82e3e440ab3 100644
--- a/packages/eui/src-docs/src/views/theme/consuming.tsx
+++ b/packages/eui/src-docs/src/views/theme/consuming.tsx
@@ -22,8 +22,8 @@ export default () => {
`}
>
The padding of this box is created using calc(){' '}
- because EUI's theme sizes are string pixel values that are
- calculated off the theme's base
+ because EUI's theme sizes are string pixel values that are calculated
+ off the theme's base
);
diff --git a/packages/website/docs/01_guidelines/getting_started.mdx b/packages/website/docs/01_guidelines/getting_started.mdx
index e40b4f48a3c..231f8c2fa76 100644
--- a/packages/website/docs/01_guidelines/getting_started.mdx
+++ b/packages/website/docs/01_guidelines/getting_started.mdx
@@ -65,56 +65,42 @@ For more configuration options of the provider, see the
## Styling your application
-To build your custom components using EUI theme variables, functions, and mixins, you will need to consume them
-through one of the [Sass](https://eui.elastic.co/#/theming/sass),
-[Emotion](https://eui.elastic.co/#/theming/theme-provider),
-or [JSON import](https://github.com/elastic/eui/blob/main/wiki/consuming-eui/README.md#a-not-recommended-legacy-method-to-consume-theming-variables-from-sass) methods.
+You can build custom components using EUI's theme tokens, consumed via `useEuiTheme()`. The below example uses Emotion's `css` prop, but any CSS-in-JS library should be able to interpolate the JS variables.
-
-
- ```scss title="This will require style, css, postcss, and sass loaders."
- // index.scss
- @import '@elastic/eui/src/themes/amsterdam/colors_light';
- @import '@elastic/eui/src/themes/amsterdam/globals';
-
- @import 'your/custom/styles';
- ```
-
-
- ```jsx title="As long as you have wrapped your application with EuiProvider, you have access to the JS theme tokens via useEuiTheme() and Emotion's css prop."
- import React from 'react';
- import { EuiIcon, EuiCode, EuiText, useEuiTheme } from '@elastic/eui';
- import { css } from '@emotion/react';
+For more ways to consume EUI's theme, see the [**EuiThemeProvider** documentation](https://eui.elastic.co/#/theming/theme-provider#consuming-with-the-react-hook).
- export default () => {
- const { euiTheme } = useEuiTheme();
- return (
-
-
- {' '}
- This primary color will adjust based on the light or dark theme value
-
-
-
- The padding of this box is created using calc(){' '}
- because EUI's theme sizes are string pixel values that are
- calculated off the theme's base
-
+ {' '}
+ This primary color will adjust based on the light or dark theme value
+
+
+
+ The padding of this box is created using calc(){' '}
+ because EUI's theme sizes are string pixel values that are
+ calculated off the theme's base
+
+
+ );
+};
+```
### Customizing the style tokens
diff --git a/wiki/consuming-eui/README.md b/wiki/consuming-eui/README.md
index 6bc0430d971..a9322741e24 100644
--- a/wiki/consuming-eui/README.md
+++ b/wiki/consuming-eui/README.md
@@ -67,7 +67,7 @@ const MyApp = () => (
export default MyApp;
```
-#### The recommended method to consume theming variables using Emotion
+#### Consuming theme tokens
Using EUI's theme layer with Emotion is [documented in our docs](https://elastic.github.io/eui/#/theming/theme-provider) and should cover the majority of your theming needs.
@@ -87,25 +87,6 @@ export default () => {
);
};
```
-#### A not-recommended, legacy method to consume theming variables from Sass
-
-Until the conversion is complete, the components you consume may still contain soon-to-be-removed Sass styling. EUI's distribution also provides both a light and dark JSON token file that exposes these Sass variables (through an automatic process derived from the Sass) to make tokens from the individual Sass components available to consume if you need them. As components continue to convert to Emotion, these Sass-to-JS tokens in these files will degrade, eventually disappearing altogether. We therefore recommend not relying on the JSON dist of these tokens, and instead using the above recommended Emotion approach.
-
-The following is provided as an example of the soon-to-be-deprecated Sass theme variables, to aid consumers in converting legacy usage.
-
-```jsx
-import * as euiVars from '@elastic/eui/dist/eui_theme_light.json';
-
-const styles = {
- color: euiVars.euiColorPrimary,
- border: euiVars.euiBorderThin
- padding: euiVars.euiPanelPaddingModifiers.paddingSmall
-};
-
-export default () => (
-
-)
-```
### "Module build failed" or "Module parse failed: Unexpected token" error
From 61b779162f0231d716c173882ae699e28fb0ea40 Mon Sep 17 00:00:00 2001
From: Cee Chen
Date: Wed, 18 Sep 2024 18:10:30 -0700
Subject: [PATCH 3/9] [Getting started] Update style token customization docs
+ move bottom bullet point to a location where it'll actually be read, and wrap it in a warning callout
---
.../getting_started/getting_started.js | 42 ++++----
.../docs/01_guidelines/getting_started.mdx | 102 +++++++-----------
2 files changed, 61 insertions(+), 83 deletions(-)
diff --git a/packages/eui/src-docs/src/views/guidelines/getting_started/getting_started.js b/packages/eui/src-docs/src/views/guidelines/getting_started/getting_started.js
index 1c51cf5e126..38ee0673506 100644
--- a/packages/eui/src-docs/src/views/guidelines/getting_started/getting_started.js
+++ b/packages/eui/src-docs/src/views/guidelines/getting_started/getting_started.js
@@ -7,13 +7,13 @@ import {
EuiText,
EuiSpacer,
EuiPanel,
+ EuiCallOut,
} from '../../../../../src';
import { AppSetup } from './_app_setup';
-import { Customizing } from './_customizing';
-import { ThemeNotice } from '../../../views/theme/_components/_theme_notice.tsx';
import { GuideSectionExampleCode } from '../../../components/guide_section/guide_section_parts/guide_section_code';
const consumingSource = require('!!raw-loader!../../theme/consuming');
+const overrideSimpleSource = require('!!raw-loader!../../theme/override_simple');
import { euiProviderComponentDefaultsSnippet } from '../../provider/provider_component_defaults';
export const GettingStarted = {
@@ -102,29 +102,35 @@ export const GettingStarted = {
Customizing the style tokens
EUI can be slightly customized to fit your branding needs by
- altering the base tokens like color and typography. Simply declare
- your token overrides before importing the whole EUI theme. This
- will re-compile all of the EUI components with your colors.
+ altering the base tokens like color and typography. You can pass a
+ full or partial list of override tokens to the{' '}
+ EuiProvider's modify prop.
+
+ By nature, EUI is very rigid. You shouldn't need much to make
+ drastic changes to color. Most themes are less then a dozen
+ variable overwrites in total.
+
+
- For a full list of global tokens visit{' '}
- Customizing theme.
+ For a full list of global tokens, visit{' '}
+ Customizing themes.
+ For more examples of the modify prop, see the{' '}
+
+ EuiThemeProvider docs
+
+ .
-
-
-
+
+
+
-
Do not use in conjunction with the compiled CSS.
-
If you provide both, it will duplicate the imported styles.
-
Touch the least amount of variables possible.
-
- By nature EUI is very rigid. You shouldn't need much to make
- drastic changes to color. Most themes are less then a dozen
- variable overwrites in total.
-
Do not overwrite individual component variables or{' '}
.eui class names.
diff --git a/packages/website/docs/01_guidelines/getting_started.mdx b/packages/website/docs/01_guidelines/getting_started.mdx
index 231f8c2fa76..5b75c9f77f7 100644
--- a/packages/website/docs/01_guidelines/getting_started.mdx
+++ b/packages/website/docs/01_guidelines/getting_started.mdx
@@ -104,79 +104,51 @@ export default () => {
### Customizing the style tokens
-EUI can be slightly customized to fit your branding needs by altering the base tokens like color and typography.
-Simply declare your token overrides before importing the whole EUI theme. This will re-compile
-all of the EUI components with your colors.
+EUI can be slightly customized to fit your branding needs by altering the base tokens like color and typography. You can pass a full or partial list of override tokens to the **EuiProvider**'s `modify` prop.
-For a full list of global tokens visit Customizing theme.
-
-:::warning Partial component support
-EUI is transitioning to a CSS-in-JS solution for theming and requires consuming/customizing global variables
-in **both the Sass and CSS-in-JS** methods. To track this effort,
-subscribe to the [Meta ticket](https://github.com/elastic/eui/issues/3912).
+:::warning Touch the least amount of variables possible
+By nature, EUI is very rigid. You shouldn't need much to make drastic changes to color. Most themes are less then a dozen variable overwrites in total.
:::
-
-
- ```scss title="This will require style, css, postcss, and sass loaders and a full re-compile of all EUI component styles."
- $euiColorPrimary: #7B61FF;
-
- // The following rebuilds the entire EUI component styles
- @import '@elastic/eui/src/themes/amsterdam/theme_light';
+For a full list of global tokens visit [Customizing themes](https://eui.elastic.co/#/theming/customizing-themes). For more examples of the modify prop, see the [**EuiThemeProvider** docs](https://eui.elastic.co/#/theming/theme-provider#simple-instance-overrides).
- @import 'your/custom/styles';
- ```
-
-
- ```jsx title="You can pass along a full or partial list of global overrides to the EuiProvider which will update the EUI components that are currently using the Emotion method of theming."
- import React, { FunctionComponent, ReactNode } from 'react';
- import { EuiCode, EuiText, EuiThemeProvider, useEuiTheme } from '@elastic/eui';
-
- const Box: FunctionComponent<{ children: ReactNode }> = ({ children }) => {
- const { euiTheme } = useEuiTheme();
-
- return (
-
-
-
-
- The background of this box is using the locally overridden value of{' '}
- euiTheme.colors.lightShade
-
-
-
- );
- };
- ```
-
-
+```jsx
+import React, { FunctionComponent, ReactNode } from 'react';
+import { EuiCode, EuiText, EuiThemeProvider, useEuiTheme } from '@elastic/eui';
-#### Do not use in conjunction with the compiled CSS.
+const Box: FunctionComponent<{ children: ReactNode }> = ({ children }) => {
+ const { euiTheme } = useEuiTheme();
-If you provide both, it will duplicate the imported styles.
+ return (
+
+
{children}
+
+ );
+};
-#### Touch the least amount of variables possible.
+export default () => {
+ const overrides = {
+ colors: {
+ LIGHT: { lightShade: '#d3e6df' },
+ DARK: { lightShade: '#394c4b' },
+ },
+ };
-By nature EUI is very rigid. You shouldn't need much to make drastic changes to color. Most themes are less then a dozen variable overwrites in total.
+ return (
+
+
+ The background of this box is using the locally overridden value of{' '}
+ euiTheme.colors.lightShade
+
+
+ );
+};
+```
#### Do not overwrite individual component variables or .eui class names.
From dec612629f2f0d474d39ff1b1736ceee35b52450 Mon Sep 17 00:00:00 2001
From: Cee Chen
Date: Wed, 18 Sep 2024 18:26:24 -0700
Subject: [PATCH 4/9] [Getting started] Move and rewrite classes example
- should be under styling section, where it's actually useful
- add link to cache config, since that affects CSS specificity
- modify example to be usable in codesandbox
---
.../getting_started/getting_started.js | 103 +++++++++++-------
.../docs/01_guidelines/getting_started.mdx | 49 +++++----
2 files changed, 90 insertions(+), 62 deletions(-)
diff --git a/packages/eui/src-docs/src/views/guidelines/getting_started/getting_started.js b/packages/eui/src-docs/src/views/guidelines/getting_started/getting_started.js
index 38ee0673506..f30b0bb294a 100644
--- a/packages/eui/src-docs/src/views/guidelines/getting_started/getting_started.js
+++ b/packages/eui/src-docs/src/views/guidelines/getting_started/getting_started.js
@@ -8,6 +8,7 @@ import {
EuiSpacer,
EuiPanel,
EuiCallOut,
+ EuiLink,
} from '../../../../../src';
import { AppSetup } from './_app_setup';
@@ -98,6 +99,67 @@ export const GettingStarted = {
+
+
Customizing with classes
+
+ For consumers using vanilla or preprocessed CSS, all components
+ allow you to pass a custom className prop,
+ which will be appended onto the component.
+
+
+ Avoid overwriting .eui class names
+ >
+ }
+ >
+ EUI's class names are not a guaranteed API and are prone to
+ change, which will risk breaking your theme. Target your custom
+ classNames instead.
+
+
+
+ While EUI's styles are generally low in{' '}
+
+ specificity
+ {' '}
+ due to our usage of CSS-in-JS, you may need to ensure that your
+ CSS is defined after ours in your {''}.{' '}
+ See{' '}
+
+ EuiProvider's cache customization
+ {' '}
+ for more style injection options.
+
- Do not overwrite individual component variables or{' '}
- .eui class names.
-
-
- Although this may be possible, components are much more prone to
- change and you'll risk breaking your theme. All EUI
- components accept custom a className which you
- can use to append your custom styles.
-
- We do not recommend customizing EUI components by applying styles
- directly to EUI classes, eg. .euiButton. All
- components allow you to pass a custom className{' '}
- prop directly to the component which will then append this to the
- class list. Utilizing the cascade feature of CSS, you can then
- customize by overriding styles so long as your styles are imported{' '}
- after the EUI import.
-
-
-
-
- {''}
-
-
-
Renders as:
-
- {''}
-
- >
- ),
- },
{
title: 'Customizing component defaults',
wrapText: false,
diff --git a/packages/website/docs/01_guidelines/getting_started.mdx b/packages/website/docs/01_guidelines/getting_started.mdx
index 5b75c9f77f7..6175877fd4e 100644
--- a/packages/website/docs/01_guidelines/getting_started.mdx
+++ b/packages/website/docs/01_guidelines/getting_started.mdx
@@ -102,6 +102,34 @@ export default () => {
};
```
+### Customizing with classes
+
+For consumers using vanilla or preprocessed CSS, all components allow you to pass a custom `className` prop, which will be appended onto the component.
+
+:::warning Avoid overwriting `.eui` class names
+EUI's class names are not a guaranteed API and are prone to change, which will risk breaking your theme. Target your custom classNames instead.
+:::
+
+While EUI's styles are generally low in [specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) due to our usage of CSS-in-JS, you may need to ensure that your CSS is defined after ours in your ``. See [EuiProvider's cache customization](https://eui.elastic.co/#/utilities/provider#cache-customization) for more style injection options.
+
+```jsx
+import React from 'react';
+import { EuiButton } from '@elastic/eui';
+
+const myCustomCSS = `
+ .myCustomButton {
+ background-color: pink;
+ }
+`;
+
+export default () => (
+ <>
+
+ Hello world!
+ >
+);
+```
+
### Customizing the style tokens
EUI can be slightly customized to fit your branding needs by altering the base tokens like color and typography. You can pass a full or partial list of override tokens to the **EuiProvider**'s `modify` prop.
@@ -150,10 +178,6 @@ export default () => {
};
```
-#### Do not overwrite individual component variables or .eui class names.
-
-Although this may be possible, components are much more prone to change and you'll risk breaking your theme. All EUI components accept custom a className which you can use to append your custom styles.
-
## Fonts
By default, EUI ships with a font stack that includes some outside, open source fonts. If your system is internet
@@ -221,23 +245,6 @@ import { findTestSubject } from '@elastic/eui/lib/test'; // Enzyme
import { findByTestSubject, render, screen } from '@elastic/eui/lib/test/rtl'; // React Testing Library
```
-## Customizing with classes
-
-We do not recommend customizing EUI components by applying styles directly to EUI classes, eg. `.euiButton`.
-All components allow you to pass a custom `className` prop directly to the component which will then append this
-to the class list. Utilizing the cascade feature of CSS, you can then customize by overriding styles
-so long as your styles are imported `after` the EUI import.
-
-```jsx
-
-```
-
-Renders as:
-
-```jsx
-
-```
-
## Customizing component defaults
While all props can be individually customized via props, some components can have their default props customized
From 6b7435b3a06563e59b603bf790e9ca29aa3015b3 Mon Sep 17 00:00:00 2001
From: Cee Chen
Date: Wed, 18 Sep 2024 18:38:56 -0700
Subject: [PATCH 5/9] Delete now-unused `_customizing` file
+ refactor usage elsewhere
---
.../getting_started/_customizing.tsx | 105 ------------------
.../src/views/theme/customizing/_sass.tsx | 25 ++++-
2 files changed, 21 insertions(+), 109 deletions(-)
delete mode 100644 packages/eui/src-docs/src/views/guidelines/getting_started/_customizing.tsx
diff --git a/packages/eui/src-docs/src/views/guidelines/getting_started/_customizing.tsx b/packages/eui/src-docs/src/views/guidelines/getting_started/_customizing.tsx
deleted file mode 100644
index bd19330490e..00000000000
--- a/packages/eui/src-docs/src/views/guidelines/getting_started/_customizing.tsx
+++ /dev/null
@@ -1,105 +0,0 @@
-import React, { FunctionComponent, useContext } from 'react';
-import { Link } from 'react-router-dom';
-
-import {
- EuiCodeBlock,
- EuiSplitPanel,
- EuiFlexGroup,
- EuiFlexItem,
- EuiText,
- EuiHorizontalRule,
- EuiCode,
-} from '../../../../../src';
-
-import { GuideSectionExampleCode } from '../../../components/guide_section/guide_section_parts/guide_section_code';
-import { LanguageSelector, ThemeContext } from '../../../components/with_theme';
-const overrideSimpleSource = require('!!raw-loader!../../theme/override_simple');
-
-export const CustomizeTokens = () => {
- const themeContext = useContext(ThemeContext);
- let files;
- switch (themeContext.theme) {
- case 'dark':
- files = "@import '@elastic/eui/src/themes/amsterdam/theme_dark';";
- break;
- default:
- files = "@import '@elastic/eui/src/themes/amsterdam/theme_light';";
- break;
- }
-
- return (
-
- {`// mytheme.scss
-$euiColorPrimary: #7B61FF;
-
-// The following rebuilds the entire EUI component styles
-${files}
-
-@import 'your/custom/styles';`}
-
- );
-};
-
-export const Customizing: FunctionComponent = () => {
- const themeContext = useContext(ThemeContext);
- const currentLanguage = themeContext.themeLanguage;
- const showSass = currentLanguage.includes('sass');
-
- return (
-
-
-
-
-
-
-
- Keep an eye out for this language selector that will allow you
- to view the syntax for either the Sass or CSS-in-JS (Emotion)
- theming mechanisms.
-
-
-
-
-
-
-
-
-
-
- {showSass ? (
- <>
-
-
-
- This will require style, css, postcss, and sass loaders and a
- full re-compile of all EUI component styles.
-
-
-
-
-
-
- >
- ) : (
- <>
-
-
-
- You can pass along a full or partial list of global{' '}
- overrides to the{' '}
-
- EuiProvider
- {' '}
- which will update the EUI components that are currently using
- the Emotion method of theming.
-
diff --git a/packages/eui/src-docs/src/views/theme/_components/_theme_notice.tsx b/packages/eui/src-docs/src/views/theme/_components/_theme_notice.tsx
index 209b74e53a3..75d63c50315 100644
--- a/packages/eui/src-docs/src/views/theme/_components/_theme_notice.tsx
+++ b/packages/eui/src-docs/src/views/theme/_components/_theme_notice.tsx
@@ -1,32 +1,25 @@
-import React, { FunctionComponent } from 'react';
+import React from 'react';
+import { Link } from 'react-router-dom';
import { EuiCallOut, EuiLink } from '../../../../../src';
-type ThemeNotice = {
- type?: 'support' | null;
-};
-
-export const ThemeNotice: FunctionComponent = ({
- type = 'support',
-}) => {
- const support = (
-
-
- EUI is transitioning to a CSS-in-JS solution for theming and requires
- consuming/customizing global variables in{' '}
- both the Sass and CSS-in-JS methods. To track this
- effort, subscribe to the{' '}
-
- Meta ticket
-
- .
-
+ EUI is transitioning to a CSS-in-JS solution for theming, and will
+ eventually deprecate all exported Sass variables and mixins. We strongly
+ recommend moving your usages of Sass to{' '}
+
+ Emotion
+ {' '}
+ or other CSS-in-JS solutions. To track this migration, subscribe to the{' '}
+
+ Meta ticket
+
+ .
+
+
+);
From 4a2e0ffa90f5852fe6555cbfb84006cce6fcec12 Mon Sep 17 00:00:00 2001
From: Cee Chen
Date: Wed, 18 Sep 2024 18:59:56 -0700
Subject: [PATCH 7/9] Clean up CodeSandbox links
- no need to import `.css` files any longer
- remove context, use `useEuiTheme()` instead
---
.../src/components/codesandbox/link.js | 37 +++----------------
1 file changed, 5 insertions(+), 32 deletions(-)
diff --git a/packages/eui/src-docs/src/components/codesandbox/link.js b/packages/eui/src-docs/src/components/codesandbox/link.js
index 214a8aae8de..4ed303ea954 100644
--- a/packages/eui/src-docs/src/components/codesandbox/link.js
+++ b/packages/eui/src-docs/src/components/codesandbox/link.js
@@ -1,13 +1,12 @@
import React from 'react';
import { getParameters } from 'codesandbox/lib/api/define';
+import { useEuiTheme } from '../../../../src/services';
import {
cleanEuiImports,
hasDisplayToggles,
listExtraDeps,
} from '../../services';
-import { ThemeContext } from '../with_theme';
-
const pkg = require('../../../../package.json');
const getVersion = (packageName) => {
@@ -33,39 +32,14 @@ const getVersion = (packageName) => {
const displayTogglesRawCode =
require('!!raw-loader!../../views/form_controls/display_toggles').default;
-export const CodeSandboxLink = ({ ...rest }) => {
- return (
-
- {(context) => }
-
- );
-};
-
/* 1 */
-export const CodeSandboxLinkComponent = ({
+export const CodeSandboxLink = ({
children,
className,
content,
type = 'js',
- context,
}) => {
- const isDarkMode = context.theme.includes('dark');
- const colorMode = isDarkMode ? 'dark' : 'light';
-
- const cssFile = `@elastic/eui/dist/eui_theme_${colorMode}.css`;
-
- const providerPropsObject = {};
- // Only add configuration if it isn't the default
- if (isDarkMode) {
- providerPropsObject.colorMode = 'dark';
- }
- // Can't spread an object inside of a string literal
- const providerProps = Object.keys(providerPropsObject)
- .map((prop) => {
- const value = providerPropsObject[prop];
- return value !== null ? `${prop}="${value}"` : `${prop}={${value}}`;
- })
- .join(' ');
+ const { colorMode } = useEuiTheme();
let demoContent;
@@ -165,8 +139,7 @@ import '@elastic/charts/dist/theme_only_${colorMode}.css';`
content: demoContent,
},
'index.js': {
- content: `import '${cssFile}';
-import React from 'react';
+ content: `import React from 'react';
import { createRoot } from 'react-dom/client';
import createCache from '@emotion/cache';
import { EuiProvider, euiStylisPrefixer } from '@elastic/eui';
@@ -182,7 +155,7 @@ cache.compat = true;
const root = createRoot(document.getElementById('root'));
root.render(
-
+
);`,
From 6bbfad70378e96c20e4bc3f3dccd5adaed798490 Mon Sep 17 00:00:00 2001
From: Cee Chen
Date: Wed, 18 Sep 2024 18:57:26 -0700
Subject: [PATCH 8/9] Remove reference to Emotion migration in top-level README
+ remove duplicated README in `packges/eui` - half the links don't work anyway
---
README.md | 7 ++---
packages/eui/README.md | 70 +-----------------------------------------
2 files changed, 3 insertions(+), 74 deletions(-)
diff --git a/README.md b/README.md
index 694c966f993..54db578deb3 100644
--- a/README.md
+++ b/README.md
@@ -45,12 +45,9 @@ This activity counter can be soft reset by commenting on the issue directly, but
The EUI team, like everyone else, has a finite amount of time and resources, and it is not humanly possible for us to implement every task or feature requested of us. However, that's where the beauty of open source comes in - if your request is important to you, we strongly encourage you to [contribute code directly to EUI](wiki/contributing-to-eui/) that addresses your issue or request!
-
-### What is the status of EUI's theming?
+### I have more questions!
-The EUI library was previously built upon Sass and is in the process of migrating to CSS-in-JS (specifically [Emotion](https://emotion.sh)). While this work is in progress, we ask for your patience with our in-between state in areas such as documentation and setup.
-
-If you're a Kibana developer with questions around CSS-in-JS usage in Kibana, please check out our [FAQ discussion](https://github.com/elastic/eui/discussions/6828)!
+The EUI team has ongoing FAQs for more transient or component-specific questions. [Please see the FAQ section in our GitHub discussions here](https://github.com/elastic/eui/discussions/categories/faq).
## Wiki
diff --git a/packages/eui/README.md b/packages/eui/README.md
index 694c966f993..7012e6ff7d0 100644
--- a/packages/eui/README.md
+++ b/packages/eui/README.md
@@ -1,69 +1 @@
-
-
-# Elastic UI Framework
-
-**The Elastic UI Framework is a collection of React UI components for quickly building user interfaces at Elastic.**
-
-Check out our [full documentation site][docs] which contains many examples of components in the EUI framework aesthetic, and how to use them in your products. Our FAQ below covers common usage questions — for other general questions regarding EUI, check out the [Discussions tab](https://github.com/elastic/eui/discussions).
-
-> [!NOTE]
-> We're in the process of migrating this repository to a monorepo structure. You can find `@elastic/eui` files in the [packages/eui](https://github.com/elastic/eui/tree/main/packages/eui) directory.
-
-## Frequently Asked Questions
-
-### What is the Elastic UI Framework?
-
-The Elastic UI Framework (EUI) is a design library in use at Elastic to build React applications that need to share our branding and aesthetics. It distributes typed UI React components and static assets for use in building web layouts. Alongside the React components, we ship theme & style utilities that can be used independently on their own.
-
-The primary goal of this library is to provide reusable UI components that can be used throughout Elastic's web products. As React components, they remove CSS from the process of building UIs. As a single source of truth, the framework allows our designers to make changes to our aesthetic directly in the code. And unit test coverage for the UI components allows us to deliver a stable "API for user interfaces".
-
-### Can I use EUI?
-
-Please see Elastic's licensing FAQ: [I’m using EUI or Elastic Charts in my application outside of Kibana, how does this affect me?][licensing-faq]
-
-### Why is EUI open source?
-
-Many of Elastic's products are open source and rely upon this library to function. The Elastic UI Framework began as a folder of code in Kibana and we decided it could be used beyond that codebase. It exists as an independent library so that patterns can be shared across teams and design standards can be scaled across our organization. Since most of our products are open source, we treat this one similarly as far as public publishing and conversation even if its usage tends to focus more inward towards Elastic itself.
-
-### What is the versioning, release, and upgrade strategy?
-
-We use [semver](https://semver.org/) for versioning and use that to denote breaking changes in EUI upgrades. Traditionally we consider API changes in our prop names or existing component functionality to be a reason for a breaking change, but do not track the renaming of CSS selectors, mixins or other style changes under this same rigor.
-
-Traditionally releases are made weekly against whatever is in the `main` branch and you can upgrade from NPM as you see fit.
-
-### Can I contribute to EUI?
-
-Yes! We welcome community-contributed PRs, especially around feature requests that the EUI team may not have bandwidth to carry out alone. You can find documentation around creating and submitting new components in [our wiki](wiki/contributing-to-eui/).
-
-### What about reporting bugs and feature requests?
-
-Bug reports and feature requests are most welcome, but our roadmap and prioritization are driven primarily by [internal Elastic usage](wiki/contributing-to-eui#how-we-assign-work-and-define-our-roadmap).
-
-Please note that in order to keep our backlog manageable and focused on tasks we intend to complete, feature requests & tech debt issues that are inactive for a year will be auto-closed (bugs will remain open if determined to be reproducible and valid).
-
-This activity counter can be soft reset by commenting on the issue directly, but please do so mindfully. We would ask that you proactively let the EUI team know why this request matters to you or how it impacts you or your users, in order to help us prioritize accordingly.
-
-The EUI team, like everyone else, has a finite amount of time and resources, and it is not humanly possible for us to implement every task or feature requested of us. However, that's where the beauty of open source comes in - if your request is important to you, we strongly encourage you to [contribute code directly to EUI](wiki/contributing-to-eui/) that addresses your issue or request!
-
-
-### What is the status of EUI's theming?
-
-The EUI library was previously built upon Sass and is in the process of migrating to CSS-in-JS (specifically [Emotion](https://emotion.sh)). While this work is in progress, we ask for your patience with our in-between state in areas such as documentation and setup.
-
-If you're a Kibana developer with questions around CSS-in-JS usage in Kibana, please check out our [FAQ discussion](https://github.com/elastic/eui/discussions/6828)!
-
-## Wiki
-
-Our wiki docs contain instructions and guidelines on multiple areas of EUI usage and development that are too detailed for an initial README. For more information, see:
-
-- [Consuming EUI](wiki/consuming-eui)
-- [Contributing to EUI](wiki/contributing-to-eui/)
-- [Running EUI locally](wiki/contributing-to-eui/running-eui-locally.md)
-
-## License
-
-[Dual-licensed under Elastic v2 and Server Side Public License, v1][license]. See Elastic's [licensing FAQ][licensing-faq] for details.
-
-[license]: LICENSE.txt
-[licensing-faq]: https://www.elastic.co/pricing/faq/licensing#im-using-eui-or-elastic-charts-in-my-application-outside-of-kibana-how-does-this-affect-me
-[docs]: https://elastic.github.io/eui/
+## See [the top-level repo README](../../#readme) and [wiki](../../wiki) for more information on consuming and contributing to EUI.
From 21c747023d3982b9f29f7c38d140039a8ae52fdf Mon Sep 17 00:00:00 2001
From: Cee Chen
Date: Fri, 20 Sep 2024 13:34:33 -0700
Subject: [PATCH 9/9] Remove page title beta badge from Emotion utilities
---
.../guide_tabbed_page/guide_tabbed_page.tsx | 19 +++++++++----------
.../src/views/theme/borders/borders.tsx | 1 -
.../src/views/theme/customizing/values.tsx | 1 -
.../src-docs/src/views/theme/other/other.tsx | 1 -
4 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/packages/eui/src-docs/src/components/guide_tabbed_page/guide_tabbed_page.tsx b/packages/eui/src-docs/src/components/guide_tabbed_page/guide_tabbed_page.tsx
index 8155a4a333a..78116df1354 100644
--- a/packages/eui/src-docs/src/components/guide_tabbed_page/guide_tabbed_page.tsx
+++ b/packages/eui/src-docs/src/components/guide_tabbed_page/guide_tabbed_page.tsx
@@ -62,16 +62,15 @@ export const GuideTabbedPage: FunctionComponent = ({
const currentLanguage = themeContext.themeLanguage;
const showSass = currentLanguage.includes('sass');
- const headerBadge =
- isBeta || (showThemeLanguageToggle && !showSass) ? (
-
- ) : isNew ? (
-
- ) : undefined;
+ const headerBadge = isBeta ? (
+
+ ) : isNew ? (
+
+ ) : undefined;
let tabs:
| Array<{
diff --git a/packages/eui/src-docs/src/views/theme/borders/borders.tsx b/packages/eui/src-docs/src/views/theme/borders/borders.tsx
index 70866f0fbde..cf0ccca8e82 100644
--- a/packages/eui/src-docs/src/views/theme/borders/borders.tsx
+++ b/packages/eui/src-docs/src/views/theme/borders/borders.tsx
@@ -90,7 +90,6 @@ export default () => {
return (
}
description="The border tokens contain both individual border property values and full shorthand border properties."
showThemeLanguageToggle
diff --git a/packages/eui/src-docs/src/views/theme/customizing/values.tsx b/packages/eui/src-docs/src/views/theme/customizing/values.tsx
index e9980cd6d28..dacec14139b 100644
--- a/packages/eui/src-docs/src/views/theme/customizing/values.tsx
+++ b/packages/eui/src-docs/src/views/theme/customizing/values.tsx
@@ -81,7 +81,6 @@ export default () => {
return (
}
showThemeLanguageToggle
diff --git a/packages/eui/src-docs/src/views/theme/other/other.tsx b/packages/eui/src-docs/src/views/theme/other/other.tsx
index 9dfe253df29..68202c35c23 100644
--- a/packages/eui/src-docs/src/views/theme/other/other.tsx
+++ b/packages/eui/src-docs/src/views/theme/other/other.tsx
@@ -121,7 +121,6 @@ export default () => {
return (
}
showThemeLanguageToggle
description="Here are a few more global theme tokens for styles we use throughout EUI."