@wordpress/edit-site 4.18.0 → 4.19.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 +2 -0
- package/build/components/add-new-template/add-custom-template-modal.js +3 -1
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +9 -47
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +46 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +32 -0
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/palette.js +8 -1
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +52 -16
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +43 -8
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +3 -1
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +14 -7
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +3 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/list/table.js +1 -1
- package/build/components/list/table.js.map +1 -1
- package/build/components/list/use-register-shortcuts.js +3 -0
- package/build/components/list/use-register-shortcuts.js.map +1 -1
- package/build/components/save-button/index.js +20 -2
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-card/index.js +4 -2
- package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -1
- package/build/components/template-details/index.js +4 -2
- package/build/components/template-details/index.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +2 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +11 -49
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +46 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +27 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/palette.js +9 -3
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +53 -16
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +44 -9
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +2 -1
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +13 -7
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +3 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/list/table.js +1 -1
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/list/use-register-shortcuts.js +3 -0
- package/build-module/components/list/use-register-shortcuts.js.map +1 -1
- package/build-module/components/save-button/index.js +21 -2
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-card/index.js +3 -2
- package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -1
- package/build-module/components/template-details/index.js +3 -2
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-style/style-rtl.css +15 -15
- package/build-style/style.css +15 -15
- package/package.json +30 -29
- package/src/components/add-new-template/add-custom-template-modal.js +5 -1
- package/src/components/block-editor/resizable-editor.js +10 -55
- package/src/components/editor/style.scss +1 -7
- package/src/components/global-styles/dimensions-panel.js +59 -1
- package/src/components/global-styles/hooks.js +36 -0
- package/src/components/global-styles/palette.js +15 -1
- package/src/components/global-styles/test/typography-utils.js +82 -98
- package/src/components/global-styles/test/use-global-styles-output.js +6 -6
- package/src/components/global-styles/typography-panel.js +57 -15
- package/src/components/global-styles/use-global-styles-output.js +47 -10
- package/src/components/header-edit-mode/document-actions/index.js +2 -1
- package/src/components/header-edit-mode/index.js +8 -4
- package/src/components/keyboard-shortcuts/index.js +4 -0
- package/src/components/list/table.js +1 -1
- package/src/components/list/use-register-shortcuts.js +4 -0
- package/src/components/navigation-sidebar/navigation-panel/style.scss +0 -7
- package/src/components/navigation-sidebar/navigation-toggle/test/index.js +20 -24
- package/src/components/save-button/index.js +17 -1
- package/src/components/sidebar-edit-mode/template-card/index.js +3 -2
- package/src/components/template-details/index.js +3 -2
- package/src/components/navigation-sidebar/navigation-toggle/test/__snapshots__/index.js.snap +0 -41
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-site",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.19.0",
|
|
4
4
|
"description": "Edit Site Page module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,34 +27,35 @@
|
|
|
27
27
|
"react-native": "src/index",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/a11y": "^3.
|
|
31
|
-
"@wordpress/api-fetch": "^6.
|
|
32
|
-
"@wordpress/block-editor": "^10.
|
|
33
|
-
"@wordpress/block-library": "^7.
|
|
34
|
-
"@wordpress/blocks": "^11.
|
|
35
|
-
"@wordpress/components": "^22.
|
|
36
|
-
"@wordpress/compose": "^5.
|
|
37
|
-
"@wordpress/core-data": "^5.
|
|
38
|
-
"@wordpress/data": "^7.
|
|
39
|
-
"@wordpress/deprecated": "^3.
|
|
40
|
-
"@wordpress/editor": "^12.
|
|
41
|
-
"@wordpress/element": "^4.
|
|
42
|
-
"@wordpress/hooks": "^3.
|
|
43
|
-
"@wordpress/html-entities": "^3.
|
|
44
|
-
"@wordpress/i18n": "^4.
|
|
45
|
-
"@wordpress/icons": "^9.
|
|
46
|
-
"@wordpress/interface": "^4.
|
|
47
|
-
"@wordpress/keyboard-shortcuts": "^3.
|
|
48
|
-
"@wordpress/keycodes": "^3.
|
|
49
|
-
"@wordpress/media-utils": "^4.
|
|
50
|
-
"@wordpress/notices": "^3.
|
|
51
|
-
"@wordpress/plugins": "^4.
|
|
52
|
-
"@wordpress/preferences": "^2.
|
|
53
|
-
"@wordpress/reusable-blocks": "^3.
|
|
54
|
-
"@wordpress/style-engine": "^1.
|
|
55
|
-
"@wordpress/url": "^3.
|
|
56
|
-
"@wordpress/viewport": "^4.
|
|
30
|
+
"@wordpress/a11y": "^3.22.0",
|
|
31
|
+
"@wordpress/api-fetch": "^6.19.0",
|
|
32
|
+
"@wordpress/block-editor": "^10.5.0",
|
|
33
|
+
"@wordpress/block-library": "^7.19.0",
|
|
34
|
+
"@wordpress/blocks": "^11.21.0",
|
|
35
|
+
"@wordpress/components": "^22.1.0",
|
|
36
|
+
"@wordpress/compose": "^5.20.0",
|
|
37
|
+
"@wordpress/core-data": "^5.5.0",
|
|
38
|
+
"@wordpress/data": "^7.6.0",
|
|
39
|
+
"@wordpress/deprecated": "^3.22.0",
|
|
40
|
+
"@wordpress/editor": "^12.21.0",
|
|
41
|
+
"@wordpress/element": "^4.20.0",
|
|
42
|
+
"@wordpress/hooks": "^3.22.0",
|
|
43
|
+
"@wordpress/html-entities": "^3.22.0",
|
|
44
|
+
"@wordpress/i18n": "^4.22.0",
|
|
45
|
+
"@wordpress/icons": "^9.13.0",
|
|
46
|
+
"@wordpress/interface": "^4.21.0",
|
|
47
|
+
"@wordpress/keyboard-shortcuts": "^3.20.0",
|
|
48
|
+
"@wordpress/keycodes": "^3.22.0",
|
|
49
|
+
"@wordpress/media-utils": "^4.13.0",
|
|
50
|
+
"@wordpress/notices": "^3.22.0",
|
|
51
|
+
"@wordpress/plugins": "^4.20.0",
|
|
52
|
+
"@wordpress/preferences": "^2.14.0",
|
|
53
|
+
"@wordpress/reusable-blocks": "^3.20.0",
|
|
54
|
+
"@wordpress/style-engine": "^1.5.0",
|
|
55
|
+
"@wordpress/url": "^3.23.0",
|
|
56
|
+
"@wordpress/viewport": "^4.20.0",
|
|
57
57
|
"classnames": "^2.3.1",
|
|
58
|
+
"colord": "^2.9.2",
|
|
58
59
|
"downloadjs": "^1.4.7",
|
|
59
60
|
"history": "^5.1.0",
|
|
60
61
|
"lodash": "^4.17.21",
|
|
@@ -68,5 +69,5 @@
|
|
|
68
69
|
"publishConfig": {
|
|
69
70
|
"access": "public"
|
|
70
71
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "7ac04f446242452d3cb24372f9ca58f0cae97715"
|
|
72
73
|
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from '@wordpress/components';
|
|
18
18
|
import { useDebounce } from '@wordpress/compose';
|
|
19
19
|
import { useEntityRecords } from '@wordpress/core-data';
|
|
20
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Internal dependencies
|
|
@@ -50,7 +51,10 @@ function SuggestionListItem( {
|
|
|
50
51
|
}
|
|
51
52
|
>
|
|
52
53
|
<span className={ `${ baseCssClass }__title` }>
|
|
53
|
-
<TextHighlight
|
|
54
|
+
<TextHighlight
|
|
55
|
+
text={ decodeEntities( suggestion.name ) }
|
|
56
|
+
highlight={ search }
|
|
57
|
+
/>
|
|
54
58
|
</span>
|
|
55
59
|
{ suggestion.link && (
|
|
56
60
|
<span className={ `${ baseCssClass }__info` }>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useState,
|
|
4
|
+
import { useState, useRef, useCallback } from '@wordpress/element';
|
|
5
5
|
import { ResizableBox } from '@wordpress/components';
|
|
6
6
|
import {
|
|
7
7
|
__experimentalUseResizeCanvas as useResizeCanvas,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
store as blockEditorStore,
|
|
12
12
|
} from '@wordpress/block-editor';
|
|
13
13
|
import { useSelect } from '@wordpress/data';
|
|
14
|
-
import { useMergeRefs } from '@wordpress/compose';
|
|
14
|
+
import { useMergeRefs, useResizeObserver } from '@wordpress/compose';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Internal dependencies
|
|
@@ -19,11 +19,6 @@ import { useMergeRefs } from '@wordpress/compose';
|
|
|
19
19
|
import { store as editSiteStore } from '../../store';
|
|
20
20
|
import ResizeHandle from './resize-handle';
|
|
21
21
|
|
|
22
|
-
const DEFAULT_STYLES = {
|
|
23
|
-
width: '100%',
|
|
24
|
-
height: '100%',
|
|
25
|
-
};
|
|
26
|
-
|
|
27
22
|
// Removes the inline styles in the drag handles.
|
|
28
23
|
const HANDLE_STYLES_OVERRIDE = {
|
|
29
24
|
position: undefined,
|
|
@@ -38,6 +33,7 @@ const HANDLE_STYLES_OVERRIDE = {
|
|
|
38
33
|
};
|
|
39
34
|
|
|
40
35
|
function ResizableEditor( { enableResizing, settings, children, ...props } ) {
|
|
36
|
+
const [ resizeObserver, sizes ] = useResizeObserver();
|
|
41
37
|
const { deviceType, isZoomOutMode } = useSelect(
|
|
42
38
|
( select ) => ( {
|
|
43
39
|
deviceType:
|
|
@@ -49,60 +45,21 @@ function ResizableEditor( { enableResizing, settings, children, ...props } ) {
|
|
|
49
45
|
[]
|
|
50
46
|
);
|
|
51
47
|
const deviceStyles = useResizeCanvas( deviceType );
|
|
52
|
-
const [ width, setWidth ] = useState(
|
|
53
|
-
const [ height, setHeight ] = useState( DEFAULT_STYLES.height );
|
|
48
|
+
const [ width, setWidth ] = useState( '100%' );
|
|
54
49
|
const iframeRef = useRef();
|
|
55
50
|
const mouseMoveTypingResetRef = useMouseMoveTypingReset();
|
|
56
51
|
const ref = useMergeRefs( [ iframeRef, mouseMoveTypingResetRef ] );
|
|
57
52
|
|
|
58
|
-
useEffect(
|
|
59
|
-
function autoResizeIframeHeight() {
|
|
60
|
-
if ( ! iframeRef.current || ! enableResizing ) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const iframe = iframeRef.current;
|
|
65
|
-
|
|
66
|
-
function setFrameHeight() {
|
|
67
|
-
setHeight( iframe.contentDocument.body.scrollHeight );
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
let resizeObserver;
|
|
71
|
-
|
|
72
|
-
function registerObserver() {
|
|
73
|
-
resizeObserver?.disconnect();
|
|
74
|
-
|
|
75
|
-
resizeObserver = new iframe.contentWindow.ResizeObserver(
|
|
76
|
-
setFrameHeight
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
// Observe the body, since the `html` element seems to always
|
|
80
|
-
// have a height of `100%`.
|
|
81
|
-
resizeObserver.observe( iframe.contentDocument.body );
|
|
82
|
-
setFrameHeight();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
iframe.addEventListener( 'load', registerObserver );
|
|
86
|
-
|
|
87
|
-
return () => {
|
|
88
|
-
resizeObserver?.disconnect();
|
|
89
|
-
iframe.removeEventListener( 'load', registerObserver );
|
|
90
|
-
};
|
|
91
|
-
},
|
|
92
|
-
[ enableResizing, iframeRef.current ]
|
|
93
|
-
);
|
|
94
|
-
|
|
95
53
|
const resizeWidthBy = useCallback( ( deltaPixels ) => {
|
|
96
54
|
if ( iframeRef.current ) {
|
|
97
55
|
setWidth( iframeRef.current.offsetWidth + deltaPixels );
|
|
98
56
|
}
|
|
99
57
|
}, [] );
|
|
100
|
-
|
|
101
58
|
return (
|
|
102
59
|
<ResizableBox
|
|
103
60
|
size={ {
|
|
104
|
-
width,
|
|
105
|
-
height,
|
|
61
|
+
width: enableResizing ? width : '100%',
|
|
62
|
+
height: enableResizing && sizes.height ? sizes.height : '100%',
|
|
106
63
|
} }
|
|
107
64
|
onResizeStop={ ( event, direction, element ) => {
|
|
108
65
|
setWidth( element.style.width );
|
|
@@ -141,21 +98,18 @@ function ResizableEditor( { enableResizing, settings, children, ...props } ) {
|
|
|
141
98
|
>
|
|
142
99
|
<Iframe
|
|
143
100
|
isZoomedOut={ isZoomOutMode }
|
|
144
|
-
style={ enableResizing ? {
|
|
101
|
+
style={ enableResizing ? {} : deviceStyles }
|
|
145
102
|
head={
|
|
146
103
|
<>
|
|
147
104
|
<EditorStyles styles={ settings.styles } />
|
|
148
105
|
<style>{
|
|
149
106
|
// Forming a "block formatting context" to prevent margin collapsing.
|
|
150
107
|
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
|
|
151
|
-
`.is-root-container { display: flow-root; }
|
|
108
|
+
`.is-root-container { display: flow-root; }
|
|
109
|
+
body { position: relative; }`
|
|
152
110
|
}</style>
|
|
153
111
|
{ enableResizing && (
|
|
154
112
|
<style>
|
|
155
|
-
{
|
|
156
|
-
// Force the <html> and <body>'s heights to fit the content.
|
|
157
|
-
`html, body { height: -moz-fit-content !important; height: fit-content !important; min-height: 0 !important; }`
|
|
158
|
-
}
|
|
159
113
|
{
|
|
160
114
|
// Some themes will have `min-height: 100vh` for the root container,
|
|
161
115
|
// which isn't a requirement in auto resize mode.
|
|
@@ -173,6 +127,7 @@ function ResizableEditor( { enableResizing, settings, children, ...props } ) {
|
|
|
173
127
|
>
|
|
174
128
|
{ /* Filters need to be rendered before children to avoid Safari rendering issues. */ }
|
|
175
129
|
{ settings.svgFilters }
|
|
130
|
+
{ resizeObserver }
|
|
176
131
|
{ children }
|
|
177
132
|
</Iframe>
|
|
178
133
|
</ResizableBox>
|
|
@@ -7,16 +7,10 @@ html.wp-toolbar {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.edit-site-editor__toggle-save-panel {
|
|
10
|
-
|
|
11
|
-
position: fixed !important; // Need to override the default relative positioning
|
|
12
|
-
top: -9999em;
|
|
13
|
-
bottom: auto;
|
|
14
|
-
left: auto;
|
|
15
|
-
right: 0;
|
|
10
|
+
box-sizing: border-box;
|
|
16
11
|
width: $sidebar-width;
|
|
17
12
|
background-color: $white;
|
|
18
13
|
border: 1px dotted $gray-300;
|
|
19
|
-
height: auto !important; // Need to override the default sidebar positioning
|
|
20
14
|
padding: $grid-unit-30;
|
|
21
15
|
display: flex;
|
|
22
16
|
justify-content: center;
|
|
@@ -35,8 +35,16 @@ export function useHasDimensionsPanel( name ) {
|
|
|
35
35
|
const hasPadding = useHasPadding( name );
|
|
36
36
|
const hasMargin = useHasMargin( name );
|
|
37
37
|
const hasGap = useHasGap( name );
|
|
38
|
+
const hasMinHeight = useHasMinHeight( name );
|
|
38
39
|
|
|
39
|
-
return
|
|
40
|
+
return (
|
|
41
|
+
hasContentSize ||
|
|
42
|
+
hasWideSize ||
|
|
43
|
+
hasPadding ||
|
|
44
|
+
hasMargin ||
|
|
45
|
+
hasGap ||
|
|
46
|
+
hasMinHeight
|
|
47
|
+
);
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
function useHasContentSize( name ) {
|
|
@@ -74,6 +82,13 @@ function useHasGap( name ) {
|
|
|
74
82
|
return settings && supports.includes( 'blockGap' );
|
|
75
83
|
}
|
|
76
84
|
|
|
85
|
+
function useHasMinHeight( name ) {
|
|
86
|
+
const supports = getSupportedGlobalStylesPanels( name );
|
|
87
|
+
const [ settings ] = useSetting( 'dimensions.minHeight', name );
|
|
88
|
+
|
|
89
|
+
return settings && supports.includes( 'minHeight' );
|
|
90
|
+
}
|
|
91
|
+
|
|
77
92
|
function useHasSpacingPresets() {
|
|
78
93
|
const [ settings ] = useSetting( 'spacing.spacingSizes' );
|
|
79
94
|
|
|
@@ -271,12 +286,29 @@ function useBlockGapProps( name ) {
|
|
|
271
286
|
};
|
|
272
287
|
}
|
|
273
288
|
|
|
289
|
+
// Props for managing `dimensions.minHeight`.
|
|
290
|
+
function useMinHeightProps( name ) {
|
|
291
|
+
const [ minHeightValue, setMinHeightValue ] = useStyle(
|
|
292
|
+
'dimensions.minHeight',
|
|
293
|
+
name
|
|
294
|
+
);
|
|
295
|
+
const resetMinHeightValue = () => setMinHeightValue( undefined );
|
|
296
|
+
const hasMinHeightValue = () => !! minHeightValue;
|
|
297
|
+
return {
|
|
298
|
+
minHeightValue,
|
|
299
|
+
setMinHeightValue,
|
|
300
|
+
resetMinHeightValue,
|
|
301
|
+
hasMinHeightValue,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
274
305
|
export default function DimensionsPanel( { name } ) {
|
|
275
306
|
const showContentSizeControl = useHasContentSize( name );
|
|
276
307
|
const showWideSizeControl = useHasWideSize( name );
|
|
277
308
|
const showPaddingControl = useHasPadding( name );
|
|
278
309
|
const showMarginControl = useHasMargin( name );
|
|
279
310
|
const showGapControl = useHasGap( name );
|
|
311
|
+
const showMinHeightControl = useHasMinHeight( name );
|
|
280
312
|
const showSpacingPresetsControl = useHasSpacingPresets();
|
|
281
313
|
const units = useCustomUnits( {
|
|
282
314
|
availableUnits: useSetting( 'spacing.units', name )[ 0 ] || [
|
|
@@ -336,6 +368,14 @@ export default function DimensionsPanel( { name } ) {
|
|
|
336
368
|
hasGapValue,
|
|
337
369
|
} = useBlockGapProps( name );
|
|
338
370
|
|
|
371
|
+
// Props for managing `dimensions.minHeight`.
|
|
372
|
+
const {
|
|
373
|
+
minHeightValue,
|
|
374
|
+
setMinHeightValue,
|
|
375
|
+
resetMinHeightValue,
|
|
376
|
+
hasMinHeightValue,
|
|
377
|
+
} = useMinHeightProps( name );
|
|
378
|
+
|
|
339
379
|
const resetAll = () => {
|
|
340
380
|
resetPaddingValue();
|
|
341
381
|
resetMarginValue();
|
|
@@ -514,6 +554,24 @@ export default function DimensionsPanel( { name } ) {
|
|
|
514
554
|
) }
|
|
515
555
|
</ToolsPanelItem>
|
|
516
556
|
) }
|
|
557
|
+
{ showMinHeightControl && (
|
|
558
|
+
<ToolsPanelItem
|
|
559
|
+
className="single-column"
|
|
560
|
+
hasValue={ hasMinHeightValue }
|
|
561
|
+
label={ __( 'Min. height' ) }
|
|
562
|
+
onDeselect={ resetMinHeightValue }
|
|
563
|
+
isShownByDefault={ true }
|
|
564
|
+
>
|
|
565
|
+
<UnitControl
|
|
566
|
+
label={ __( 'Min. height' ) }
|
|
567
|
+
value={ minHeightValue }
|
|
568
|
+
onChange={ setMinHeightValue }
|
|
569
|
+
units={ units }
|
|
570
|
+
min={ 0 }
|
|
571
|
+
size={ '__unstable-large' }
|
|
572
|
+
/>
|
|
573
|
+
</ToolsPanelItem>
|
|
574
|
+
) }
|
|
517
575
|
</ToolsPanel>
|
|
518
576
|
);
|
|
519
577
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { get, set, isEqual } from 'lodash';
|
|
5
|
+
import { colord, extend } from 'colord';
|
|
6
|
+
import a11yPlugin from 'colord/plugins/a11y';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* WordPress dependencies
|
|
@@ -20,6 +22,9 @@ import {
|
|
|
20
22
|
import { getValueFromVariable, getPresetVariableFromValue } from './utils';
|
|
21
23
|
import { GlobalStylesContext } from './context';
|
|
22
24
|
|
|
25
|
+
// Enable colord's a11y plugin.
|
|
26
|
+
extend( [ a11yPlugin ] );
|
|
27
|
+
|
|
23
28
|
const EMPTY_CONFIG = { settings: {}, styles: {} };
|
|
24
29
|
|
|
25
30
|
export const useGlobalStylesReset = () => {
|
|
@@ -323,3 +328,34 @@ export function useGradientsPerOrigin( name ) {
|
|
|
323
328
|
return result;
|
|
324
329
|
}, [ customGradients, themeGradients, defaultGradients ] );
|
|
325
330
|
}
|
|
331
|
+
|
|
332
|
+
export function useColorRandomizer( name ) {
|
|
333
|
+
const [ themeColors, setThemeColors ] = useSetting(
|
|
334
|
+
'color.palette.theme',
|
|
335
|
+
name
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
function randomizeColors() {
|
|
339
|
+
/* eslint-disable no-restricted-syntax */
|
|
340
|
+
const randomRotationValue = Math.floor( Math.random() * 225 );
|
|
341
|
+
/* eslint-enable no-restricted-syntax */
|
|
342
|
+
|
|
343
|
+
const newColors = themeColors.map( ( colorObject ) => {
|
|
344
|
+
const { color } = colorObject;
|
|
345
|
+
const newColor = colord( color )
|
|
346
|
+
.rotate( randomRotationValue )
|
|
347
|
+
.toHex();
|
|
348
|
+
|
|
349
|
+
return {
|
|
350
|
+
...colorObject,
|
|
351
|
+
color: newColor,
|
|
352
|
+
};
|
|
353
|
+
} );
|
|
354
|
+
|
|
355
|
+
setThemeColors( newColors );
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return window.__experimentalEnableColorRandomizer
|
|
359
|
+
? [ randomizeColors ]
|
|
360
|
+
: [];
|
|
361
|
+
}
|
|
@@ -8,8 +8,10 @@ import {
|
|
|
8
8
|
__experimentalZStack as ZStack,
|
|
9
9
|
__experimentalVStack as VStack,
|
|
10
10
|
ColorIndicator,
|
|
11
|
+
Button,
|
|
11
12
|
} from '@wordpress/components';
|
|
12
13
|
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
14
|
+
import { shuffle } from '@wordpress/icons';
|
|
13
15
|
import { useMemo } from '@wordpress/element';
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -17,7 +19,7 @@ import { useMemo } from '@wordpress/element';
|
|
|
17
19
|
*/
|
|
18
20
|
import Subtitle from './subtitle';
|
|
19
21
|
import { NavigationButtonAsItem } from './navigation-button';
|
|
20
|
-
import { useSetting } from './hooks';
|
|
22
|
+
import { useColorRandomizer, useSetting } from './hooks';
|
|
21
23
|
import ColorIndicatorWrapper from './color-indicator-wrapper';
|
|
22
24
|
|
|
23
25
|
const EMPTY_COLORS = [];
|
|
@@ -31,6 +33,9 @@ function Palette( { name } ) {
|
|
|
31
33
|
'color.defaultPalette',
|
|
32
34
|
name
|
|
33
35
|
);
|
|
36
|
+
|
|
37
|
+
const [ randomizeThemeColors ] = useColorRandomizer();
|
|
38
|
+
|
|
34
39
|
const colors = useMemo(
|
|
35
40
|
() => [
|
|
36
41
|
...( customColors || EMPTY_COLORS ),
|
|
@@ -82,6 +87,15 @@ function Palette( { name } ) {
|
|
|
82
87
|
</HStack>
|
|
83
88
|
</NavigationButtonAsItem>
|
|
84
89
|
</ItemGroup>
|
|
90
|
+
{ randomizeThemeColors && (
|
|
91
|
+
<Button
|
|
92
|
+
variant="secondary"
|
|
93
|
+
icon={ shuffle }
|
|
94
|
+
onClick={ randomizeThemeColors }
|
|
95
|
+
>
|
|
96
|
+
{ __( 'Randomize colors' ) }
|
|
97
|
+
</Button>
|
|
98
|
+
) }
|
|
85
99
|
</VStack>
|
|
86
100
|
);
|
|
87
101
|
}
|