@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
|
@@ -8,12 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.getSupportedGlobalStylesPanels = getSupportedGlobalStylesPanels;
|
|
9
9
|
exports.useColorRandomizer = useColorRandomizer;
|
|
10
10
|
exports.useColorsPerOrigin = useColorsPerOrigin;
|
|
11
|
-
exports.useGlobalStylesReset = void 0;
|
|
12
11
|
exports.useGradientsPerOrigin = useGradientsPerOrigin;
|
|
13
|
-
exports.useSetting = useSetting;
|
|
14
|
-
exports.useStyle = useStyle;
|
|
15
|
-
|
|
16
|
-
var _es = _interopRequireDefault(require("fast-deep-equal/es6"));
|
|
17
12
|
|
|
18
13
|
var _lodash = require("lodash");
|
|
19
14
|
|
|
@@ -27,9 +22,9 @@ var _element = require("@wordpress/element");
|
|
|
27
22
|
|
|
28
23
|
var _blocks = require("@wordpress/blocks");
|
|
29
24
|
|
|
30
|
-
var
|
|
25
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
31
26
|
|
|
32
|
-
var
|
|
27
|
+
var _experiments = require("../../experiments");
|
|
33
28
|
|
|
34
29
|
/**
|
|
35
30
|
* External dependencies
|
|
@@ -42,136 +37,15 @@ var _context = require("./context");
|
|
|
42
37
|
/**
|
|
43
38
|
* Internal dependencies
|
|
44
39
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
settings: {},
|
|
49
|
-
styles: {}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const useGlobalStylesReset = () => {
|
|
53
|
-
const {
|
|
54
|
-
user: config,
|
|
55
|
-
setUserConfig
|
|
56
|
-
} = (0, _element.useContext)(_context.GlobalStylesContext);
|
|
57
|
-
const canReset = !!config && !(0, _es.default)(config, EMPTY_CONFIG);
|
|
58
|
-
return [canReset, (0, _element.useCallback)(() => setUserConfig(() => EMPTY_CONFIG), [setUserConfig])];
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
exports.useGlobalStylesReset = useGlobalStylesReset;
|
|
62
|
-
|
|
63
|
-
function useSetting(path, blockName) {
|
|
64
|
-
var _getSettingValueForCo;
|
|
65
|
-
|
|
66
|
-
let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'all';
|
|
67
|
-
const {
|
|
68
|
-
merged: mergedConfig,
|
|
69
|
-
base: baseConfig,
|
|
70
|
-
user: userConfig,
|
|
71
|
-
setUserConfig
|
|
72
|
-
} = (0, _element.useContext)(_context.GlobalStylesContext);
|
|
73
|
-
const fullPath = !blockName ? `settings.${path}` : `settings.blocks.${blockName}.${path}`;
|
|
74
|
-
|
|
75
|
-
const setSetting = newValue => {
|
|
76
|
-
setUserConfig(currentConfig => {
|
|
77
|
-
// Deep clone `currentConfig` to avoid mutating it later.
|
|
78
|
-
const newUserConfig = JSON.parse(JSON.stringify(currentConfig));
|
|
79
|
-
const pathToSet = _blocks.__EXPERIMENTAL_PATHS_WITH_MERGE[path] ? fullPath + '.custom' : fullPath;
|
|
80
|
-
(0, _lodash.set)(newUserConfig, pathToSet, newValue);
|
|
81
|
-
return newUserConfig;
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const getSettingValueForContext = name => {
|
|
86
|
-
const currentPath = !name ? `settings.${path}` : `settings.blocks.${name}.${path}`;
|
|
87
|
-
|
|
88
|
-
const getSettingValue = configToUse => {
|
|
89
|
-
const result = (0, _lodash.get)(configToUse, currentPath);
|
|
90
|
-
|
|
91
|
-
if (_blocks.__EXPERIMENTAL_PATHS_WITH_MERGE[path]) {
|
|
92
|
-
var _ref, _result$custom;
|
|
93
|
-
|
|
94
|
-
return (_ref = (_result$custom = result === null || result === void 0 ? void 0 : result.custom) !== null && _result$custom !== void 0 ? _result$custom : result === null || result === void 0 ? void 0 : result.theme) !== null && _ref !== void 0 ? _ref : result === null || result === void 0 ? void 0 : result.default;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return result;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
let result;
|
|
101
|
-
|
|
102
|
-
switch (source) {
|
|
103
|
-
case 'all':
|
|
104
|
-
result = getSettingValue(mergedConfig);
|
|
105
|
-
break;
|
|
106
|
-
|
|
107
|
-
case 'user':
|
|
108
|
-
result = getSettingValue(userConfig);
|
|
109
|
-
break;
|
|
110
|
-
|
|
111
|
-
case 'base':
|
|
112
|
-
result = getSettingValue(baseConfig);
|
|
113
|
-
break;
|
|
114
|
-
|
|
115
|
-
default:
|
|
116
|
-
throw 'Unsupported source';
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return result;
|
|
120
|
-
}; // Unlike styles settings get inherited from top level settings.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const resultWithFallback = (_getSettingValueForCo = getSettingValueForContext(blockName)) !== null && _getSettingValueForCo !== void 0 ? _getSettingValueForCo : getSettingValueForContext();
|
|
124
|
-
return [resultWithFallback, setSetting];
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function useStyle(path, blockName) {
|
|
128
|
-
var _get;
|
|
129
|
-
|
|
130
|
-
let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'all';
|
|
131
|
-
const {
|
|
132
|
-
merged: mergedConfig,
|
|
133
|
-
base: baseConfig,
|
|
134
|
-
user: userConfig,
|
|
135
|
-
setUserConfig
|
|
136
|
-
} = (0, _element.useContext)(_context.GlobalStylesContext);
|
|
137
|
-
const finalPath = !blockName ? `styles.${path}` : `styles.blocks.${blockName}.${path}`;
|
|
138
|
-
|
|
139
|
-
const setStyle = newValue => {
|
|
140
|
-
setUserConfig(currentConfig => {
|
|
141
|
-
// Deep clone `currentConfig` to avoid mutating it later.
|
|
142
|
-
const newUserConfig = JSON.parse(JSON.stringify(currentConfig));
|
|
143
|
-
(0, _lodash.set)(newUserConfig, finalPath, (0, _utils.getPresetVariableFromValue)(mergedConfig.settings, blockName, path, newValue));
|
|
144
|
-
return newUserConfig;
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
let result;
|
|
149
|
-
|
|
150
|
-
switch (source) {
|
|
151
|
-
case 'all':
|
|
152
|
-
result = (0, _utils.getValueFromVariable)(mergedConfig, blockName, // The stlyes.css path is allowed to be empty, so don't revert to base if undefined.
|
|
153
|
-
finalPath === 'styles.css' ? (0, _lodash.get)(userConfig, finalPath) : (_get = (0, _lodash.get)(userConfig, finalPath)) !== null && _get !== void 0 ? _get : (0, _lodash.get)(baseConfig, finalPath));
|
|
154
|
-
break;
|
|
155
|
-
|
|
156
|
-
case 'user':
|
|
157
|
-
result = (0, _utils.getValueFromVariable)(mergedConfig, blockName, (0, _lodash.get)(userConfig, finalPath));
|
|
158
|
-
break;
|
|
159
|
-
|
|
160
|
-
case 'base':
|
|
161
|
-
result = (0, _utils.getValueFromVariable)(baseConfig, blockName, (0, _lodash.get)(baseConfig, finalPath));
|
|
162
|
-
break;
|
|
163
|
-
|
|
164
|
-
default:
|
|
165
|
-
throw 'Unsupported source';
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return [result, setStyle];
|
|
169
|
-
}
|
|
40
|
+
const {
|
|
41
|
+
useGlobalSetting
|
|
42
|
+
} = (0, _experiments.unlock)(_blockEditor.experiments); // Enable colord's a11y plugin.
|
|
170
43
|
|
|
44
|
+
(0, _colord.extend)([_a11y.default]);
|
|
171
45
|
const ROOT_BLOCK_SUPPORTS = ['background', 'backgroundColor', 'color', 'linkColor', 'buttonColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'textDecoration', 'padding', 'contentSize', 'wideSize', 'blockGap'];
|
|
172
46
|
|
|
173
47
|
function getSupportedGlobalStylesPanels(name) {
|
|
174
|
-
var _blockType$supports, _blockType$supports$s, _blockType$supports2, _blockType$supports2$, _blockType$supports3, _blockType$supports3$, _blockType$supports3$2, _blockType$supports3$3;
|
|
48
|
+
var _blockType$supports, _blockType$supports$s, _blockType$supports2, _blockType$supports2$, _blockType$supports3, _blockType$supports3$, _blockType$supports3$2, _blockType$supports3$3, _blockType$supports4;
|
|
175
49
|
|
|
176
50
|
if (!name) {
|
|
177
51
|
return ROOT_BLOCK_SUPPORTS;
|
|
@@ -189,6 +63,11 @@ function getSupportedGlobalStylesPanels(name) {
|
|
|
189
63
|
|
|
190
64
|
if (blockType !== null && blockType !== void 0 && (_blockType$supports = blockType.supports) !== null && _blockType$supports !== void 0 && (_blockType$supports$s = _blockType$supports.spacing) !== null && _blockType$supports$s !== void 0 && _blockType$supports$s.blockGap && (blockType === null || blockType === void 0 ? void 0 : (_blockType$supports2 = blockType.supports) === null || _blockType$supports2 === void 0 ? void 0 : (_blockType$supports2$ = _blockType$supports2.spacing) === null || _blockType$supports2$ === void 0 ? void 0 : _blockType$supports2$.__experimentalSkipSerialization) !== true && !(blockType !== null && blockType !== void 0 && (_blockType$supports3 = blockType.supports) !== null && _blockType$supports3 !== void 0 && (_blockType$supports3$ = _blockType$supports3.spacing) !== null && _blockType$supports3$ !== void 0 && (_blockType$supports3$2 = _blockType$supports3$.__experimentalSkipSerialization) !== null && _blockType$supports3$2 !== void 0 && (_blockType$supports3$3 = _blockType$supports3$2.some) !== null && _blockType$supports3$3 !== void 0 && _blockType$supports3$3.call(_blockType$supports3$2, spacingType => spacingType === 'blockGap'))) {
|
|
191
65
|
supportKeys.push('blockGap');
|
|
66
|
+
} // check for shadow support
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if (blockType !== null && blockType !== void 0 && (_blockType$supports4 = blockType.supports) !== null && _blockType$supports4 !== void 0 && _blockType$supports4.shadow) {
|
|
70
|
+
supportKeys.push('shadow');
|
|
192
71
|
}
|
|
193
72
|
|
|
194
73
|
Object.keys(_blocks.__EXPERIMENTAL_STYLE_PROPERTY).forEach(styleName => {
|
|
@@ -213,10 +92,10 @@ function getSupportedGlobalStylesPanels(name) {
|
|
|
213
92
|
}
|
|
214
93
|
|
|
215
94
|
function useColorsPerOrigin(name) {
|
|
216
|
-
const [customColors] =
|
|
217
|
-
const [themeColors] =
|
|
218
|
-
const [defaultColors] =
|
|
219
|
-
const [shouldDisplayDefaultColors] =
|
|
95
|
+
const [customColors] = useGlobalSetting('color.palette.custom', name);
|
|
96
|
+
const [themeColors] = useGlobalSetting('color.palette.theme', name);
|
|
97
|
+
const [defaultColors] = useGlobalSetting('color.palette.default', name);
|
|
98
|
+
const [shouldDisplayDefaultColors] = useGlobalSetting('color.defaultPalette');
|
|
220
99
|
return (0, _element.useMemo)(() => {
|
|
221
100
|
const result = [];
|
|
222
101
|
|
|
@@ -246,10 +125,10 @@ function useColorsPerOrigin(name) {
|
|
|
246
125
|
}
|
|
247
126
|
|
|
248
127
|
function useGradientsPerOrigin(name) {
|
|
249
|
-
const [customGradients] =
|
|
250
|
-
const [themeGradients] =
|
|
251
|
-
const [defaultGradients] =
|
|
252
|
-
const [shouldDisplayDefaultGradients] =
|
|
128
|
+
const [customGradients] = useGlobalSetting('color.gradients.custom', name);
|
|
129
|
+
const [themeGradients] = useGlobalSetting('color.gradients.theme', name);
|
|
130
|
+
const [defaultGradients] = useGlobalSetting('color.gradients.default', name);
|
|
131
|
+
const [shouldDisplayDefaultGradients] = useGlobalSetting('color.defaultGradients');
|
|
253
132
|
return (0, _element.useMemo)(() => {
|
|
254
133
|
const result = [];
|
|
255
134
|
|
|
@@ -279,7 +158,7 @@ function useGradientsPerOrigin(name) {
|
|
|
279
158
|
}
|
|
280
159
|
|
|
281
160
|
function useColorRandomizer(name) {
|
|
282
|
-
const [themeColors, setThemeColors] =
|
|
161
|
+
const [themeColors, setThemeColors] = useGlobalSetting('color.palette.theme', name);
|
|
283
162
|
|
|
284
163
|
function randomizeColors() {
|
|
285
164
|
/* eslint-disable no-restricted-syntax */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/hooks.js"],"names":["a11yPlugin","EMPTY_CONFIG","settings","styles","useGlobalStylesReset","user","config","setUserConfig","GlobalStylesContext","canReset","useSetting","path","blockName","source","merged","mergedConfig","base","baseConfig","userConfig","fullPath","setSetting","newValue","currentConfig","newUserConfig","JSON","parse","stringify","pathToSet","PATHS_WITH_MERGE","getSettingValueForContext","name","currentPath","getSettingValue","configToUse","result","custom","theme","default","resultWithFallback","useStyle","finalPath","setStyle","ROOT_BLOCK_SUPPORTS","getSupportedGlobalStylesPanels","blockType","supportKeys","supports","spacing","blockGap","__experimentalSkipSerialization","some","spacingType","push","Object","keys","STYLE_PROPERTY","forEach","styleName","support","requiresOptOut","useColorsPerOrigin","customColors","themeColors","defaultColors","shouldDisplayDefaultColors","length","colors","useGradientsPerOrigin","customGradients","themeGradients","defaultGradients","shouldDisplayDefaultGradients","gradients","useColorRandomizer","setThemeColors","randomizeColors","randomRotationValue","Math","floor","random","newColors","map","colorObject","color","newColor","rotate","toHex","window","__experimentalEnableColorRandomizer"],"mappings":";;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AASA;;AACA;;AAvBA;AACA;AACA;;AAMA;AACA;AACA;;AASA;AACA;AACA;AAIA;AACA,oBAAQ,CAAEA,aAAF,CAAR;AAEA,MAAMC,YAAY,GAAG;AAAEC,EAAAA,QAAQ,EAAE,EAAZ;AAAgBC,EAAAA,MAAM,EAAE;AAAxB,CAArB;;AAEO,MAAMC,oBAAoB,GAAG,MAAM;AACzC,QAAM;AAAEC,IAAAA,IAAI,EAAEC,MAAR;AAAgBC,IAAAA;AAAhB,MAAkC,yBAAYC,4BAAZ,CAAxC;AACA,QAAMC,QAAQ,GAAG,CAAC,CAAEH,MAAH,IAAa,CAAE,iBAAeA,MAAf,EAAuBL,YAAvB,CAAhC;AACA,SAAO,CACNQ,QADM,EAEN,0BACC,MAAMF,aAAa,CAAE,MAAMN,YAAR,CADpB,EAEC,CAAEM,aAAF,CAFD,CAFM,CAAP;AAOA,CAVM;;;;AAYA,SAASG,UAAT,CAAqBC,IAArB,EAA2BC,SAA3B,EAAuD;AAAA;;AAAA,MAAjBC,MAAiB,uEAAR,KAAQ;AAC7D,QAAM;AACLC,IAAAA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AAYAV,IAAAA,cAAc,CAAEM,SAAF,CAAd;AACA;;AAED,SAAOO,MAAM,CAACC,mCAAP,GACJ,CAAEb,eAAF,CADI,GAEJ,EAFH;AAGA","sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\nimport { get, set } from 'lodash';\nimport { colord, extend } from 'colord';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useContext, useCallback, useMemo } from '@wordpress/element';\nimport {\n\tgetBlockType,\n\t__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromVariable, getPresetVariableFromValue } from './utils';\nimport { GlobalStylesContext } from './context';\n\n// Enable colord's a11y plugin.\nextend( [ a11yPlugin ] );\n\nconst EMPTY_CONFIG = { settings: {}, styles: {} };\n\nexport const useGlobalStylesReset = () => {\n\tconst { user: config, setUserConfig } = useContext( GlobalStylesContext );\n\tconst canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );\n\treturn [\n\t\tcanReset,\n\t\tuseCallback(\n\t\t\t() => setUserConfig( () => EMPTY_CONFIG ),\n\t\t\t[ setUserConfig ]\n\t\t),\n\t];\n};\n\nexport function useSetting( path, blockName, source = 'all' ) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\n\tconst fullPath = ! blockName\n\t\t? `settings.${ path }`\n\t\t: `settings.blocks.${ blockName }.${ path }`;\n\n\tconst setSetting = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\t// Deep clone `currentConfig` to avoid mutating it later.\n\t\t\tconst newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );\n\t\t\tconst pathToSet = PATHS_WITH_MERGE[ path ]\n\t\t\t\t? fullPath + '.custom'\n\t\t\t\t: fullPath;\n\t\t\tset( newUserConfig, pathToSet, newValue );\n\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\tconst getSettingValueForContext = ( name ) => {\n\t\tconst currentPath = ! name\n\t\t\t? `settings.${ path }`\n\t\t\t: `settings.blocks.${ name }.${ path }`;\n\n\t\tconst getSettingValue = ( configToUse ) => {\n\t\t\tconst result = get( configToUse, currentPath );\n\t\t\tif ( PATHS_WITH_MERGE[ path ] ) {\n\t\t\t\treturn result?.custom ?? result?.theme ?? result?.default;\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\n\t\tlet result;\n\t\tswitch ( source ) {\n\t\t\tcase 'all':\n\t\t\t\tresult = getSettingValue( mergedConfig );\n\t\t\t\tbreak;\n\t\t\tcase 'user':\n\t\t\t\tresult = getSettingValue( userConfig );\n\t\t\t\tbreak;\n\t\t\tcase 'base':\n\t\t\t\tresult = getSettingValue( baseConfig );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow 'Unsupported source';\n\t\t}\n\n\t\treturn result;\n\t};\n\n\t// Unlike styles settings get inherited from top level settings.\n\tconst resultWithFallback =\n\t\tgetSettingValueForContext( blockName ) ?? getSettingValueForContext();\n\n\treturn [ resultWithFallback, setSetting ];\n}\n\nexport function useStyle( path, blockName, source = 'all' ) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\tconst finalPath = ! blockName\n\t\t? `styles.${ path }`\n\t\t: `styles.blocks.${ blockName }.${ path }`;\n\n\tconst setStyle = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\t// Deep clone `currentConfig` to avoid mutating it later.\n\t\t\tconst newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );\n\t\t\tset(\n\t\t\t\tnewUserConfig,\n\t\t\t\tfinalPath,\n\t\t\t\tgetPresetVariableFromValue(\n\t\t\t\t\tmergedConfig.settings,\n\t\t\t\t\tblockName,\n\t\t\t\t\tpath,\n\t\t\t\t\tnewValue\n\t\t\t\t)\n\t\t\t);\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\tlet result;\n\tswitch ( source ) {\n\t\tcase 'all':\n\t\t\tresult = getValueFromVariable(\n\t\t\t\tmergedConfig,\n\t\t\t\tblockName,\n\t\t\t\t// The stlyes.css path is allowed to be empty, so don't revert to base if undefined.\n\t\t\t\tfinalPath === 'styles.css'\n\t\t\t\t\t? get( userConfig, finalPath )\n\t\t\t\t\t: get( userConfig, finalPath ) ??\n\t\t\t\t\t\t\tget( baseConfig, finalPath )\n\t\t\t);\n\t\t\tbreak;\n\t\tcase 'user':\n\t\t\tresult = getValueFromVariable(\n\t\t\t\tmergedConfig,\n\t\t\t\tblockName,\n\t\t\t\tget( userConfig, finalPath )\n\t\t\t);\n\t\t\tbreak;\n\t\tcase 'base':\n\t\t\tresult = getValueFromVariable(\n\t\t\t\tbaseConfig,\n\t\t\t\tblockName,\n\t\t\t\tget( baseConfig, finalPath )\n\t\t\t);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow 'Unsupported source';\n\t}\n\n\treturn [ result, setStyle ];\n}\n\nconst ROOT_BLOCK_SUPPORTS = [\n\t'background',\n\t'backgroundColor',\n\t'color',\n\t'linkColor',\n\t'buttonColor',\n\t'fontFamily',\n\t'fontSize',\n\t'fontStyle',\n\t'fontWeight',\n\t'lineHeight',\n\t'textDecoration',\n\t'padding',\n\t'contentSize',\n\t'wideSize',\n\t'blockGap',\n];\n\nexport function getSupportedGlobalStylesPanels( name ) {\n\tif ( ! name ) {\n\t\treturn ROOT_BLOCK_SUPPORTS;\n\t}\n\n\tconst blockType = getBlockType( name );\n\n\tif ( ! blockType ) {\n\t\treturn [];\n\t}\n\n\tconst supportKeys = [];\n\n\t// Check for blockGap support.\n\t// Block spacing support doesn't map directly to a single style property, so needs to be handled separately.\n\t// Also, only allow `blockGap` support if serialization has not been skipped, to be sure global spacing can be applied.\n\tif (\n\t\tblockType?.supports?.spacing?.blockGap &&\n\t\tblockType?.supports?.spacing?.__experimentalSkipSerialization !==\n\t\t\ttrue &&\n\t\t! blockType?.supports?.spacing?.__experimentalSkipSerialization?.some?.(\n\t\t\t( spacingType ) => spacingType === 'blockGap'\n\t\t)\n\t) {\n\t\tsupportKeys.push( 'blockGap' );\n\t}\n\n\tObject.keys( STYLE_PROPERTY ).forEach( ( styleName ) => {\n\t\tif ( ! STYLE_PROPERTY[ styleName ].support ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Opting out means that, for certain support keys like background color,\n\t\t// blocks have to explicitly set the support value false. If the key is\n\t\t// unset, we still enable it.\n\t\tif ( STYLE_PROPERTY[ styleName ].requiresOptOut ) {\n\t\t\tif (\n\t\t\t\tSTYLE_PROPERTY[ styleName ].support[ 0 ] in\n\t\t\t\t\tblockType.supports &&\n\t\t\t\tget(\n\t\t\t\t\tblockType.supports,\n\t\t\t\t\tSTYLE_PROPERTY[ styleName ].support\n\t\t\t\t) !== false\n\t\t\t) {\n\t\t\t\treturn supportKeys.push( styleName );\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tget(\n\t\t\t\tblockType.supports,\n\t\t\t\tSTYLE_PROPERTY[ styleName ].support,\n\t\t\t\tfalse\n\t\t\t)\n\t\t) {\n\t\t\treturn supportKeys.push( styleName );\n\t\t}\n\t} );\n\n\treturn supportKeys;\n}\n\nexport function useColorsPerOrigin( name ) {\n\tconst [ customColors ] = useSetting( 'color.palette.custom', name );\n\tconst [ themeColors ] = useSetting( 'color.palette.theme', name );\n\tconst [ defaultColors ] = useSetting( 'color.palette.default', name );\n\tconst [ shouldDisplayDefaultColors ] = useSetting( 'color.defaultPalette' );\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [ customColors, themeColors, defaultColors ] );\n}\n\nexport function useGradientsPerOrigin( name ) {\n\tconst [ customGradients ] = useSetting( 'color.gradients.custom', name );\n\tconst [ themeGradients ] = useSetting( 'color.gradients.theme', name );\n\tconst [ defaultGradients ] = useSetting( 'color.gradients.default', name );\n\tconst [ shouldDisplayDefaultGradients ] = useSetting(\n\t\t'color.defaultGradients'\n\t);\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [ customGradients, themeGradients, defaultGradients ] );\n}\n\nexport function useColorRandomizer( name ) {\n\tconst [ themeColors, setThemeColors ] = useSetting(\n\t\t'color.palette.theme',\n\t\tname\n\t);\n\n\tfunction randomizeColors() {\n\t\t/* eslint-disable no-restricted-syntax */\n\t\tconst randomRotationValue = Math.floor( Math.random() * 225 );\n\t\t/* eslint-enable no-restricted-syntax */\n\n\t\tconst newColors = themeColors.map( ( colorObject ) => {\n\t\t\tconst { color } = colorObject;\n\t\t\tconst newColor = colord( color )\n\t\t\t\t.rotate( randomRotationValue )\n\t\t\t\t.toHex();\n\n\t\t\treturn {\n\t\t\t\t...colorObject,\n\t\t\t\tcolor: newColor,\n\t\t\t};\n\t\t} );\n\n\t\tsetThemeColors( newColors );\n\t}\n\n\treturn window.__experimentalEnableColorRandomizer\n\t\t? [ randomizeColors ]\n\t\t: [];\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/hooks.js"],"names":["useGlobalSetting","blockEditorExperiments","a11yPlugin","ROOT_BLOCK_SUPPORTS","getSupportedGlobalStylesPanels","name","blockType","supportKeys","supports","spacing","blockGap","__experimentalSkipSerialization","some","spacingType","push","shadow","Object","keys","STYLE_PROPERTY","forEach","styleName","support","requiresOptOut","useColorsPerOrigin","customColors","themeColors","defaultColors","shouldDisplayDefaultColors","result","length","colors","useGradientsPerOrigin","customGradients","themeGradients","defaultGradients","shouldDisplayDefaultGradients","gradients","useColorRandomizer","setThemeColors","randomizeColors","randomRotationValue","Math","floor","random","newColors","map","colorObject","color","newColor","rotate","toHex","window","__experimentalEnableColorRandomizer"],"mappings":";;;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAIA;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6BAA6B,IAC7BD,gBADA,IAEAA,gBAAgB,CAACL,MAHlB,EAIE;AACDD,MAAAA,MAAM,CAACd,IAAP,CAAa;AACZT,QAAAA,IAAI,EAAE,cACL,SADK,EAEL,8CAFK,CADM;AAKZ+B,QAAAA,SAAS,EAAEF;AALC,OAAb;AAOA;;AACD,QAAKF,eAAe,IAAIA,eAAe,CAACH,MAAxC,EAAiD;AAChDD,MAAAA,MAAM,CAACd,IAAP,CAAa;AACZT,QAAAA,IAAI,EAAE,cACL,QADK,EAEL,gDAFK,CADM;AAKZ+B,QAAAA,SAAS,EAAEJ;AALC,OAAb;AAOA;;AACD,WAAOJ,MAAP;AACA,GAlCM,EAkCJ,CAAEI,eAAF,EAAmBC,cAAnB,EAAmCC,gBAAnC,CAlCI,CAAP;AAmCA;;AAEM,SAASG,kBAAT,CAA6BhC,IAA7B,EAAoC;AAC1C,QAAM,CAAEoB,WAAF,EAAea,cAAf,IAAkCtC,gBAAgB,CACvD,qBADuD,EAEvDK,IAFuD,CAAxD;;AAKA,WAASkC,eAAT,GAA2B;AAC1B;AACA,UAAMC,mBAAmB,GAAGC,IAAI,CAACC,KAAL,CAAYD,IAAI,CAACE,MAAL,KAAgB,GAA5B,CAA5B;AACA;;AAEA,UAAMC,SAAS,GAAGnB,WAAW,CAACoB,GAAZ,CAAmBC,WAAF,IAAmB;AACrD,YAAM;AAAEC,QAAAA;AAAF,UAAYD,WAAlB;AACA,YAAME,QAAQ,GAAG,oBAAQD,KAAR,EACfE,MADe,CACPT,mBADO,EAEfU,KAFe,EAAjB;AAIA,aAAO,EACN,GAAGJ,WADG;AAENC,QAAAA,KAAK,EAAEC;AAFD,OAAP;AAIA,KAViB,CAAlB;AAYAV,IAAAA,cAAc,CAAEM,SAAF,CAAd;AACA;;AAED,SAAOO,MAAM,CAACC,mCAAP,GACJ,CAAEb,eAAF,CADI,GAEJ,EAFH;AAGA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\nimport { colord, extend } from 'colord';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport {\n\tgetBlockType,\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n} from '@wordpress/blocks';\nimport { experiments as blockEditorExperiments } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../experiments';\n\nconst { useGlobalSetting } = unlock( blockEditorExperiments );\n\n// Enable colord's a11y plugin.\nextend( [ a11yPlugin ] );\n\nconst ROOT_BLOCK_SUPPORTS = [\n\t'background',\n\t'backgroundColor',\n\t'color',\n\t'linkColor',\n\t'buttonColor',\n\t'fontFamily',\n\t'fontSize',\n\t'fontStyle',\n\t'fontWeight',\n\t'lineHeight',\n\t'textDecoration',\n\t'padding',\n\t'contentSize',\n\t'wideSize',\n\t'blockGap',\n];\n\nexport function getSupportedGlobalStylesPanels( name ) {\n\tif ( ! name ) {\n\t\treturn ROOT_BLOCK_SUPPORTS;\n\t}\n\n\tconst blockType = getBlockType( name );\n\n\tif ( ! blockType ) {\n\t\treturn [];\n\t}\n\n\tconst supportKeys = [];\n\n\t// Check for blockGap support.\n\t// Block spacing support doesn't map directly to a single style property, so needs to be handled separately.\n\t// Also, only allow `blockGap` support if serialization has not been skipped, to be sure global spacing can be applied.\n\tif (\n\t\tblockType?.supports?.spacing?.blockGap &&\n\t\tblockType?.supports?.spacing?.__experimentalSkipSerialization !==\n\t\t\ttrue &&\n\t\t! blockType?.supports?.spacing?.__experimentalSkipSerialization?.some?.(\n\t\t\t( spacingType ) => spacingType === 'blockGap'\n\t\t)\n\t) {\n\t\tsupportKeys.push( 'blockGap' );\n\t}\n\n\t// check for shadow support\n\tif ( blockType?.supports?.shadow ) {\n\t\tsupportKeys.push( 'shadow' );\n\t}\n\n\tObject.keys( STYLE_PROPERTY ).forEach( ( styleName ) => {\n\t\tif ( ! STYLE_PROPERTY[ styleName ].support ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Opting out means that, for certain support keys like background color,\n\t\t// blocks have to explicitly set the support value false. If the key is\n\t\t// unset, we still enable it.\n\t\tif ( STYLE_PROPERTY[ styleName ].requiresOptOut ) {\n\t\t\tif (\n\t\t\t\tSTYLE_PROPERTY[ styleName ].support[ 0 ] in\n\t\t\t\t\tblockType.supports &&\n\t\t\t\tget(\n\t\t\t\t\tblockType.supports,\n\t\t\t\t\tSTYLE_PROPERTY[ styleName ].support\n\t\t\t\t) !== false\n\t\t\t) {\n\t\t\t\treturn supportKeys.push( styleName );\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tget(\n\t\t\t\tblockType.supports,\n\t\t\t\tSTYLE_PROPERTY[ styleName ].support,\n\t\t\t\tfalse\n\t\t\t)\n\t\t) {\n\t\t\treturn supportKeys.push( styleName );\n\t\t}\n\t} );\n\n\treturn supportKeys;\n}\n\nexport function useColorsPerOrigin( name ) {\n\tconst [ customColors ] = useGlobalSetting( 'color.palette.custom', name );\n\tconst [ themeColors ] = useGlobalSetting( 'color.palette.theme', name );\n\tconst [ defaultColors ] = useGlobalSetting( 'color.palette.default', name );\n\tconst [ shouldDisplayDefaultColors ] = useGlobalSetting(\n\t\t'color.defaultPalette'\n\t);\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [ customColors, themeColors, defaultColors ] );\n}\n\nexport function useGradientsPerOrigin( name ) {\n\tconst [ customGradients ] = useGlobalSetting(\n\t\t'color.gradients.custom',\n\t\tname\n\t);\n\tconst [ themeGradients ] = useGlobalSetting(\n\t\t'color.gradients.theme',\n\t\tname\n\t);\n\tconst [ defaultGradients ] = useGlobalSetting(\n\t\t'color.gradients.default',\n\t\tname\n\t);\n\tconst [ shouldDisplayDefaultGradients ] = useGlobalSetting(\n\t\t'color.defaultGradients'\n\t);\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [ customGradients, themeGradients, defaultGradients ] );\n}\n\nexport function useColorRandomizer( name ) {\n\tconst [ themeColors, setThemeColors ] = useGlobalSetting(\n\t\t'color.palette.theme',\n\t\tname\n\t);\n\n\tfunction randomizeColors() {\n\t\t/* eslint-disable no-restricted-syntax */\n\t\tconst randomRotationValue = Math.floor( Math.random() * 225 );\n\t\t/* eslint-enable no-restricted-syntax */\n\n\t\tconst newColors = themeColors.map( ( colorObject ) => {\n\t\t\tconst { color } = colorObject;\n\t\t\tconst newColor = colord( color )\n\t\t\t\t.rotate( randomRotationValue )\n\t\t\t\t.toHex();\n\n\t\t\treturn {\n\t\t\t\t...colorObject,\n\t\t\t\tcolor: newColor,\n\t\t\t};\n\t\t} );\n\n\t\tsetThemeColors( newColors );\n\t}\n\n\treturn window.__experimentalEnableColorRandomizer\n\t\t? [ randomizeColors ]\n\t\t: [];\n}\n"]}
|
|
@@ -11,34 +11,6 @@ Object.defineProperty(exports, "GlobalStylesUI", {
|
|
|
11
11
|
return _ui.default;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
-
Object.defineProperty(exports, "useGlobalStylesOutput", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () {
|
|
17
|
-
return _useGlobalStylesOutput.useGlobalStylesOutput;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(exports, "useGlobalStylesReset", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () {
|
|
23
|
-
return _hooks.useGlobalStylesReset;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
Object.defineProperty(exports, "useSetting", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () {
|
|
29
|
-
return _hooks.useSetting;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(exports, "useStyle", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _hooks.useStyle;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
14
|
|
|
39
15
|
var _ui = _interopRequireDefault(require("./ui"));
|
|
40
|
-
|
|
41
|
-
var _hooks = require("./hooks");
|
|
42
|
-
|
|
43
|
-
var _useGlobalStylesOutput = require("./use-global-styles-output");
|
|
44
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA","sourcesContent":["export { default as GlobalStylesUI } from './ui';\n"]}
|
|
@@ -15,6 +15,8 @@ var _i18n = require("@wordpress/i18n");
|
|
|
15
15
|
|
|
16
16
|
var _icons = require("@wordpress/icons");
|
|
17
17
|
|
|
18
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
19
|
+
|
|
18
20
|
var _subtitle = _interopRequireDefault(require("./subtitle"));
|
|
19
21
|
|
|
20
22
|
var _navigationButton = require("./navigation-button");
|
|
@@ -23,6 +25,8 @@ var _hooks = require("./hooks");
|
|
|
23
25
|
|
|
24
26
|
var _colorIndicatorWrapper = _interopRequireDefault(require("./color-indicator-wrapper"));
|
|
25
27
|
|
|
28
|
+
var _experiments = require("../../experiments");
|
|
29
|
+
|
|
26
30
|
/**
|
|
27
31
|
* WordPress dependencies
|
|
28
32
|
*/
|
|
@@ -30,16 +34,19 @@ var _colorIndicatorWrapper = _interopRequireDefault(require("./color-indicator-w
|
|
|
30
34
|
/**
|
|
31
35
|
* Internal dependencies
|
|
32
36
|
*/
|
|
37
|
+
const {
|
|
38
|
+
useGlobalSetting
|
|
39
|
+
} = (0, _experiments.unlock)(_blockEditor.experiments);
|
|
33
40
|
const EMPTY_COLORS = [];
|
|
34
41
|
|
|
35
42
|
function Palette(_ref) {
|
|
36
43
|
let {
|
|
37
44
|
name
|
|
38
45
|
} = _ref;
|
|
39
|
-
const [customColors] = (
|
|
40
|
-
const [themeColors] = (
|
|
41
|
-
const [defaultColors] = (
|
|
42
|
-
const [defaultPaletteEnabled] = (
|
|
46
|
+
const [customColors] = useGlobalSetting('color.palette.custom');
|
|
47
|
+
const [themeColors] = useGlobalSetting('color.palette.theme');
|
|
48
|
+
const [defaultColors] = useGlobalSetting('color.palette.default');
|
|
49
|
+
const [defaultPaletteEnabled] = useGlobalSetting('color.defaultPalette', name);
|
|
43
50
|
const [randomizeThemeColors] = (0, _hooks.useColorRandomizer)();
|
|
44
51
|
const colors = (0, _element.useMemo)(() => [...(customColors || EMPTY_COLORS), ...(themeColors || EMPTY_COLORS), ...(defaultColors && defaultPaletteEnabled ? defaultColors : EMPTY_COLORS)], [customColors, themeColors, defaultColors, defaultPaletteEnabled]);
|
|
45
52
|
const screenPath = !name ? '/colors/palette' : '/blocks/' + encodeURIComponent(name) + '/colors/palette';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/palette.js"],"names":["EMPTY_COLORS","Palette","name","customColors","themeColors","defaultColors","defaultPaletteEnabled","randomizeThemeColors","colors","screenPath","encodeURIComponent","paletteButtonText","length","slice","map","index","color","shuffle"],"mappings":";;;;;;;;;AAcA;;AAXA;;AASA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/palette.js"],"names":["useGlobalSetting","blockEditorExperiments","EMPTY_COLORS","Palette","name","customColors","themeColors","defaultColors","defaultPaletteEnabled","randomizeThemeColors","colors","screenPath","encodeURIComponent","paletteButtonText","length","slice","map","index","color","shuffle"],"mappings":";;;;;;;;;AAcA;;AAXA;;AASA;;AACA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAeA;AACA;AACA;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAuB,yBAAQC,wBAAR,CAA7B;AAEA,MAAMC,YAAY,GAAG,EAArB;;AAEA,SAASC,OAAT,OAA6B;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AAC5B,QAAM,CAAEC,YAAF,IAAmBL,gBAAgB,CAAE,sBAAF,CAAzC;AACA,QAAM,CAAEM,WAAF,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G,CAAC;AAAtC,KACGJ,MAAM,CACNK,KADA,CACO,CADP,EACU,CADV,EAEAC,GAFA,CAEK,QAAaC,KAAb;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WACL,4BAAC,8BAAD;AACC,MAAA,GAAG,EAAI,GAAGA,KAAO,IAAID,KAAO;AAD7B,OAGC,4BAAC,0BAAD;AAAgB,MAAA,UAAU,EAAGC;AAA7B,MAHD,CADK;AAAA,GAFL,CADH,CALD,EAgBC,4BAAC,oBAAD,QAAYL,iBAAZ,CAhBD,CAJD,CADD,CAFD,EA2BGJ,oBAAoB,IACrB,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,IAAI,EAAGU,cAFR;AAGC,IAAA,OAAO,EAAGV;AAHX,KAKG,cAAI,kBAAJ,CALH,CA5BF,CADD;AAuCA;;eAEcN,O","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\tFlexItem,\n\t__experimentalHStack as HStack,\n\t__experimentalZStack as ZStack,\n\t__experimentalVStack as VStack,\n\tColorIndicator,\n\tButton,\n} from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { shuffle } from '@wordpress/icons';\nimport { useMemo } from '@wordpress/element';\nimport { experiments as blockEditorExperiments } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport Subtitle from './subtitle';\nimport { NavigationButtonAsItem } from './navigation-button';\nimport { useColorRandomizer } from './hooks';\nimport ColorIndicatorWrapper from './color-indicator-wrapper';\nimport { unlock } from '../../experiments';\n\nconst { useGlobalSetting } = unlock( blockEditorExperiments );\n\nconst EMPTY_COLORS = [];\n\nfunction Palette( { name } ) {\n\tconst [ customColors ] = useGlobalSetting( 'color.palette.custom' );\n\tconst [ themeColors ] = useGlobalSetting( 'color.palette.theme' );\n\tconst [ defaultColors ] = useGlobalSetting( 'color.palette.default' );\n\n\tconst [ defaultPaletteEnabled ] = useGlobalSetting(\n\t\t'color.defaultPalette',\n\t\tname\n\t);\n\n\tconst [ randomizeThemeColors ] = useColorRandomizer();\n\n\tconst colors = useMemo(\n\t\t() => [\n\t\t\t...( customColors || EMPTY_COLORS ),\n\t\t\t...( themeColors || EMPTY_COLORS ),\n\t\t\t...( defaultColors && defaultPaletteEnabled\n\t\t\t\t? defaultColors\n\t\t\t\t: EMPTY_COLORS ),\n\t\t],\n\t\t[ customColors, themeColors, defaultColors, defaultPaletteEnabled ]\n\t);\n\n\tconst screenPath = ! name\n\t\t? '/colors/palette'\n\t\t: '/blocks/' + encodeURIComponent( name ) + '/colors/palette';\n\tconst paletteButtonText =\n\t\tcolors.length > 0\n\t\t\t? sprintf(\n\t\t\t\t\t// Translators: %d: Number of palette colors.\n\t\t\t\t\t_n( '%d color', '%d colors', colors.length ),\n\t\t\t\t\tcolors.length\n\t\t\t )\n\t\t\t: __( 'Add custom colors' );\n\n\treturn (\n\t\t<VStack spacing={ 3 }>\n\t\t\t<Subtitle>{ __( 'Palette' ) }</Subtitle>\n\t\t\t<ItemGroup isBordered isSeparated>\n\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\tpath={ screenPath }\n\t\t\t\t\taria-label={ __( 'Color palettes' ) }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tdirection={\n\t\t\t\t\t\t\tcolors.length === 0 ? 'row-reverse' : 'row'\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ZStack isLayered={ false } offset={ -8 }>\n\t\t\t\t\t\t\t{ colors\n\t\t\t\t\t\t\t\t.slice( 0, 5 )\n\t\t\t\t\t\t\t\t.map( ( { color }, index ) => (\n\t\t\t\t\t\t\t\t\t<ColorIndicatorWrapper\n\t\t\t\t\t\t\t\t\t\tkey={ `${ color }-${ index }` }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<ColorIndicator colorValue={ color } />\n\t\t\t\t\t\t\t\t\t</ColorIndicatorWrapper>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t</ZStack>\n\t\t\t\t\t\t<FlexItem>{ paletteButtonText }</FlexItem>\n\t\t\t\t\t</HStack>\n\t\t\t\t</NavigationButtonAsItem>\n\t\t\t</ItemGroup>\n\t\t\t{ randomizeThemeColors && (\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\ticon={ shuffle }\n\t\t\t\t\tonClick={ randomizeThemeColors }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Randomize colors' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport default Palette;\n"]}
|
|
@@ -13,9 +13,7 @@ var _components = require("@wordpress/components");
|
|
|
13
13
|
|
|
14
14
|
var _compose = require("@wordpress/compose");
|
|
15
15
|
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
var _useGlobalStylesOutput = require("./use-global-styles-output");
|
|
16
|
+
var _experiments = require("../../experiments");
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
19
|
* WordPress dependencies
|
|
@@ -24,6 +22,11 @@ var _useGlobalStylesOutput = require("./use-global-styles-output");
|
|
|
24
22
|
/**
|
|
25
23
|
* Internal dependencies
|
|
26
24
|
*/
|
|
25
|
+
const {
|
|
26
|
+
useGlobalSetting,
|
|
27
|
+
useGlobalStyle,
|
|
28
|
+
useGlobalStylesOutput
|
|
29
|
+
} = (0, _experiments.unlock)(_blockEditor.experiments);
|
|
27
30
|
const firstFrame = {
|
|
28
31
|
start: {
|
|
29
32
|
scale: 1,
|
|
@@ -62,19 +65,19 @@ const StylesPreview = _ref => {
|
|
|
62
65
|
isFocused,
|
|
63
66
|
withHoverView
|
|
64
67
|
} = _ref;
|
|
65
|
-
const [fontWeight] = (
|
|
66
|
-
const [fontFamily = 'serif'] = (
|
|
67
|
-
const [headingFontFamily = fontFamily] = (
|
|
68
|
-
const [headingFontWeight = fontWeight] = (
|
|
69
|
-
const [textColor = 'black'] = (
|
|
70
|
-
const [headingColor = textColor] = (
|
|
71
|
-
const [backgroundColor = 'white'] = (
|
|
72
|
-
const [gradientValue] = (
|
|
73
|
-
const [styles] =
|
|
68
|
+
const [fontWeight] = useGlobalStyle('typography.fontWeight');
|
|
69
|
+
const [fontFamily = 'serif'] = useGlobalStyle('typography.fontFamily');
|
|
70
|
+
const [headingFontFamily = fontFamily] = useGlobalStyle('elements.h1.typography.fontFamily');
|
|
71
|
+
const [headingFontWeight = fontWeight] = useGlobalStyle('elements.h1.typography.fontWeight');
|
|
72
|
+
const [textColor = 'black'] = useGlobalStyle('color.text');
|
|
73
|
+
const [headingColor = textColor] = useGlobalStyle('elements.h1.color.text');
|
|
74
|
+
const [backgroundColor = 'white'] = useGlobalStyle('color.background');
|
|
75
|
+
const [gradientValue] = useGlobalStyle('color.gradient');
|
|
76
|
+
const [styles] = useGlobalStylesOutput();
|
|
74
77
|
const disableMotion = (0, _compose.useReducedMotion)();
|
|
75
|
-
const [coreColors] = (
|
|
76
|
-
const [themeColors] = (
|
|
77
|
-
const [customColors] = (
|
|
78
|
+
const [coreColors] = useGlobalSetting('color.palette.core');
|
|
79
|
+
const [themeColors] = useGlobalSetting('color.palette.theme');
|
|
80
|
+
const [customColors] = useGlobalSetting('color.palette.custom');
|
|
78
81
|
const [isHovered, setIsHovered] = (0, _element.useState)(false);
|
|
79
82
|
const [containerResizeListener, {
|
|
80
83
|
width
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/preview.js"],"names":["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;;AAVA;;AAIA;;AAKA;;AAMA;;AACA;;AAnBA;AACA;AACA;;AAaA;AACA;AACA;AAIA,MAAMA,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;AAASC,IAAAA,SAAT;AAAoBC,IAAAA;AAApB,GAAyC;AAChE,QAAM,CAAEC,UAAF,IAAiB,qBAAU,uBAAV,CAAvB;AACA,QAAM,CAAEC,UAAU,GAAG,OAAf,IAA2B,qBAAU,uBAAV,CAAjC;AACA,QAAM,CAAEC,iBAAiB,GAAGD,UAAtB,IAAqC,qBAC1C,mCAD0C,CAA3C;AAGA,QAAM,CAAEE,iBAAiB,GAAGH,UAAtB,IAAqC,qBAC1C,mCAD0C,CAA3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,MAAAA,GAAG,EAAE;AALE;AAFT,KAUC,4BAAC,gCAAD;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;;eA8MeD,a","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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/preview.js"],"names":["useGlobalSetting","useGlobalStyle","useGlobalStylesOutput","blockEditorExperiments","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":";;;;;;;AAcA;;AAXA;;AAKA;;AAKA;;AAMA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,MAAM;AAAEA,EAAAA,gBAAF;AAAoBC,EAAAA,cAApB;A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AG,EAAE;AALE;AAFT,KAUC,4BAAC,gCAAD;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,CA9MD;;eAgNeD,a","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__unstableIframe as Iframe,\n\t__unstableEditorStyles as EditorStyles,\n\texperiments as blockEditorExperiments,\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 { unlock } from '../../experiments';\n\nconst { useGlobalSetting, useGlobalStyle, useGlobalStylesOutput } = unlock(\n\tblockEditorExperiments\n);\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 ] = useGlobalStyle( 'typography.fontWeight' );\n\tconst [ fontFamily = 'serif' ] = useGlobalStyle( 'typography.fontFamily' );\n\tconst [ headingFontFamily = fontFamily ] = useGlobalStyle(\n\t\t'elements.h1.typography.fontFamily'\n\t);\n\tconst [ headingFontWeight = fontWeight ] = useGlobalStyle(\n\t\t'elements.h1.typography.fontWeight'\n\t);\n\tconst [ textColor = 'black' ] = useGlobalStyle( 'color.text' );\n\tconst [ headingColor = textColor ] = useGlobalStyle(\n\t\t'elements.h1.color.text'\n\t);\n\tconst [ backgroundColor = 'white' ] = useGlobalStyle( 'color.background' );\n\tconst [ gradientValue ] = useGlobalStyle( 'color.gradient' );\n\tconst [ styles ] = useGlobalStylesOutput();\n\tconst disableMotion = useReducedMotion();\n\tconst [ coreColors ] = useGlobalSetting( 'color.palette.core' );\n\tconst [ themeColors ] = useGlobalSetting( 'color.palette.theme' );\n\tconst [ customColors ] = useGlobalSetting( '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"]}
|
|
@@ -11,6 +11,8 @@ var _element = require("@wordpress/element");
|
|
|
11
11
|
|
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
13
|
|
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
+
|
|
14
16
|
var _i18n = require("@wordpress/i18n");
|
|
15
17
|
|
|
16
18
|
var _blockEditor = require("@wordpress/block-editor");
|
|
@@ -19,6 +21,12 @@ var _header = _interopRequireDefault(require("./header"));
|
|
|
19
21
|
|
|
20
22
|
var _hooks = require("./hooks");
|
|
21
23
|
|
|
24
|
+
var _experiments = require("../../experiments");
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* External dependencies
|
|
28
|
+
*/
|
|
29
|
+
|
|
22
30
|
/**
|
|
23
31
|
* WordPress dependencies
|
|
24
32
|
*/
|
|
@@ -26,25 +34,29 @@ var _hooks = require("./hooks");
|
|
|
26
34
|
/**
|
|
27
35
|
* Internal dependencies
|
|
28
36
|
*/
|
|
37
|
+
const {
|
|
38
|
+
useGlobalSetting,
|
|
39
|
+
useGlobalStyle
|
|
40
|
+
} = (0, _experiments.unlock)(_blockEditor.experiments);
|
|
41
|
+
|
|
29
42
|
function ScreenBackgroundColor(_ref) {
|
|
30
43
|
let {
|
|
31
44
|
name,
|
|
32
|
-
|
|
45
|
+
variation = ''
|
|
33
46
|
} = _ref;
|
|
47
|
+
const prefix = variation ? `variations.${variation}.` : '';
|
|
34
48
|
const supports = (0, _hooks.getSupportedGlobalStylesPanels)(name);
|
|
35
|
-
const [
|
|
36
|
-
const [
|
|
37
|
-
const [areCustomSolidsEnabled] = (0, _hooks.useSetting)('color.custom', name);
|
|
38
|
-
const [areCustomGradientsEnabled] = (0, _hooks.useSetting)('color.customGradient', name);
|
|
49
|
+
const [areCustomSolidsEnabled] = useGlobalSetting('color.custom', name);
|
|
50
|
+
const [areCustomGradientsEnabled] = useGlobalSetting('color.customGradient', name);
|
|
39
51
|
const colorsPerOrigin = (0, _hooks.useColorsPerOrigin)(name);
|
|
40
52
|
const gradientsPerOrigin = (0, _hooks.useGradientsPerOrigin)(name);
|
|
41
|
-
const [isBackgroundEnabled] = (
|
|
42
|
-
const hasBackgroundColor = supports.includes('backgroundColor') && isBackgroundEnabled && (
|
|
43
|
-
const hasGradientColor = supports.includes('background') && (
|
|
44
|
-
const [backgroundColor, setBackgroundColor] = (
|
|
45
|
-
const [userBackgroundColor] = (
|
|
46
|
-
const [gradient, setGradient] = (
|
|
47
|
-
const [userGradient] = (
|
|
53
|
+
const [isBackgroundEnabled] = useGlobalSetting('color.background', name);
|
|
54
|
+
const hasBackgroundColor = supports.includes('backgroundColor') && isBackgroundEnabled && (colorsPerOrigin.length > 0 || areCustomSolidsEnabled);
|
|
55
|
+
const hasGradientColor = supports.includes('background') && (gradientsPerOrigin.length > 0 || areCustomGradientsEnabled);
|
|
56
|
+
const [backgroundColor, setBackgroundColor] = useGlobalStyle(prefix + 'color.background', name);
|
|
57
|
+
const [userBackgroundColor] = useGlobalStyle(prefix + 'color.background', name, 'user');
|
|
58
|
+
const [gradient, setGradient] = useGlobalStyle(prefix + 'color.gradient', name);
|
|
59
|
+
const [userGradient] = useGlobalStyle(prefix + 'color.gradient', name, 'user');
|
|
48
60
|
|
|
49
61
|
if (!hasBackgroundColor && !hasGradientColor) {
|
|
50
62
|
return null;
|
|
@@ -83,7 +95,9 @@ function ScreenBackgroundColor(_ref) {
|
|
|
83
95
|
title: (0, _i18n.__)('Background'),
|
|
84
96
|
description: (0, _i18n.__)('Set a background color or gradient for the whole site.')
|
|
85
97
|
}), (0, _element.createElement)(_blockEditor.__experimentalColorGradientControl, (0, _extends2.default)({
|
|
86
|
-
className:
|
|
98
|
+
className: (0, _classnames.default)('edit-site-screen-background-color__control', {
|
|
99
|
+
'has-no-tabs': !hasBackgroundColor || !hasGradientColor
|
|
100
|
+
}),
|
|
87
101
|
colors: colorsPerOrigin,
|
|
88
102
|
gradients: gradientsPerOrigin,
|
|
89
103
|
disableCustomColors: !areCustomSolidsEnabled,
|