@wordpress/global-styles-ui 1.17.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/build/block-preview-panel.cjs +36 -3
- package/build/block-preview-panel.cjs.map +3 -3
- package/build/font-library/font-collection.cjs +0 -1
- package/build/font-library/font-collection.cjs.map +2 -2
- package/build/font-sizes/rename-font-size-dialog.cjs +0 -1
- package/build/font-sizes/rename-font-size-dialog.cjs.map +2 -2
- package/build/preview-wrapper.cjs +11 -0
- package/build/preview-wrapper.cjs.map +2 -2
- package/build/screen-block.cjs +35 -23
- package/build/screen-block.cjs.map +2 -2
- package/build/screen-color-palette.cjs +8 -10
- package/build/screen-color-palette.cjs.map +3 -3
- package/build/screen-typography-element.cjs +0 -1
- package/build/screen-typography-element.cjs.map +2 -2
- package/build/shadows-edit-panel.cjs +0 -3
- package/build/shadows-edit-panel.cjs.map +2 -2
- package/build/size-control/index.cjs +0 -2
- package/build/size-control/index.cjs.map +2 -2
- package/build/utils.cjs +7 -2
- package/build/utils.cjs.map +3 -3
- package/build-module/block-preview-panel.mjs +40 -4
- package/build-module/block-preview-panel.mjs.map +2 -2
- package/build-module/font-library/font-collection.mjs +0 -1
- package/build-module/font-library/font-collection.mjs.map +2 -2
- package/build-module/font-sizes/rename-font-size-dialog.mjs +0 -1
- package/build-module/font-sizes/rename-font-size-dialog.mjs.map +2 -2
- package/build-module/preview-wrapper.mjs +11 -0
- package/build-module/preview-wrapper.mjs.map +2 -2
- package/build-module/screen-block.mjs +35 -23
- package/build-module/screen-block.mjs.map +2 -2
- package/build-module/screen-color-palette.mjs +8 -10
- package/build-module/screen-color-palette.mjs.map +2 -2
- package/build-module/screen-typography-element.mjs +0 -1
- package/build-module/screen-typography-element.mjs.map +2 -2
- package/build-module/shadows-edit-panel.mjs +0 -3
- package/build-module/shadows-edit-panel.mjs.map +2 -2
- package/build-module/size-control/index.mjs +0 -2
- package/build-module/size-control/index.mjs.map +2 -2
- package/build-module/utils.mjs +11 -3
- package/build-module/utils.mjs.map +2 -2
- package/build-style/style-rtl.css +21 -7
- package/build-style/style.css +21 -7
- package/build-types/background-panel.d.ts +0 -3
- package/build-types/background-panel.d.ts.map +1 -1
- package/build-types/block-preview-panel.d.ts +5 -4
- package/build-types/block-preview-panel.d.ts.map +1 -1
- package/build-types/confirm-reset-shadow-dialog.d.ts +1 -1
- package/build-types/confirm-reset-shadow-dialog.d.ts.map +1 -1
- package/build-types/dimensions-panel.d.ts +0 -3
- package/build-types/dimensions-panel.d.ts.map +1 -1
- package/build-types/font-library/collection-font-variant.d.ts +1 -1
- package/build-types/font-library/collection-font-variant.d.ts.map +1 -1
- package/build-types/font-library/font-card.d.ts +1 -1
- package/build-types/font-library/font-card.d.ts.map +1 -1
- package/build-types/font-library/font-collection.d.ts.map +1 -1
- package/build-types/font-library/font-library.d.ts +1 -1
- package/build-types/font-library/font-library.d.ts.map +1 -1
- package/build-types/font-library/library-font-variant.d.ts +1 -1
- package/build-types/font-library/library-font-variant.d.ts.map +1 -1
- package/build-types/font-library/modal.d.ts +1 -1
- package/build-types/font-library/modal.d.ts.map +1 -1
- package/build-types/font-sizes/confirm-delete-font-size-dialog.d.ts +1 -1
- package/build-types/font-sizes/confirm-delete-font-size-dialog.d.ts.map +1 -1
- package/build-types/font-sizes/confirm-reset-font-sizes-dialog.d.ts +1 -1
- package/build-types/font-sizes/confirm-reset-font-sizes-dialog.d.ts.map +1 -1
- package/build-types/font-sizes/font-size-preview.d.ts +0 -3
- package/build-types/font-sizes/font-size-preview.d.ts.map +1 -1
- package/build-types/font-sizes/rename-font-size-dialog.d.ts +1 -1
- package/build-types/font-sizes/rename-font-size-dialog.d.ts.map +1 -1
- package/build-types/global-styles-ui.d.ts +1 -1
- package/build-types/global-styles-ui.d.ts.map +1 -1
- package/build-types/gradients-palette-panel.d.ts +1 -1
- package/build-types/gradients-palette-panel.d.ts.map +1 -1
- package/build-types/highlighted-colors.d.ts +1 -1
- package/build-types/highlighted-colors.d.ts.map +1 -1
- package/build-types/pagination/index.d.ts +1 -1
- package/build-types/pagination/index.d.ts.map +1 -1
- package/build-types/preview-styles.d.ts +1 -1
- package/build-types/preview-styles.d.ts.map +1 -1
- package/build-types/preview-wrapper.d.ts +1 -1
- package/build-types/preview-wrapper.d.ts.map +1 -1
- package/build-types/provider.d.ts +1 -1
- package/build-types/provider.d.ts.map +1 -1
- package/build-types/screen-block.d.ts.map +1 -1
- package/build-types/screen-color-palette.d.ts.map +1 -1
- package/build-types/screen-header.d.ts +1 -1
- package/build-types/screen-header.d.ts.map +1 -1
- package/build-types/screen-revisions/revisions-buttons.d.ts +1 -1
- package/build-types/screen-revisions/revisions-buttons.d.ts.map +1 -1
- package/build-types/screen-revisions/use-global-styles-revisions.d.ts +1 -1
- package/build-types/screen-revisions/use-global-styles-revisions.d.ts.map +1 -1
- package/build-types/screen-typography-element.d.ts.map +1 -1
- package/build-types/shadows-edit-panel.d.ts.map +1 -1
- package/build-types/size-control/index.d.ts.map +1 -1
- package/build-types/style-variations-container.d.ts +1 -1
- package/build-types/style-variations-container.d.ts.map +1 -1
- package/build-types/typography-example.d.ts +1 -1
- package/build-types/typography-example.d.ts.map +1 -1
- package/build-types/typography-panel.d.ts +1 -4
- package/build-types/typography-panel.d.ts.map +1 -1
- package/build-types/typography-preview.d.ts +1 -1
- package/build-types/typography-preview.d.ts.map +1 -1
- package/build-types/utils.d.ts +3 -2
- package/build-types/utils.d.ts.map +1 -1
- package/build-types/variations/variation.d.ts +1 -1
- package/build-types/variations/variation.d.ts.map +1 -1
- package/build-types/variations/variations-color.d.ts +1 -1
- package/build-types/variations/variations-color.d.ts.map +1 -1
- package/build-types/variations/variations-typography.d.ts +1 -1
- package/build-types/variations/variations-typography.d.ts.map +1 -1
- package/package.json +22 -22
- package/src/block-preview-panel.tsx +56 -4
- package/src/font-library/font-collection.tsx +0 -1
- package/src/font-library/style.scss +4 -4
- package/src/font-sizes/rename-font-size-dialog.tsx +0 -1
- package/src/preview-wrapper.tsx +10 -0
- package/src/screen-block.tsx +40 -25
- package/src/screen-color-palette.tsx +15 -19
- package/src/screen-revisions/style.scss +1 -1
- package/src/screen-typography-element.tsx +0 -1
- package/src/shadows-edit-panel.tsx +0 -3
- package/src/size-control/index.tsx +0 -2
- package/src/stories/index.story.jsx +1 -1
- package/src/style.scss +10 -2
- package/src/utils.ts +26 -4
package/src/preview-wrapper.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
useResizeObserver,
|
|
14
14
|
} from '@wordpress/compose';
|
|
15
15
|
import { useLayoutEffect, useState } from '@wordpress/element';
|
|
16
|
+
import { Skeleton } from '@wordpress/ui';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Internal dependencies
|
|
@@ -101,6 +102,15 @@ function PreviewWrapper( {
|
|
|
101
102
|
<div style={ { position: 'relative' } }>
|
|
102
103
|
{ containerResizeListener }
|
|
103
104
|
</div>
|
|
105
|
+
{ ! isReady && (
|
|
106
|
+
// Match the preview aspect ratio so layout doesn't jump once width is measured.
|
|
107
|
+
<Skeleton
|
|
108
|
+
className="global-styles-ui-preview__wrapper"
|
|
109
|
+
style={ {
|
|
110
|
+
aspectRatio: normalizedWidth / normalizedHeight,
|
|
111
|
+
} }
|
|
112
|
+
/>
|
|
113
|
+
) }
|
|
104
114
|
{ isReady && (
|
|
105
115
|
<div
|
|
106
116
|
className={ clsx( 'global-styles-ui-preview__wrapper', {
|
package/src/screen-block.tsx
CHANGED
|
@@ -100,8 +100,11 @@ interface ScreenBlockProps {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
function ScreenBlock( { name, variation }: ScreenBlockProps ) {
|
|
103
|
-
const {
|
|
104
|
-
|
|
103
|
+
const {
|
|
104
|
+
user: userConfig,
|
|
105
|
+
merged: mergedConfig,
|
|
106
|
+
onChange: onChangeGlobalStyles,
|
|
107
|
+
} = useContext( GlobalStylesContext );
|
|
105
108
|
|
|
106
109
|
let prefixParts: string[] = [];
|
|
107
110
|
if ( variation ) {
|
|
@@ -114,13 +117,24 @@ function ScreenBlock( { name, variation }: ScreenBlockProps ) {
|
|
|
114
117
|
useState< string >( 'default' );
|
|
115
118
|
const [ selectedPseudoState, setSelectedPseudoState ] =
|
|
116
119
|
useState< string >( 'default' );
|
|
117
|
-
const
|
|
120
|
+
const viewportSettings = mergedConfig.settings?.viewport;
|
|
121
|
+
const validViewportStates = useMemo(
|
|
122
|
+
() => getValidViewportStates( viewportSettings ),
|
|
123
|
+
[ viewportSettings ]
|
|
124
|
+
);
|
|
125
|
+
const effectiveSelectedViewport =
|
|
126
|
+
selectedViewport === 'default' ||
|
|
127
|
+
validViewportStates.some(
|
|
128
|
+
( state ) => state.value === selectedViewport
|
|
129
|
+
)
|
|
130
|
+
? selectedViewport
|
|
131
|
+
: 'default';
|
|
118
132
|
const validPseudoStates = useMemo(
|
|
119
133
|
() => getValidPseudoStates( name ),
|
|
120
134
|
[ name ]
|
|
121
135
|
);
|
|
122
136
|
|
|
123
|
-
const stateParam = [
|
|
137
|
+
const stateParam = [ effectiveSelectedViewport, selectedPseudoState ]
|
|
124
138
|
.filter( ( value ) => value !== 'default' )
|
|
125
139
|
.join( '.' );
|
|
126
140
|
const hasSelectedState = stateParam.length > 0;
|
|
@@ -194,7 +208,7 @@ function ScreenBlock( { name, variation }: ScreenBlockProps ) {
|
|
|
194
208
|
const hasDimensionsPanel = useHasDimensionsPanel( settings );
|
|
195
209
|
const hasFiltersPanel = useHasFiltersPanel( settings );
|
|
196
210
|
const shouldShowFiltersPanel =
|
|
197
|
-
hasFiltersPanel &&
|
|
211
|
+
hasFiltersPanel && effectiveSelectedViewport === 'default';
|
|
198
212
|
const hasImageSettingsPanel = useHasImageSettingsPanel(
|
|
199
213
|
name,
|
|
200
214
|
userSettings,
|
|
@@ -344,7 +358,7 @@ function ScreenBlock( { name, variation }: ScreenBlockProps ) {
|
|
|
344
358
|
}
|
|
345
359
|
viewportStates={ validViewportStates }
|
|
346
360
|
pseudoStates={ validPseudoStates }
|
|
347
|
-
selectedViewport={
|
|
361
|
+
selectedViewport={ effectiveSelectedViewport }
|
|
348
362
|
selectedPseudoState={ selectedPseudoState }
|
|
349
363
|
onChangeViewport={ setSelectedViewport }
|
|
350
364
|
onChangePseudoState={ setSelectedPseudoState }
|
|
@@ -352,9 +366,10 @@ function ScreenBlock( { name, variation }: ScreenBlockProps ) {
|
|
|
352
366
|
<BlockPreviewPanel
|
|
353
367
|
name={ name }
|
|
354
368
|
variation={ variation }
|
|
355
|
-
selectedViewport={
|
|
369
|
+
selectedViewport={ effectiveSelectedViewport }
|
|
356
370
|
selectedState={ hasSelectedState ? stateParam : 'default' }
|
|
357
371
|
stateStyles={ hasSelectedState ? inheritedStyle : undefined }
|
|
372
|
+
viewportSettings={ viewportSettings }
|
|
358
373
|
/>
|
|
359
374
|
{ hasVariationsPanel && (
|
|
360
375
|
<div className="global-styles-ui-screen-variations">
|
|
@@ -364,15 +379,6 @@ function ScreenBlock( { name, variation }: ScreenBlockProps ) {
|
|
|
364
379
|
</VStack>
|
|
365
380
|
</div>
|
|
366
381
|
) }
|
|
367
|
-
{ hasBackgroundPanel && (
|
|
368
|
-
<StylesBackgroundPanel
|
|
369
|
-
inheritedValue={ inheritedStyle }
|
|
370
|
-
value={ style }
|
|
371
|
-
onChange={ setStyle }
|
|
372
|
-
settings={ settings }
|
|
373
|
-
defaultValues={ BACKGROUND_BLOCK_DEFAULT_VALUES }
|
|
374
|
-
/>
|
|
375
|
-
) }
|
|
376
382
|
{ hasTypographyPanel && (
|
|
377
383
|
<StylesTypographyPanel
|
|
378
384
|
inheritedValue={ inheritedStyle }
|
|
@@ -385,6 +391,24 @@ function ScreenBlock( { name, variation }: ScreenBlockProps ) {
|
|
|
385
391
|
isGlobalStyles={ ! hasSelectedState }
|
|
386
392
|
/>
|
|
387
393
|
) }
|
|
394
|
+
{ hasBackgroundPanel && (
|
|
395
|
+
<StylesBackgroundPanel
|
|
396
|
+
inheritedValue={ inheritedStyle }
|
|
397
|
+
value={ style }
|
|
398
|
+
onChange={ setStyle }
|
|
399
|
+
settings={ settings }
|
|
400
|
+
defaultValues={ BACKGROUND_BLOCK_DEFAULT_VALUES }
|
|
401
|
+
/>
|
|
402
|
+
) }
|
|
403
|
+
{ shouldShowFiltersPanel && (
|
|
404
|
+
<StylesFiltersPanel
|
|
405
|
+
inheritedValue={ inheritedStyleWithLayout }
|
|
406
|
+
value={ styleWithLayout }
|
|
407
|
+
onChange={ setStyle }
|
|
408
|
+
settings={ settings }
|
|
409
|
+
includeLayoutControls
|
|
410
|
+
/>
|
|
411
|
+
) }
|
|
388
412
|
{ hasDimensionsPanel && (
|
|
389
413
|
<StylesDimensionsPanel
|
|
390
414
|
inheritedValue={ inheritedStyleWithLayout }
|
|
@@ -402,15 +426,6 @@ function ScreenBlock( { name, variation }: ScreenBlockProps ) {
|
|
|
402
426
|
settings={ settings }
|
|
403
427
|
/>
|
|
404
428
|
) }
|
|
405
|
-
{ shouldShowFiltersPanel && (
|
|
406
|
-
<StylesFiltersPanel
|
|
407
|
-
inheritedValue={ inheritedStyleWithLayout }
|
|
408
|
-
value={ styleWithLayout }
|
|
409
|
-
onChange={ setStyle }
|
|
410
|
-
settings={ settings }
|
|
411
|
-
includeLayoutControls
|
|
412
|
-
/>
|
|
413
|
-
) }
|
|
414
429
|
{ hasColorPanel && (
|
|
415
430
|
<StylesColorPanel
|
|
416
431
|
inheritedValue={ inheritedStyle }
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
|
|
6
|
-
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
5
|
+
import { Tabs } from '@wordpress/ui';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Internal dependencies
|
|
@@ -12,13 +11,6 @@ import { ScreenHeader } from './screen-header';
|
|
|
12
11
|
import ColorPalettePanel from './color-palette-panel';
|
|
13
12
|
import GradientPalettePanel from './gradients-palette-panel';
|
|
14
13
|
|
|
15
|
-
/**
|
|
16
|
-
* External dependencies
|
|
17
|
-
*/
|
|
18
|
-
import { unlock } from './lock-unlock';
|
|
19
|
-
|
|
20
|
-
const { Tabs } = unlock( componentsPrivateApis );
|
|
21
|
-
|
|
22
14
|
function ScreenColorPalette( { name }: { name?: string } ) {
|
|
23
15
|
return (
|
|
24
16
|
<>
|
|
@@ -28,18 +20,22 @@ function ScreenColorPalette( { name }: { name?: string } ) {
|
|
|
28
20
|
'The combination of colors used across the site and in color pickers.'
|
|
29
21
|
) }
|
|
30
22
|
/>
|
|
31
|
-
<Tabs>
|
|
32
|
-
<
|
|
33
|
-
<Tabs.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
<Tabs.Root defaultValue="color">
|
|
24
|
+
<div className="global-styles-ui-color-palette__tablist-container">
|
|
25
|
+
<Tabs.List className="global-styles-ui-color-palette__tablist">
|
|
26
|
+
<Tabs.Tab value="color">{ __( 'Color' ) }</Tabs.Tab>
|
|
27
|
+
<Tabs.Tab value="gradient">
|
|
28
|
+
{ __( 'Gradient' ) }
|
|
29
|
+
</Tabs.Tab>
|
|
30
|
+
</Tabs.List>
|
|
31
|
+
</div>
|
|
32
|
+
<Tabs.Panel value="color" tabIndex={ -1 }>
|
|
37
33
|
<ColorPalettePanel name={ name } />
|
|
38
|
-
</Tabs.
|
|
39
|
-
<Tabs.
|
|
34
|
+
</Tabs.Panel>
|
|
35
|
+
<Tabs.Panel value="gradient" tabIndex={ -1 }>
|
|
40
36
|
<GradientPalettePanel name={ name } />
|
|
41
|
-
</Tabs.
|
|
42
|
-
</Tabs>
|
|
37
|
+
</Tabs.Panel>
|
|
38
|
+
</Tabs.Root>
|
|
43
39
|
</>
|
|
44
40
|
);
|
|
45
41
|
}
|
|
@@ -243,7 +243,6 @@ export default function ShadowsEditPanel() {
|
|
|
243
243
|
} }
|
|
244
244
|
>
|
|
245
245
|
<InputControl
|
|
246
|
-
__next40pxDefaultSize
|
|
247
246
|
autoComplete="off"
|
|
248
247
|
label={ __( 'Name' ) }
|
|
249
248
|
placeholder={ __( 'Shadow name' ) }
|
|
@@ -494,7 +493,6 @@ function ShadowPopover( { shadowObj, onChange }: ShadowPopoverProps ) {
|
|
|
494
493
|
onShadowChange( 'inset', value === 'inset' )
|
|
495
494
|
}
|
|
496
495
|
hideLabelFromVision
|
|
497
|
-
__next40pxDefaultSize
|
|
498
496
|
>
|
|
499
497
|
<ToggleGroupControlOption
|
|
500
498
|
value="outset"
|
|
@@ -551,7 +549,6 @@ function ShadowInputControl( {
|
|
|
551
549
|
return (
|
|
552
550
|
<UnitControl
|
|
553
551
|
label={ label }
|
|
554
|
-
__next40pxDefaultSize
|
|
555
552
|
value={ value }
|
|
556
553
|
onChange={ onValueChange }
|
|
557
554
|
/>
|
|
@@ -56,7 +56,6 @@ function SizeControl( props: SizeControlProps ) {
|
|
|
56
56
|
<Flex>
|
|
57
57
|
<FlexItem isBlock>
|
|
58
58
|
<UnitControl
|
|
59
|
-
__next40pxDefaultSize
|
|
60
59
|
label={ label }
|
|
61
60
|
hideLabelFromVision
|
|
62
61
|
value={ value }
|
|
@@ -69,7 +68,6 @@ function SizeControl( props: SizeControlProps ) {
|
|
|
69
68
|
<FlexItem isBlock>
|
|
70
69
|
<Spacer marginX={ 2 } marginBottom={ 0 }>
|
|
71
70
|
<RangeControl
|
|
72
|
-
__next40pxDefaultSize
|
|
73
71
|
label={ label }
|
|
74
72
|
hideLabelFromVision
|
|
75
73
|
value={ valueQuantity }
|
|
@@ -366,7 +366,7 @@ const BASE_SETTINGS = {
|
|
|
366
366
|
theme: [
|
|
367
367
|
{
|
|
368
368
|
fontFamily:
|
|
369
|
-
'-apple-system,
|
|
369
|
+
'-apple-system,system-ui,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif',
|
|
370
370
|
name: 'System Font',
|
|
371
371
|
slug: 'system-font',
|
|
372
372
|
},
|
package/src/style.scss
CHANGED
|
@@ -81,13 +81,13 @@
|
|
|
81
81
|
// Need to override the too specific styles for complementary areas.
|
|
82
82
|
margin-bottom: 0 !important;
|
|
83
83
|
text-transform: uppercase;
|
|
84
|
-
font-weight:
|
|
84
|
+
font-weight: var(--wpds-typography-font-weight-emphasis) !important;
|
|
85
85
|
font-size: 11px !important;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
.global-styles-ui-section-title {
|
|
89
89
|
color: colors.$gray-800;
|
|
90
|
-
font-weight:
|
|
90
|
+
font-weight: var(--wpds-typography-font-weight-emphasis);
|
|
91
91
|
line-height: 1.2;
|
|
92
92
|
padding: 16px 16px 0;
|
|
93
93
|
margin: 0;
|
|
@@ -233,6 +233,14 @@
|
|
|
233
233
|
height: 100%;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
+
.global-styles-ui-color-palette__tablist-container {
|
|
237
|
+
border-bottom: variables.$border-width solid colors.$gray-300;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.global-styles-ui-color-palette__tablist {
|
|
241
|
+
margin-bottom: calc(-1 * variables.$border-width);
|
|
242
|
+
}
|
|
243
|
+
|
|
236
244
|
.global-styles-ui-sidebar__navigator-screen .single-column {
|
|
237
245
|
grid-column: span 1;
|
|
238
246
|
}
|
package/src/utils.ts
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
areGlobalStylesEqual,
|
|
6
|
+
privateApis as globalStylesEnginePrivateApis,
|
|
7
|
+
} from '@wordpress/global-styles-engine';
|
|
8
|
+
import type {
|
|
9
|
+
GlobalStylesConfig,
|
|
10
|
+
GlobalStylesSettings,
|
|
11
|
+
} from '@wordpress/global-styles-engine';
|
|
6
12
|
import { __ } from '@wordpress/i18n';
|
|
7
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import { unlock } from './lock-unlock';
|
|
18
|
+
|
|
19
|
+
const { getViewportBreakpoints } = unlock( globalStylesEnginePrivateApis );
|
|
20
|
+
|
|
8
21
|
/**
|
|
9
22
|
* State definition with value and label.
|
|
10
23
|
*/
|
|
@@ -83,10 +96,19 @@ export function getValidPseudoStates( name: string ): StateDefinition[] {
|
|
|
83
96
|
/**
|
|
84
97
|
* Get the valid viewport state definitions.
|
|
85
98
|
*
|
|
99
|
+
* @param viewportSettings
|
|
86
100
|
* @return Array of valid viewport state definitions.
|
|
87
101
|
*/
|
|
88
|
-
export function getValidViewportStates(
|
|
89
|
-
|
|
102
|
+
export function getValidViewportStates(
|
|
103
|
+
viewportSettings?: GlobalStylesSettings[ 'viewport' ]
|
|
104
|
+
): StateDefinition[] {
|
|
105
|
+
const breakpoints = getViewportBreakpoints( viewportSettings );
|
|
106
|
+
|
|
107
|
+
return RESPONSIVE_STATES.filter(
|
|
108
|
+
( state ) =>
|
|
109
|
+
( state.value !== '@tablet' || breakpoints.tablet !== undefined ) &&
|
|
110
|
+
( state.value !== '@mobile' || breakpoints.mobile !== undefined )
|
|
111
|
+
);
|
|
90
112
|
}
|
|
91
113
|
|
|
92
114
|
/**
|