@wordpress/edit-site 5.0.0 → 5.1.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 +12 -1
- package/build/components/block-editor/index.js +3 -2
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/editor/index.js +4 -16
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +20 -5
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +0 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/custom-css.js +1 -0
- package/build/components/global-styles/custom-css.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +3 -2
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +0 -1
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-block.js +2 -6
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-border.js +4 -0
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/screen-button-color.js +0 -2
- package/build/components/global-styles/screen-button-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +4 -0
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +1 -3
- package/build/components/global-styles/screen-heading-color.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +4 -0
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +0 -1
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-root.js +7 -2
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +0 -1
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +4 -0
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +17 -5
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/utils.js +11 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +10 -41
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/layout/index.js +52 -83
- package/build/components/layout/index.js.map +1 -1
- package/build/components/sidebar/index.js +5 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +3 -1
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +10 -0
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +1 -31
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +3 -22
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/site-hub/index.js +149 -0
- package/build/components/site-hub/index.js.map +1 -0
- package/build/components/use-edited-entity-record/index.js +60 -0
- package/build/components/use-edited-entity-record/index.js.map +1 -0
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +144 -0
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -0
- package/build/index.js +5 -0
- package/build/index.js.map +1 -1
- package/build-module/components/block-editor/index.js +3 -2
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +1 -12
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +19 -5
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +0 -1
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/custom-css.js +1 -0
- package/build-module/components/global-styles/custom-css.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +3 -2
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +0 -1
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +2 -5
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +3 -0
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/screen-button-color.js +0 -2
- package/build-module/components/global-styles/screen-button-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +3 -0
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +1 -3
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +3 -0
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +0 -1
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +8 -3
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +0 -1
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +3 -0
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +17 -5
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/utils.js +9 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +10 -38
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/layout/index.js +51 -81
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +4 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +3 -1
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +11 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +2 -27
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +5 -23
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +126 -0
- package/build-module/components/site-hub/index.js.map +1 -0
- package/build-module/components/use-edited-entity-record/index.js +48 -0
- package/build-module/components/use-edited-entity-record/index.js.map +1 -0
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +132 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -0
- package/build-module/index.js +4 -0
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +106 -113
- package/build-style/style.css +106 -113
- package/package.json +30 -29
- package/src/components/block-editor/index.js +3 -5
- package/src/components/editor/index.js +1 -16
- package/src/components/global-styles/block-preview-panel.js +24 -9
- package/src/components/global-styles/border-panel.js +0 -1
- package/src/components/global-styles/custom-css.js +1 -0
- package/src/components/global-styles/global-styles-provider.js +11 -5
- package/src/components/global-styles/screen-background-color.js +0 -1
- package/src/components/global-styles/screen-block.js +1 -4
- package/src/components/global-styles/screen-border.js +2 -0
- package/src/components/global-styles/screen-button-color.js +0 -2
- package/src/components/global-styles/screen-colors.js +3 -0
- package/src/components/global-styles/screen-heading-color.js +1 -3
- package/src/components/global-styles/screen-layout.js +2 -0
- package/src/components/global-styles/screen-link-color.js +0 -1
- package/src/components/global-styles/screen-root.js +34 -27
- package/src/components/global-styles/screen-text-color.js +0 -1
- package/src/components/global-styles/screen-typography.js +3 -0
- package/src/components/global-styles/test/typography-utils.js +72 -23
- package/src/components/global-styles/typography-utils.js +24 -4
- package/src/components/global-styles/utils.js +10 -1
- package/src/components/header-edit-mode/document-actions/index.js +18 -37
- package/src/components/header-edit-mode/style.scss +1 -0
- package/src/components/layout/index.js +122 -165
- package/src/components/layout/style.scss +70 -63
- package/src/components/list/style.scss +1 -8
- package/src/components/sidebar/index.js +4 -1
- package/src/components/sidebar-edit-mode/index.js +1 -1
- package/src/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +10 -0
- package/src/components/sidebar-navigation-screen/style.scss +2 -4
- package/src/components/sidebar-navigation-screen-main/index.js +1 -29
- package/src/components/sidebar-navigation-screen-templates/index.js +9 -27
- package/src/components/site-hub/index.js +150 -0
- package/src/components/site-hub/style.scss +31 -0
- package/src/components/use-edited-entity-record/index.js +37 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/push-changes-to-global-styles/index.js +162 -0
- package/src/hooks/push-changes-to-global-styles/style.scss +4 -0
- package/src/index.js +2 -0
- package/src/style.scss +2 -0
- package/build/components/site-title/index.js +0 -55
- package/build/components/site-title/index.js.map +0 -1
- package/build-module/components/site-title/index.js +0 -43
- package/build-module/components/site-title/index.js.map +0 -1
- package/src/components/site-title/index.js +0 -39
|
@@ -70,7 +70,6 @@ function ScreenButtonColor( { name } ) {
|
|
|
70
70
|
className="edit-site-screen-button-color__control"
|
|
71
71
|
colors={ colorsPerOrigin }
|
|
72
72
|
disableCustomColors={ ! areCustomSolidsEnabled }
|
|
73
|
-
__experimentalHasMultipleOrigins
|
|
74
73
|
showTitle={ false }
|
|
75
74
|
enableAlpha
|
|
76
75
|
__experimentalIsRenderedInSidebar
|
|
@@ -87,7 +86,6 @@ function ScreenButtonColor( { name } ) {
|
|
|
87
86
|
className="edit-site-screen-button-color__control"
|
|
88
87
|
colors={ colorsPerOrigin }
|
|
89
88
|
disableCustomColors={ ! areCustomSolidsEnabled }
|
|
90
|
-
__experimentalHasMultipleOrigins
|
|
91
89
|
showTitle={ false }
|
|
92
90
|
enableAlpha
|
|
93
91
|
__experimentalIsRenderedInSidebar
|
|
@@ -20,6 +20,7 @@ import { NavigationButtonAsItem } from './navigation-button';
|
|
|
20
20
|
import { getSupportedGlobalStylesPanels, useStyle } from './hooks';
|
|
21
21
|
import Subtitle from './subtitle';
|
|
22
22
|
import ColorIndicatorWrapper from './color-indicator-wrapper';
|
|
23
|
+
import BlockPreviewPanel from './block-preview-panel';
|
|
23
24
|
|
|
24
25
|
function BackgroundColorItem( { name, parentMenu } ) {
|
|
25
26
|
const supports = getSupportedGlobalStylesPanels( name );
|
|
@@ -186,6 +187,8 @@ function ScreenColors( { name } ) {
|
|
|
186
187
|
) }
|
|
187
188
|
/>
|
|
188
189
|
|
|
190
|
+
<BlockPreviewPanel name={ name } />
|
|
191
|
+
|
|
189
192
|
<div className="edit-site-global-styles-screen-colors">
|
|
190
193
|
<VStack spacing={ 10 }>
|
|
191
194
|
<Palette name={ name } />
|
|
@@ -132,7 +132,7 @@ function ScreenHeadingColor( { name } ) {
|
|
|
132
132
|
>
|
|
133
133
|
<ToggleGroupControlOption
|
|
134
134
|
value="heading"
|
|
135
|
-
/* translators: 'All' refers to selecting all heading levels
|
|
135
|
+
/* translators: 'All' refers to selecting all heading levels
|
|
136
136
|
and applying the same style to h1-h6. */
|
|
137
137
|
label={ __( 'All' ) }
|
|
138
138
|
/>
|
|
@@ -159,7 +159,6 @@ function ScreenHeadingColor( { name } ) {
|
|
|
159
159
|
className="edit-site-screen-heading-text-color__control"
|
|
160
160
|
colors={ colorsPerOrigin }
|
|
161
161
|
disableCustomColors={ ! areCustomSolidsEnabled }
|
|
162
|
-
__experimentalHasMultipleOrigins
|
|
163
162
|
showTitle={ false }
|
|
164
163
|
enableAlpha
|
|
165
164
|
__experimentalIsRenderedInSidebar
|
|
@@ -186,7 +185,6 @@ function ScreenHeadingColor( { name } ) {
|
|
|
186
185
|
gradients={ gradientsPerOrigin }
|
|
187
186
|
disableCustomColors={ ! areCustomSolidsEnabled }
|
|
188
187
|
disableCustomGradients={ ! areCustomGradientsEnabled }
|
|
189
|
-
__experimentalHasMultipleOrigins
|
|
190
188
|
showTitle={ false }
|
|
191
189
|
enableAlpha
|
|
192
190
|
__experimentalIsRenderedInSidebar
|
|
@@ -8,6 +8,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
8
8
|
*/
|
|
9
9
|
import DimensionsPanel, { useHasDimensionsPanel } from './dimensions-panel';
|
|
10
10
|
import ScreenHeader from './header';
|
|
11
|
+
import BlockPreviewPanel from './block-preview-panel';
|
|
11
12
|
|
|
12
13
|
function ScreenLayout( { name } ) {
|
|
13
14
|
const hasDimensionsPanel = useHasDimensionsPanel( name );
|
|
@@ -15,6 +16,7 @@ function ScreenLayout( { name } ) {
|
|
|
15
16
|
return (
|
|
16
17
|
<>
|
|
17
18
|
<ScreenHeader title={ __( 'Layout' ) } />
|
|
19
|
+
<BlockPreviewPanel name={ name } />
|
|
18
20
|
{ hasDimensionsPanel && <DimensionsPanel name={ name } /> }
|
|
19
21
|
</>
|
|
20
22
|
);
|
|
@@ -90,7 +90,6 @@ function ScreenLinkColor( { name } ) {
|
|
|
90
90
|
className="edit-site-screen-link-color__control"
|
|
91
91
|
colors={ colorsPerOrigin }
|
|
92
92
|
disableCustomColors={ ! areCustomSolidsEnabled }
|
|
93
|
-
__experimentalHasMultipleOrigins
|
|
94
93
|
showTitle={ false }
|
|
95
94
|
enableAlpha
|
|
96
95
|
__experimentalIsRenderedInSidebar
|
|
@@ -35,6 +35,8 @@ function ScreenRoot() {
|
|
|
35
35
|
};
|
|
36
36
|
}, [] );
|
|
37
37
|
|
|
38
|
+
const __experimentalGlobalStylesCustomCSS =
|
|
39
|
+
window?.__experimentalEnableGlobalStylesCustomCSS;
|
|
38
40
|
return (
|
|
39
41
|
<Card size="small">
|
|
40
42
|
<CardBody>
|
|
@@ -100,33 +102,38 @@ function ScreenRoot() {
|
|
|
100
102
|
</ItemGroup>
|
|
101
103
|
</CardBody>
|
|
102
104
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
105
|
+
{ __experimentalGlobalStylesCustomCSS && (
|
|
106
|
+
<>
|
|
107
|
+
<CardDivider />
|
|
108
|
+
<CardBody>
|
|
109
|
+
<Spacer
|
|
110
|
+
as="p"
|
|
111
|
+
paddingTop={ 2 }
|
|
112
|
+
paddingX="13px"
|
|
113
|
+
marginBottom={ 4 }
|
|
114
|
+
>
|
|
115
|
+
{ __(
|
|
116
|
+
'Add your own CSS to customize the appearance and layout of your site.'
|
|
117
|
+
) }
|
|
118
|
+
</Spacer>
|
|
119
|
+
<ItemGroup>
|
|
120
|
+
<NavigationButtonAsItem
|
|
121
|
+
path="/css"
|
|
122
|
+
aria-label={ __( 'Additional CSS' ) }
|
|
123
|
+
>
|
|
124
|
+
<HStack justify="space-between">
|
|
125
|
+
<FlexItem>{ __( 'Custom' ) }</FlexItem>
|
|
126
|
+
<IconWithCurrentColor
|
|
127
|
+
icon={
|
|
128
|
+
isRTL() ? chevronLeft : chevronRight
|
|
129
|
+
}
|
|
130
|
+
/>
|
|
131
|
+
</HStack>
|
|
132
|
+
</NavigationButtonAsItem>
|
|
133
|
+
</ItemGroup>
|
|
134
|
+
</CardBody>
|
|
135
|
+
</>
|
|
136
|
+
) }
|
|
130
137
|
</Card>
|
|
131
138
|
);
|
|
132
139
|
}
|
|
@@ -47,7 +47,6 @@ function ScreenTextColor( { name } ) {
|
|
|
47
47
|
className="edit-site-screen-text-color__control"
|
|
48
48
|
colors={ colorsPerOrigin }
|
|
49
49
|
disableCustomColors={ ! areCustomSolidsEnabled }
|
|
50
|
-
__experimentalHasMultipleOrigins
|
|
51
50
|
showTitle={ false }
|
|
52
51
|
enableAlpha
|
|
53
52
|
__experimentalIsRenderedInSidebar
|
|
@@ -17,6 +17,7 @@ import { NavigationButtonAsItem } from './navigation-button';
|
|
|
17
17
|
import { useStyle } from './hooks';
|
|
18
18
|
import Subtitle from './subtitle';
|
|
19
19
|
import TypographyPanel from './typography-panel';
|
|
20
|
+
import BlockPreviewPanel from './block-preview-panel';
|
|
20
21
|
|
|
21
22
|
function Item( { name, parentMenu, element, label } ) {
|
|
22
23
|
const hasSupport = ! name;
|
|
@@ -87,6 +88,8 @@ function ScreenTypography( { name } ) {
|
|
|
87
88
|
) }
|
|
88
89
|
/>
|
|
89
90
|
|
|
91
|
+
<BlockPreviewPanel name={ name } />
|
|
92
|
+
|
|
90
93
|
{ ! name && (
|
|
91
94
|
<div className="edit-site-global-styles-screen-typography">
|
|
92
95
|
<VStack spacing={ 3 }>
|
|
@@ -7,7 +7,8 @@ describe( 'typography utils', () => {
|
|
|
7
7
|
describe( 'getTypographyFontSizeValue', () => {
|
|
8
8
|
[
|
|
9
9
|
{
|
|
10
|
-
message:
|
|
10
|
+
message:
|
|
11
|
+
'should return value when fluid typography is not active',
|
|
11
12
|
preset: {
|
|
12
13
|
size: '28px',
|
|
13
14
|
},
|
|
@@ -16,7 +17,7 @@ describe( 'typography utils', () => {
|
|
|
16
17
|
},
|
|
17
18
|
|
|
18
19
|
{
|
|
19
|
-
message: '
|
|
20
|
+
message: 'should return value where font size is 0',
|
|
20
21
|
preset: {
|
|
21
22
|
size: 0,
|
|
22
23
|
},
|
|
@@ -25,7 +26,7 @@ describe( 'typography utils', () => {
|
|
|
25
26
|
},
|
|
26
27
|
|
|
27
28
|
{
|
|
28
|
-
message: "
|
|
29
|
+
message: "should return value where font size is '0'",
|
|
29
30
|
preset: {
|
|
30
31
|
size: '0',
|
|
31
32
|
},
|
|
@@ -34,7 +35,7 @@ describe( 'typography utils', () => {
|
|
|
34
35
|
},
|
|
35
36
|
|
|
36
37
|
{
|
|
37
|
-
message: '
|
|
38
|
+
message: 'should return value where `size` is `null`.',
|
|
38
39
|
preset: {
|
|
39
40
|
size: null,
|
|
40
41
|
},
|
|
@@ -43,7 +44,7 @@ describe( 'typography utils', () => {
|
|
|
43
44
|
},
|
|
44
45
|
|
|
45
46
|
{
|
|
46
|
-
message: '
|
|
47
|
+
message: 'should return value when fluid is `false`',
|
|
47
48
|
preset: {
|
|
48
49
|
size: '28px',
|
|
49
50
|
fluid: false,
|
|
@@ -55,7 +56,7 @@ describe( 'typography utils', () => {
|
|
|
55
56
|
},
|
|
56
57
|
|
|
57
58
|
{
|
|
58
|
-
message: '
|
|
59
|
+
message: 'should return already clamped value',
|
|
59
60
|
preset: {
|
|
60
61
|
size: 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
|
|
61
62
|
fluid: false,
|
|
@@ -68,7 +69,7 @@ describe( 'typography utils', () => {
|
|
|
68
69
|
},
|
|
69
70
|
|
|
70
71
|
{
|
|
71
|
-
message: '
|
|
72
|
+
message: 'should return value with unsupported unit',
|
|
72
73
|
preset: {
|
|
73
74
|
size: '1000%',
|
|
74
75
|
fluid: false,
|
|
@@ -80,7 +81,7 @@ describe( 'typography utils', () => {
|
|
|
80
81
|
},
|
|
81
82
|
|
|
82
83
|
{
|
|
83
|
-
message: '
|
|
84
|
+
message: 'should return clamp value with rem min and max units',
|
|
84
85
|
preset: {
|
|
85
86
|
size: '1.75rem',
|
|
86
87
|
},
|
|
@@ -92,7 +93,7 @@ describe( 'typography utils', () => {
|
|
|
92
93
|
},
|
|
93
94
|
|
|
94
95
|
{
|
|
95
|
-
message: '
|
|
96
|
+
message: 'should return clamp value with eem min and max units',
|
|
96
97
|
preset: {
|
|
97
98
|
size: '1.75em',
|
|
98
99
|
},
|
|
@@ -104,7 +105,7 @@ describe( 'typography utils', () => {
|
|
|
104
105
|
},
|
|
105
106
|
|
|
106
107
|
{
|
|
107
|
-
message: '
|
|
108
|
+
message: 'should return clamp value for floats',
|
|
108
109
|
preset: {
|
|
109
110
|
size: '100.175px',
|
|
110
111
|
},
|
|
@@ -116,7 +117,8 @@ describe( 'typography utils', () => {
|
|
|
116
117
|
},
|
|
117
118
|
|
|
118
119
|
{
|
|
119
|
-
message:
|
|
120
|
+
message:
|
|
121
|
+
'should coerce integer to `px` and returns clamp value',
|
|
120
122
|
preset: {
|
|
121
123
|
size: 33,
|
|
122
124
|
fluid: true,
|
|
@@ -129,7 +131,7 @@ describe( 'typography utils', () => {
|
|
|
129
131
|
},
|
|
130
132
|
|
|
131
133
|
{
|
|
132
|
-
message: '
|
|
134
|
+
message: 'should coerce float to `px` and returns clamp value',
|
|
133
135
|
preset: {
|
|
134
136
|
size: 100.23,
|
|
135
137
|
fluid: true,
|
|
@@ -142,7 +144,8 @@ describe( 'typography utils', () => {
|
|
|
142
144
|
},
|
|
143
145
|
|
|
144
146
|
{
|
|
145
|
-
message:
|
|
147
|
+
message:
|
|
148
|
+
'should return clamp value when `fluid` is empty array',
|
|
146
149
|
preset: {
|
|
147
150
|
size: '28px',
|
|
148
151
|
fluid: [],
|
|
@@ -155,7 +158,7 @@ describe( 'typography utils', () => {
|
|
|
155
158
|
},
|
|
156
159
|
|
|
157
160
|
{
|
|
158
|
-
message: '
|
|
161
|
+
message: 'should return clamp value when `fluid` is `null`',
|
|
159
162
|
preset: {
|
|
160
163
|
size: '28px',
|
|
161
164
|
fluid: null,
|
|
@@ -169,7 +172,7 @@ describe( 'typography utils', () => {
|
|
|
169
172
|
|
|
170
173
|
{
|
|
171
174
|
message:
|
|
172
|
-
'
|
|
175
|
+
'should return clamp value if min font size is greater than max',
|
|
173
176
|
preset: {
|
|
174
177
|
size: '3rem',
|
|
175
178
|
fluid: {
|
|
@@ -185,7 +188,7 @@ describe( 'typography utils', () => {
|
|
|
185
188
|
},
|
|
186
189
|
|
|
187
190
|
{
|
|
188
|
-
message: '
|
|
191
|
+
message: 'should return value with invalid min/max fluid units',
|
|
189
192
|
preset: {
|
|
190
193
|
size: '10em',
|
|
191
194
|
fluid: {
|
|
@@ -201,7 +204,7 @@ describe( 'typography utils', () => {
|
|
|
201
204
|
|
|
202
205
|
{
|
|
203
206
|
message:
|
|
204
|
-
'
|
|
207
|
+
'should return value when size is < lower bounds and no fluid min/max set',
|
|
205
208
|
preset: {
|
|
206
209
|
size: '3px',
|
|
207
210
|
},
|
|
@@ -213,7 +216,7 @@ describe( 'typography utils', () => {
|
|
|
213
216
|
|
|
214
217
|
{
|
|
215
218
|
message:
|
|
216
|
-
'
|
|
219
|
+
'should return value when size is equal to lower bounds and no fluid min/max set',
|
|
217
220
|
preset: {
|
|
218
221
|
size: '14px',
|
|
219
222
|
},
|
|
@@ -224,7 +227,8 @@ describe( 'typography utils', () => {
|
|
|
224
227
|
},
|
|
225
228
|
|
|
226
229
|
{
|
|
227
|
-
message:
|
|
230
|
+
message:
|
|
231
|
+
'should return clamp value with different min max units',
|
|
228
232
|
preset: {
|
|
229
233
|
size: '28px',
|
|
230
234
|
fluid: {
|
|
@@ -240,7 +244,8 @@ describe( 'typography utils', () => {
|
|
|
240
244
|
},
|
|
241
245
|
|
|
242
246
|
{
|
|
243
|
-
message:
|
|
247
|
+
message:
|
|
248
|
+
'should return clamp value where no fluid max size is set',
|
|
244
249
|
preset: {
|
|
245
250
|
size: '28px',
|
|
246
251
|
fluid: {
|
|
@@ -255,7 +260,8 @@ describe( 'typography utils', () => {
|
|
|
255
260
|
},
|
|
256
261
|
|
|
257
262
|
{
|
|
258
|
-
message:
|
|
263
|
+
message:
|
|
264
|
+
'should return clamp value where no fluid min size is set',
|
|
259
265
|
preset: {
|
|
260
266
|
size: '28px',
|
|
261
267
|
fluid: {
|
|
@@ -320,7 +326,7 @@ describe( 'typography utils', () => {
|
|
|
320
326
|
|
|
321
327
|
{
|
|
322
328
|
message:
|
|
323
|
-
'
|
|
329
|
+
'should return clamp value when min and max font sizes are equal',
|
|
324
330
|
preset: {
|
|
325
331
|
size: '4rem',
|
|
326
332
|
fluid: {
|
|
@@ -333,8 +339,51 @@ describe( 'typography utils', () => {
|
|
|
333
339
|
},
|
|
334
340
|
expected: 'clamp(30px, 1.875rem + ((1vw - 7.68px) * 1), 30px)',
|
|
335
341
|
},
|
|
342
|
+
|
|
343
|
+
{
|
|
344
|
+
message:
|
|
345
|
+
'should use default min font size value where min font size unit in fluid config is not supported',
|
|
346
|
+
preset: {
|
|
347
|
+
size: '15px',
|
|
348
|
+
},
|
|
349
|
+
typographySettings: {
|
|
350
|
+
fluid: {
|
|
351
|
+
minFontSize: '16%',
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
expected:
|
|
355
|
+
'clamp(14px, 0.875rem + ((1vw - 7.68px) * 0.12), 15px)',
|
|
356
|
+
},
|
|
357
|
+
|
|
358
|
+
// Equivalent custom config PHP unit tests in `test_should_covert_font_sizes_to_fluid_values()`.
|
|
359
|
+
{
|
|
360
|
+
message: 'should return clamp value using custom fluid config',
|
|
361
|
+
preset: {
|
|
362
|
+
size: '17px',
|
|
363
|
+
},
|
|
364
|
+
typographySettings: {
|
|
365
|
+
fluid: {
|
|
366
|
+
minFontSize: '16px',
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
expected: 'clamp(16px, 1rem + ((1vw - 7.68px) * 0.12), 17px)',
|
|
370
|
+
},
|
|
371
|
+
|
|
372
|
+
{
|
|
373
|
+
message:
|
|
374
|
+
'should return value when font size <= custom min font size bound',
|
|
375
|
+
preset: {
|
|
376
|
+
size: '15px',
|
|
377
|
+
},
|
|
378
|
+
typographySettings: {
|
|
379
|
+
fluid: {
|
|
380
|
+
minFontSize: '16px',
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
expected: '15px',
|
|
384
|
+
},
|
|
336
385
|
].forEach( ( { message, preset, typographySettings, expected } ) => {
|
|
337
|
-
it(
|
|
386
|
+
it( `${ message }`, () => {
|
|
338
387
|
expect(
|
|
339
388
|
getTypographyFontSizeValue( preset, typographySettings )
|
|
340
389
|
).toBe( expected );
|
|
@@ -23,13 +23,23 @@ import { getComputedFluidTypographyValue } from '@wordpress/block-editor';
|
|
|
23
23
|
* @property {boolean|FluidPreset|undefined} fluid A font size slug
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {Object} TypographySettings
|
|
28
|
+
* @property {?string|?number} size A default font size.
|
|
29
|
+
* @property {?string} minViewPortWidth Minimum viewport size from which type will have fluidity. Optional if size is specified.
|
|
30
|
+
* @property {?string} maxViewPortWidth Maximum size up to which type will have fluidity. Optional if size is specified.
|
|
31
|
+
* @property {?number} scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.
|
|
32
|
+
* @property {?number} minFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.
|
|
33
|
+
* @property {?string} minFontSize The smallest a calculated font size may be. Optional.
|
|
34
|
+
*/
|
|
35
|
+
|
|
26
36
|
/**
|
|
27
37
|
* Returns a font-size value based on a given font-size preset.
|
|
28
38
|
* Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.
|
|
29
39
|
*
|
|
30
|
-
* @param {Preset}
|
|
31
|
-
* @param {Object}
|
|
32
|
-
* @param {boolean} typographySettings.fluid Whether fluid typography is enabled.
|
|
40
|
+
* @param {Preset} preset
|
|
41
|
+
* @param {Object} typographySettings
|
|
42
|
+
* @param {boolean|TypographySettings} typographySettings.fluid Whether fluid typography is enabled, and, optionally, fluid font size options.
|
|
33
43
|
*
|
|
34
44
|
* @return {string|*} A font-size value or the value of preset.size.
|
|
35
45
|
*/
|
|
@@ -44,7 +54,11 @@ export function getTypographyFontSizeValue( preset, typographySettings ) {
|
|
|
44
54
|
return defaultSize;
|
|
45
55
|
}
|
|
46
56
|
|
|
47
|
-
if (
|
|
57
|
+
if (
|
|
58
|
+
! typographySettings?.fluid ||
|
|
59
|
+
( typeof typographySettings?.fluid === 'object' &&
|
|
60
|
+
Object.keys( typographySettings.fluid ).length === 0 )
|
|
61
|
+
) {
|
|
48
62
|
return defaultSize;
|
|
49
63
|
}
|
|
50
64
|
|
|
@@ -53,10 +67,16 @@ export function getTypographyFontSizeValue( preset, typographySettings ) {
|
|
|
53
67
|
return defaultSize;
|
|
54
68
|
}
|
|
55
69
|
|
|
70
|
+
const fluidTypographySettings =
|
|
71
|
+
typeof typographySettings?.fluid === 'object'
|
|
72
|
+
? typographySettings?.fluid
|
|
73
|
+
: {};
|
|
74
|
+
|
|
56
75
|
const fluidFontSizeValue = getComputedFluidTypographyValue( {
|
|
57
76
|
minimumFontSize: preset?.fluid?.min,
|
|
58
77
|
maximumFontSize: preset?.fluid?.max,
|
|
59
78
|
fontSize: defaultSize,
|
|
79
|
+
minimumFontSizeLimit: fluidTypographySettings?.minFontSize,
|
|
60
80
|
} );
|
|
61
81
|
|
|
62
82
|
if ( !! fluidFontSizeValue ) {
|
|
@@ -86,7 +86,7 @@ export const PRESET_METADATA = [
|
|
|
86
86
|
},
|
|
87
87
|
];
|
|
88
88
|
|
|
89
|
-
const STYLE_PATH_TO_CSS_VAR_INFIX = {
|
|
89
|
+
export const STYLE_PATH_TO_CSS_VAR_INFIX = {
|
|
90
90
|
'color.background': 'color',
|
|
91
91
|
'color.text': 'color',
|
|
92
92
|
'elements.link.color.text': 'color',
|
|
@@ -100,6 +100,15 @@ const STYLE_PATH_TO_CSS_VAR_INFIX = {
|
|
|
100
100
|
'typography.fontFamily': 'font-family',
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
+
// A static list of block attributes that store global style preset slugs.
|
|
104
|
+
export const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
|
|
105
|
+
'color.background': 'backgroundColor',
|
|
106
|
+
'color.text': 'textColor',
|
|
107
|
+
'color.gradient': 'gradient',
|
|
108
|
+
'typography.fontSize': 'fontSize',
|
|
109
|
+
'typography.fontFamily': 'fontFamily',
|
|
110
|
+
};
|
|
111
|
+
|
|
103
112
|
function findInPresetsBy(
|
|
104
113
|
features,
|
|
105
114
|
blockName,
|
|
@@ -25,16 +25,13 @@ import {
|
|
|
25
25
|
useBlockDisplayInformation,
|
|
26
26
|
BlockIcon,
|
|
27
27
|
} from '@wordpress/block-editor';
|
|
28
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
29
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
30
28
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
31
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
32
29
|
|
|
33
30
|
/**
|
|
34
31
|
* Internal dependencies
|
|
35
32
|
*/
|
|
36
33
|
import TemplateDetails from '../../template-details';
|
|
37
|
-
import
|
|
34
|
+
import useEditedEntityRecord from '../../use-edited-entity-record';
|
|
38
35
|
|
|
39
36
|
function getBlockDisplayText( block ) {
|
|
40
37
|
if ( block ) {
|
|
@@ -70,36 +67,15 @@ function useSecondaryText() {
|
|
|
70
67
|
}
|
|
71
68
|
|
|
72
69
|
export default function DocumentActions() {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const record = getEditedEntityRecord(
|
|
83
|
-
'postType',
|
|
84
|
-
postType,
|
|
85
|
-
postId
|
|
86
|
-
);
|
|
87
|
-
const _isLoaded = !! postId;
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
showIconLabels: select( preferencesStore ).get(
|
|
91
|
-
'core/edit-site',
|
|
92
|
-
'showIconLabels'
|
|
93
|
-
),
|
|
94
|
-
entityTitle: getTemplateInfo( record ).title,
|
|
95
|
-
isLoaded: _isLoaded,
|
|
96
|
-
template: record,
|
|
97
|
-
templateType: postType,
|
|
98
|
-
};
|
|
99
|
-
}, [] );
|
|
100
|
-
|
|
101
|
-
const entityLabel =
|
|
102
|
-
templateType === 'wp_template_part' ? 'template part' : 'template';
|
|
70
|
+
const showIconLabels = useSelect(
|
|
71
|
+
( select ) =>
|
|
72
|
+
select( preferencesStore ).get(
|
|
73
|
+
'core/edit-site',
|
|
74
|
+
'showIconLabels'
|
|
75
|
+
),
|
|
76
|
+
[]
|
|
77
|
+
);
|
|
78
|
+
const { isLoaded, record, getTitle } = useEditedEntityRecord();
|
|
103
79
|
const { label, icon } = useSecondaryText();
|
|
104
80
|
|
|
105
81
|
// Use internal state instead of a ref to make sure that the component
|
|
@@ -126,7 +102,7 @@ export default function DocumentActions() {
|
|
|
126
102
|
}
|
|
127
103
|
|
|
128
104
|
// Return feedback that the template does not seem to exist.
|
|
129
|
-
if ( !
|
|
105
|
+
if ( ! record ) {
|
|
130
106
|
return (
|
|
131
107
|
<div className="edit-site-document-actions">
|
|
132
108
|
{ __( 'Template not found' ) }
|
|
@@ -134,6 +110,11 @@ export default function DocumentActions() {
|
|
|
134
110
|
);
|
|
135
111
|
}
|
|
136
112
|
|
|
113
|
+
const entityLabel =
|
|
114
|
+
record.type === 'wp_template_part'
|
|
115
|
+
? __( 'template part' )
|
|
116
|
+
: __( 'template' );
|
|
117
|
+
|
|
137
118
|
return (
|
|
138
119
|
<div
|
|
139
120
|
className={ classnames( 'edit-site-document-actions', {
|
|
@@ -156,7 +137,7 @@ export default function DocumentActions() {
|
|
|
156
137
|
entityLabel
|
|
157
138
|
) }
|
|
158
139
|
</VisuallyHidden>
|
|
159
|
-
{
|
|
140
|
+
{ getTitle() }
|
|
160
141
|
</Text>
|
|
161
142
|
<div className="edit-site-document-actions__secondary-item">
|
|
162
143
|
<BlockIcon icon={ icon } showColors />
|
|
@@ -186,7 +167,7 @@ export default function DocumentActions() {
|
|
|
186
167
|
contentClassName="edit-site-document-actions__info-dropdown"
|
|
187
168
|
renderContent={ ( { onClose } ) => (
|
|
188
169
|
<TemplateDetails
|
|
189
|
-
template={
|
|
170
|
+
template={ record }
|
|
190
171
|
onClose={ onClose }
|
|
191
172
|
/>
|
|
192
173
|
) }
|