Skip to content

Commit

Permalink
Merge branch 'main' into emotion/progress
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Jun 22, 2022
2 parents 111f321 + a91b47d commit 03f0b5a
Show file tree
Hide file tree
Showing 16 changed files with 2,392 additions and 1,040 deletions.
2 changes: 2 additions & 0 deletions src-docs/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<meta property="og:url" content="hhttps://elastic.github.io/eui">
<meta name="twitter:card" content="summary_large_image">
<meta name="emotion-styles">
<meta name="sass-styles-compiled">
<meta name="emotion-styles-utility">
</head>
<body class="guideBody">
<div id="guide"></div>
Expand Down
15 changes: 11 additions & 4 deletions src-docs/src/views/app_context.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ import favicon16Dev from '../images/favicon/dev/favicon-16x16.png';
import favicon32Dev from '../images/favicon/dev/favicon-32x32.png';
import favicon96Dev from '../images/favicon/dev/favicon-96x96.png';

const emotionCache = createCache({
key: 'eui-docs',
const generalEmotionCache = createCache({
key: 'css',
container: document.querySelector('meta[name="emotion-styles"]'),
});
emotionCache.compat = true;
generalEmotionCache.compat = true;
const utilityCache = createCache({
key: 'util',
container: document.querySelector('meta[name="emotion-styles-utility"]'),
});

export const AppContext = ({ children }) => {
const { theme } = useContext(ThemeContext);
Expand All @@ -41,7 +45,10 @@ export const AppContext = ({ children }) => {

return (
<EuiProvider
cache={emotionCache}
cache={{
default: generalEmotionCache,
utility: utilityCache,
}}
theme={EUI_THEMES.find((t) => t.value === theme)?.provider}
colorMode={theme.includes('light') ? 'light' : 'dark'}
>
Expand Down
17 changes: 15 additions & 2 deletions src-docs/src/views/provider/provider_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,25 @@ export const ProviderExample = {
The <strong>@emotion/cache</strong> library
</EuiLink>{' '}
provides configuration options that help with specifying the
injection location. We recommend using a{' '}
<EuiCode>{'<meta>'}</EuiCode> tag to achieve this.
injection location. We recommend using <EuiCode>{'<meta>'}</EuiCode>{' '}
tags to achieve this.
</p>

<GlobalStyles />

<p>
For most applications, the above configuration will be enough to
have styles ordered correctly. In advanced more cases, you may use
the <EuiCode>default</EuiCode>,<EuiCode>global</EuiCode>, and{' '}
<EuiCode>utility</EuiCode> properties on the{' '}
<EuiCode>cache</EuiCode> prop to further define where specific
styles should be inserted. See{' '}
<EuiLink href="#/utilities/provider#euiprovider-props">
the props documentation
</EuiLink>{' '}
for details.
</p>

<p>
Any other options available with{' '}
<EuiLink
Expand Down
13 changes: 8 additions & 5 deletions src-docs/src/views/provider/provider_styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export default () => {
<html lang="en">
<head>
<title>My App</title>
<meta name="emotion-style-insert">
<meta name="eui-style-insert">
<link name="compiled-css-here" />
</head>
<body>
<div id="root"></div>
Expand All @@ -28,13 +29,15 @@ export default () => {
import { EuiProvider } from '@elastic/eui'
import createCache from '@emotion/cache';
const cache = createCache({
key: 'myApp',
container: document.querySelector('meta[name="emotion-style-insert"]'),
const euiCache = createCache({
key: 'eui',
container: document.querySelector('meta[name="eui-style-insert"]'),
});
cache.compat = true;
<EuiProvider${colorMode === 'DARK' ? ' colorMode="dark"' : ''} cache={cache}'>
<EuiProvider${
colorMode === 'DARK' ? ' colorMode="dark"' : ''
} cache={euiCache}'>
{/* Content */}
</EuiProvider>
`}
Expand Down
5 changes: 4 additions & 1 deletion src-docs/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ const webpackConfig = {
loaders: employCache([
{
loader: 'style-loader',
options: { injectType: 'lazySingletonStyleTag' },
options: {
injectType: 'lazySingletonStyleTag',
insert: 'meta[name="sass-styles-compiled"]',
},
},
'css-loader',
'postcss-loader',
Expand Down
Loading

0 comments on commit 03f0b5a

Please sign in to comment.