@wordpress/edit-site 4.1.1 → 4.3.1
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 +4 -0
- package/build/components/add-new-template/new-template-part.js +2 -9
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +28 -12
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/index.js +53 -4
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/editor/index.js +12 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +25 -24
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-indicator-wrapper.js +37 -0
- package/build/components/global-styles/color-indicator-wrapper.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +6 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/header.js +1 -4
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/icon-with-current-color.js +34 -0
- package/build/components/global-styles/icon-with-current-color.js.map +1 -0
- package/build/components/global-styles/navigation-button.js +7 -3
- package/build/components/global-styles/navigation-button.js.map +1 -1
- package/build/components/global-styles/palette.js +8 -5
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/preview.js +142 -26
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +50 -6
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +11 -3
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-root.js +7 -5
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +12 -5
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/header/document-actions/index.js +13 -11
- package/build/components/header/document-actions/index.js.map +1 -1
- package/build/components/header/index.js +5 -3
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +9 -1
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/more-menu/site-export.js +5 -2
- package/build/components/header/more-menu/site-export.js.map +1 -1
- package/build/components/header/plugin-more-menu-item/index.js +5 -0
- package/build/components/header/plugin-more-menu-item/index.js.map +1 -1
- package/build/components/list/actions/rename-menu-item.js +3 -10
- package/build/components/list/actions/rename-menu-item.js.map +1 -1
- package/build/components/preferences-modal/enable-feature.js +40 -0
- package/build/components/preferences-modal/enable-feature.js.map +1 -0
- package/build/components/preferences-modal/index.js +68 -0
- package/build/components/preferences-modal/index.js.map +1 -0
- package/build/components/sidebar/index.js +12 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar/navigation-menu-sidebar/index.js +40 -0
- package/build/components/sidebar/navigation-menu-sidebar/index.js.map +1 -0
- package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +185 -0
- package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +54 -0
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -0
- package/build/components/template-part-converter/convert-to-regular.js +6 -0
- package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +3 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +3 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +3 -10
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +27 -12
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/index.js +51 -6
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +12 -5
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +27 -26
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-indicator-wrapper.js +25 -0
- package/build-module/components/global-styles/color-indicator-wrapper.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +6 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/header.js +2 -5
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/icon-with-current-color.js +22 -0
- package/build-module/components/global-styles/icon-with-current-color.js.map +1 -0
- package/build-module/components/global-styles/navigation-button.js +7 -3
- package/build-module/components/global-styles/navigation-button.js.map +1 -1
- package/build-module/components/global-styles/palette.js +8 -6
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/preview.js +141 -27
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +49 -6
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +10 -3
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +8 -7
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +13 -6
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/header/document-actions/index.js +13 -11
- package/build-module/components/header/document-actions/index.js.map +1 -1
- package/build-module/components/header/index.js +5 -3
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +8 -1
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/more-menu/site-export.js +5 -2
- package/build-module/components/header/more-menu/site-export.js.map +1 -1
- package/build-module/components/header/plugin-more-menu-item/index.js +4 -0
- package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -1
- package/build-module/components/list/actions/rename-menu-item.js +4 -11
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
- package/build-module/components/preferences-modal/enable-feature.js +27 -0
- package/build-module/components/preferences-modal/enable-feature.js.map +1 -0
- package/build-module/components/preferences-modal/index.js +57 -0
- package/build-module/components/preferences-modal/index.js.map +1 -0
- package/build-module/components/sidebar/index.js +11 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/index.js +26 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/index.js.map +1 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +168 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +45 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -0
- package/build-module/components/template-part-converter/convert-to-regular.js +6 -0
- package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +3 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +3 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +88 -6
- package/build-style/style.css +88 -6
- package/package.json +29 -29
- package/src/components/add-new-template/new-template-part.js +3 -12
- package/src/components/add-new-template/new-template.js +49 -12
- package/src/components/block-editor/index.js +79 -9
- package/src/components/editor/index.js +19 -1
- package/src/components/global-styles/border-panel.js +32 -26
- package/src/components/global-styles/color-indicator-wrapper.js +23 -0
- package/src/components/global-styles/dimensions-panel.js +7 -2
- package/src/components/global-styles/header.js +2 -7
- package/src/components/global-styles/icon-with-current-color.js +21 -0
- package/src/components/global-styles/navigation-button.js +6 -4
- package/src/components/global-styles/palette.js +8 -11
- package/src/components/global-styles/preview.js +186 -29
- package/src/components/global-styles/screen-block-list.js +64 -11
- package/src/components/global-styles/screen-colors.js +7 -6
- package/src/components/global-styles/screen-root.js +15 -17
- package/src/components/global-styles/screen-style-variations.js +13 -4
- package/src/components/global-styles/style.scss +20 -7
- package/src/components/header/document-actions/index.js +14 -10
- package/src/components/header/index.js +6 -1
- package/src/components/header/more-menu/index.js +15 -0
- package/src/components/header/more-menu/site-export.js +13 -2
- package/src/components/header/plugin-more-menu-item/index.js +2 -0
- package/src/components/header/style.scss +45 -0
- package/src/components/list/actions/rename-menu-item.js +3 -13
- package/src/components/preferences-modal/enable-feature.js +24 -0
- package/src/components/preferences-modal/index.js +76 -0
- package/src/components/sidebar/index.js +12 -0
- package/src/components/sidebar/navigation-menu-sidebar/index.js +34 -0
- package/src/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +224 -0
- package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +62 -0
- package/src/components/sidebar/navigation-menu-sidebar/style.scss +42 -0
- package/src/components/sidebar/style.scss +1 -1
- package/src/components/template-part-converter/convert-to-regular.js +9 -0
- package/src/index.js +1 -0
- package/src/store/actions.js +4 -4
- package/src/store/selectors.js +10 -0
- package/src/store/test/selectors.js +4 -0
- package/src/style.scss +1 -0
|
@@ -5,65 +5,222 @@ import {
|
|
|
5
5
|
__unstableIframe as Iframe,
|
|
6
6
|
__unstableEditorStyles as EditorStyles,
|
|
7
7
|
} from '@wordpress/block-editor';
|
|
8
|
+
import {
|
|
9
|
+
__unstableMotion as motion,
|
|
10
|
+
__experimentalHStack as HStack,
|
|
11
|
+
__experimentalVStack as VStack,
|
|
12
|
+
} from '@wordpress/components';
|
|
13
|
+
import { useReducedMotion, useResizeObserver } from '@wordpress/compose';
|
|
14
|
+
import { useState } from '@wordpress/element';
|
|
8
15
|
|
|
9
16
|
/**
|
|
10
17
|
* Internal dependencies
|
|
11
18
|
*/
|
|
12
|
-
import { useStyle } from './hooks';
|
|
19
|
+
import { useSetting, useStyle } from './hooks';
|
|
13
20
|
import { useGlobalStylesOutput } from './use-global-styles-output';
|
|
14
21
|
|
|
15
|
-
const
|
|
22
|
+
const firstFrame = {
|
|
23
|
+
start: {
|
|
24
|
+
opacity: 1,
|
|
25
|
+
display: 'block',
|
|
26
|
+
},
|
|
27
|
+
hover: {
|
|
28
|
+
opacity: 0,
|
|
29
|
+
display: 'none',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const secondFrame = {
|
|
34
|
+
hover: {
|
|
35
|
+
opacity: 1,
|
|
36
|
+
display: 'block',
|
|
37
|
+
},
|
|
38
|
+
start: {
|
|
39
|
+
opacity: 0,
|
|
40
|
+
display: 'none',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const normalizedWidth = 248;
|
|
45
|
+
const normalizedHeight = 152;
|
|
46
|
+
|
|
47
|
+
const normalizedColorSwatchSize = 32;
|
|
48
|
+
|
|
49
|
+
const StylesPreview = ( { label, isFocused } ) => {
|
|
50
|
+
const [ fontWeight ] = useStyle( 'typography.fontWeight' );
|
|
16
51
|
const [ fontFamily = 'serif' ] = useStyle( 'typography.fontFamily' );
|
|
52
|
+
const [ headingFontFamily = fontFamily ] = useStyle(
|
|
53
|
+
'elements.h1.typography.fontFamily'
|
|
54
|
+
);
|
|
55
|
+
const [ headingFontWeight = fontWeight ] = useStyle(
|
|
56
|
+
'elements.h1.typography.fontWeight'
|
|
57
|
+
);
|
|
17
58
|
const [ textColor = 'black' ] = useStyle( 'color.text' );
|
|
59
|
+
const [ headingColor = textColor ] = useStyle( 'elements.h1.color.text' );
|
|
18
60
|
const [ linkColor = 'blue' ] = useStyle( 'elements.link.color.text' );
|
|
19
61
|
const [ backgroundColor = 'white' ] = useStyle( 'color.background' );
|
|
20
62
|
const [ gradientValue ] = useStyle( 'color.gradient' );
|
|
21
63
|
const [ styles ] = useGlobalStylesOutput();
|
|
64
|
+
const disableMotion = useReducedMotion();
|
|
65
|
+
const [ coreColors ] = useSetting( 'color.palette.core' );
|
|
66
|
+
const [ themeColors ] = useSetting( 'color.palette.theme' );
|
|
67
|
+
const [ customColors ] = useSetting( 'color.palette.custom' );
|
|
68
|
+
const [ isHovered, setIsHovered ] = useState( false );
|
|
69
|
+
const [ containerResizeListener, { width } ] = useResizeObserver();
|
|
70
|
+
const ratio = width ? width / normalizedWidth : 1;
|
|
71
|
+
|
|
72
|
+
const paletteColors = ( themeColors ?? [] )
|
|
73
|
+
.concat( customColors ?? [] )
|
|
74
|
+
.concat( coreColors ?? [] );
|
|
75
|
+
const highlightedColors = paletteColors
|
|
76
|
+
.filter(
|
|
77
|
+
// we exclude these two colors because they are already visible in the preview.
|
|
78
|
+
( { color } ) => color !== backgroundColor && color !== headingColor
|
|
79
|
+
)
|
|
80
|
+
.slice( 0, 2 );
|
|
22
81
|
|
|
23
82
|
return (
|
|
24
83
|
<Iframe
|
|
25
84
|
className="edit-site-global-styles-preview__iframe"
|
|
26
85
|
head={ <EditorStyles styles={ styles } /> }
|
|
27
|
-
style={ {
|
|
86
|
+
style={ {
|
|
87
|
+
height: normalizedHeight * ratio,
|
|
88
|
+
visibility: ! width ? 'hidden' : 'visible',
|
|
89
|
+
} }
|
|
90
|
+
onMouseEnter={ () => setIsHovered( true ) }
|
|
91
|
+
onMouseLeave={ () => setIsHovered( false ) }
|
|
92
|
+
tabIndex={ -1 }
|
|
28
93
|
>
|
|
29
|
-
|
|
94
|
+
{ containerResizeListener }
|
|
95
|
+
<motion.div
|
|
30
96
|
style={ {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
alignItems: 'center',
|
|
34
|
-
justifyContent: 'center',
|
|
35
|
-
height: '100%',
|
|
36
|
-
transform: `scale(${ height / 150 })`,
|
|
97
|
+
height: normalizedHeight * ratio,
|
|
98
|
+
width: '100%',
|
|
37
99
|
background: gradientValue ?? backgroundColor,
|
|
38
100
|
cursor: 'pointer',
|
|
39
101
|
} }
|
|
102
|
+
initial="start"
|
|
103
|
+
animate={
|
|
104
|
+
( isHovered || isFocused ) && ! disableMotion
|
|
105
|
+
? 'hover'
|
|
106
|
+
: 'start'
|
|
107
|
+
}
|
|
40
108
|
>
|
|
41
|
-
<div
|
|
42
|
-
|
|
109
|
+
<motion.div
|
|
110
|
+
variants={ firstFrame }
|
|
43
111
|
style={ {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
flexDirection: 'column',
|
|
112
|
+
height: '100%',
|
|
113
|
+
overflow: 'hidden',
|
|
47
114
|
} }
|
|
48
115
|
>
|
|
49
|
-
<
|
|
116
|
+
<HStack
|
|
117
|
+
spacing={ 10 * ratio }
|
|
118
|
+
justify="center"
|
|
50
119
|
style={ {
|
|
51
|
-
height:
|
|
52
|
-
|
|
53
|
-
background: textColor,
|
|
54
|
-
borderRadius: 20,
|
|
120
|
+
height: '100%',
|
|
121
|
+
overflow: 'hidden',
|
|
55
122
|
} }
|
|
56
|
-
|
|
57
|
-
|
|
123
|
+
>
|
|
124
|
+
<div
|
|
125
|
+
style={ {
|
|
126
|
+
fontFamily: headingFontFamily,
|
|
127
|
+
fontSize: 65 * ratio,
|
|
128
|
+
color: headingColor,
|
|
129
|
+
fontWeight: headingFontWeight,
|
|
130
|
+
} }
|
|
131
|
+
>
|
|
132
|
+
Aa
|
|
133
|
+
</div>
|
|
134
|
+
<VStack spacing={ 4 * ratio }>
|
|
135
|
+
{ highlightedColors.map( ( { slug, color } ) => (
|
|
136
|
+
<div
|
|
137
|
+
key={ slug }
|
|
138
|
+
style={ {
|
|
139
|
+
height:
|
|
140
|
+
normalizedColorSwatchSize * ratio,
|
|
141
|
+
width:
|
|
142
|
+
normalizedColorSwatchSize * ratio,
|
|
143
|
+
background: color,
|
|
144
|
+
borderRadius:
|
|
145
|
+
( normalizedColorSwatchSize *
|
|
146
|
+
ratio ) /
|
|
147
|
+
2,
|
|
148
|
+
} }
|
|
149
|
+
/>
|
|
150
|
+
) ) }
|
|
151
|
+
</VStack>
|
|
152
|
+
</HStack>
|
|
153
|
+
</motion.div>
|
|
154
|
+
<motion.div
|
|
155
|
+
variants={ secondFrame }
|
|
156
|
+
style={ {
|
|
157
|
+
height: '100%',
|
|
158
|
+
overflow: 'hidden',
|
|
159
|
+
} }
|
|
160
|
+
>
|
|
161
|
+
<VStack
|
|
162
|
+
spacing={ 3 * ratio }
|
|
163
|
+
justify="center"
|
|
58
164
|
style={ {
|
|
59
|
-
height:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
165
|
+
height: '100%',
|
|
166
|
+
overflow: 'hidden',
|
|
167
|
+
padding: 10 * ratio,
|
|
168
|
+
boxSizing: 'border-box',
|
|
63
169
|
} }
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
170
|
+
>
|
|
171
|
+
{ label && (
|
|
172
|
+
<div
|
|
173
|
+
style={ {
|
|
174
|
+
fontSize: 35 * ratio,
|
|
175
|
+
fontFamily: headingFontFamily,
|
|
176
|
+
color: headingColor,
|
|
177
|
+
fontWeight: headingFontWeight,
|
|
178
|
+
lineHeight: '1em',
|
|
179
|
+
} }
|
|
180
|
+
>
|
|
181
|
+
{ label }
|
|
182
|
+
</div>
|
|
183
|
+
) }
|
|
184
|
+
<HStack spacing={ 2 * ratio } justify="flex-start">
|
|
185
|
+
<div
|
|
186
|
+
style={ {
|
|
187
|
+
fontFamily,
|
|
188
|
+
fontSize: 24 * ratio,
|
|
189
|
+
color: textColor,
|
|
190
|
+
} }
|
|
191
|
+
>
|
|
192
|
+
Aa
|
|
193
|
+
</div>
|
|
194
|
+
<div
|
|
195
|
+
style={ {
|
|
196
|
+
fontFamily,
|
|
197
|
+
fontSize: 24 * ratio,
|
|
198
|
+
color: linkColor,
|
|
199
|
+
} }
|
|
200
|
+
>
|
|
201
|
+
Aa
|
|
202
|
+
</div>
|
|
203
|
+
</HStack>
|
|
204
|
+
{ paletteColors && (
|
|
205
|
+
<HStack spacing={ 0 }>
|
|
206
|
+
{ paletteColors
|
|
207
|
+
.slice( 0, 4 )
|
|
208
|
+
.map( ( { color }, index ) => (
|
|
209
|
+
<div
|
|
210
|
+
key={ index }
|
|
211
|
+
style={ {
|
|
212
|
+
height: 10 * ratio,
|
|
213
|
+
width: 30 * ratio,
|
|
214
|
+
background: color,
|
|
215
|
+
flexGrow: 1,
|
|
216
|
+
} }
|
|
217
|
+
/>
|
|
218
|
+
) ) }
|
|
219
|
+
</HStack>
|
|
220
|
+
) }
|
|
221
|
+
</VStack>
|
|
222
|
+
</motion.div>
|
|
223
|
+
</motion.div>
|
|
67
224
|
</Iframe>
|
|
68
225
|
);
|
|
69
226
|
};
|
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
5
|
-
import {
|
|
6
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { __, sprintf, _n } from '@wordpress/i18n';
|
|
7
6
|
import {
|
|
8
7
|
FlexItem,
|
|
8
|
+
SearchControl,
|
|
9
9
|
__experimentalHStack as HStack,
|
|
10
10
|
} from '@wordpress/components';
|
|
11
|
+
import { useSelect } from '@wordpress/data';
|
|
12
|
+
import { useState, useMemo, useEffect, useRef } from '@wordpress/element';
|
|
11
13
|
import { BlockIcon } from '@wordpress/block-editor';
|
|
14
|
+
import { useDebounce } from '@wordpress/compose';
|
|
15
|
+
import { speak } from '@wordpress/a11y';
|
|
12
16
|
|
|
13
17
|
/**
|
|
14
18
|
* Internal dependencies
|
|
@@ -59,9 +63,7 @@ function BlockMenuItem( { block } ) {
|
|
|
59
63
|
return (
|
|
60
64
|
<NavigationButton path={ '/blocks/' + block.name }>
|
|
61
65
|
<HStack justify="flex-start">
|
|
62
|
-
<
|
|
63
|
-
<BlockIcon icon={ block.icon } />
|
|
64
|
-
</FlexItem>
|
|
66
|
+
<BlockIcon icon={ block.icon } />
|
|
65
67
|
<FlexItem>{ block.title }</FlexItem>
|
|
66
68
|
</HStack>
|
|
67
69
|
</NavigationButton>
|
|
@@ -70,6 +72,45 @@ function BlockMenuItem( { block } ) {
|
|
|
70
72
|
|
|
71
73
|
function ScreenBlockList() {
|
|
72
74
|
const sortedBlockTypes = useSortedBlockTypes();
|
|
75
|
+
const [ filterValue, setFilterValue ] = useState( '' );
|
|
76
|
+
const debouncedSpeak = useDebounce( speak, 500 );
|
|
77
|
+
const isMatchingSearchTerm = useSelect(
|
|
78
|
+
( select ) => select( blocksStore ).isMatchingSearchTerm,
|
|
79
|
+
[]
|
|
80
|
+
);
|
|
81
|
+
const filteredBlockTypes = useMemo( () => {
|
|
82
|
+
if ( ! filterValue ) {
|
|
83
|
+
return sortedBlockTypes;
|
|
84
|
+
}
|
|
85
|
+
return sortedBlockTypes.filter( ( blockType ) =>
|
|
86
|
+
isMatchingSearchTerm( blockType, filterValue )
|
|
87
|
+
);
|
|
88
|
+
}, [ filterValue, sortedBlockTypes, isMatchingSearchTerm ] );
|
|
89
|
+
|
|
90
|
+
const blockTypesListRef = useRef();
|
|
91
|
+
|
|
92
|
+
// Announce search results on change
|
|
93
|
+
useEffect( () => {
|
|
94
|
+
if ( ! filterValue ) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// We extract the results from the wrapper div's `ref` because
|
|
98
|
+
// filtered items can contain items that will eventually not
|
|
99
|
+
// render and there is no reliable way to detect when a child
|
|
100
|
+
// will return `null`.
|
|
101
|
+
// TODO: We should find a better way of handling this as it's
|
|
102
|
+
// fragile and depends on the number of rendered elements of `BlockMenuItem`,
|
|
103
|
+
// which is now one.
|
|
104
|
+
// @see https://github.com/WordPress/gutenberg/pull/39117#discussion_r816022116
|
|
105
|
+
const count = blockTypesListRef.current.childElementCount;
|
|
106
|
+
const resultsFoundMessage = sprintf(
|
|
107
|
+
/* translators: %d: number of results. */
|
|
108
|
+
_n( '%d result found.', '%d results found.', count ),
|
|
109
|
+
count
|
|
110
|
+
);
|
|
111
|
+
debouncedSpeak( resultsFoundMessage, count );
|
|
112
|
+
}, [ filterValue, debouncedSpeak ] );
|
|
113
|
+
|
|
73
114
|
return (
|
|
74
115
|
<>
|
|
75
116
|
<ScreenHeader
|
|
@@ -78,12 +119,24 @@ function ScreenBlockList() {
|
|
|
78
119
|
'Customize the appearance of specific blocks and for the whole site.'
|
|
79
120
|
) }
|
|
80
121
|
/>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
122
|
+
<SearchControl
|
|
123
|
+
className="edit-site-block-types-search"
|
|
124
|
+
onChange={ setFilterValue }
|
|
125
|
+
value={ filterValue }
|
|
126
|
+
label={ __( 'Search for blocks' ) }
|
|
127
|
+
placeholder={ __( 'Search' ) }
|
|
128
|
+
/>
|
|
129
|
+
<div
|
|
130
|
+
ref={ blockTypesListRef }
|
|
131
|
+
className="edit-site-block-types-item-list"
|
|
132
|
+
>
|
|
133
|
+
{ filteredBlockTypes.map( ( block ) => (
|
|
134
|
+
<BlockMenuItem
|
|
135
|
+
block={ block }
|
|
136
|
+
key={ 'menu-itemblock-' + block.name }
|
|
137
|
+
/>
|
|
138
|
+
) ) }
|
|
139
|
+
</div>
|
|
87
140
|
</>
|
|
88
141
|
);
|
|
89
142
|
}
|
|
@@ -18,6 +18,7 @@ import Palette from './palette';
|
|
|
18
18
|
import { NavigationButton } from './navigation-button';
|
|
19
19
|
import { getSupportedGlobalStylesPanels, useStyle } from './hooks';
|
|
20
20
|
import Subtitle from './subtitle';
|
|
21
|
+
import ColorIndicatorWrapper from './color-indicator-wrapper';
|
|
21
22
|
|
|
22
23
|
function BackgroundColorItem( { name, parentMenu } ) {
|
|
23
24
|
const supports = getSupportedGlobalStylesPanels( name );
|
|
@@ -34,11 +35,11 @@ function BackgroundColorItem( { name, parentMenu } ) {
|
|
|
34
35
|
return (
|
|
35
36
|
<NavigationButton path={ parentMenu + '/colors/background' }>
|
|
36
37
|
<HStack justify="flex-start">
|
|
37
|
-
<
|
|
38
|
+
<ColorIndicatorWrapper expanded={ false }>
|
|
38
39
|
<ColorIndicator
|
|
39
40
|
colorValue={ gradientValue ?? backgroundColor }
|
|
40
41
|
/>
|
|
41
|
-
</
|
|
42
|
+
</ColorIndicatorWrapper>
|
|
42
43
|
<FlexItem>{ __( 'Background' ) }</FlexItem>
|
|
43
44
|
</HStack>
|
|
44
45
|
</NavigationButton>
|
|
@@ -57,9 +58,9 @@ function TextColorItem( { name, parentMenu } ) {
|
|
|
57
58
|
return (
|
|
58
59
|
<NavigationButton path={ parentMenu + '/colors/text' }>
|
|
59
60
|
<HStack justify="flex-start">
|
|
60
|
-
<
|
|
61
|
+
<ColorIndicatorWrapper expanded={ false }>
|
|
61
62
|
<ColorIndicator colorValue={ color } />
|
|
62
|
-
</
|
|
63
|
+
</ColorIndicatorWrapper>
|
|
63
64
|
<FlexItem>{ __( 'Text' ) }</FlexItem>
|
|
64
65
|
</HStack>
|
|
65
66
|
</NavigationButton>
|
|
@@ -78,9 +79,9 @@ function LinkColorItem( { name, parentMenu } ) {
|
|
|
78
79
|
return (
|
|
79
80
|
<NavigationButton path={ parentMenu + '/colors/link' }>
|
|
80
81
|
<HStack justify="flex-start">
|
|
81
|
-
<
|
|
82
|
+
<ColorIndicatorWrapper expanded={ false }>
|
|
82
83
|
<ColorIndicator colorValue={ color } />
|
|
83
|
-
</
|
|
84
|
+
</ColorIndicatorWrapper>
|
|
84
85
|
<FlexItem>{ __( 'Links' ) }</FlexItem>
|
|
85
86
|
</HStack>
|
|
86
87
|
</NavigationButton>
|
|
@@ -10,15 +10,17 @@ import {
|
|
|
10
10
|
CardBody,
|
|
11
11
|
Card,
|
|
12
12
|
CardDivider,
|
|
13
|
+
CardMedia,
|
|
13
14
|
} from '@wordpress/components';
|
|
14
15
|
import { isRTL, __ } from '@wordpress/i18n';
|
|
15
|
-
import { chevronLeft, chevronRight
|
|
16
|
+
import { chevronLeft, chevronRight } from '@wordpress/icons';
|
|
16
17
|
import { useSelect } from '@wordpress/data';
|
|
17
18
|
import { store as coreStore } from '@wordpress/core-data';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Internal dependencies
|
|
21
22
|
*/
|
|
23
|
+
import { IconWithCurrentColor } from './icon-with-current-color';
|
|
22
24
|
import { NavigationButton } from './navigation-button';
|
|
23
25
|
import ContextMenu from './context-menu';
|
|
24
26
|
import StylesPreview from './preview';
|
|
@@ -37,19 +39,19 @@ function ScreenRoot() {
|
|
|
37
39
|
<CardBody>
|
|
38
40
|
<VStack spacing={ 2 }>
|
|
39
41
|
<Card>
|
|
40
|
-
<
|
|
42
|
+
<CardMedia>
|
|
43
|
+
<StylesPreview />
|
|
44
|
+
</CardMedia>
|
|
41
45
|
</Card>
|
|
42
46
|
{ !! variations?.length && (
|
|
43
47
|
<NavigationButton path="/variations">
|
|
44
48
|
<HStack justify="space-between">
|
|
45
|
-
<FlexItem>{ __( '
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/>
|
|
52
|
-
</FlexItem>
|
|
49
|
+
<FlexItem>{ __( 'Browse styles' ) }</FlexItem>
|
|
50
|
+
<IconWithCurrentColor
|
|
51
|
+
icon={
|
|
52
|
+
isRTL() ? chevronLeft : chevronRight
|
|
53
|
+
}
|
|
54
|
+
/>
|
|
53
55
|
</HStack>
|
|
54
56
|
</NavigationButton>
|
|
55
57
|
) }
|
|
@@ -72,13 +74,9 @@ function ScreenRoot() {
|
|
|
72
74
|
<NavigationButton path="/blocks">
|
|
73
75
|
<HStack justify="space-between">
|
|
74
76
|
<FlexItem>{ __( 'Blocks' ) }</FlexItem>
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
isRTL() ? chevronLeft : chevronRight
|
|
79
|
-
}
|
|
80
|
-
/>
|
|
81
|
-
</FlexItem>
|
|
77
|
+
<IconWithCurrentColor
|
|
78
|
+
icon={ isRTL() ? chevronLeft : chevronRight }
|
|
79
|
+
/>
|
|
82
80
|
</HStack>
|
|
83
81
|
</NavigationButton>
|
|
84
82
|
</ItemGroup>
|
|
@@ -9,7 +9,7 @@ import classnames from 'classnames';
|
|
|
9
9
|
*/
|
|
10
10
|
import { store as coreStore } from '@wordpress/core-data';
|
|
11
11
|
import { useSelect } from '@wordpress/data';
|
|
12
|
-
import { useMemo, useContext } from '@wordpress/element';
|
|
12
|
+
import { useMemo, useContext, useState } from '@wordpress/element';
|
|
13
13
|
import { ENTER } from '@wordpress/keycodes';
|
|
14
14
|
import {
|
|
15
15
|
__experimentalGrid as Grid,
|
|
@@ -31,6 +31,7 @@ function compareVariations( a, b ) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function Variation( { variation } ) {
|
|
34
|
+
const [ isFocused, setIsFocused ] = useState( false );
|
|
34
35
|
const { base, user, setUserConfig } = useContext( GlobalStylesContext );
|
|
35
36
|
const context = useMemo( () => {
|
|
36
37
|
return {
|
|
@@ -77,8 +78,16 @@ function Variation( { variation } ) {
|
|
|
77
78
|
onClick={ selectVariation }
|
|
78
79
|
onKeyDown={ selectOnEnter }
|
|
79
80
|
tabIndex="0"
|
|
81
|
+
aria-label={ variation?.title }
|
|
82
|
+
onFocus={ () => setIsFocused( true ) }
|
|
83
|
+
onBlur={ () => setIsFocused( false ) }
|
|
80
84
|
>
|
|
81
|
-
<
|
|
85
|
+
<div className="edit-site-global-styles-variations_item-preview">
|
|
86
|
+
<StylesPreview
|
|
87
|
+
label={ variation?.title }
|
|
88
|
+
isFocused={ isFocused }
|
|
89
|
+
/>
|
|
90
|
+
</div>
|
|
82
91
|
</div>
|
|
83
92
|
</GlobalStylesContext.Provider>
|
|
84
93
|
);
|
|
@@ -96,7 +105,7 @@ function ScreenStyleVariations() {
|
|
|
96
105
|
const withEmptyVariation = useMemo( () => {
|
|
97
106
|
return [
|
|
98
107
|
{
|
|
99
|
-
|
|
108
|
+
title: __( 'Default' ),
|
|
100
109
|
settings: {},
|
|
101
110
|
styles: {},
|
|
102
111
|
},
|
|
@@ -108,7 +117,7 @@ function ScreenStyleVariations() {
|
|
|
108
117
|
<>
|
|
109
118
|
<ScreenHeader
|
|
110
119
|
back="/"
|
|
111
|
-
title={ __( '
|
|
120
|
+
title={ __( 'Browse styles' ) }
|
|
112
121
|
description={ __(
|
|
113
122
|
'Choose a different style combination for the theme styles'
|
|
114
123
|
) }
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
.edit-site-global-styles-header__description
|
|
47
|
+
.edit-site-global-styles-header__description,
|
|
48
|
+
.edit-site-block-types-search {
|
|
48
49
|
padding: 0 $grid-unit-20;
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -73,19 +74,31 @@
|
|
|
73
74
|
|
|
74
75
|
.edit-site-global-styles-variations_item {
|
|
75
76
|
box-sizing: border-box;
|
|
76
|
-
padding: $border-width * 2;
|
|
77
|
-
border-radius: $radius-block-ui;
|
|
78
|
-
border: $gray-200 $border-width solid;
|
|
79
77
|
|
|
80
|
-
|
|
78
|
+
.edit-site-global-styles-variations_item-preview {
|
|
79
|
+
padding: $border-width * 2;
|
|
80
|
+
border-radius: $radius-block-ui;
|
|
81
|
+
border: $gray-200 $border-width solid;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&.is-active .edit-site-global-styles-variations_item-preview {
|
|
81
85
|
border: $gray-900 $border-width solid;
|
|
82
86
|
}
|
|
83
87
|
|
|
84
|
-
&:hover {
|
|
88
|
+
&:hover .edit-site-global-styles-variations_item-preview {
|
|
85
89
|
border: var(--wp-admin-theme-color) $border-width solid;
|
|
86
90
|
}
|
|
87
91
|
|
|
88
|
-
&:focus {
|
|
92
|
+
&:focus .edit-site-global-styles-variations_item-preview {
|
|
89
93
|
border: var(--wp-admin-theme-color) $border-width solid;
|
|
90
94
|
}
|
|
91
95
|
}
|
|
96
|
+
|
|
97
|
+
.edit-site-global-styles-icon-with-current-color {
|
|
98
|
+
fill: currentColor;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.edit-site-global-styles__color-indicator-wrapper {
|
|
102
|
+
// Match the height of the rest of the icons (24px).
|
|
103
|
+
height: $grid-unit * 3;
|
|
104
|
+
}
|
|
@@ -53,21 +53,23 @@ function useSecondaryText() {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* @param {Object} props
|
|
57
|
-
* @param {string} props.entityTitle
|
|
58
|
-
* @param {string} props.entityLabel
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* @param {boolean} props.isLoaded
|
|
62
|
-
* @param {Function} props.children
|
|
63
|
-
*
|
|
64
|
-
*
|
|
56
|
+
* @param {Object} props Props for the DocumentActions component.
|
|
57
|
+
* @param {string} props.entityTitle The title to display.
|
|
58
|
+
* @param {string} props.entityLabel A label to use for entity-related options.
|
|
59
|
+
* E.g. "template" would be used for "edit
|
|
60
|
+
* template" and "show template details".
|
|
61
|
+
* @param {boolean} props.isLoaded Whether the data is available.
|
|
62
|
+
* @param {Function} props.children React component to use for the
|
|
63
|
+
* information dropdown area. Should be a
|
|
64
|
+
* function which accepts dropdown props.
|
|
65
|
+
* @param {boolean} props.showIconLabels Whether buttons display icons or text labels.
|
|
65
66
|
*/
|
|
66
67
|
export default function DocumentActions( {
|
|
67
68
|
entityTitle,
|
|
68
69
|
entityLabel,
|
|
69
70
|
isLoaded,
|
|
70
71
|
children: dropdownContent,
|
|
72
|
+
showIconLabels,
|
|
71
73
|
} ) {
|
|
72
74
|
const { label } = useSecondaryText();
|
|
73
75
|
|
|
@@ -144,7 +146,9 @@ export default function DocumentActions( {
|
|
|
144
146
|
__( 'Show %s details' ),
|
|
145
147
|
entityLabel
|
|
146
148
|
) }
|
|
147
|
-
|
|
149
|
+
>
|
|
150
|
+
{ showIconLabels && __( 'Details' ) }
|
|
151
|
+
</Button>
|
|
148
152
|
) }
|
|
149
153
|
contentClassName="edit-site-document-actions__info-dropdown"
|
|
150
154
|
renderContent={ dropdownContent }
|
|
@@ -34,6 +34,7 @@ const preventDefault = ( event ) => {
|
|
|
34
34
|
export default function Header( {
|
|
35
35
|
openEntitiesSavedStates,
|
|
36
36
|
isEntitiesSavedStatesOpen,
|
|
37
|
+
showIconLabels,
|
|
37
38
|
} ) {
|
|
38
39
|
const inserterButton = useRef();
|
|
39
40
|
const {
|
|
@@ -122,7 +123,10 @@ export default function Header( {
|
|
|
122
123
|
'Toggle block inserter',
|
|
123
124
|
'Generic label for block inserter button'
|
|
124
125
|
) }
|
|
125
|
-
|
|
126
|
+
>
|
|
127
|
+
{ showIconLabels &&
|
|
128
|
+
( ! isInserterOpen ? __( 'Add' ) : __( 'Close' ) ) }
|
|
129
|
+
</Button>
|
|
126
130
|
{ isLargeViewport && (
|
|
127
131
|
<>
|
|
128
132
|
<ToolbarItem
|
|
@@ -155,6 +159,7 @@ export default function Header( {
|
|
|
155
159
|
: 'template'
|
|
156
160
|
}
|
|
157
161
|
isLoaded={ isLoaded }
|
|
162
|
+
showIconLabels={ showIconLabels }
|
|
158
163
|
>
|
|
159
164
|
{ ( { onClose } ) => (
|
|
160
165
|
<TemplateDetails
|
|
@@ -14,6 +14,7 @@ import { PreferenceToggleMenuItem } from '@wordpress/preferences';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import KeyboardShortcutHelpModal from '../../keyboard-shortcut-help-modal';
|
|
17
|
+
import EditSitePreferencesModal from '../../preferences-modal';
|
|
17
18
|
import ToolsMoreMenuGroup from '../tools-more-menu-group';
|
|
18
19
|
import SiteExport from './site-export';
|
|
19
20
|
import WelcomeGuideMenuItem from './welcome-guide-menu-item';
|
|
@@ -26,6 +27,11 @@ export default function MoreMenu() {
|
|
|
26
27
|
false
|
|
27
28
|
);
|
|
28
29
|
|
|
30
|
+
const [ isPreferencesModalActive, togglePreferencesModal ] = useReducer(
|
|
31
|
+
( isActive ) => ! isActive,
|
|
32
|
+
false
|
|
33
|
+
);
|
|
34
|
+
|
|
29
35
|
useShortcut( 'core/edit-site/keyboard-shortcuts', toggleModal );
|
|
30
36
|
|
|
31
37
|
return (
|
|
@@ -99,6 +105,11 @@ export default function MoreMenu() {
|
|
|
99
105
|
fillProps={ { onClose } }
|
|
100
106
|
/>
|
|
101
107
|
</MenuGroup>
|
|
108
|
+
<MenuGroup>
|
|
109
|
+
<MenuItem onClick={ togglePreferencesModal }>
|
|
110
|
+
{ __( 'Preferences' ) }
|
|
111
|
+
</MenuItem>
|
|
112
|
+
</MenuGroup>
|
|
102
113
|
</>
|
|
103
114
|
) }
|
|
104
115
|
</MoreMenuDropdown>
|
|
@@ -106,6 +117,10 @@ export default function MoreMenu() {
|
|
|
106
117
|
isModalActive={ isModalActive }
|
|
107
118
|
toggleModal={ toggleModal }
|
|
108
119
|
/>
|
|
120
|
+
<EditSitePreferencesModal
|
|
121
|
+
isModalActive={ isPreferencesModalActive }
|
|
122
|
+
toggleModal={ togglePreferencesModal }
|
|
123
|
+
/>
|
|
109
124
|
</>
|
|
110
125
|
);
|
|
111
126
|
}
|