@wordpress/edit-site 4.15.1-next.4d3b314fd5.0 → 4.17.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 +4 -0
- package/build/components/block-editor/block-inspector-button.js +1 -1
- package/build/components/block-editor/block-inspector-button.js.map +1 -1
- package/build/components/block-editor/index.js +17 -11
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +11 -35
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/editor/index.js +5 -7
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/preview.js +85 -50
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +35 -4
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-typography-element.js +49 -2
- package/build/components/global-styles/screen-typography-element.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +143 -83
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-preview.js +54 -0
- package/build/components/global-styles/typography-preview.js.map +1 -0
- package/build/components/global-styles/typography-utils.js +39 -176
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +34 -16
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/{header → header-edit-mode}/document-actions/index.js +58 -24
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -0
- package/build/components/{header → header-edit-mode}/index.js +13 -49
- package/build/components/header-edit-mode/index.js.map +1 -0
- package/build/components/{header → header-edit-mode}/mode-switcher/index.js +0 -0
- package/build/components/header-edit-mode/mode-switcher/index.js.map +1 -0
- package/build/components/{header → header-edit-mode}/more-menu/copy-content-menu-item.js +0 -0
- package/build/components/header-edit-mode/more-menu/copy-content-menu-item.js.map +1 -0
- package/build/components/{header → header-edit-mode}/more-menu/index.js +0 -0
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -0
- package/build/components/{header → header-edit-mode}/more-menu/site-export.js +0 -0
- package/build/components/header-edit-mode/more-menu/site-export.js.map +1 -0
- package/build/components/{header → header-edit-mode}/more-menu/welcome-guide-menu-item.js +0 -0
- package/build/components/header-edit-mode/more-menu/welcome-guide-menu-item.js.map +1 -0
- package/build/components/{header → header-edit-mode}/plugin-more-menu-item/index.js +0 -0
- package/build/components/header-edit-mode/plugin-more-menu-item/index.js.map +1 -0
- package/build/components/{header → header-edit-mode}/plugin-sidebar-more-menu-item/index.js +0 -0
- package/build/components/header-edit-mode/plugin-sidebar-more-menu-item/index.js.map +1 -0
- package/build/components/{header → header-edit-mode}/tools-more-menu-group/index.js +0 -0
- package/build/components/header-edit-mode/tools-more-menu-group/index.js.map +1 -0
- package/build/components/{header → header-edit-mode}/undo-redo/redo.js +0 -0
- package/build/components/header-edit-mode/undo-redo/redo.js.map +1 -0
- package/build/components/{header → header-edit-mode}/undo-redo/undo.js +0 -0
- package/build/components/header-edit-mode/undo-redo/undo.js.map +1 -0
- package/build/components/keyboard-shortcuts/index.js +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/main-dashboard-button/index.js +2 -2
- package/build/components/main-dashboard-button/index.js.map +1 -1
- package/build/components/{sidebar → sidebar-edit-mode}/constants.js +0 -0
- package/build/components/sidebar-edit-mode/constants.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/default-sidebar.js +0 -0
- package/build/components/sidebar-edit-mode/default-sidebar.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/global-styles-sidebar.js +0 -0
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/index.js +1 -1
- package/build/components/sidebar-edit-mode/index.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/index.js +0 -0
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-inspector.js +0 -0
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-menu.js +0 -0
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/plugin-sidebar/index.js +1 -1
- package/build/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/settings-header/index.js +2 -2
- package/build/components/sidebar-edit-mode/settings-header/index.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/template-card/index.js +0 -0
- package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/template-card/template-actions.js +0 -0
- package/build/components/sidebar-edit-mode/template-card/template-actions.js.map +1 -0
- package/build/components/{sidebar → sidebar-edit-mode}/template-card/template-areas.js +0 -0
- package/build/components/sidebar-edit-mode/template-card/template-areas.js.map +1 -0
- package/build/index.js +23 -4
- package/build/index.js.map +1 -1
- package/build-module/components/block-editor/block-inspector-button.js +1 -1
- package/build-module/components/block-editor/block-inspector-button.js.map +1 -1
- package/build-module/components/block-editor/index.js +16 -10
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +10 -34
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/editor/index.js +4 -6
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/preview.js +85 -50
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +36 -6
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-typography-element.js +48 -2
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +143 -85
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-preview.js +46 -0
- package/build-module/components/global-styles/typography-preview.js.map +1 -0
- package/build-module/components/global-styles/typography-utils.js +37 -169
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +33 -16
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/{header → header-edit-mode}/document-actions/index.js +53 -24
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/index.js +13 -46
- package/build-module/components/header-edit-mode/index.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/mode-switcher/index.js +0 -0
- package/build-module/components/header-edit-mode/mode-switcher/index.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/more-menu/copy-content-menu-item.js +0 -0
- package/build-module/components/header-edit-mode/more-menu/copy-content-menu-item.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/more-menu/index.js +0 -0
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/more-menu/site-export.js +0 -0
- package/build-module/components/header-edit-mode/more-menu/site-export.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/more-menu/welcome-guide-menu-item.js +0 -0
- package/build-module/components/header-edit-mode/more-menu/welcome-guide-menu-item.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/plugin-more-menu-item/index.js +0 -0
- package/build-module/components/header-edit-mode/plugin-more-menu-item/index.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/plugin-sidebar-more-menu-item/index.js +0 -0
- package/build-module/components/header-edit-mode/plugin-sidebar-more-menu-item/index.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/tools-more-menu-group/index.js +0 -0
- package/build-module/components/header-edit-mode/tools-more-menu-group/index.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/undo-redo/redo.js +0 -0
- package/build-module/components/header-edit-mode/undo-redo/redo.js.map +1 -0
- package/build-module/components/{header → header-edit-mode}/undo-redo/undo.js +0 -0
- package/build-module/components/header-edit-mode/undo-redo/undo.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/index.js +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/main-dashboard-button/index.js +3 -3
- package/build-module/components/main-dashboard-button/index.js.map +1 -1
- package/build-module/components/{sidebar → sidebar-edit-mode}/constants.js +0 -0
- package/build-module/components/sidebar-edit-mode/constants.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/default-sidebar.js +0 -0
- package/build-module/components/sidebar-edit-mode/default-sidebar.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/global-styles-sidebar.js +0 -0
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/index.js +1 -1
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/index.js +0 -0
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-inspector.js +0 -0
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-menu.js +0 -0
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/plugin-sidebar/index.js +1 -1
- package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/settings-header/index.js +2 -2
- package/build-module/components/sidebar-edit-mode/settings-header/index.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/template-card/index.js +0 -0
- package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/template-card/template-actions.js +0 -0
- package/build-module/components/sidebar-edit-mode/template-card/template-actions.js.map +1 -0
- package/build-module/components/{sidebar → sidebar-edit-mode}/template-card/template-areas.js +0 -0
- package/build-module/components/sidebar-edit-mode/template-card/template-areas.js.map +1 -0
- package/build-module/index.js +22 -4
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +64 -89
- package/build-style/style.css +64 -89
- package/package.json +29 -29
- package/src/components/block-editor/block-inspector-button.js +1 -1
- package/src/components/block-editor/index.js +29 -11
- package/src/components/block-editor/resizable-editor.js +8 -37
- package/src/components/editor/index.js +2 -4
- package/src/components/global-styles/preview.js +81 -60
- package/src/components/global-styles/screen-style-variations.js +39 -4
- package/src/components/global-styles/screen-typography-element.js +65 -1
- package/src/components/global-styles/style.scss +2 -2
- package/src/components/global-styles/test/typography-utils.js +333 -103
- package/src/components/global-styles/test/use-global-styles-output.js +57 -3
- package/src/components/global-styles/typography-panel.js +205 -150
- package/src/components/global-styles/typography-preview.js +49 -0
- package/src/components/global-styles/typography-utils.js +34 -195
- package/src/components/global-styles/use-global-styles-output.js +31 -9
- package/src/components/{header → header-edit-mode}/document-actions/index.js +67 -46
- package/src/components/{header → header-edit-mode}/document-actions/style.scss +0 -0
- package/src/components/{header → header-edit-mode}/index.js +12 -44
- package/src/components/{header → header-edit-mode}/mode-switcher/index.js +0 -0
- package/src/components/{header → header-edit-mode}/more-menu/copy-content-menu-item.js +0 -0
- package/src/components/{header → header-edit-mode}/more-menu/index.js +0 -0
- package/src/components/{header → header-edit-mode}/more-menu/site-export.js +0 -0
- package/src/components/{header → header-edit-mode}/more-menu/welcome-guide-menu-item.js +0 -0
- package/src/components/{header → header-edit-mode}/plugin-more-menu-item/index.js +0 -0
- package/src/components/{header → header-edit-mode}/plugin-sidebar-more-menu-item/index.js +0 -0
- package/src/components/{header → header-edit-mode}/style.scss +20 -50
- package/src/components/{header → header-edit-mode}/tools-more-menu-group/index.js +0 -0
- package/src/components/{header → header-edit-mode}/undo-redo/redo.js +0 -0
- package/src/components/{header → header-edit-mode}/undo-redo/undo.js +0 -0
- package/src/components/keyboard-shortcuts/index.js +1 -1
- package/src/components/main-dashboard-button/index.js +3 -3
- package/src/components/{sidebar → sidebar-edit-mode}/constants.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/default-sidebar.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/global-styles-sidebar.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/index.js +1 -1
- package/src/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/index.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-inspector.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-menu.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/style.scss +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/plugin-sidebar/index.js +1 -1
- package/src/components/{sidebar → sidebar-edit-mode}/settings-header/index.js +2 -2
- package/src/components/{sidebar → sidebar-edit-mode}/settings-header/style.scss +2 -2
- package/src/components/{sidebar → sidebar-edit-mode}/style.scss +2 -2
- package/src/components/{sidebar → sidebar-edit-mode}/template-card/index.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/template-card/style.scss +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/template-card/template-actions.js +0 -0
- package/src/components/{sidebar → sidebar-edit-mode}/template-card/template-areas.js +0 -0
- package/src/index.js +24 -3
- package/src/style.scss +6 -6
- package/build/components/header/document-actions/index.js.map +0 -1
- package/build/components/header/index.js.map +0 -1
- package/build/components/header/mode-switcher/index.js.map +0 -1
- package/build/components/header/more-menu/copy-content-menu-item.js.map +0 -1
- package/build/components/header/more-menu/index.js.map +0 -1
- package/build/components/header/more-menu/site-export.js.map +0 -1
- package/build/components/header/more-menu/welcome-guide-menu-item.js.map +0 -1
- package/build/components/header/plugin-more-menu-item/index.js.map +0 -1
- package/build/components/header/plugin-sidebar-more-menu-item/index.js.map +0 -1
- package/build/components/header/tools-more-menu-group/index.js.map +0 -1
- package/build/components/header/undo-redo/redo.js.map +0 -1
- package/build/components/header/undo-redo/undo.js.map +0 -1
- package/build/components/sidebar/constants.js.map +0 -1
- package/build/components/sidebar/default-sidebar.js.map +0 -1
- package/build/components/sidebar/global-styles-sidebar.js.map +0 -1
- package/build/components/sidebar/index.js.map +0 -1
- package/build/components/sidebar/navigation-menu-sidebar/index.js.map +0 -1
- package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +0 -1
- package/build/components/sidebar/plugin-sidebar/index.js.map +0 -1
- package/build/components/sidebar/settings-header/index.js.map +0 -1
- package/build/components/sidebar/template-card/index.js.map +0 -1
- package/build/components/sidebar/template-card/template-actions.js.map +0 -1
- package/build/components/sidebar/template-card/template-areas.js.map +0 -1
- package/build-module/components/header/document-actions/index.js.map +0 -1
- package/build-module/components/header/index.js.map +0 -1
- package/build-module/components/header/mode-switcher/index.js.map +0 -1
- package/build-module/components/header/more-menu/copy-content-menu-item.js.map +0 -1
- package/build-module/components/header/more-menu/index.js.map +0 -1
- package/build-module/components/header/more-menu/site-export.js.map +0 -1
- package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +0 -1
- package/build-module/components/header/plugin-more-menu-item/index.js.map +0 -1
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js.map +0 -1
- package/build-module/components/header/tools-more-menu-group/index.js.map +0 -1
- package/build-module/components/header/undo-redo/redo.js.map +0 -1
- package/build-module/components/header/undo-redo/undo.js.map +0 -1
- package/build-module/components/sidebar/constants.js.map +0 -1
- package/build-module/components/sidebar/default-sidebar.js.map +0 -1
- package/build-module/components/sidebar/global-styles-sidebar.js.map +0 -1
- package/build-module/components/sidebar/index.js.map +0 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/index.js.map +0 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +0 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +0 -1
- package/build-module/components/sidebar/settings-header/index.js.map +0 -1
- package/build-module/components/sidebar/template-card/index.js.map +0 -1
- package/build-module/components/sidebar/template-card/template-actions.js.map +0 -1
- package/build-module/components/sidebar/template-card/template-areas.js.map +0 -1
|
@@ -15,22 +15,30 @@ import { useSetting, useStyle } from './hooks';
|
|
|
15
15
|
import { useGlobalStylesOutput } from './use-global-styles-output';
|
|
16
16
|
const firstFrame = {
|
|
17
17
|
start: {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
scale: 1,
|
|
19
|
+
opacity: 1
|
|
20
20
|
},
|
|
21
21
|
hover: {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
scale: 0,
|
|
23
|
+
opacity: 0
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const midFrame = {
|
|
27
|
+
hover: {
|
|
28
|
+
opacity: 1
|
|
29
|
+
},
|
|
30
|
+
start: {
|
|
31
|
+
opacity: 0.5
|
|
24
32
|
}
|
|
25
33
|
};
|
|
26
34
|
const secondFrame = {
|
|
27
35
|
hover: {
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
scale: 1,
|
|
37
|
+
opacity: 1
|
|
30
38
|
},
|
|
31
39
|
start: {
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
scale: 0,
|
|
41
|
+
opacity: 0
|
|
34
42
|
}
|
|
35
43
|
};
|
|
36
44
|
const normalizedWidth = 248;
|
|
@@ -40,7 +48,8 @@ const normalizedColorSwatchSize = 32;
|
|
|
40
48
|
const StylesPreview = _ref => {
|
|
41
49
|
let {
|
|
42
50
|
label,
|
|
43
|
-
isFocused
|
|
51
|
+
isFocused,
|
|
52
|
+
withHoverView
|
|
44
53
|
} = _ref;
|
|
45
54
|
const [fontWeight] = useStyle('typography.fontWeight');
|
|
46
55
|
const [fontFamily = 'serif'] = useStyle('typography.fontFamily');
|
|
@@ -48,7 +57,6 @@ const StylesPreview = _ref => {
|
|
|
48
57
|
const [headingFontWeight = fontWeight] = useStyle('elements.h1.typography.fontWeight');
|
|
49
58
|
const [textColor = 'black'] = useStyle('color.text');
|
|
50
59
|
const [headingColor = textColor] = useStyle('elements.h1.color.text');
|
|
51
|
-
const [linkColor = 'blue'] = useStyle('elements.link.color.text');
|
|
52
60
|
const [backgroundColor = 'white'] = useStyle('color.background');
|
|
53
61
|
const [gradientValue] = useStyle('color.gradient');
|
|
54
62
|
const [styles] = useGlobalStylesOutput();
|
|
@@ -68,12 +76,12 @@ const StylesPreview = _ref => {
|
|
|
68
76
|
color
|
|
69
77
|
} = _ref2;
|
|
70
78
|
return color !== backgroundColor && color !== headingColor;
|
|
71
|
-
}).slice(0, 2); // Reset leaked styles from WP common.css and remove main content layout padding.
|
|
79
|
+
}).slice(0, 2); // Reset leaked styles from WP common.css and remove main content layout padding and border.
|
|
72
80
|
|
|
73
81
|
const editorStyles = useMemo(() => {
|
|
74
82
|
if (styles) {
|
|
75
83
|
return [...styles, {
|
|
76
|
-
css: 'body{min-width: 0;padding: 0;}',
|
|
84
|
+
css: 'html{overflow:hidden}body{min-width: 0;padding: 0;border: none;}',
|
|
77
85
|
isGlobalStyles: true
|
|
78
86
|
}];
|
|
79
87
|
}
|
|
@@ -100,7 +108,7 @@ const StylesPreview = _ref => {
|
|
|
100
108
|
cursor: 'pointer'
|
|
101
109
|
},
|
|
102
110
|
initial: "start",
|
|
103
|
-
animate: (isHovered || isFocused) && !disableMotion ? 'hover' : 'start'
|
|
111
|
+
animate: (isHovered || isFocused) && !disableMotion && label ? 'hover' : 'start'
|
|
104
112
|
}, createElement(motion.div, {
|
|
105
113
|
variants: firstFrame,
|
|
106
114
|
style: {
|
|
@@ -114,35 +122,91 @@ const StylesPreview = _ref => {
|
|
|
114
122
|
height: '100%',
|
|
115
123
|
overflow: 'hidden'
|
|
116
124
|
}
|
|
117
|
-
}, createElement(
|
|
125
|
+
}, createElement(motion.div, {
|
|
118
126
|
style: {
|
|
119
127
|
fontFamily: headingFontFamily,
|
|
120
128
|
fontSize: 65 * ratio,
|
|
121
129
|
color: headingColor,
|
|
122
130
|
fontWeight: headingFontWeight
|
|
131
|
+
},
|
|
132
|
+
animate: {
|
|
133
|
+
scale: 1,
|
|
134
|
+
opacity: 1
|
|
135
|
+
},
|
|
136
|
+
initial: {
|
|
137
|
+
scale: 0.1,
|
|
138
|
+
opacity: 0
|
|
139
|
+
},
|
|
140
|
+
transition: {
|
|
141
|
+
delay: 0.3,
|
|
142
|
+
type: 'tween'
|
|
123
143
|
}
|
|
124
144
|
}, "Aa"), createElement(VStack, {
|
|
125
145
|
spacing: 4 * ratio
|
|
126
|
-
}, highlightedColors.map(_ref3 => {
|
|
146
|
+
}, highlightedColors.map((_ref3, index) => {
|
|
127
147
|
let {
|
|
128
148
|
slug,
|
|
129
149
|
color
|
|
130
150
|
} = _ref3;
|
|
131
|
-
return createElement(
|
|
151
|
+
return createElement(motion.div, {
|
|
132
152
|
key: slug,
|
|
133
153
|
style: {
|
|
134
154
|
height: normalizedColorSwatchSize * ratio,
|
|
135
155
|
width: normalizedColorSwatchSize * ratio,
|
|
136
156
|
background: color,
|
|
137
157
|
borderRadius: normalizedColorSwatchSize * ratio / 2
|
|
158
|
+
},
|
|
159
|
+
animate: {
|
|
160
|
+
scale: 1,
|
|
161
|
+
opacity: 1
|
|
162
|
+
},
|
|
163
|
+
initial: {
|
|
164
|
+
scale: 0.1,
|
|
165
|
+
opacity: 0
|
|
166
|
+
},
|
|
167
|
+
transition: {
|
|
168
|
+
delay: index === 1 ? 0.2 : 0.1
|
|
138
169
|
}
|
|
139
170
|
});
|
|
140
171
|
})))), createElement(motion.div, {
|
|
141
|
-
variants:
|
|
172
|
+
variants: withHoverView && midFrame,
|
|
173
|
+
style: {
|
|
174
|
+
height: '100%',
|
|
175
|
+
width: '100%',
|
|
176
|
+
position: 'absolute',
|
|
177
|
+
top: 0,
|
|
178
|
+
overflow: 'hidden',
|
|
179
|
+
filter: 'blur(60px)',
|
|
180
|
+
opacity: 0.1
|
|
181
|
+
}
|
|
182
|
+
}, createElement(HStack, {
|
|
183
|
+
spacing: 0,
|
|
184
|
+
justify: "flex-start",
|
|
142
185
|
style: {
|
|
143
186
|
height: '100%',
|
|
144
187
|
overflow: 'hidden'
|
|
145
188
|
}
|
|
189
|
+
}, paletteColors.slice(0, 4).map((_ref4, index) => {
|
|
190
|
+
let {
|
|
191
|
+
color
|
|
192
|
+
} = _ref4;
|
|
193
|
+
return createElement("div", {
|
|
194
|
+
key: index,
|
|
195
|
+
style: {
|
|
196
|
+
height: '100%',
|
|
197
|
+
background: color,
|
|
198
|
+
flexGrow: 1
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}))), createElement(motion.div, {
|
|
202
|
+
variants: secondFrame,
|
|
203
|
+
style: {
|
|
204
|
+
height: '100%',
|
|
205
|
+
width: '100%',
|
|
206
|
+
overflow: 'hidden',
|
|
207
|
+
position: 'absolute',
|
|
208
|
+
top: 0
|
|
209
|
+
}
|
|
146
210
|
}, createElement(VStack, {
|
|
147
211
|
spacing: 3 * ratio,
|
|
148
212
|
justify: "center",
|
|
@@ -154,43 +218,14 @@ const StylesPreview = _ref => {
|
|
|
154
218
|
}
|
|
155
219
|
}, label && createElement("div", {
|
|
156
220
|
style: {
|
|
157
|
-
fontSize:
|
|
221
|
+
fontSize: 40 * ratio,
|
|
158
222
|
fontFamily: headingFontFamily,
|
|
159
223
|
color: headingColor,
|
|
160
224
|
fontWeight: headingFontWeight,
|
|
161
|
-
lineHeight: '1em'
|
|
162
|
-
|
|
163
|
-
}, label), createElement(HStack, {
|
|
164
|
-
spacing: 2 * ratio,
|
|
165
|
-
justify: "flex-start"
|
|
166
|
-
}, createElement("div", {
|
|
167
|
-
style: {
|
|
168
|
-
fontFamily,
|
|
169
|
-
fontSize: 24 * ratio,
|
|
170
|
-
color: textColor
|
|
171
|
-
}
|
|
172
|
-
}, "Aa"), createElement("div", {
|
|
173
|
-
style: {
|
|
174
|
-
fontFamily,
|
|
175
|
-
fontSize: 24 * ratio,
|
|
176
|
-
color: linkColor
|
|
225
|
+
lineHeight: '1em',
|
|
226
|
+
textAlign: 'center'
|
|
177
227
|
}
|
|
178
|
-
},
|
|
179
|
-
spacing: 0
|
|
180
|
-
}, paletteColors.slice(0, 4).map((_ref4, index) => {
|
|
181
|
-
let {
|
|
182
|
-
color
|
|
183
|
-
} = _ref4;
|
|
184
|
-
return createElement("div", {
|
|
185
|
-
key: index,
|
|
186
|
-
style: {
|
|
187
|
-
height: 10 * ratio,
|
|
188
|
-
width: 30 * ratio,
|
|
189
|
-
background: color,
|
|
190
|
-
flexGrow: 1
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
}))))));
|
|
228
|
+
}, label)))));
|
|
194
229
|
};
|
|
195
230
|
|
|
196
231
|
export default StylesPreview;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/preview.js"],"names":["__unstableIframe","Iframe","__unstableEditorStyles","EditorStyles","__unstableMotion","motion","__experimentalHStack","HStack","__experimentalVStack","VStack","useReducedMotion","useResizeObserver","useState","useMemo","useSetting","useStyle","useGlobalStylesOutput","firstFrame","start","opacity","display","hover","secondFrame","normalizedWidth","normalizedHeight","normalizedColorSwatchSize","StylesPreview","label","isFocused","fontWeight","fontFamily","headingFontFamily","headingFontWeight","textColor","headingColor","linkColor","backgroundColor","gradientValue","styles","disableMotion","coreColors","themeColors","customColors","isHovered","setIsHovered","containerResizeListener","width","ratio","paletteColors","concat","highlightedColors","filter","color","slice","editorStyles","css","isGlobalStyles","height","visibility","background","cursor","overflow","fontSize","map","slug","borderRadius","padding","boxSizing","lineHeight","index","flexGrow"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,gBAAgB,IAAIC,MADrB,EAECC,sBAAsB,IAAIC,YAF3B,QAGO,yBAHP;AAIA,SACCC,gBAAgB,IAAIC,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ditorStyles,\n} from '@wordpress/block-editor';\nimport {\n\t__unstableMotion as motion,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useReducedMotion, useResizeObserver } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSetting, useStyle } from './hooks';\nimport { useGlobalStylesOutput } from './use-global-styles-output';\n\nconst firstFrame = {\n\tstart: {\n\t\topacity: 1,\n\t\tdisplay: 'block',\n\t},\n\thover: {\n\t\topacity: 0,\n\t\tdisplay: 'none',\n\t},\n};\n\nconst secondFrame = {\n\thover: {\n\t\topacity: 1,\n\t\tdisplay: 'block',\n\t},\n\tstart: {\n\t\topacity: 0,\n\t\tdisplay: 'none',\n\t},\n};\n\nconst normalizedWidth = 248;\nconst normalizedHeight = 152;\n\nconst normalizedColorSwatchSize = 32;\n\nconst StylesPreview = ( { label, isFocused } ) => {\n\tconst [ fontWeight ] = useStyle( 'typography.fontWeight' );\n\tconst [ fontFamily = 'serif' ] = useStyle( 'typography.fontFamily' );\n\tconst [ headingFontFamily = fontFamily ] = useStyle(\n\t\t'elements.h1.typography.fontFamily'\n\t);\n\tconst [ headingFontWeight = fontWeight ] = useStyle(\n\t\t'elements.h1.typography.fontWeight'\n\t);\n\tconst [ textColor = 'black' ] = useStyle( 'color.text' );\n\tconst [ headingColor = textColor ] = useStyle( 'elements.h1.color.text' );\n\tconst [ linkColor = 'blue' ] = useStyle( 'elements.link.color.text' );\n\tconst [ backgroundColor = 'white' ] = useStyle( 'color.background' );\n\tconst [ gradientValue ] = useStyle( 'color.gradient' );\n\tconst [ styles ] = useGlobalStylesOutput();\n\tconst disableMotion = useReducedMotion();\n\tconst [ coreColors ] = useSetting( 'color.palette.core' );\n\tconst [ themeColors ] = useSetting( 'color.palette.theme' );\n\tconst [ customColors ] = useSetting( 'color.palette.custom' );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst [ containerResizeListener, { width } ] = useResizeObserver();\n\tconst ratio = width ? width / normalizedWidth : 1;\n\n\tconst paletteColors = ( themeColors ?? [] )\n\t\t.concat( customColors ?? [] )\n\t\t.concat( coreColors ?? [] );\n\tconst highlightedColors = paletteColors\n\t\t.filter(\n\t\t\t// we exclude these two colors because they are already visible in the preview.\n\t\t\t( { color } ) => color !== backgroundColor && color !== headingColor\n\t\t)\n\t\t.slice( 0, 2 );\n\n\t// Reset leaked styles from WP common.css and remove main content layout padding.\n\tconst editorStyles = useMemo( () => {\n\t\tif ( styles ) {\n\t\t\treturn [\n\t\t\t\t...styles,\n\t\t\t\t{\n\t\t\t\t\tcss: 'body{min-width: 0;padding: 0;}',\n\t\t\t\t\tisGlobalStyles: true,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn styles;\n\t}, [ styles ] );\n\n\treturn (\n\t\t<Iframe\n\t\t\tclassName=\"edit-site-global-styles-preview__iframe\"\n\t\t\thead={ <EditorStyles styles={ editorStyles } /> }\n\t\t\tstyle={ {\n\t\t\t\theight: normalizedHeight * ratio,\n\t\t\t\tvisibility: ! width ? 'hidden' : 'visible',\n\t\t\t} }\n\t\t\tonMouseEnter={ () => setIsHovered( true ) }\n\t\t\tonMouseLeave={ () => setIsHovered( false ) }\n\t\t\ttabIndex={ -1 }\n\t\t>\n\t\t\t{ containerResizeListener }\n\t\t\t<motion.div\n\t\t\t\tstyle={ {\n\t\t\t\t\theight: normalizedHeight * ratio,\n\t\t\t\t\twidth: '100%',\n\t\t\t\t\tbackground: gradientValue ?? backgroundColor,\n\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t} }\n\t\t\t\tinitial=\"start\"\n\t\t\t\tanimate={\n\t\t\t\t\t( isHovered || isFocused ) && ! disableMotion\n\t\t\t\t\t\t? 'hover'\n\t\t\t\t\t\t: 'start'\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ firstFrame }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tspacing={ 10 * ratio }\n\t\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tfontFamily: headingFontFamily,\n\t\t\t\t\t\t\t\tfontSize: 65 * ratio,\n\t\t\t\t\t\t\t\tcolor: headingColor,\n\t\t\t\t\t\t\t\tfontWeight: headingFontWeight,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tAa\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<VStack spacing={ 4 * ratio }>\n\t\t\t\t\t\t\t{ highlightedColors.map( ( { slug, color } ) => (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\theight:\n\t\t\t\t\t\t\t\t\t\t\tnormalizedColorSwatchSize * ratio,\n\t\t\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\t\t\tnormalizedColorSwatchSize * ratio,\n\t\t\t\t\t\t\t\t\t\tbackground: color,\n\t\t\t\t\t\t\t\t\t\tborderRadius:\n\t\t\t\t\t\t\t\t\t\t\t( normalizedColorSwatchSize *\n\t\t\t\t\t\t\t\t\t\t\t\tratio ) /\n\t\t\t\t\t\t\t\t\t\t\t2,\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</HStack>\n\t\t\t\t</motion.div>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ secondFrame }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<VStack\n\t\t\t\t\t\tspacing={ 3 * ratio }\n\t\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\tpadding: 10 * ratio,\n\t\t\t\t\t\t\tboxSizing: 'border-box',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tfontSize: 35 * ratio,\n\t\t\t\t\t\t\t\t\tfontFamily: headingFontFamily,\n\t\t\t\t\t\t\t\t\tcolor: headingColor,\n\t\t\t\t\t\t\t\t\tfontWeight: headingFontWeight,\n\t\t\t\t\t\t\t\t\tlineHeight: '1em',\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<HStack spacing={ 2 * ratio } justify=\"flex-start\">\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tfontFamily,\n\t\t\t\t\t\t\t\t\tfontSize: 24 * ratio,\n\t\t\t\t\t\t\t\t\tcolor: textColor,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tAa\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tfontFamily,\n\t\t\t\t\t\t\t\t\tfontSize: 24 * ratio,\n\t\t\t\t\t\t\t\t\tcolor: linkColor,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tAa\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t{ paletteColors && (\n\t\t\t\t\t\t\t<HStack spacing={ 0 }>\n\t\t\t\t\t\t\t\t{ paletteColors\n\t\t\t\t\t\t\t\t\t.slice( 0, 4 )\n\t\t\t\t\t\t\t\t\t.map( ( { color }, index ) => (\n\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\theight: 10 * ratio,\n\t\t\t\t\t\t\t\t\t\t\t\twidth: 30 * ratio,\n\t\t\t\t\t\t\t\t\t\t\t\tbackground: color,\n\t\t\t\t\t\t\t\t\t\t\t\tflexGrow: 1,\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</VStack>\n\t\t\t\t</motion.div>\n\t\t\t</motion.div>\n\t\t</Iframe>\n\t);\n};\n\nexport default StylesPreview;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/preview.js"],"names":["__unstableIframe","Iframe","__unstableEditorStyles","EditorStyles","__unstableMotion","motion","__experimentalHStack","HStack","__experimentalVStack","VStack","useReducedMotion","useResizeObserver","useState","useMemo","useSetting","useStyle","useGlobalStylesOutput","firstFrame","start","scale","opacity","hover","midFrame","secondFrame","normalizedWidth","normalizedHeight","normalizedColorSwatchSize","StylesPreview","label","isFocused","withHoverView","fontWeight","fontFamily","headingFontFamily","headingFontWeight","textColor","headingColor","backgroundColor","gradientValue","styles","disableMotion","coreColors","themeColors","customColors","isHovered","setIsHovered","containerResizeListener","width","ratio","paletteColors","concat","highlightedColors","filter","color","slice","editorStyles","css","isGlobalStyles","height","visibility","background","cursor","overflow","fontSize","delay","type","map","index","slug","borderRadius","position","top","flexGrow","padding","boxSizing","lineHeight","textAlign"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,gBAAgB,IAAIC,MADrB,EAECC,sBAAsB,IAAIC,YAF3B,QAGO,yBAHP;AAIA,SACCC,gBAAgB,IAAIC,MADrB,EAECC,oBAAoB,IAAIC,MAFzB,EAGCC,oBAAoB,IAAIC,MAHzB,QAIO,uBAJP;AAKA,SAASC,gBAAT,EAA2BC,iBAA3B,QAAoD,oBAApD;AACA,SAASC,QAAT,EAAmBC,OAAnB,QAAkC,oBAAlC;AAEA;AACA;AACA;;AACA,SAASC,UAAT,EAAqBC,QAArB,QAAqC,SAArC;AACA,SAASC,qBAAT,QAAsC,4BAAtC;AAEA,MAAMC,UAAU,GAAG;AAClBC,EAAAA,KAAK,EAAE;AACNC,IAAAA,KAAK,EAAE,CADD;AAENC,IAAAA,OAAO,EAAE;AAFH,GADW;AAKlBC,EAAAA,KAAK,EAAE;AACNF,IAAAA,KAAK,EAAE,CADD;AAENC,IAAAA,OAAO,EAAE;AAFH;AALW,CAAnB;AAWA,MAAME,QAAQ,GAAG;AAChBD,EAAAA,KAAK,EAAE;AACND,IAAAA,OAAO,EAAE;AADH,GADS;AAIhBF,EAAAA,KAAK,EAAE;AACNE,IAAAA,OAAO,EAAE;AADH;AAJS,CAAjB;AASA,MAAMG,WAAW,GAAG;AACnBF,EAAAA,KAAK,EAAE;AACNF,IAAAA,KAAK,EAAE,CADD;AAENC,IAAAA,OAAO,EAAE;AAFH,GADY;AAKnBF,EAAAA,KAAK,EAAE;AACNC,IAAAA,KAAK,EAAE,CADD;AAENC,IAAAA,OAAO,EAAE;AAFH;AALY,CAApB;AAWA,MAAMI,eAAe,GAAG,GAAxB;AACA,MAAMC,gBAAgB,GAAG,GAAzB;AAEA,MAAMC,yBAAyB,GAAG,EAAlC;;AAEA,MAAMC,aAAa,GAAG,QAA2C;AAAA,MAAzC;AAAEC,IAAAA,KAAF;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AAAA,WACL;AACC,MAAA,GAAG,EAAGc,KADP;AAEC,MAAA,KAAK,EAAG;AACPT,QAAAA,MAAM,EAAE,MADD;AAEPE,QAAAA,UAAU,EAAEP,KAFL;AAGPmB,QAAAA,QAAQ,EAAE;AAHH;AAFT,MADK;AAAA,GAFL,CARH,CAZD,CAvED,EAyGC,cAAC,MAAD,CAAQ,GAAR;AACC,IAAA,QAAQ,EAAGjD,WADZ;AAEC,IAAA,KAAK,EAAG;AACPmC,MAAAA,MAAM,EAAE,MADD;AAEPX,MAAAA,KAAK,EAAE,MAFA;AAGPe,MAAAA,QAAQ,EAAE,QAHH;AAIPQ,MAAAA,QAAQ,EAAE,UAJH;AAKPC,MAAAA,GAAG,EAAE;AALE;AAFT,KAUC,cAAC,MAAD;AACC,IAAA,OAAO,EAAG,IAAIvB,KADf;AAEC,IAAA,OAAO,EAAC,QAFT;AAGC,IAAA,KAAK,EAAG;AACPU,MAAAA,MAAM,EAAE,MADD;AAEPI,MAAAA,QAAQ,EAAE,QAFH;AAGPW,MAAAA,OAAO,EAAE,KAAKzB,KAHP;AAIP0B,MAAAA,SAAS,EAAE;AAJJ;AAHT,KAUG9C,KAAK,IACN;AACC,IAAA,KAAK,EAAG;AACPmC,MAAAA,QAAQ,EAAE,KAAKf,KADR;AAEPhB,MAAAA,UAAU,EAAEC,iBAFL;AAGPoB,MAAAA,KAAK,EAAEjB,YAHA;AAIPL,MAAAA,UAAU,EAAEG,iBAJL;AAKPyC,MAAAA,UAAU,EAAE,KALL;AAMPC,MAAAA,SAAS,EAAE;AANJ;AADT,KAUGhD,KAVH,CAXF,CAVD,CAzGD,CAZD,CADD;AA6JA,CA5MD;;AA8MA,eAAeD,aAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__unstableIframe as Iframe,\n\t__unstableEditorStyles as EditorStyles,\n} from '@wordpress/block-editor';\nimport {\n\t__unstableMotion as motion,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useReducedMotion, useResizeObserver } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSetting, useStyle } from './hooks';\nimport { useGlobalStylesOutput } from './use-global-styles-output';\n\nconst firstFrame = {\n\tstart: {\n\t\tscale: 1,\n\t\topacity: 1,\n\t},\n\thover: {\n\t\tscale: 0,\n\t\topacity: 0,\n\t},\n};\n\nconst midFrame = {\n\thover: {\n\t\topacity: 1,\n\t},\n\tstart: {\n\t\topacity: 0.5,\n\t},\n};\n\nconst secondFrame = {\n\thover: {\n\t\tscale: 1,\n\t\topacity: 1,\n\t},\n\tstart: {\n\t\tscale: 0,\n\t\topacity: 0,\n\t},\n};\n\nconst normalizedWidth = 248;\nconst normalizedHeight = 152;\n\nconst normalizedColorSwatchSize = 32;\n\nconst StylesPreview = ( { label, isFocused, withHoverView } ) => {\n\tconst [ fontWeight ] = useStyle( 'typography.fontWeight' );\n\tconst [ fontFamily = 'serif' ] = useStyle( 'typography.fontFamily' );\n\tconst [ headingFontFamily = fontFamily ] = useStyle(\n\t\t'elements.h1.typography.fontFamily'\n\t);\n\tconst [ headingFontWeight = fontWeight ] = useStyle(\n\t\t'elements.h1.typography.fontWeight'\n\t);\n\tconst [ textColor = 'black' ] = useStyle( 'color.text' );\n\tconst [ headingColor = textColor ] = useStyle( 'elements.h1.color.text' );\n\tconst [ backgroundColor = 'white' ] = useStyle( 'color.background' );\n\tconst [ gradientValue ] = useStyle( 'color.gradient' );\n\tconst [ styles ] = useGlobalStylesOutput();\n\tconst disableMotion = useReducedMotion();\n\tconst [ coreColors ] = useSetting( 'color.palette.core' );\n\tconst [ themeColors ] = useSetting( 'color.palette.theme' );\n\tconst [ customColors ] = useSetting( 'color.palette.custom' );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst [ containerResizeListener, { width } ] = useResizeObserver();\n\tconst ratio = width ? width / normalizedWidth : 1;\n\n\tconst paletteColors = ( themeColors ?? [] )\n\t\t.concat( customColors ?? [] )\n\t\t.concat( coreColors ?? [] );\n\tconst highlightedColors = paletteColors\n\t\t.filter(\n\t\t\t// we exclude these two colors because they are already visible in the preview.\n\t\t\t( { color } ) => color !== backgroundColor && color !== headingColor\n\t\t)\n\t\t.slice( 0, 2 );\n\n\t// Reset leaked styles from WP common.css and remove main content layout padding and border.\n\tconst editorStyles = useMemo( () => {\n\t\tif ( styles ) {\n\t\t\treturn [\n\t\t\t\t...styles,\n\t\t\t\t{\n\t\t\t\t\tcss: 'html{overflow:hidden}body{min-width: 0;padding: 0;border: none;}',\n\t\t\t\t\tisGlobalStyles: true,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn styles;\n\t}, [ styles ] );\n\n\treturn (\n\t\t<Iframe\n\t\t\tclassName=\"edit-site-global-styles-preview__iframe\"\n\t\t\thead={ <EditorStyles styles={ editorStyles } /> }\n\t\t\tstyle={ {\n\t\t\t\theight: normalizedHeight * ratio,\n\t\t\t\tvisibility: ! width ? 'hidden' : 'visible',\n\t\t\t} }\n\t\t\tonMouseEnter={ () => setIsHovered( true ) }\n\t\t\tonMouseLeave={ () => setIsHovered( false ) }\n\t\t\ttabIndex={ -1 }\n\t\t>\n\t\t\t{ containerResizeListener }\n\t\t\t<motion.div\n\t\t\t\tstyle={ {\n\t\t\t\t\theight: normalizedHeight * ratio,\n\t\t\t\t\twidth: '100%',\n\t\t\t\t\tbackground: gradientValue ?? backgroundColor,\n\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t} }\n\t\t\t\tinitial=\"start\"\n\t\t\t\tanimate={\n\t\t\t\t\t( isHovered || isFocused ) && ! disableMotion && label\n\t\t\t\t\t\t? 'hover'\n\t\t\t\t\t\t: 'start'\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ firstFrame }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tspacing={ 10 * ratio }\n\t\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tfontFamily: headingFontFamily,\n\t\t\t\t\t\t\t\tfontSize: 65 * ratio,\n\t\t\t\t\t\t\t\tcolor: headingColor,\n\t\t\t\t\t\t\t\tfontWeight: headingFontWeight,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanimate={ { scale: 1, opacity: 1 } }\n\t\t\t\t\t\t\tinitial={ { scale: 0.1, opacity: 0 } }\n\t\t\t\t\t\t\ttransition={ { delay: 0.3, type: 'tween' } }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tAa\n\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t\t<VStack spacing={ 4 * ratio }>\n\t\t\t\t\t\t\t{ highlightedColors.map(\n\t\t\t\t\t\t\t\t( { slug, color }, index ) => (\n\t\t\t\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\theight:\n\t\t\t\t\t\t\t\t\t\t\t\tnormalizedColorSwatchSize *\n\t\t\t\t\t\t\t\t\t\t\t\tratio,\n\t\t\t\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\t\t\t\tnormalizedColorSwatchSize *\n\t\t\t\t\t\t\t\t\t\t\t\tratio,\n\t\t\t\t\t\t\t\t\t\t\tbackground: color,\n\t\t\t\t\t\t\t\t\t\t\tborderRadius:\n\t\t\t\t\t\t\t\t\t\t\t\t( normalizedColorSwatchSize *\n\t\t\t\t\t\t\t\t\t\t\t\t\tratio ) /\n\t\t\t\t\t\t\t\t\t\t\t\t2,\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tanimate={ { scale: 1, opacity: 1 } }\n\t\t\t\t\t\t\t\t\t\tinitial={ { scale: 0.1, opacity: 0 } }\n\t\t\t\t\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\t\t\t\t\tdelay: index === 1 ? 0.2 : 0.1,\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</HStack>\n\t\t\t\t</motion.div>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ withHoverView && midFrame }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t\ttop: 0,\n\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\tfilter: 'blur(60px)',\n\t\t\t\t\t\topacity: 0.1,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tspacing={ 0 }\n\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ paletteColors\n\t\t\t\t\t\t\t.slice( 0, 4 )\n\t\t\t\t\t\t\t.map( ( { color }, index ) => (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\t\t\t\tbackground: color,\n\t\t\t\t\t\t\t\t\t\tflexGrow: 1,\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t</HStack>\n\t\t\t\t</motion.div>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ secondFrame }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t\ttop: 0,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<VStack\n\t\t\t\t\t\tspacing={ 3 * ratio }\n\t\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\tpadding: 10 * ratio,\n\t\t\t\t\t\t\tboxSizing: 'border-box',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tfontSize: 40 * ratio,\n\t\t\t\t\t\t\t\t\tfontFamily: headingFontFamily,\n\t\t\t\t\t\t\t\t\tcolor: headingColor,\n\t\t\t\t\t\t\t\t\tfontWeight: headingFontWeight,\n\t\t\t\t\t\t\t\t\tlineHeight: '1em',\n\t\t\t\t\t\t\t\t\ttextAlign: 'center',\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</VStack>\n\t\t\t\t</motion.div>\n\t\t\t</motion.div>\n\t\t</Iframe>\n\t);\n};\n\nexport default StylesPreview;\n"]}
|
|
@@ -10,11 +10,12 @@ import classnames from 'classnames';
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { store as coreStore } from '@wordpress/core-data';
|
|
13
|
-
import { useSelect } from '@wordpress/data';
|
|
14
|
-
import { useMemo, useContext, useState } from '@wordpress/element';
|
|
13
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
14
|
+
import { useMemo, useContext, useState, useEffect, useRef } from '@wordpress/element';
|
|
15
15
|
import { ENTER } from '@wordpress/keycodes';
|
|
16
16
|
import { __experimentalGrid as Grid, Card, CardBody } from '@wordpress/components';
|
|
17
17
|
import { __ } from '@wordpress/i18n';
|
|
18
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
18
19
|
/**
|
|
19
20
|
* Internal dependencies
|
|
20
21
|
*/
|
|
@@ -89,16 +90,19 @@ function Variation(_ref) {
|
|
|
89
90
|
className: "edit-site-global-styles-variations_item-preview"
|
|
90
91
|
}, createElement(StylesPreview, {
|
|
91
92
|
label: variation === null || variation === void 0 ? void 0 : variation.title,
|
|
92
|
-
isFocused: isFocused
|
|
93
|
+
isFocused: isFocused,
|
|
94
|
+
withHoverView: true
|
|
93
95
|
}))));
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
function ScreenStyleVariations() {
|
|
97
99
|
const {
|
|
98
|
-
variations
|
|
100
|
+
variations,
|
|
101
|
+
mode
|
|
99
102
|
} = useSelect(select => {
|
|
100
103
|
return {
|
|
101
|
-
variations: select(coreStore).__experimentalGetCurrentThemeGlobalStylesVariations()
|
|
104
|
+
variations: select(coreStore).__experimentalGetCurrentThemeGlobalStylesVariations(),
|
|
105
|
+
mode: select(blockEditorStore).__unstableGetEditorMode()
|
|
102
106
|
};
|
|
103
107
|
}, []);
|
|
104
108
|
const withEmptyVariation = useMemo(() => {
|
|
@@ -115,10 +119,36 @@ function ScreenStyleVariations() {
|
|
|
115
119
|
};
|
|
116
120
|
})];
|
|
117
121
|
}, [variations]);
|
|
122
|
+
const {
|
|
123
|
+
__unstableSetEditorMode
|
|
124
|
+
} = useDispatch(blockEditorStore);
|
|
125
|
+
const shouldRevertInitialMode = useRef(null);
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
// ignore changes to zoom-out mode as we explictily change to it on mount.
|
|
128
|
+
if (mode !== 'zoom-out') {
|
|
129
|
+
shouldRevertInitialMode.current = false;
|
|
130
|
+
}
|
|
131
|
+
}, [mode]); // Intentionality left without any dependency.
|
|
132
|
+
// This effect should only run the first time the component is rendered.
|
|
133
|
+
// The effect opens the zoom-out view if it is not open before when applying a style variation.
|
|
134
|
+
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (mode !== 'zoom-out') {
|
|
137
|
+
__unstableSetEditorMode('zoom-out');
|
|
138
|
+
|
|
139
|
+
shouldRevertInitialMode.current = true;
|
|
140
|
+
return () => {
|
|
141
|
+
// if there were not mode changes revert to the initial mode when unmounting.
|
|
142
|
+
if (shouldRevertInitialMode.current) {
|
|
143
|
+
__unstableSetEditorMode(mode);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}, []);
|
|
118
148
|
return createElement(Fragment, null, createElement(ScreenHeader, {
|
|
119
149
|
back: "/",
|
|
120
150
|
title: __('Browse styles'),
|
|
121
|
-
description: __('Choose a
|
|
151
|
+
description: __('Choose a variation to change the look of the site.')
|
|
122
152
|
}), createElement(Card, {
|
|
123
153
|
size: "small",
|
|
124
154
|
isBorderless: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/screen-style-variations.js"],"names":["isEqual","classnames","store","coreStore","useSelect","useMemo","useContext","useState","ENTER","__experimentalGrid","Grid","Card","CardBody","__","mergeBaseAndUserConfigs","GlobalStylesContext","StylesPreview","ScreenHeader","compareVariations","a","b","styles","settings","Variation","variation","isFocused","setIsFocused","base","user","setUserConfig","context","merged","selectVariation","selectOnEnter","event","keyCode","preventDefault","isActive","title","ScreenStyleVariations","variations","select","__experimentalGetCurrentThemeGlobalStylesVariations","withEmptyVariation","map","index"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/screen-style-variations.js"],"names":["isEqual","classnames","store","coreStore","useSelect","useDispatch","useMemo","useContext","useState","useEffect","useRef","ENTER","__experimentalGrid","Grid","Card","CardBody","__","blockEditorStore","mergeBaseAndUserConfigs","GlobalStylesContext","StylesPreview","ScreenHeader","compareVariations","a","b","styles","settings","Variation","variation","isFocused","setIsFocused","base","user","setUserConfig","context","merged","selectVariation","selectOnEnter","event","keyCode","preventDefault","isActive","title","ScreenStyleVariations","variations","mode","select","__experimentalGetCurrentThemeGlobalStylesVariations","__unstableGetEditorMode","withEmptyVariation","map","__unstableSetEditorMode","shouldRevertInitialMode","current","index"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,OADD,EAECC,UAFD,EAGCC,QAHD,EAICC,SAJD,EAKCC,MALD,QAMO,oBANP;AAOA,SAASC,KAAT,QAAsB,qBAAtB;AACA,SACCC,kBAAkB,IAAIC,IADvB,EAECC,IAFD,EAGCC,QAHD,QAIO,uBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASd,KAAK,IAAIe,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,SAASC,uBAAT,QAAwC,0BAAxC;AACA,SAASC,mBAAT,QAAoC,WAApC;AACA,OAAOC,aAAP,MAA0B,WAA1B;AACA,OAAOC,YAAP,MAAyB,UAAzB;;AAEA,SAASC,iBAAT,CAA4BC,CAA5B,EAA+BC,CAA/B,EAAmC;AAClC,SAAOxB,OAAO,CAAEuB,CAAC,CAACE,MAAJ,EAAYD,CAAC,CAACC,MAAd,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,IAAA,OAAO,EAAG;AAAhB,KACGiC,kBADH,aACGA,kBADH,uBACGA,kBAAkB,CAAEC,GAApB,CAAyB,CAAEtB,SAAF,EAAa0B,KAAb,KAC1B,cAAC,SAAD;AAAW,IAAA,GAAG,EAAGA,KAAjB;AAAyB,IAAA,SAAS,EAAG1B;AAArC,IADC,CADH,CADD,CADD,CATD,CADD;AAqBA;;AAED,eAAee,qBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseMemo,\n\tuseContext,\n\tuseState,\n\tuseEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { ENTER } from '@wordpress/keycodes';\nimport {\n\t__experimentalGrid as Grid,\n\tCard,\n\tCardBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { mergeBaseAndUserConfigs } from './global-styles-provider';\nimport { GlobalStylesContext } from './context';\nimport StylesPreview from './preview';\nimport ScreenHeader from './header';\n\nfunction compareVariations( a, b ) {\n\treturn isEqual( a.styles, b.styles ) && isEqual( a.settings, b.settings );\n}\n\nfunction Variation( { variation } ) {\n\tconst [ isFocused, setIsFocused ] = useState( false );\n\tconst { base, user, setUserConfig } = useContext( GlobalStylesContext );\n\tconst context = useMemo( () => {\n\t\treturn {\n\t\t\tuser: {\n\t\t\t\tsettings: variation.settings ?? {},\n\t\t\t\tstyles: variation.styles ?? {},\n\t\t\t},\n\t\t\tbase,\n\t\t\tmerged: mergeBaseAndUserConfigs( base, variation ),\n\t\t\tsetUserConfig: () => {},\n\t\t};\n\t}, [ variation, base ] );\n\n\tconst selectVariation = () => {\n\t\tsetUserConfig( () => {\n\t\t\treturn {\n\t\t\t\tsettings: variation.settings,\n\t\t\t\tstyles: variation.styles,\n\t\t\t};\n\t\t} );\n\t};\n\n\tconst selectOnEnter = ( event ) => {\n\t\tif ( event.keyCode === ENTER ) {\n\t\t\tevent.preventDefault();\n\t\t\tselectVariation();\n\t\t}\n\t};\n\n\tconst isActive = useMemo( () => {\n\t\treturn compareVariations( user, variation );\n\t}, [ user, variation ] );\n\n\treturn (\n\t\t<GlobalStylesContext.Provider value={ context }>\n\t\t\t<div\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'edit-site-global-styles-variations_item',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-active': isActive,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\trole=\"button\"\n\t\t\t\tonClick={ selectVariation }\n\t\t\t\tonKeyDown={ selectOnEnter }\n\t\t\t\ttabIndex=\"0\"\n\t\t\t\taria-label={ variation?.title }\n\t\t\t\taria-current={ isActive }\n\t\t\t\tonFocus={ () => setIsFocused( true ) }\n\t\t\t\tonBlur={ () => setIsFocused( false ) }\n\t\t\t>\n\t\t\t\t<div className=\"edit-site-global-styles-variations_item-preview\">\n\t\t\t\t\t<StylesPreview\n\t\t\t\t\t\tlabel={ variation?.title }\n\t\t\t\t\t\tisFocused={ isFocused }\n\t\t\t\t\t\twithHoverView\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</GlobalStylesContext.Provider>\n\t);\n}\n\nfunction ScreenStyleVariations() {\n\tconst { variations, mode } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tvariations:\n\t\t\t\tselect(\n\t\t\t\t\tcoreStore\n\t\t\t\t).__experimentalGetCurrentThemeGlobalStylesVariations(),\n\n\t\t\tmode: select( blockEditorStore ).__unstableGetEditorMode(),\n\t\t};\n\t}, [] );\n\n\tconst withEmptyVariation = useMemo( () => {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttitle: __( 'Default' ),\n\t\t\t\tsettings: {},\n\t\t\t\tstyles: {},\n\t\t\t},\n\t\t\t...variations.map( ( variation ) => ( {\n\t\t\t\t...variation,\n\t\t\t\tsettings: variation.settings ?? {},\n\t\t\t\tstyles: variation.styles ?? {},\n\t\t\t} ) ),\n\t\t];\n\t}, [ variations ] );\n\n\tconst { __unstableSetEditorMode } = useDispatch( blockEditorStore );\n\tconst shouldRevertInitialMode = useRef( null );\n\tuseEffect( () => {\n\t\t// ignore changes to zoom-out mode as we explictily change to it on mount.\n\t\tif ( mode !== 'zoom-out' ) {\n\t\t\tshouldRevertInitialMode.current = false;\n\t\t}\n\t}, [ mode ] );\n\n\t// Intentionality left without any dependency.\n\t// This effect should only run the first time the component is rendered.\n\t// The effect opens the zoom-out view if it is not open before when applying a style variation.\n\tuseEffect( () => {\n\t\tif ( mode !== 'zoom-out' ) {\n\t\t\t__unstableSetEditorMode( 'zoom-out' );\n\t\t\tshouldRevertInitialMode.current = true;\n\t\t\treturn () => {\n\t\t\t\t// if there were not mode changes revert to the initial mode when unmounting.\n\t\t\t\tif ( shouldRevertInitialMode.current ) {\n\t\t\t\t\t__unstableSetEditorMode( mode );\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\tback=\"/\"\n\t\t\t\ttitle={ __( 'Browse styles' ) }\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Choose a variation to change the look of the site.'\n\t\t\t\t) }\n\t\t\t/>\n\n\t\t\t<Card size=\"small\" isBorderless>\n\t\t\t\t<CardBody>\n\t\t\t\t\t<Grid columns={ 2 }>\n\t\t\t\t\t\t{ withEmptyVariation?.map( ( variation, index ) => (\n\t\t\t\t\t\t\t<Variation key={ index } variation={ variation } />\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Grid>\n\t\t\t\t</CardBody>\n\t\t\t</Card>\n\t\t</>\n\t);\n}\n\nexport default ScreenStyleVariations;\n"]}
|
|
@@ -4,12 +4,15 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, __experimentalSpacer as Spacer } from '@wordpress/components';
|
|
8
|
+
import { useState } from '@wordpress/element';
|
|
7
9
|
/**
|
|
8
10
|
* Internal dependencies
|
|
9
11
|
*/
|
|
10
12
|
|
|
11
13
|
import TypographyPanel from './typography-panel';
|
|
12
14
|
import ScreenHeader from './header';
|
|
15
|
+
import TypographyPreview from './typography-preview';
|
|
13
16
|
const elements = {
|
|
14
17
|
text: {
|
|
15
18
|
description: __('Manage the fonts used on the site.'),
|
|
@@ -34,12 +37,55 @@ function ScreenTypographyElement(_ref) {
|
|
|
34
37
|
name,
|
|
35
38
|
element
|
|
36
39
|
} = _ref;
|
|
40
|
+
const [headingLevel, setHeadingLevel] = useState('heading');
|
|
37
41
|
return createElement(Fragment, null, createElement(ScreenHeader, {
|
|
38
42
|
title: elements[element].title,
|
|
39
43
|
description: elements[element].description
|
|
40
|
-
}), createElement(
|
|
44
|
+
}), createElement(Spacer, {
|
|
45
|
+
marginX: 4
|
|
46
|
+
}, createElement(TypographyPreview, {
|
|
41
47
|
name: name,
|
|
42
|
-
element: element
|
|
48
|
+
element: element,
|
|
49
|
+
headingLevel: headingLevel
|
|
50
|
+
})), element === 'heading' && createElement(Spacer, {
|
|
51
|
+
marginX: 4,
|
|
52
|
+
marginBottom: "1em"
|
|
53
|
+
}, createElement(ToggleGroupControl, {
|
|
54
|
+
label: __('Select heading level'),
|
|
55
|
+
hideLabelFromVision: true,
|
|
56
|
+
value: headingLevel,
|
|
57
|
+
onChange: setHeadingLevel,
|
|
58
|
+
isBlock: true,
|
|
59
|
+
size: "__unstable-large",
|
|
60
|
+
__nextHasNoMarginBottom: true
|
|
61
|
+
}, createElement(ToggleGroupControlOption, {
|
|
62
|
+
value: "heading"
|
|
63
|
+
/* translators: 'All' refers to selecting all heading levels
|
|
64
|
+
and applying the same style to h1-h6. */
|
|
65
|
+
,
|
|
66
|
+
label: __('All')
|
|
67
|
+
}), createElement(ToggleGroupControlOption, {
|
|
68
|
+
value: "h1",
|
|
69
|
+
label: __('H1')
|
|
70
|
+
}), createElement(ToggleGroupControlOption, {
|
|
71
|
+
value: "h2",
|
|
72
|
+
label: __('H2')
|
|
73
|
+
}), createElement(ToggleGroupControlOption, {
|
|
74
|
+
value: "h3",
|
|
75
|
+
label: __('H3')
|
|
76
|
+
}), createElement(ToggleGroupControlOption, {
|
|
77
|
+
value: "h4",
|
|
78
|
+
label: __('H4')
|
|
79
|
+
}), createElement(ToggleGroupControlOption, {
|
|
80
|
+
value: "h5",
|
|
81
|
+
label: __('H5')
|
|
82
|
+
}), createElement(ToggleGroupControlOption, {
|
|
83
|
+
value: "h6",
|
|
84
|
+
label: __('H6')
|
|
85
|
+
}))), createElement(TypographyPanel, {
|
|
86
|
+
name: name,
|
|
87
|
+
element: element,
|
|
88
|
+
headingLevel: headingLevel
|
|
43
89
|
}));
|
|
44
90
|
}
|
|
45
91
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/screen-typography-element.js"],"names":["__","TypographyPanel","ScreenHeader","elements","text","description","title","link","heading","button","ScreenTypographyElement","name","element"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AACA,OAAOC,YAAP,MAAyB,UAAzB;AAEA,MAAMC,QAAQ,GAAG;AAChBC,EAAAA,IAAI,EAAE;AACLC,IAAAA,WAAW,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/screen-typography-element.js"],"names":["__","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","__experimentalSpacer","Spacer","useState","TypographyPanel","ScreenHeader","TypographyPreview","elements","text","description","title","link","heading","button","ScreenTypographyElement","name","element","headingL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AAE,CAAE,IAAF;AAFX,IAnCD,CADD,CAbF,EAwDC,cAAC,eAAD;AACC,IAAA,IAAI,EAAGmB,IADR;AAEC,IAAA,OAAO,EAAGC,OAFX;AAGC,IAAA,YAAY,EAAGC;AAHhB,IAxDD,CADD;AAgEA;;AAED,eAAeH,uBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalSpacer as Spacer,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TypographyPanel from './typography-panel';\nimport ScreenHeader from './header';\nimport TypographyPreview from './typography-preview';\n\nconst elements = {\n\ttext: {\n\t\tdescription: __( 'Manage the fonts used on the site.' ),\n\t\ttitle: __( 'Text' ),\n\t},\n\tlink: {\n\t\tdescription: __( 'Manage the fonts and typography used on the links.' ),\n\t\ttitle: __( 'Links' ),\n\t},\n\theading: {\n\t\tdescription: __( 'Manage the fonts and typography used on headings.' ),\n\t\ttitle: __( 'Headings' ),\n\t},\n\tbutton: {\n\t\tdescription: __( 'Manage the fonts and typography used on buttons.' ),\n\t\ttitle: __( 'Buttons' ),\n\t},\n};\n\nfunction ScreenTypographyElement( { name, element } ) {\n\tconst [ headingLevel, setHeadingLevel ] = useState( 'heading' );\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={ elements[ element ].title }\n\t\t\t\tdescription={ elements[ element ].description }\n\t\t\t/>\n\t\t\t<Spacer marginX={ 4 }>\n\t\t\t\t<TypographyPreview\n\t\t\t\t\tname={ name }\n\t\t\t\t\telement={ element }\n\t\t\t\t\theadingLevel={ headingLevel }\n\t\t\t\t/>\n\t\t\t</Spacer>\n\t\t\t{ element === 'heading' && (\n\t\t\t\t<Spacer marginX={ 4 } marginBottom=\"1em\">\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\tlabel={ __( 'Select heading level' ) }\n\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\tvalue={ headingLevel }\n\t\t\t\t\t\tonChange={ setHeadingLevel }\n\t\t\t\t\t\tisBlock\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"heading\"\n\t\t\t\t\t\t\t/* translators: 'All' refers to selecting all heading levels \n\t\t\t\t\t\t\tand applying the same style to h1-h6. */\n\t\t\t\t\t\t\tlabel={ __( 'All' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"h1\"\n\t\t\t\t\t\t\tlabel={ __( 'H1' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"h2\"\n\t\t\t\t\t\t\tlabel={ __( 'H2' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"h3\"\n\t\t\t\t\t\t\tlabel={ __( 'H3' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"h4\"\n\t\t\t\t\t\t\tlabel={ __( 'H4' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"h5\"\n\t\t\t\t\t\t\tlabel={ __( 'H5' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"h6\"\n\t\t\t\t\t\t\tlabel={ __( 'H6' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t</Spacer>\n\t\t\t) }\n\t\t\t<TypographyPanel\n\t\t\t\tname={ name }\n\t\t\t\telement={ element }\n\t\t\t\theadingLevel={ headingLevel }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default ScreenTypographyElement;\n"]}
|