Skip to content
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

[WIP] Components: Add size variant context #41913

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { isEmpty } from 'lodash';
* WordPress dependencies
*/
import {
__experimentalContextSystemProvider as ContextSystemProvider,
__experimentalSizeVariantContext as SIZE_VARIANT_CONTEXT,
__experimentalStyleProvider as StyleProvider,
__experimentalToolsPanelContext as ToolsPanelContext,
} from '@wordpress/components';
Expand Down Expand Up @@ -42,9 +44,13 @@ export default function InspectorControlsFill( {
// Provider in this subtree.
const value = ! isEmpty( fillProps ) ? fillProps : null;
return (
<ContextSystemProvider
value={ SIZE_VARIANT_CONTEXT[ '40px' ] }
>
<ToolsPanelContext.Provider value={ value }>
{ children }
</ToolsPanelContext.Provider>
</ContextSystemProvider>
);
} }
</Fill>
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export {
useCompositeState as __unstableUseCompositeState,
} from './composite';
export { ConfirmDialog as __experimentalConfirmDialog } from './confirm-dialog';
export {
SIZE_VARIANT_CONTEXT as __experimentalSizeVariantContext,
ContextSystemProvider as __experimentalContextSystemProvider,
} from './ui/context';
export { default as CustomSelectControl } from './custom-select-control';
export { default as Dashicon } from './dashicon';
export { default as DateTimePicker, DatePicker, TimePicker } from './date-time';
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/ui/context/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ export const CONTEXT_COMPONENT_NAMESPACE = 'data-wp-c5tc8t';
* This is attached to Context connected components as a static property.
*/
export const CONNECT_STATIC_NAMESPACE = '__contextSystemKey__';

export const SIZE_VARIANT_CONTEXT = {
'40px': {
InputControl: {
size: '__unstable-large',
},
},
};
1 change: 1 addition & 0 deletions packages/components/src/ui/context/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { SIZE_VARIANT_CONTEXT } from './constants';
export {
ContextSystemProvider,
useComponentsContext,
Expand Down
4 changes: 4 additions & 0 deletions packages/edit-site/src/components/global-styles/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
* WordPress dependencies
*/
import {
__experimentalContextSystemProvider as ContextSystemProvider,
__experimentalNavigatorProvider as NavigatorProvider,
__experimentalNavigatorScreen as NavigatorScreen,
__experimentalSizeVariantContext as SIZE_VARIANT_CONTEXT,
} from '@wordpress/components';
import { getBlockTypes } from '@wordpress/blocks';

Expand Down Expand Up @@ -97,6 +99,7 @@ function GlobalStylesUI() {
className="edit-site-global-styles-sidebar__navigator-provider"
initialPath="/"
>
<ContextSystemProvider value={ SIZE_VARIANT_CONTEXT[ '40px' ] }>
<GlobalStylesNavigationScreen path="/">
<ScreenRoot />
</GlobalStylesNavigationScreen>
Expand Down Expand Up @@ -126,6 +129,7 @@ function GlobalStylesUI() {
name={ block.name }
/>
) ) }
</ContextSystemProvider>
</NavigatorProvider>
);
}
Expand Down