@wordpress/edit-site 5.2.0 → 5.3.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 +6 -0
- package/build/components/add-new-template/add-custom-generic-template-modal.js +8 -10
- package/build/components/add-new-template/add-custom-generic-template-modal.js.map +1 -1
- package/build/components/add-new-template/add-custom-template-modal.js +0 -1
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template-part.js +5 -29
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/utils.js +1 -9
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/app/index.js +2 -7
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/index.js +13 -11
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/inserter-media-categories.js +237 -0
- package/build/components/block-editor/inserter-media-categories.js.map +1 -0
- package/build/components/canvas-spinner/index.js +20 -0
- package/build/components/canvas-spinner/index.js.map +1 -0
- package/build/components/create-template-part-modal/index.js +4 -2
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/editor/index.js +4 -2
- package/build/components/editor/index.js.map +1 -1
- package/build/components/error-boundary/index.js +2 -12
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/error-boundary/warning.js +5 -28
- package/build/components/error-boundary/warning.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +2 -2
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +17 -9
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +13 -7
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +39 -4
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/custom-css.js +65 -14
- package/build/components/global-styles/custom-css.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +49 -31
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +13 -3
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +17 -11
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +21 -142
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +0 -28
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/palette.js +11 -4
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/preview.js +18 -15
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +27 -13
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-border.js +10 -4
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/screen-button-color.js +16 -9
- package/build/components/global-styles/screen-button-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +43 -34
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-css.js +20 -8
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +23 -16
- package/build/components/global-styles/screen-heading-color.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +3 -3
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +18 -11
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-root.js +25 -9
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +8 -4
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +14 -7
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +18 -12
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/shadow-panel.js +196 -0
- package/build/components/global-styles/shadow-panel.js.map +1 -0
- package/build/components/global-styles/typography-panel.js +43 -29
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-preview.js +19 -9
- package/build/components/global-styles/typography-preview.js.map +1 -1
- package/build/components/global-styles/ui.js +85 -34
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/utils.js +5 -334
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/global-styles-renderer/index.js +7 -5
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +2 -2
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +0 -1
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/layout/index.js +6 -8
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/actions/rename-menu-item.js +8 -11
- package/build/components/list/actions/rename-menu-item.js.map +1 -1
- package/build/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +1 -2
- package/build/components/navigation-inspector/index.js.map +1 -0
- package/build/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +13 -15
- package/build/components/navigation-inspector/navigation-menu.js.map +1 -0
- package/build/components/sidebar/index.js +3 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js +3 -18
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +1 -14
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +3 -2
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +23 -1
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +35 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-templates/index.js +3 -8
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/site-hub/index.js +2 -2
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/site-icon/index.js +1 -1
- package/build/components/site-icon/index.js.map +1 -1
- package/build/components/style-book/index.js +7 -4
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +5 -9
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/experiments.js +19 -0
- package/build/experiments.js.map +1 -0
- package/build/hooks/push-changes-to-global-styles/index.js +65 -6
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/index.js +53 -60
- package/build/index.js.map +1 -1
- package/build/store/selectors.js +7 -27
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +77 -0
- package/build/store/utils.js.map +1 -0
- package/build/utils/template-part-create.js +71 -0
- package/build/utils/template-part-create.js.map +1 -0
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js +9 -11
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +0 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +4 -27
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +0 -5
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/app/index.js +2 -7
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/index.js +14 -12
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/inserter-media-categories.js +225 -0
- package/build-module/components/block-editor/inserter-media-categories.js.map +1 -0
- package/build-module/components/canvas-spinner/index.js +12 -0
- package/build-module/components/canvas-spinner/index.js.map +1 -0
- package/build-module/components/create-template-part-modal/index.js +5 -3
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/editor/index.js +3 -2
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +2 -12
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/error-boundary/warning.js +5 -28
- package/build-module/components/error-boundary/warning.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +2 -2
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +17 -11
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +11 -7
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +40 -8
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/custom-css.js +61 -15
- package/build-module/components/global-styles/custom-css.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +49 -32
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +7 -2
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +15 -11
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +23 -134
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +0 -2
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/palette.js +10 -5
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/preview.js +18 -14
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +26 -15
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +10 -5
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/screen-button-color.js +16 -11
- package/build-module/components/global-styles/screen-button-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +43 -37
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +21 -9
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +23 -18
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +4 -4
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +18 -13
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +23 -9
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +5 -2
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +14 -9
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +16 -12
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel.js +177 -0
- package/build-module/components/global-styles/shadow-panel.js.map +1 -0
- package/build-module/components/global-styles/typography-panel.js +43 -31
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-preview.js +17 -9
- package/build-module/components/global-styles/typography-preview.js.map +1 -1
- package/build-module/components/global-styles/ui.js +80 -35
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/utils.js +4 -319
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/global-styles-renderer/index.js +5 -5
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +2 -2
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +0 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/layout/index.js +6 -8
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/actions/rename-menu-item.js +9 -12
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
- package/build-module/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +1 -2
- package/build-module/components/navigation-inspector/index.js.map +1 -0
- package/build-module/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +13 -16
- package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -0
- package/build-module/components/sidebar/index.js +2 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +6 -21
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +1 -13
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +3 -2
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +22 -2
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +23 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-templates/index.js +4 -9
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +2 -2
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/site-icon/index.js +1 -1
- package/build-module/components/site-icon/index.js.map +1 -1
- package/build-module/components/style-book/index.js +8 -5
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +5 -9
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/experiments.js +9 -0
- package/build-module/experiments.js.map +1 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js +62 -3
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/index.js +52 -60
- package/build-module/index.js.map +1 -1
- package/build-module/store/selectors.js +6 -26
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +66 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-module/utils/template-part-create.js +53 -0
- package/build-module/utils/template-part-create.js.map +1 -0
- package/build-style/style-rtl.css +314 -216
- package/build-style/style.css +314 -216
- package/package.json +32 -30
- package/src/components/add-new-template/add-custom-generic-template-modal.js +20 -28
- package/src/components/add-new-template/add-custom-template-modal.js +0 -1
- package/src/components/add-new-template/new-template-part.js +11 -32
- package/src/components/add-new-template/style.scss +0 -4
- package/src/components/add-new-template/utils.js +0 -14
- package/src/components/app/index.js +2 -2
- package/src/components/block-editor/index.js +12 -25
- package/src/components/block-editor/inserter-media-categories.js +247 -0
- package/src/components/block-editor/style.scss +19 -7
- package/src/components/canvas-spinner/index.js +12 -0
- package/src/components/canvas-spinner/style.scss +7 -0
- package/src/components/create-template-part-modal/index.js +75 -67
- package/src/components/create-template-part-modal/style.scss +0 -10
- package/src/components/editor/index.js +4 -2
- package/src/components/error-boundary/index.js +2 -10
- package/src/components/error-boundary/warning.js +6 -35
- package/src/components/global-styles/README.md +1 -75
- package/src/components/global-styles/block-preview-panel.js +2 -2
- package/src/components/global-styles/border-panel.js +19 -17
- package/src/components/global-styles/color-palette-panel.js +10 -7
- package/src/components/global-styles/context-menu.js +114 -44
- package/src/components/global-styles/custom-css.js +76 -19
- package/src/components/global-styles/dimensions-panel.js +46 -36
- package/src/components/global-styles/global-styles-provider.js +6 -2
- package/src/components/global-styles/gradients-palette-panel.js +17 -11
- package/src/components/global-styles/hooks.js +31 -155
- package/src/components/global-styles/index.js +0 -2
- package/src/components/global-styles/palette.js +9 -5
- package/src/components/global-styles/preview.js +19 -13
- package/src/components/global-styles/screen-background-color.js +37 -21
- package/src/components/global-styles/screen-border.js +10 -5
- package/src/components/global-styles/screen-button-color.js +21 -19
- package/src/components/global-styles/screen-colors.js +48 -65
- package/src/components/global-styles/screen-css.js +30 -14
- package/src/components/global-styles/screen-heading-color.js +32 -27
- package/src/components/global-styles/screen-layout.js +4 -7
- package/src/components/global-styles/screen-link-color.js +26 -26
- package/src/components/global-styles/screen-root.js +24 -9
- package/src/components/global-styles/screen-style-variations.js +7 -2
- package/src/components/global-styles/screen-text-color.js +15 -19
- package/src/components/global-styles/screen-typography.js +27 -12
- package/src/components/global-styles/shadow-panel.js +174 -0
- package/src/components/global-styles/style.scss +85 -1
- package/src/components/global-styles/typography-panel.js +60 -48
- package/src/components/global-styles/typography-preview.js +28 -9
- package/src/components/global-styles/ui.js +78 -53
- package/src/components/global-styles/utils.js +4 -371
- package/src/components/global-styles-renderer/index.js +3 -4
- package/src/components/header-edit-mode/document-actions/index.js +1 -1
- package/src/components/keyboard-shortcut-help-modal/index.js +0 -1
- package/src/components/layout/index.js +9 -2
- package/src/components/layout/style.scss +4 -5
- package/src/components/list/actions/rename-menu-item.js +14 -23
- package/src/components/list/style.scss +0 -4
- package/src/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +1 -4
- package/src/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +10 -12
- package/src/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/style.scss +0 -17
- package/src/components/sidebar/index.js +2 -0
- package/src/components/sidebar-edit-mode/global-styles-sidebar.js +8 -32
- package/src/components/sidebar-edit-mode/index.js +0 -11
- package/src/components/sidebar-edit-mode/settings-header/style.scss +8 -0
- package/src/components/sidebar-navigation-item/style.scss +28 -3
- package/src/components/sidebar-navigation-screen/index.js +4 -3
- package/src/components/sidebar-navigation-screen/style.scss +2 -0
- package/src/components/sidebar-navigation-screen-main/index.js +23 -1
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +25 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +12 -0
- package/src/components/sidebar-navigation-screen-templates/index.js +12 -19
- package/src/components/site-hub/index.js +1 -1
- package/src/components/site-hub/style.scss +7 -1
- package/src/components/site-icon/index.js +1 -1
- package/src/components/site-icon/style.scss +2 -2
- package/src/components/style-book/index.js +10 -5
- package/src/components/template-part-converter/convert-to-template-part.js +12 -10
- package/src/experiments.js +10 -0
- package/src/hooks/push-changes-to-global-styles/index.js +63 -5
- package/src/index.js +51 -59
- package/src/store/selectors.js +6 -26
- package/src/store/test/utils.js +181 -0
- package/src/store/utils.js +69 -0
- package/src/style.scss +4 -2
- package/src/utils/template-part-create.js +62 -0
- package/src/utils/test/template-part-create.js +63 -0
- package/build/components/global-styles/context.js +0 -22
- package/build/components/global-styles/context.js.map +0 -1
- package/build/components/global-styles/typography-utils.js +0 -92
- package/build/components/global-styles/typography-utils.js.map +0 -1
- package/build/components/global-styles/use-global-styles-output.js +0 -943
- package/build/components/global-styles/use-global-styles-output.js.map +0 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -42
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +0 -1
- package/build-module/components/global-styles/context.js +0 -12
- package/build-module/components/global-styles/context.js.map +0 -1
- package/build-module/components/global-styles/typography-utils.js +0 -84
- package/build-module/components/global-styles/typography-utils.js.map +0 -1
- package/build-module/components/global-styles/use-global-styles-output.js +0 -901
- package/build-module/components/global-styles/use-global-styles-output.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -28
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +0 -1
- package/src/components/global-styles/context.js +0 -15
- package/src/components/global-styles/test/typography-utils.js +0 -393
- package/src/components/global-styles/test/use-global-styles-output.js +0 -814
- package/src/components/global-styles/test/utils.js +0 -206
- package/src/components/global-styles/typography-utils.js +0 -87
- package/src/components/global-styles/use-global-styles-output.js +0 -1059
- package/src/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -37
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Internal dependencies
|
|
3
8
|
*/
|
|
4
|
-
import {
|
|
9
|
+
import { unlock } from '../../experiments';
|
|
10
|
+
|
|
11
|
+
const { useGlobalStyle } = unlock( blockEditorExperiments );
|
|
5
12
|
|
|
6
13
|
export default function TypographyPreview( { name, element, headingLevel } ) {
|
|
7
14
|
let prefix = '';
|
|
@@ -11,14 +18,26 @@ export default function TypographyPreview( { name, element, headingLevel } ) {
|
|
|
11
18
|
prefix = `elements.${ element }.`;
|
|
12
19
|
}
|
|
13
20
|
|
|
14
|
-
const [ fontFamily ] =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const [
|
|
19
|
-
const [
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
const [ fontFamily ] = useGlobalStyle(
|
|
22
|
+
prefix + 'typography.fontFamily',
|
|
23
|
+
name
|
|
24
|
+
);
|
|
25
|
+
const [ gradientValue ] = useGlobalStyle( prefix + 'color.gradient', name );
|
|
26
|
+
const [ backgroundColor ] = useGlobalStyle(
|
|
27
|
+
prefix + 'color.background',
|
|
28
|
+
name
|
|
29
|
+
);
|
|
30
|
+
const [ color ] = useGlobalStyle( prefix + 'color.text', name );
|
|
31
|
+
const [ fontSize ] = useGlobalStyle( prefix + 'typography.fontSize', name );
|
|
32
|
+
const [ fontStyle ] = useGlobalStyle(
|
|
33
|
+
prefix + 'typography.fontStyle',
|
|
34
|
+
name
|
|
35
|
+
);
|
|
36
|
+
const [ fontWeight ] = useGlobalStyle(
|
|
37
|
+
prefix + 'typography.fontWeight',
|
|
38
|
+
name
|
|
39
|
+
);
|
|
40
|
+
const [ letterSpacing ] = useGlobalStyle(
|
|
22
41
|
prefix + 'typography.letterSpacing',
|
|
23
42
|
name
|
|
24
43
|
);
|
|
@@ -5,10 +5,15 @@ import {
|
|
|
5
5
|
__experimentalNavigatorProvider as NavigatorProvider,
|
|
6
6
|
__experimentalNavigatorScreen as NavigatorScreen,
|
|
7
7
|
__experimentalUseNavigator as useNavigator,
|
|
8
|
+
createSlotFill,
|
|
9
|
+
DropdownMenu,
|
|
8
10
|
} from '@wordpress/components';
|
|
9
11
|
import { getBlockTypes, store as blocksStore } from '@wordpress/blocks';
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
13
|
+
import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
|
|
14
|
+
import { __ } from '@wordpress/i18n';
|
|
15
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
16
|
+
import { moreVertical } from '@wordpress/icons';
|
|
12
17
|
|
|
13
18
|
/**
|
|
14
19
|
* Internal dependencies
|
|
@@ -31,6 +36,43 @@ import { ScreenVariation } from './screen-variations';
|
|
|
31
36
|
import ScreenBorder from './screen-border';
|
|
32
37
|
import StyleBook from '../style-book';
|
|
33
38
|
import ScreenCSS from './screen-css';
|
|
39
|
+
import { unlock } from '../../experiments';
|
|
40
|
+
|
|
41
|
+
const SLOT_FILL_NAME = 'GlobalStylesMenu';
|
|
42
|
+
const { Slot: GlobalStylesMenuSlot, Fill: GlobalStylesMenuFill } =
|
|
43
|
+
createSlotFill( SLOT_FILL_NAME );
|
|
44
|
+
|
|
45
|
+
function GlobalStylesActionMenu() {
|
|
46
|
+
const { toggle } = useDispatch( preferencesStore );
|
|
47
|
+
const { useGlobalStylesReset } = unlock( blockEditorExperiments );
|
|
48
|
+
const [ canReset, onReset ] = useGlobalStylesReset();
|
|
49
|
+
const { goTo } = useNavigator();
|
|
50
|
+
const loadCustomCSS = () => goTo( '/css' );
|
|
51
|
+
return (
|
|
52
|
+
<GlobalStylesMenuFill>
|
|
53
|
+
<DropdownMenu
|
|
54
|
+
icon={ moreVertical }
|
|
55
|
+
label={ __( 'More Styles actions' ) }
|
|
56
|
+
controls={ [
|
|
57
|
+
{
|
|
58
|
+
title: __( 'Reset to defaults' ),
|
|
59
|
+
onClick: onReset,
|
|
60
|
+
isDisabled: ! canReset,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
title: __( 'Welcome Guide' ),
|
|
64
|
+
onClick: () =>
|
|
65
|
+
toggle( 'core/edit-site', 'welcomeGuideStyles' ),
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
title: __( 'Additional CSS' ),
|
|
69
|
+
onClick: loadCustomCSS,
|
|
70
|
+
},
|
|
71
|
+
] }
|
|
72
|
+
/>
|
|
73
|
+
</GlobalStylesMenuFill>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
34
76
|
|
|
35
77
|
function GlobalStylesNavigationScreen( { className, ...props } ) {
|
|
36
78
|
return (
|
|
@@ -68,19 +110,27 @@ function BlockStyleVariationsScreens( { name } ) {
|
|
|
68
110
|
'/variations/' +
|
|
69
111
|
encodeURIComponent( variation.name )
|
|
70
112
|
}
|
|
113
|
+
variation={ variation.name }
|
|
71
114
|
/>
|
|
72
115
|
) );
|
|
73
116
|
}
|
|
74
117
|
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
118
|
+
function BlockStylesNavigationScreens( {
|
|
119
|
+
parentMenu,
|
|
120
|
+
blockStyles,
|
|
121
|
+
blockName,
|
|
122
|
+
} ) {
|
|
123
|
+
return blockStyles.map( ( style, index ) => (
|
|
124
|
+
<GlobalStylesNavigationScreen
|
|
125
|
+
key={ index }
|
|
126
|
+
path={ parentMenu + '/variations/' + style.name }
|
|
127
|
+
>
|
|
128
|
+
<ScreenVariation blockName={ blockName } style={ style } />
|
|
129
|
+
</GlobalStylesNavigationScreen>
|
|
130
|
+
) );
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function ContextScreens( { name, parentMenu = '', variation = '' } ) {
|
|
84
134
|
const blockStyleVariations = useSelect(
|
|
85
135
|
( select ) => {
|
|
86
136
|
const { getBlockStyles } = select( blocksStore );
|
|
@@ -89,24 +139,10 @@ function ContextScreens( { name, parentMenu = '' } ) {
|
|
|
89
139
|
[ name ]
|
|
90
140
|
);
|
|
91
141
|
|
|
92
|
-
const BlockStylesNavigationScreens = ( { blockStyles, blockName } ) => {
|
|
93
|
-
return blockStyles.map( ( style, index ) => (
|
|
94
|
-
<GlobalStylesNavigationScreen
|
|
95
|
-
key={ index }
|
|
96
|
-
path={ parentMenu + '/variations/' + style.name }
|
|
97
|
-
>
|
|
98
|
-
<ScreenVariation blockName={ blockName } style={ style } />
|
|
99
|
-
</GlobalStylesNavigationScreen>
|
|
100
|
-
) );
|
|
101
|
-
};
|
|
102
|
-
|
|
103
142
|
return (
|
|
104
143
|
<>
|
|
105
144
|
<GlobalStylesNavigationScreen path={ parentMenu + '/typography' }>
|
|
106
|
-
<ScreenTypography
|
|
107
|
-
name={ name }
|
|
108
|
-
variationPath={ variationPath }
|
|
109
|
-
/>
|
|
145
|
+
<ScreenTypography name={ name } variation={ variation } />
|
|
110
146
|
</GlobalStylesNavigationScreen>
|
|
111
147
|
|
|
112
148
|
<GlobalStylesNavigationScreen
|
|
@@ -134,7 +170,7 @@ function ContextScreens( { name, parentMenu = '' } ) {
|
|
|
134
170
|
</GlobalStylesNavigationScreen>
|
|
135
171
|
|
|
136
172
|
<GlobalStylesNavigationScreen path={ parentMenu + '/colors' }>
|
|
137
|
-
<ScreenColors name={ name }
|
|
173
|
+
<ScreenColors name={ name } variation={ variation } />
|
|
138
174
|
</GlobalStylesNavigationScreen>
|
|
139
175
|
|
|
140
176
|
<GlobalStylesNavigationScreen
|
|
@@ -146,54 +182,44 @@ function ContextScreens( { name, parentMenu = '' } ) {
|
|
|
146
182
|
<GlobalStylesNavigationScreen
|
|
147
183
|
path={ parentMenu + '/colors/background' }
|
|
148
184
|
>
|
|
149
|
-
<ScreenBackgroundColor
|
|
150
|
-
name={ name }
|
|
151
|
-
variationPath={ variationPath }
|
|
152
|
-
/>
|
|
185
|
+
<ScreenBackgroundColor name={ name } variation={ variation } />
|
|
153
186
|
</GlobalStylesNavigationScreen>
|
|
154
187
|
|
|
155
188
|
<GlobalStylesNavigationScreen path={ parentMenu + '/colors/text' }>
|
|
156
|
-
<ScreenTextColor
|
|
157
|
-
name={ name }
|
|
158
|
-
variationPath={ variationPath }
|
|
159
|
-
/>
|
|
189
|
+
<ScreenTextColor name={ name } variation={ variation } />
|
|
160
190
|
</GlobalStylesNavigationScreen>
|
|
161
191
|
|
|
162
192
|
<GlobalStylesNavigationScreen path={ parentMenu + '/colors/link' }>
|
|
163
|
-
<ScreenLinkColor
|
|
164
|
-
name={ name }
|
|
165
|
-
variationPath={ variationPath }
|
|
166
|
-
/>
|
|
193
|
+
<ScreenLinkColor name={ name } variation={ variation } />
|
|
167
194
|
</GlobalStylesNavigationScreen>
|
|
168
195
|
|
|
169
196
|
<GlobalStylesNavigationScreen
|
|
170
197
|
path={ parentMenu + '/colors/heading' }
|
|
171
198
|
>
|
|
172
|
-
<ScreenHeadingColor
|
|
173
|
-
name={ name }
|
|
174
|
-
variationPath={ variationPath }
|
|
175
|
-
/>
|
|
199
|
+
<ScreenHeadingColor name={ name } variation={ variation } />
|
|
176
200
|
</GlobalStylesNavigationScreen>
|
|
177
201
|
|
|
178
202
|
<GlobalStylesNavigationScreen
|
|
179
203
|
path={ parentMenu + '/colors/button' }
|
|
180
204
|
>
|
|
181
|
-
<ScreenButtonColor
|
|
182
|
-
name={ name }
|
|
183
|
-
variationPath={ variationPath }
|
|
184
|
-
/>
|
|
205
|
+
<ScreenButtonColor name={ name } variation={ variation } />
|
|
185
206
|
</GlobalStylesNavigationScreen>
|
|
186
207
|
|
|
187
208
|
<GlobalStylesNavigationScreen path={ parentMenu + '/border' }>
|
|
188
|
-
<ScreenBorder name={ name }
|
|
209
|
+
<ScreenBorder name={ name } variation={ variation } />
|
|
189
210
|
</GlobalStylesNavigationScreen>
|
|
190
211
|
|
|
191
212
|
<GlobalStylesNavigationScreen path={ parentMenu + '/layout' }>
|
|
192
|
-
<ScreenLayout name={ name }
|
|
213
|
+
<ScreenLayout name={ name } variation={ variation } />
|
|
214
|
+
</GlobalStylesNavigationScreen>
|
|
215
|
+
|
|
216
|
+
<GlobalStylesNavigationScreen path={ parentMenu + '/css' }>
|
|
217
|
+
<ScreenCSS name={ name } />
|
|
193
218
|
</GlobalStylesNavigationScreen>
|
|
194
219
|
|
|
195
220
|
{ !! blockStyleVariations?.length && (
|
|
196
221
|
<BlockStylesNavigationScreens
|
|
222
|
+
parentMenu={ parentMenu }
|
|
197
223
|
blockStyles={ blockStyleVariations }
|
|
198
224
|
blockName={ name }
|
|
199
225
|
/>
|
|
@@ -280,11 +306,10 @@ function GlobalStylesUI( { isStyleBookOpened, onCloseStyleBook } ) {
|
|
|
280
306
|
{ isStyleBookOpened && (
|
|
281
307
|
<GlobalStylesStyleBook onClose={ onCloseStyleBook } />
|
|
282
308
|
) }
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
</GlobalStylesNavigationScreen>
|
|
309
|
+
|
|
310
|
+
<GlobalStylesActionMenu />
|
|
286
311
|
</NavigatorProvider>
|
|
287
312
|
);
|
|
288
313
|
}
|
|
289
|
-
|
|
314
|
+
export { GlobalStylesMenuSlot };
|
|
290
315
|
export default GlobalStylesUI;
|
|
@@ -1,379 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { get } from 'lodash';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { getTypographyFontSizeValue } from './typography-utils';
|
|
10
|
-
|
|
11
|
-
/* Supporting data. */
|
|
12
|
-
export const ROOT_BLOCK_NAME = 'root';
|
|
13
|
-
export const ROOT_BLOCK_SELECTOR = 'body';
|
|
14
|
-
export const ROOT_BLOCK_SUPPORTS = [
|
|
15
|
-
'background',
|
|
16
|
-
'backgroundColor',
|
|
17
|
-
'color',
|
|
18
|
-
'linkColor',
|
|
19
|
-
'buttonColor',
|
|
20
|
-
'fontFamily',
|
|
21
|
-
'fontSize',
|
|
22
|
-
'fontStyle',
|
|
23
|
-
'fontWeight',
|
|
24
|
-
'lineHeight',
|
|
25
|
-
'textDecoration',
|
|
26
|
-
'textTransform',
|
|
27
|
-
'padding',
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
export const PRESET_METADATA = [
|
|
31
|
-
{
|
|
32
|
-
path: [ 'color', 'palette' ],
|
|
33
|
-
valueKey: 'color',
|
|
34
|
-
cssVarInfix: 'color',
|
|
35
|
-
classes: [
|
|
36
|
-
{ classSuffix: 'color', propertyName: 'color' },
|
|
37
|
-
{
|
|
38
|
-
classSuffix: 'background-color',
|
|
39
|
-
propertyName: 'background-color',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
classSuffix: 'border-color',
|
|
43
|
-
propertyName: 'border-color',
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
path: [ 'color', 'gradients' ],
|
|
49
|
-
valueKey: 'gradient',
|
|
50
|
-
cssVarInfix: 'gradient',
|
|
51
|
-
classes: [
|
|
52
|
-
{
|
|
53
|
-
classSuffix: 'gradient-background',
|
|
54
|
-
propertyName: 'background',
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
path: [ 'color', 'duotone' ],
|
|
60
|
-
cssVarInfix: 'duotone',
|
|
61
|
-
valueFunc: ( { slug } ) => `url( '#wp-duotone-${ slug }' )`,
|
|
62
|
-
classes: [],
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
path: [ 'typography', 'fontSizes' ],
|
|
66
|
-
valueFunc: ( preset, { typography: typographySettings } ) =>
|
|
67
|
-
getTypographyFontSizeValue( preset, typographySettings ),
|
|
68
|
-
valueKey: 'size',
|
|
69
|
-
cssVarInfix: 'font-size',
|
|
70
|
-
classes: [ { classSuffix: 'font-size', propertyName: 'font-size' } ],
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
path: [ 'typography', 'fontFamilies' ],
|
|
74
|
-
valueKey: 'fontFamily',
|
|
75
|
-
cssVarInfix: 'font-family',
|
|
76
|
-
classes: [
|
|
77
|
-
{ classSuffix: 'font-family', propertyName: 'font-family' },
|
|
78
|
-
],
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
path: [ 'spacing', 'spacingSizes' ],
|
|
82
|
-
valueKey: 'size',
|
|
83
|
-
cssVarInfix: 'spacing',
|
|
84
|
-
valueFunc: ( { size } ) => size,
|
|
85
|
-
classes: [],
|
|
86
|
-
},
|
|
87
|
-
];
|
|
88
|
-
|
|
89
|
-
export const STYLE_PATH_TO_CSS_VAR_INFIX = {
|
|
90
|
-
'color.background': 'color',
|
|
91
|
-
'color.text': 'color',
|
|
92
|
-
'elements.link.color.text': 'color',
|
|
93
|
-
'elements.link.:hover.color.text': 'color',
|
|
94
|
-
'elements.link.typography.fontFamily': 'font-family',
|
|
95
|
-
'elements.link.typography.fontSize': 'font-size',
|
|
96
|
-
'elements.button.color.text': 'color',
|
|
97
|
-
'elements.button.color.background': 'color',
|
|
98
|
-
'elements.button.typography.fontFamily': 'font-family',
|
|
99
|
-
'elements.button.typography.fontSize': 'font-size',
|
|
100
|
-
'elements.heading.color': 'color',
|
|
101
|
-
'elements.heading.color.background': 'color',
|
|
102
|
-
'elements.heading.typography.fontFamily': 'font-family',
|
|
103
|
-
'elements.heading.gradient': 'gradient',
|
|
104
|
-
'elements.heading.color.gradient': 'gradient',
|
|
105
|
-
'elements.h1.color': 'color',
|
|
106
|
-
'elements.h1.color.background': 'color',
|
|
107
|
-
'elements.h1.typography.fontFamily': 'font-family',
|
|
108
|
-
'elements.h1.color.gradient': 'gradient',
|
|
109
|
-
'elements.h2.color': 'color',
|
|
110
|
-
'elements.h2.color.background': 'color',
|
|
111
|
-
'elements.h2.typography.fontFamily': 'font-family',
|
|
112
|
-
'elements.h2.color.gradient': 'gradient',
|
|
113
|
-
'elements.h3.color': 'color',
|
|
114
|
-
'elements.h3.color.background': 'color',
|
|
115
|
-
'elements.h3.typography.fontFamily': 'font-family',
|
|
116
|
-
'elements.h3.color.gradient': 'gradient',
|
|
117
|
-
'elements.h4.color': 'color',
|
|
118
|
-
'elements.h4.color.background': 'color',
|
|
119
|
-
'elements.h4.typography.fontFamily': 'font-family',
|
|
120
|
-
'elements.h4.color.gradient': 'gradient',
|
|
121
|
-
'elements.h5.color': 'color',
|
|
122
|
-
'elements.h5.color.background': 'color',
|
|
123
|
-
'elements.h5.typography.fontFamily': 'font-family',
|
|
124
|
-
'elements.h5.color.gradient': 'gradient',
|
|
125
|
-
'elements.h6.color': 'color',
|
|
126
|
-
'elements.h6.color.background': 'color',
|
|
127
|
-
'elements.h6.typography.fontFamily': 'font-family',
|
|
128
|
-
'elements.h6.color.gradient': 'gradient',
|
|
129
|
-
'color.gradient': 'gradient',
|
|
130
|
-
'typography.fontSize': 'font-size',
|
|
131
|
-
'typography.fontFamily': 'font-family',
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
// A static list of block attributes that store global style preset slugs.
|
|
135
|
-
export const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
|
|
136
|
-
'color.background': 'backgroundColor',
|
|
137
|
-
'color.text': 'textColor',
|
|
138
|
-
'color.gradient': 'gradient',
|
|
139
|
-
'typography.fontSize': 'fontSize',
|
|
140
|
-
'typography.fontFamily': 'fontFamily',
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
function findInPresetsBy(
|
|
144
|
-
features,
|
|
145
|
-
blockName,
|
|
146
|
-
presetPath,
|
|
147
|
-
presetProperty,
|
|
148
|
-
presetValueValue
|
|
149
|
-
) {
|
|
150
|
-
// Block presets take priority above root level presets.
|
|
151
|
-
const orderedPresetsByOrigin = [
|
|
152
|
-
get( features, [ 'blocks', blockName, ...presetPath ] ),
|
|
153
|
-
get( features, presetPath ),
|
|
154
|
-
];
|
|
155
|
-
|
|
156
|
-
for ( const presetByOrigin of orderedPresetsByOrigin ) {
|
|
157
|
-
if ( presetByOrigin ) {
|
|
158
|
-
// Preset origins ordered by priority.
|
|
159
|
-
const origins = [ 'custom', 'theme', 'default' ];
|
|
160
|
-
for ( const origin of origins ) {
|
|
161
|
-
const presets = presetByOrigin[ origin ];
|
|
162
|
-
if ( presets ) {
|
|
163
|
-
const presetObject = presets.find(
|
|
164
|
-
( preset ) =>
|
|
165
|
-
preset[ presetProperty ] === presetValueValue
|
|
166
|
-
);
|
|
167
|
-
if ( presetObject ) {
|
|
168
|
-
if ( presetProperty === 'slug' ) {
|
|
169
|
-
return presetObject;
|
|
170
|
-
}
|
|
171
|
-
// If there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.
|
|
172
|
-
const highestPresetObjectWithSameSlug = findInPresetsBy(
|
|
173
|
-
features,
|
|
174
|
-
blockName,
|
|
175
|
-
presetPath,
|
|
176
|
-
'slug',
|
|
177
|
-
presetObject.slug
|
|
178
|
-
);
|
|
179
|
-
if (
|
|
180
|
-
highestPresetObjectWithSameSlug[
|
|
181
|
-
presetProperty
|
|
182
|
-
] === presetObject[ presetProperty ]
|
|
183
|
-
) {
|
|
184
|
-
return presetObject;
|
|
185
|
-
}
|
|
186
|
-
return undefined;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export function getPresetVariableFromValue(
|
|
195
|
-
features,
|
|
196
|
-
blockName,
|
|
197
|
-
variableStylePath,
|
|
198
|
-
presetPropertyValue
|
|
199
|
-
) {
|
|
200
|
-
if ( ! presetPropertyValue ) {
|
|
201
|
-
return presetPropertyValue;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const cssVarInfix = STYLE_PATH_TO_CSS_VAR_INFIX[ variableStylePath ];
|
|
205
|
-
|
|
206
|
-
const metadata = PRESET_METADATA.find(
|
|
207
|
-
( data ) => data.cssVarInfix === cssVarInfix
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
if ( ! metadata ) {
|
|
211
|
-
// The property doesn't have preset data
|
|
212
|
-
// so the value should be returned as it is.
|
|
213
|
-
return presetPropertyValue;
|
|
214
|
-
}
|
|
215
|
-
const { valueKey, path } = metadata;
|
|
216
|
-
|
|
217
|
-
const presetObject = findInPresetsBy(
|
|
218
|
-
features,
|
|
219
|
-
blockName,
|
|
220
|
-
path,
|
|
221
|
-
valueKey,
|
|
222
|
-
presetPropertyValue
|
|
223
|
-
);
|
|
224
|
-
|
|
225
|
-
if ( ! presetObject ) {
|
|
226
|
-
// Value wasn't found in the presets,
|
|
227
|
-
// so it must be a custom value.
|
|
228
|
-
return presetPropertyValue;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
return `var:preset|${ cssVarInfix }|${ presetObject.slug }`;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function getValueFromPresetVariable(
|
|
235
|
-
features,
|
|
236
|
-
blockName,
|
|
237
|
-
variable,
|
|
238
|
-
[ presetType, slug ]
|
|
239
|
-
) {
|
|
240
|
-
const metadata = PRESET_METADATA.find(
|
|
241
|
-
( data ) => data.cssVarInfix === presetType
|
|
242
|
-
);
|
|
243
|
-
if ( ! metadata ) {
|
|
244
|
-
return variable;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
const presetObject = findInPresetsBy(
|
|
248
|
-
features.settings,
|
|
249
|
-
blockName,
|
|
250
|
-
metadata.path,
|
|
251
|
-
'slug',
|
|
252
|
-
slug
|
|
253
|
-
);
|
|
254
|
-
|
|
255
|
-
if ( presetObject ) {
|
|
256
|
-
const { valueKey } = metadata;
|
|
257
|
-
const result = presetObject[ valueKey ];
|
|
258
|
-
return getValueFromVariable( features, blockName, result );
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
return variable;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
function getValueFromCustomVariable( features, blockName, variable, path ) {
|
|
265
|
-
const result =
|
|
266
|
-
get( features.settings, [ 'blocks', blockName, 'custom', ...path ] ) ??
|
|
267
|
-
get( features.settings, [ 'custom', ...path ] );
|
|
268
|
-
if ( ! result ) {
|
|
269
|
-
return variable;
|
|
270
|
-
}
|
|
271
|
-
// A variable may reference another variable so we need recursion until we find the value.
|
|
272
|
-
return getValueFromVariable( features, blockName, result );
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Attempts to fetch the value of a theme.json CSS variable.
|
|
277
|
-
*
|
|
278
|
-
* @param {Object} features GlobalStylesContext config, e.g., user, base or merged. Represents the theme.json tree.
|
|
279
|
-
* @param {string} blockName The name of a block as represented in the styles property. E.g., 'root' for root-level, and 'core/${blockName}' for blocks.
|
|
280
|
-
* @param {string|*} variable An incoming style value. A CSS var value is expected, but it could be any value.
|
|
281
|
-
* @return {string|*|{ref}} The value of the CSS var, if found. If not found, the passed variable argument.
|
|
282
|
-
*/
|
|
283
|
-
export function getValueFromVariable( features, blockName, variable ) {
|
|
284
|
-
if ( ! variable || typeof variable !== 'string' ) {
|
|
285
|
-
if ( variable?.ref && typeof variable?.ref === 'string' ) {
|
|
286
|
-
const refPath = variable.ref.split( '.' );
|
|
287
|
-
variable = get( features, refPath );
|
|
288
|
-
// Presence of another ref indicates a reference to another dynamic value.
|
|
289
|
-
// Pointing to another dynamic value is not supported.
|
|
290
|
-
if ( ! variable || !! variable?.ref ) {
|
|
291
|
-
return variable;
|
|
292
|
-
}
|
|
293
|
-
} else {
|
|
294
|
-
return variable;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
const USER_VALUE_PREFIX = 'var:';
|
|
298
|
-
const THEME_VALUE_PREFIX = 'var(--wp--';
|
|
299
|
-
const THEME_VALUE_SUFFIX = ')';
|
|
300
|
-
|
|
301
|
-
let parsedVar;
|
|
302
|
-
|
|
303
|
-
if ( variable.startsWith( USER_VALUE_PREFIX ) ) {
|
|
304
|
-
parsedVar = variable.slice( USER_VALUE_PREFIX.length ).split( '|' );
|
|
305
|
-
} else if (
|
|
306
|
-
variable.startsWith( THEME_VALUE_PREFIX ) &&
|
|
307
|
-
variable.endsWith( THEME_VALUE_SUFFIX )
|
|
308
|
-
) {
|
|
309
|
-
parsedVar = variable
|
|
310
|
-
.slice( THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length )
|
|
311
|
-
.split( '--' );
|
|
312
|
-
} else {
|
|
313
|
-
// We don't know how to parse the value: either is raw of uses complex CSS such as `calc(1px * var(--wp--variable) )`
|
|
314
|
-
return variable;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const [ type, ...path ] = parsedVar;
|
|
318
|
-
if ( type === 'preset' ) {
|
|
319
|
-
return getValueFromPresetVariable(
|
|
320
|
-
features,
|
|
321
|
-
blockName,
|
|
322
|
-
variable,
|
|
323
|
-
path
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
if ( type === 'custom' ) {
|
|
327
|
-
return getValueFromCustomVariable(
|
|
328
|
-
features,
|
|
329
|
-
blockName,
|
|
330
|
-
variable,
|
|
331
|
-
path
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
return variable;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Function that scopes a selector with another one. This works a bit like
|
|
339
|
-
* SCSS nesting except the `&` operator isn't supported.
|
|
340
|
-
*
|
|
341
|
-
* @example
|
|
342
|
-
* ```js
|
|
343
|
-
* const scope = '.a, .b .c';
|
|
344
|
-
* const selector = '> .x, .y';
|
|
345
|
-
* const merged = scopeSelector( scope, selector );
|
|
346
|
-
* // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'
|
|
347
|
-
* ```
|
|
348
|
-
*
|
|
349
|
-
* @param {string} scope Selector to scope to.
|
|
350
|
-
* @param {string} selector Original selector.
|
|
351
|
-
*
|
|
352
|
-
* @return {string} Scoped selector.
|
|
353
|
-
*/
|
|
354
|
-
export function scopeSelector( scope, selector ) {
|
|
355
|
-
const scopes = scope.split( ',' );
|
|
356
|
-
const selectors = selector.split( ',' );
|
|
357
|
-
|
|
358
|
-
const selectorsScoped = [];
|
|
359
|
-
scopes.forEach( ( outer ) => {
|
|
360
|
-
selectors.forEach( ( inner ) => {
|
|
361
|
-
selectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );
|
|
362
|
-
} );
|
|
363
|
-
} );
|
|
364
|
-
|
|
365
|
-
return selectorsScoped.join( ', ' );
|
|
366
|
-
}
|
|
367
|
-
|
|
368
1
|
/**
|
|
369
2
|
*
|
|
370
|
-
* @param {string}
|
|
3
|
+
* @param {string} variation The variation name.
|
|
371
4
|
*
|
|
372
5
|
* @return {string} The variation class name.
|
|
373
6
|
*/
|
|
374
|
-
export function
|
|
375
|
-
if ( !
|
|
7
|
+
export function getVariationClassName( variation ) {
|
|
8
|
+
if ( ! variation ) {
|
|
376
9
|
return '';
|
|
377
10
|
}
|
|
378
|
-
return `is-style-${
|
|
11
|
+
return `is-style-${ variation }`;
|
|
379
12
|
}
|
|
@@ -3,16 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useEffect } from '@wordpress/element';
|
|
5
5
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
+
import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
9
10
|
*/
|
|
10
11
|
import { store as editSiteStore } from '../../store';
|
|
12
|
+
import { unlock } from '../../experiments';
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import { useGlobalStylesOutput } from '../global-styles/use-global-styles-output';
|
|
14
|
+
const { useGlobalStylesOutput } = unlock( blockEditorExperiments );
|
|
16
15
|
|
|
17
16
|
function useGlobalStylesRenderer() {
|
|
18
17
|
const [ styles, settings, svgFilters ] = useGlobalStylesOutput();
|
|
@@ -88,6 +88,7 @@ export default function DocumentActions() {
|
|
|
88
88
|
// Use the title wrapper as the popover anchor so that the dropdown is
|
|
89
89
|
// centered over the whole title area rather than just one part of it.
|
|
90
90
|
anchor: popoverAnchor,
|
|
91
|
+
placement: 'bottom',
|
|
91
92
|
} ),
|
|
92
93
|
[ popoverAnchor ]
|
|
93
94
|
);
|
|
@@ -146,7 +147,6 @@ export default function DocumentActions() {
|
|
|
146
147
|
|
|
147
148
|
<Dropdown
|
|
148
149
|
popoverProps={ popoverProps }
|
|
149
|
-
position="bottom center"
|
|
150
150
|
renderToggle={ ( { isOpen, onToggle } ) => (
|
|
151
151
|
<Button
|
|
152
152
|
className="edit-site-document-actions__get-info"
|