-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Automatic CSS Variable fallbacks (Components CSS) #24094
Changes from all commits
c8e5f15
30e08f4
db5d4ee
d769a9a
dd69ce9
7f3e300
2fd0ae1
a0be76b
eeebf56
064d109
083a0f0
f354ad4
d9f69b2
094642b
a14a378
2a2118f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import createEmotionCache from '@emotion/cache'; | ||
import { CacheProvider } from '@emotion/core'; | ||
import stylisPluginCssVariables from 'stylis-plugin-css-variables'; | ||
import memoize from 'memize'; | ||
|
||
const createCustomCache = memoize( () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technique suggested by a core Emotion member: |
||
return createEmotionCache( { | ||
stylisPlugins: [ stylisPluginCssVariables() ], | ||
} ); | ||
} ); | ||
|
||
function StyledProvider( { children, ...props } ) { | ||
return ( | ||
<CacheProvider { ...props } value={ createCustomCache() }> | ||
{ children } | ||
</CacheProvider> | ||
); | ||
} | ||
|
||
export default StyledProvider; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Implementation not required (at the moment) for react-native style rendering. | ||
*/ | ||
export default function StyledProvider( { children } ) { | ||
return children; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import memize from 'memize'; | |
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __experimentalStyledProvider as StyledProvider } from '@wordpress/components'; | ||
import { compose } from '@wordpress/compose'; | ||
import { Component } from '@wordpress/element'; | ||
import { withDispatch, withSelect } from '@wordpress/data'; | ||
|
@@ -271,7 +272,7 @@ class EditorProvider extends Component { | |
); | ||
|
||
return ( | ||
<> | ||
<StyledProvider> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This enables it for the post-editor (probably better moved to edit-post) but not for edit-widgets, edit-site, edit-navigation and list-reusabale-blocks (these are the top level packages).
|
||
<EditorStyles styles={ settings.styles } /> | ||
<EntityProvider kind="root" type="site"> | ||
<EntityProvider | ||
|
@@ -296,7 +297,7 @@ class EditorProvider extends Component { | |
</BlockContextProvider> | ||
</EntityProvider> | ||
</EntityProvider> | ||
</> | ||
</StyledProvider> | ||
); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as withStyledProvider } from './with-styled-provider'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { __experimentalStyledProvider as StyledProvider } from '../../packages/components/src/index'; | ||
|
||
function withStyledProvider( storyFn ) { | ||
return <StyledProvider>{ storyFn() }</StyledProvider>; | ||
} | ||
|
||
export default withStyledProvider; |
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.
Code originally existed in this repo as part of this PR.
It was abstracted to a separate repo/package:
https://github.com/ItsJonQ/stylis-plugin-css-variables