@wordpress/edit-site 4.3.5 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/block-editor/index.js +1 -1
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +100 -79
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +3 -3
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/header.js +15 -11
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/navigation-button.js +4 -4
- package/build/components/global-styles/navigation-button.js.map +1 -1
- package/build/components/global-styles/palette.js +1 -1
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +1 -1
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +3 -3
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-root.js +13 -3
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +1 -1
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +18 -7
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +1 -5
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +1 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar/navigation-menu-sidebar/index.js +4 -2
- package/build/components/sidebar/navigation-menu-sidebar/index.js.map +1 -1
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -5
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build/index.js +0 -1
- package/build/index.js.map +1 -1
- package/build-module/components/block-editor/index.js +2 -2
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +103 -80
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +4 -4
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/header.js +16 -11
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/navigation-button.js +3 -3
- package/build-module/components/global-styles/navigation-button.js.map +1 -1
- package/build-module/components/global-styles/palette.js +2 -2
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +2 -2
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +4 -4
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +15 -5
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +2 -2
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +17 -7
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -5
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -3
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/index.js +4 -2
- package/build-module/components/sidebar/navigation-menu-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -5
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build-module/index.js +0 -1
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +58 -29
- package/build-style/style.css +58 -29
- package/package.json +29 -29
- package/src/components/block-editor/index.js +2 -2
- package/src/components/global-styles/border-panel.js +112 -109
- package/src/components/global-styles/context-menu.js +7 -7
- package/src/components/global-styles/header.js +20 -17
- package/src/components/global-styles/navigation-button.js +3 -3
- package/src/components/global-styles/palette.js +3 -3
- package/src/components/global-styles/screen-block-list.js +3 -3
- package/src/components/global-styles/screen-colors.js +7 -7
- package/src/components/global-styles/screen-root.js +34 -24
- package/src/components/global-styles/screen-typography.js +3 -3
- package/src/components/global-styles/test/use-global-styles-output.js +1 -0
- package/src/components/global-styles/use-global-styles-output.js +30 -7
- package/src/components/header/style.scss +14 -29
- package/src/components/secondary-sidebar/list-view-sidebar.js +1 -5
- package/src/components/sidebar/index.js +2 -2
- package/src/components/sidebar/navigation-menu-sidebar/index.js +4 -1
- package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -7
- package/src/components/sidebar/style.scss +56 -0
- package/src/index.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/index.js"],"names":["classnames","useSelect","useDispatch","useCallback","useRef","useEntityBlockEditor","store","coreStore","BlockList","BlockEditorProvider","__experimentalLinkControl","BlockInspector","BlockTools","__unstableBlockToolbarLastItem","__unstableBlockSettingsMenuFirstItem","__unstableUseTypingObserver","useTypingObserver","BlockEditorKeyboardShortcuts","blockEditorStore","__unstableBlockNameContext","useMergeRefs","useViewportMatch","ReusableBlocksMenuItems","listView","ToolbarButton","ToolbarGroup","__","interfaceStore","TemplatePartConverter","NavigateToLink","SidebarInspectorFill","editSiteStore","BlockInspectorButton","EditTemplatePartMenuButton","BackButton","ResizableEditor","LAYOUT","type","alignments","BlockEditor","setIsInserterOpen","settings","select","storedSettings","getSettings","__experimentalBlockPatterns","getBlockPatterns","__experimentalBlockPatternCategories","getBlockPatternCategories","templateType","templateId","page","getEditedPostType","getEditedPostId","getPage","blocks","onInput","onChange","setPage","enableComplementaryArea","openNavigationSidebar","contentRef","mergedRefs","isMobileViewport","clearSelectedBlock","isTemplatePart","NavMenuSidebarToggle","MaybeNavMenuSidebarToggle","process","env","IS_GUTENBERG_PLUGIN","fillProps","event","target","currentTarget","undefined","onClose","blockName"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB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D,QACC,cAAC,cAAD,OADD,CArBD,EAwBC,cAAC,UAAD;AACC,IAAA,SAAS,EAAGnD,UAAU,CAAE,yBAAF,EAA6B;AAClD,uBAAiBiE;AADiC,KAA7B,CADvB;AAIC,IAAA,oBAAoB,EAAGJ,UAJxB;AAKC,IAAA,OAAO,EAAKW,KAAF,IAAa;AACtB;AACA,UAAKA,KAAK,CAACC,MAAN,KAAiBD,KAAK,CAACE,aAA5B,EAA4C;AAC3CV,QAAAA,kBAAkB;AAClB;AACD;AAVF,KAYC,cAAC,4BAAD,CAA8B,QAA9B,OAZD,EAaC,cAAC,UAAD,OAbD,EAcC,cAAC,eAAD,CACC;AADD;AAEC,IAAA,GAAG,EAAGd,UAFP;AAGC,IAAA,cAAc,EACbe,cAAc,IACd;AACA,KAAEF,gBANJ;AAQC,IAAA,QAAQ,EAAGtB,QARZ;AASC,IAAA,UAAU,EAAGqB;AATd,KAWC,cAAC,SAAD;AACC,IAAA,SAAS,EAAC,mDADX;AAEC,IAAA,oBAAoB,EAAG1B,MAFxB;AAGC,IAAA,cAAc,EAAG6B,cAAc,GAAG,KAAH,GAAWU;AAH3C,IAXD,CAdD,EA+BC,cAAC,oCAAD,QACG;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WACD,cAAC,oBAAD;AAAsB,MAAA,OAAO,EAAGA;AAAhC,MADC;AAAA,GADH,CA/BD,EAoCC,cAAC,8BAAD,QACC,cAAC,0BAAD,CAA4B,QAA5B,QACKC,SAAF,IACDA,SAAS,KAAK,iBAAd,IACC,cAAC,yBAAD,OAHH,CADD,CApCD,CAxBD,EAsEC,cAAC,uBAAD,OAtED,CADD;AA0EA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport {\n\tBlockList,\n\tBlockEditorProvider,\n\t__experimentalLinkControl,\n\tBlockInspector,\n\tBlockTools,\n\t__unstableBlockToolbarLastItem,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tBlockEditorKeyboardShortcuts,\n\tstore as blockEditorStore,\n\t__unstableBlockNameContext,\n} from '@wordpress/block-editor';\nimport { useMergeRefs, useViewportMatch } from '@wordpress/compose';\nimport { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';\nimport { listView } from '@wordpress/icons';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartConverter from '../template-part-converter';\nimport NavigateToLink from '../navigate-to-link';\nimport { SidebarInspectorFill } from '../sidebar';\nimport { store as editSiteStore } from '../../store';\nimport BlockInspectorButton from './block-inspector-button';\nimport EditTemplatePartMenuButton from '../edit-template-part-menu-button';\nimport BackButton from './back-button';\nimport ResizableEditor from './resizable-editor';\n\nconst LAYOUT = {\n\ttype: 'default',\n\t// At the root level of the site editor, no alignments should be allowed.\n\talignments: [],\n};\n\nexport default function BlockEditor( { setIsInserterOpen } ) {\n\tconst { settings } = useSelect(\n\t\t( select ) => {\n\t\t\tlet storedSettings = select( editSiteStore ).getSettings(\n\t\t\t\tsetIsInserterOpen\n\t\t\t);\n\n\t\t\tif ( ! storedSettings.__experimentalBlockPatterns ) {\n\t\t\t\tstoredSettings = {\n\t\t\t\t\t...storedSettings,\n\t\t\t\t\t__experimentalBlockPatterns: select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getBlockPatterns(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( ! storedSettings.__experimentalBlockPatternCategories ) {\n\t\t\t\tstoredSettings = {\n\t\t\t\t\t...storedSettings,\n\t\t\t\t\t__experimentalBlockPatternCategories: select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getBlockPatternCategories(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsettings: storedSettings,\n\t\t\t};\n\t\t},\n\t\t[ setIsInserterOpen ]\n\t);\n\n\tconst { templateType, templateId, page } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostType, getEditedPostId, getPage } = select(\n\t\t\t\teditSiteStore\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\ttemplateType: getEditedPostType(),\n\t\t\t\ttemplateId: getEditedPostId(),\n\t\t\t\tpage: getPage(),\n\t\t\t};\n\t\t},\n\t\t[ setIsInserterOpen ]\n\t);\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\ttemplateType\n\t);\n\tconst { setPage } = useDispatch( editSiteStore );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst openNavigationSidebar = useCallback( () => {\n\t\tenableComplementaryArea(\n\t\t\t'core/edit-site',\n\t\t\t'edit-site/navigation-menu'\n\t\t);\n\t}, [ enableComplementaryArea ] );\n\tconst contentRef = useRef();\n\tconst mergedRefs = useMergeRefs( [ contentRef, useTypingObserver() ] );\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tconst isTemplatePart = templateType === 'wp_template_part';\n\n\tconst NavMenuSidebarToggle = () => (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ __( 'Open list view' ) }\n\t\t\t\tonClick={ openNavigationSidebar }\n\t\t\t\ticon={ listView }\n\t\t\t/>\n\t\t</ToolbarGroup>\n\t);\n\n\t// Conditionally include NavMenu sidebar in Plugin only.\n\t// Optimise for dead code elimination.\n\t// See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.\n\tlet MaybeNavMenuSidebarToggle = 'Fragment';\n\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\tMaybeNavMenuSidebarToggle = NavMenuSidebarToggle;\n\t}\n\n\treturn (\n\t\t<BlockEditorProvider\n\t\t\tsettings={ settings }\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t<EditTemplatePartMenuButton />\n\t\t\t<TemplatePartConverter />\n\t\t\t<__experimentalLinkControl.ViewerFill>\n\t\t\t\t{ useCallback(\n\t\t\t\t\t( fillProps ) => (\n\t\t\t\t\t\t<NavigateToLink\n\t\t\t\t\t\t\t{ ...fillProps }\n\t\t\t\t\t\t\tactivePage={ page }\n\t\t\t\t\t\t\tonActivePageChange={ setPage }\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\t[ page ]\n\t\t\t\t) }\n\t\t\t</__experimentalLinkControl.ViewerFill>\n\t\t\t<SidebarInspectorFill>\n\t\t\t\t<BlockInspector />\n\t\t\t</SidebarInspectorFill>\n\t\t\t<BlockTools\n\t\t\t\tclassName={ classnames( 'edit-site-visual-editor', {\n\t\t\t\t\t'is-focus-mode': isTemplatePart,\n\t\t\t\t} ) }\n\t\t\t\t__unstableContentRef={ contentRef }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t// Clear selected block when clicking on the gray background.\n\t\t\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<BlockEditorKeyboardShortcuts.Register />\n\t\t\t\t<BackButton />\n\t\t\t\t<ResizableEditor\n\t\t\t\t\t// Reinitialize the editor and reset the states when the template changes.\n\t\t\t\t\tkey={ templateId }\n\t\t\t\t\tenableResizing={\n\t\t\t\t\t\tisTemplatePart &&\n\t\t\t\t\t\t// Disable resizing in mobile viewport.\n\t\t\t\t\t\t! isMobileViewport\n\t\t\t\t\t}\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tcontentRef={ mergedRefs }\n\t\t\t\t>\n\t\t\t\t\t<BlockList\n\t\t\t\t\t\tclassName=\"edit-site-block-editor__block-list wp-site-blocks\"\n\t\t\t\t\t\t__experimentalLayout={ LAYOUT }\n\t\t\t\t\t\trenderAppender={ isTemplatePart ? false : undefined }\n\t\t\t\t\t/>\n\t\t\t\t</ResizableEditor>\n\t\t\t\t<__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<BlockInspectorButton onClick={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t</__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t<__unstableBlockToolbarLastItem>\n\t\t\t\t\t<__unstableBlockNameContext.Consumer>\n\t\t\t\t\t\t{ ( blockName ) =>\n\t\t\t\t\t\t\tblockName === 'core/navigation' && (\n\t\t\t\t\t\t\t\t<MaybeNavMenuSidebarToggle />\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</__unstableBlockNameContext.Consumer>\n\t\t\t\t</__unstableBlockToolbarLastItem>\n\t\t\t</BlockTools>\n\t\t\t<ReusableBlocksMenuItems />\n\t\t</BlockEditorProvider>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/index.js"],"names":["classnames","useSelect","useDispatch","useCallback","useRef","Fragment","useEntityBlockEditor","store","coreStore","BlockList","BlockEditorProvider","__experimentalLinkControl","BlockInspector","BlockTools","__unstableBlockToolbarLastItem","__unstableBlockSettingsMenuFirstItem","__unstableUseTypingObserver","useTypingObserver","BlockEditorKeyboardShortcuts","blockEditorStore","__unstableBlockNameContext","useMergeRefs","useViewportMatch","ReusableBlocksMenuItems","listView","ToolbarButton","ToolbarGroup","__","interfaceStore","TemplatePartConverter","NavigateToLink","SidebarInspectorFill","editSiteStore","BlockInspectorButton","EditTemplatePartMenuButton","BackButton","ResizableEditor","LAYOUT","type","alignments","BlockEditor","setIsInserterOpen","settings","select","storedSettings","getSettings","__experimentalBlockPatterns","getBlockPatterns","__experimentalBlockPatternCategories","getBlockPatternCategories","templateType","templateId","page","getEditedPostType","getEditedPostId","getPage","blocks","onInput","onChange","setPage","enableComplementaryArea","openNavigationSidebar","contentRef","mergedRefs","isMobileViewport","clearSelectedBlock","isTemplatePart","NavMenuSidebarToggle","MaybeNavMenuSidebarToggle","process","env","IS_GUTENBERG_PLUGIN","fillProps","event","target","currentTarget","undefined","onClose","blockName"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,WAAT,EAAsBC,MAAtB,EAA8BC,QAA9B,QAA8C,oBAA9C;AACA,SAASC,oBAAT,EAA+BC,KAAK,IAAIC,SAAxC,QAAyD,sBAAzD;AACA,SACCC,SADD,EAECC,mBAFD,EAGCC,yBAHD,EAICC,cAJD,EAKCC,UALD,EAMCC,8BAND,EAOCC,oCAPD,EAQCC,2BAA2B,IAAIC,iBARhC,EASCC,4BATD,EAUCX,KAAK,IAAIY,gBAVV,EAWCC,0BAXD,QAYO,yBAZP;AAaA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,oBAA/C;AACA,SAASC,uBAAT,QAAwC,4BAAxC;AACA,SAASC,QAAT,QAAyB,kBAAzB;AACA,SAASC,aAAT,EAAwBC,YAAxB,QAA4C,uBAA5C;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASpB,KAAK,IAAIqB,cAAlB,QAAwC,sBAAxC;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,SAASC,oBAAT,QAAqC,YAArC;AACA,SAASxB,KAAK,IAAIyB,aAAlB,QAAuC,aAAvC;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,0BAAP,MAAuC,mCAAvC;AACA,OAAOC,UAAP,MAAuB,e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AC,8BAAD,QACC,cAAC,0BAAD,CAA4B,QAA5B,QACKC,SAAF,IACDA,SAAS,KAAK,iBAAd,IACC,cAAC,yBAAD,OAHH,CADD,CApCD,CAxBD,EAsEC,cAAC,uBAAD,OAtED,CADD;AA0EA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useRef, Fragment } from '@wordpress/element';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport {\n\tBlockList,\n\tBlockEditorProvider,\n\t__experimentalLinkControl,\n\tBlockInspector,\n\tBlockTools,\n\t__unstableBlockToolbarLastItem,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tBlockEditorKeyboardShortcuts,\n\tstore as blockEditorStore,\n\t__unstableBlockNameContext,\n} from '@wordpress/block-editor';\nimport { useMergeRefs, useViewportMatch } from '@wordpress/compose';\nimport { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';\nimport { listView } from '@wordpress/icons';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartConverter from '../template-part-converter';\nimport NavigateToLink from '../navigate-to-link';\nimport { SidebarInspectorFill } from '../sidebar';\nimport { store as editSiteStore } from '../../store';\nimport BlockInspectorButton from './block-inspector-button';\nimport EditTemplatePartMenuButton from '../edit-template-part-menu-button';\nimport BackButton from './back-button';\nimport ResizableEditor from './resizable-editor';\n\nconst LAYOUT = {\n\ttype: 'default',\n\t// At the root level of the site editor, no alignments should be allowed.\n\talignments: [],\n};\n\nexport default function BlockEditor( { setIsInserterOpen } ) {\n\tconst { settings } = useSelect(\n\t\t( select ) => {\n\t\t\tlet storedSettings = select( editSiteStore ).getSettings(\n\t\t\t\tsetIsInserterOpen\n\t\t\t);\n\n\t\t\tif ( ! storedSettings.__experimentalBlockPatterns ) {\n\t\t\t\tstoredSettings = {\n\t\t\t\t\t...storedSettings,\n\t\t\t\t\t__experimentalBlockPatterns: select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getBlockPatterns(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( ! storedSettings.__experimentalBlockPatternCategories ) {\n\t\t\t\tstoredSettings = {\n\t\t\t\t\t...storedSettings,\n\t\t\t\t\t__experimentalBlockPatternCategories: select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getBlockPatternCategories(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsettings: storedSettings,\n\t\t\t};\n\t\t},\n\t\t[ setIsInserterOpen ]\n\t);\n\n\tconst { templateType, templateId, page } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostType, getEditedPostId, getPage } = select(\n\t\t\t\teditSiteStore\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\ttemplateType: getEditedPostType(),\n\t\t\t\ttemplateId: getEditedPostId(),\n\t\t\t\tpage: getPage(),\n\t\t\t};\n\t\t},\n\t\t[ setIsInserterOpen ]\n\t);\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\ttemplateType\n\t);\n\tconst { setPage } = useDispatch( editSiteStore );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst openNavigationSidebar = useCallback( () => {\n\t\tenableComplementaryArea(\n\t\t\t'core/edit-site',\n\t\t\t'edit-site/navigation-menu'\n\t\t);\n\t}, [ enableComplementaryArea ] );\n\tconst contentRef = useRef();\n\tconst mergedRefs = useMergeRefs( [ contentRef, useTypingObserver() ] );\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tconst isTemplatePart = templateType === 'wp_template_part';\n\n\tconst NavMenuSidebarToggle = () => (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ __( 'Open list view' ) }\n\t\t\t\tonClick={ openNavigationSidebar }\n\t\t\t\ticon={ listView }\n\t\t\t/>\n\t\t</ToolbarGroup>\n\t);\n\n\t// Conditionally include NavMenu sidebar in Plugin only.\n\t// Optimise for dead code elimination.\n\t// See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.\n\tlet MaybeNavMenuSidebarToggle = Fragment;\n\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\tMaybeNavMenuSidebarToggle = NavMenuSidebarToggle;\n\t}\n\n\treturn (\n\t\t<BlockEditorProvider\n\t\t\tsettings={ settings }\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t<EditTemplatePartMenuButton />\n\t\t\t<TemplatePartConverter />\n\t\t\t<__experimentalLinkControl.ViewerFill>\n\t\t\t\t{ useCallback(\n\t\t\t\t\t( fillProps ) => (\n\t\t\t\t\t\t<NavigateToLink\n\t\t\t\t\t\t\t{ ...fillProps }\n\t\t\t\t\t\t\tactivePage={ page }\n\t\t\t\t\t\t\tonActivePageChange={ setPage }\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\t[ page ]\n\t\t\t\t) }\n\t\t\t</__experimentalLinkControl.ViewerFill>\n\t\t\t<SidebarInspectorFill>\n\t\t\t\t<BlockInspector />\n\t\t\t</SidebarInspectorFill>\n\t\t\t<BlockTools\n\t\t\t\tclassName={ classnames( 'edit-site-visual-editor', {\n\t\t\t\t\t'is-focus-mode': isTemplatePart,\n\t\t\t\t} ) }\n\t\t\t\t__unstableContentRef={ contentRef }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t// Clear selected block when clicking on the gray background.\n\t\t\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<BlockEditorKeyboardShortcuts.Register />\n\t\t\t\t<BackButton />\n\t\t\t\t<ResizableEditor\n\t\t\t\t\t// Reinitialize the editor and reset the states when the template changes.\n\t\t\t\t\tkey={ templateId }\n\t\t\t\t\tenableResizing={\n\t\t\t\t\t\tisTemplatePart &&\n\t\t\t\t\t\t// Disable resizing in mobile viewport.\n\t\t\t\t\t\t! isMobileViewport\n\t\t\t\t\t}\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tcontentRef={ mergedRefs }\n\t\t\t\t>\n\t\t\t\t\t<BlockList\n\t\t\t\t\t\tclassName=\"edit-site-block-editor__block-list wp-site-blocks\"\n\t\t\t\t\t\t__experimentalLayout={ LAYOUT }\n\t\t\t\t\t\trenderAppender={ isTemplatePart ? false : undefined }\n\t\t\t\t\t/>\n\t\t\t\t</ResizableEditor>\n\t\t\t\t<__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<BlockInspectorButton onClick={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t</__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t<__unstableBlockToolbarLastItem>\n\t\t\t\t\t<__unstableBlockNameContext.Consumer>\n\t\t\t\t\t\t{ ( blockName ) =>\n\t\t\t\t\t\t\tblockName === 'core/navigation' && (\n\t\t\t\t\t\t\t\t<MaybeNavMenuSidebarToggle />\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</__unstableBlockNameContext.Consumer>\n\t\t\t\t</__unstableBlockToolbarLastItem>\n\t\t\t</BlockTools>\n\t\t\t<ReusableBlocksMenuItems />\n\t\t</BlockEditorProvider>\n\t);\n}\n"]}
|
|
@@ -3,15 +3,15 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { __experimentalBorderRadiusControl as BorderRadiusControl
|
|
7
|
-
import {
|
|
6
|
+
import { __experimentalBorderRadiusControl as BorderRadiusControl } from '@wordpress/block-editor';
|
|
7
|
+
import { __experimentalBorderBoxControl as BorderBoxControl, __experimentalHasSplitBorders as hasSplitBorders, __experimentalIsDefinedBorder as isDefinedBorder, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
|
|
8
|
+
import { useCallback } from '@wordpress/element';
|
|
8
9
|
import { __ } from '@wordpress/i18n';
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
import { getSupportedGlobalStylesPanels, useColorsPerOrigin, useSetting, useStyle } from './hooks';
|
|
14
|
-
const MIN_BORDER_WIDTH = 0;
|
|
15
15
|
export function useHasBorderPanel(name) {
|
|
16
16
|
const controls = [useHasBorderColorControl(name), useHasBorderRadiusControl(name), useHasBorderStyleControl(name), useHasBorderWidthControl(name)];
|
|
17
17
|
return controls.some(Boolean);
|
|
@@ -37,6 +37,37 @@ function useHasBorderWidthControl(name) {
|
|
|
37
37
|
return useSetting('border.width', name)[0] && supports.includes('borderWidth');
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
function applyFallbackStyle(border) {
|
|
41
|
+
if (!border) {
|
|
42
|
+
return border;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!border.style && (border.color || border.width)) {
|
|
46
|
+
return { ...border,
|
|
47
|
+
style: 'solid'
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return border;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function applyAllFallbackStyles(border) {
|
|
55
|
+
if (!border) {
|
|
56
|
+
return border;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (hasSplitBorders(border)) {
|
|
60
|
+
return {
|
|
61
|
+
top: applyFallbackStyle(border.top),
|
|
62
|
+
right: applyFallbackStyle(border.right),
|
|
63
|
+
bottom: applyFallbackStyle(border.bottom),
|
|
64
|
+
left: applyFallbackStyle(border.left)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return applyFallbackStyle(border);
|
|
69
|
+
}
|
|
70
|
+
|
|
40
71
|
export default function BorderPanel(_ref) {
|
|
41
72
|
let {
|
|
42
73
|
name
|
|
@@ -44,46 +75,11 @@ export default function BorderPanel(_ref) {
|
|
|
44
75
|
// To better reflect if the user has customized a value we need to
|
|
45
76
|
// ensure the style value being checked is from the `user` origin.
|
|
46
77
|
const [userBorderStyles] = useStyle('border', name, 'user');
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const createResetCallback = setStyle => () => setStyle(undefined);
|
|
51
|
-
|
|
52
|
-
const handleOnChange = setStyle => value => {
|
|
53
|
-
setStyle(value || undefined);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const units = useCustomUnits({
|
|
57
|
-
availableUnits: useSetting('spacing.units')[0] || ['px', 'em', 'rem']
|
|
58
|
-
}); // Border width.
|
|
59
|
-
|
|
60
|
-
const showBorderWidth = useHasBorderWidthControl(name);
|
|
61
|
-
const [borderWidthValue, setBorderWidth] = useStyle('border.width', name); // Border style.
|
|
62
|
-
|
|
63
|
-
const showBorderStyle = useHasBorderStyleControl(name);
|
|
64
|
-
const [borderStyle, setBorderStyle] = useStyle('border.style', name); // When we set a border color or width ensure we have a style so the user
|
|
65
|
-
// can see a visible border.
|
|
66
|
-
|
|
67
|
-
const handleOnChangeWithStyle = setStyle => value => {
|
|
68
|
-
if (!!value && !borderStyle) {
|
|
69
|
-
setBorderStyle('solid');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
setStyle(value || undefined);
|
|
73
|
-
}; // Border color.
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
const [border, setBorder] = useStyle('border', name);
|
|
79
|
+
const colors = useColorsPerOrigin(name);
|
|
76
80
|
const showBorderColor = useHasBorderColorControl(name);
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const disableCustomGradients = !useSetting('color.customGradient')[0];
|
|
80
|
-
const borderColorSettings = [{
|
|
81
|
-
label: __('Color'),
|
|
82
|
-
colors: useColorsPerOrigin(name),
|
|
83
|
-
colorValue: borderColor,
|
|
84
|
-
onColorChange: handleOnChangeWithStyle(setBorderColor),
|
|
85
|
-
clearable: false
|
|
86
|
-
}]; // Border radius.
|
|
81
|
+
const showBorderStyle = useHasBorderStyleControl(name);
|
|
82
|
+
const showBorderWidth = useHasBorderWidthControl(name); // Border radius.
|
|
87
83
|
|
|
88
84
|
const showBorderRadius = useHasBorderRadiusControl(name);
|
|
89
85
|
const [borderRadiusValues, setBorderRadius] = useStyle('border.radius', name);
|
|
@@ -98,57 +94,84 @@ export default function BorderPanel(_ref) {
|
|
|
98
94
|
return !!borderValues;
|
|
99
95
|
};
|
|
100
96
|
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
97
|
+
const resetBorder = () => {
|
|
98
|
+
if (hasBorderRadius()) {
|
|
99
|
+
return setBorder({
|
|
100
|
+
radius: userBorderStyles.radius
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
setBorder(undefined);
|
|
106
105
|
};
|
|
107
106
|
|
|
107
|
+
const resetAll = useCallback(() => setBorder(undefined), [setBorder]);
|
|
108
|
+
const onBorderChange = useCallback(newBorder => {
|
|
109
|
+
// Ensure we have a visible border style when a border width or
|
|
110
|
+
// color is being selected.
|
|
111
|
+
const newBorderWithStyle = applyAllFallbackStyles(newBorder); // As we can't conditionally generate styles based on if other
|
|
112
|
+
// style properties have been set we need to force split border
|
|
113
|
+
// definitions for user set border styles. Border radius is derived
|
|
114
|
+
// from the same property i.e. `border.radius` if it is a string
|
|
115
|
+
// that is used. The longhand border radii styles are only generated
|
|
116
|
+
// if that property is an object.
|
|
117
|
+
//
|
|
118
|
+
// For borders (color, style, and width) those are all properties on
|
|
119
|
+
// the `border` style property. This means if the theme.json defined
|
|
120
|
+
// split borders and the user condenses them into a flat border or
|
|
121
|
+
// vice-versa we'd get both sets of styles which would conflict.
|
|
122
|
+
|
|
123
|
+
const updatedBorder = !hasSplitBorders(newBorderWithStyle) ? {
|
|
124
|
+
top: newBorderWithStyle,
|
|
125
|
+
right: newBorderWithStyle,
|
|
126
|
+
bottom: newBorderWithStyle,
|
|
127
|
+
left: newBorderWithStyle
|
|
128
|
+
} : {
|
|
129
|
+
color: null,
|
|
130
|
+
style: null,
|
|
131
|
+
width: null,
|
|
132
|
+
...newBorderWithStyle
|
|
133
|
+
}; // As radius is maintained separately to color, style, and width
|
|
134
|
+
// maintain its value. Undefined values here will be cleaned when
|
|
135
|
+
// global styles are saved.
|
|
136
|
+
|
|
137
|
+
setBorder({
|
|
138
|
+
radius: border === null || border === void 0 ? void 0 : border.radius,
|
|
139
|
+
...updatedBorder
|
|
140
|
+
});
|
|
141
|
+
}, [setBorder]);
|
|
108
142
|
return createElement(ToolsPanel, {
|
|
109
143
|
label: __('Border'),
|
|
110
144
|
resetAll: resetAll
|
|
111
|
-
}, showBorderWidth && createElement(ToolsPanelItem, {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
onDeselect: createResetCallback(setBorderWidth),
|
|
116
|
-
isShownByDefault: true
|
|
117
|
-
}, createElement(UnitControl, {
|
|
118
|
-
value: borderWidthValue,
|
|
119
|
-
label: __('Width'),
|
|
120
|
-
min: MIN_BORDER_WIDTH,
|
|
121
|
-
onChange: handleOnChangeWithStyle(setBorderWidth),
|
|
122
|
-
units: units
|
|
123
|
-
})), showBorderStyle && createElement(ToolsPanelItem, {
|
|
124
|
-
className: "single-column",
|
|
125
|
-
hasValue: createHasValueCallback('style'),
|
|
126
|
-
label: __('Style'),
|
|
127
|
-
onDeselect: createResetCallback(setBorderStyle),
|
|
128
|
-
isShownByDefault: true
|
|
129
|
-
}, createElement(BorderStyleControl, {
|
|
130
|
-
value: borderStyle,
|
|
131
|
-
onChange: handleOnChange(setBorderStyle)
|
|
132
|
-
})), showBorderColor && createElement(ToolsPanelItem, {
|
|
133
|
-
hasValue: createHasValueCallback('color'),
|
|
134
|
-
label: __('Color'),
|
|
135
|
-
onDeselect: createResetCallback(setBorderColor),
|
|
145
|
+
}, (showBorderWidth || showBorderColor) && createElement(ToolsPanelItem, {
|
|
146
|
+
hasValue: () => isDefinedBorder(userBorderStyles),
|
|
147
|
+
label: __('Border'),
|
|
148
|
+
onDeselect: () => resetBorder(),
|
|
136
149
|
isShownByDefault: true
|
|
137
|
-
}, createElement(
|
|
138
|
-
|
|
139
|
-
__experimentalIsRenderedInSidebar: true,
|
|
140
|
-
disableCustomColors: disableCustomColors,
|
|
141
|
-
disableCustomGradients: disableCustomGradients,
|
|
150
|
+
}, createElement(BorderBoxControl, {
|
|
151
|
+
colors: colors,
|
|
142
152
|
enableAlpha: true,
|
|
143
|
-
|
|
153
|
+
onChange: onBorderChange,
|
|
154
|
+
showStyle: showBorderStyle,
|
|
155
|
+
value: border,
|
|
156
|
+
popoverClassNames: {
|
|
157
|
+
linked: 'edit-site-global-styles-sidebar__border-box-control__popover',
|
|
158
|
+
top: 'edit-site-global-styles-sidebar__border-box-control__popover-top',
|
|
159
|
+
right: 'edit-site-global-styles-sidebar__border-box-control__popover-right',
|
|
160
|
+
bottom: 'edit-site-global-styles-sidebar__border-box-control__popover-bottom',
|
|
161
|
+
left: 'edit-site-global-styles-sidebar__border-box-control__popover-left'
|
|
162
|
+
},
|
|
163
|
+
__experimentalHasMultipleOrigins: true,
|
|
164
|
+
__experimentalIsRenderedInSidebar: true
|
|
144
165
|
})), showBorderRadius && createElement(ToolsPanelItem, {
|
|
145
166
|
hasValue: hasBorderRadius,
|
|
146
167
|
label: __('Radius'),
|
|
147
|
-
onDeselect:
|
|
168
|
+
onDeselect: () => setBorderRadius(undefined),
|
|
148
169
|
isShownByDefault: true
|
|
149
170
|
}, createElement(BorderRadiusControl, {
|
|
150
171
|
values: borderRadiusValues,
|
|
151
|
-
onChange:
|
|
172
|
+
onChange: value => {
|
|
173
|
+
setBorderRadius(value || undefined);
|
|
174
|
+
}
|
|
152
175
|
})));
|
|
153
176
|
}
|
|
154
177
|
//# sourceMappingURL=border-panel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/border-panel.js"],"names":["__experimentalBorderRadiusControl","BorderRadiusControl","__experimentalBorderStyleControl","BorderStyleControl","__experimentalColorGradientSettingsDropdown","ColorGradientSettingsDropdown","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__experimentalUnitControl","UnitControl","__experimentalUseCustomUnits","useCustomUnits","__","getSupportedGlobalStylesPanels","useColorsPerOrigin","useSetting","useStyle","MIN_BORDER_WIDTH","useHasBorderPanel","name","controls","useHasBorderColorControl","useHasBorderRadiusControl","useHasBorderStyleControl","useHasBorderWidthControl","some","Boolean","supports","includes","BorderPanel","userBorderStyles","createHasValueCallback","feature","createResetCallback","setStyle","undefined","handleOnChange","value","units","availableUnits","showBorderWidth","borderWidthValue","setBorderWidth","showBorderStyle","borderStyle","setBorderStyle","handleOnChangeWithStyle","showBorderColor","borderColor","setBorderColor","disableCustomColors","disableCustomGradients","borderColorSettings","label","colors","colorValue","onColorChange","clearable","showBorderRadius","borderRadiusValues","setBorderRadius","hasBorderRadius","borderValues","radius","Object","entries","resetAll"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,iCAAiC,IAAIC,mBADtC,EAECC,gCAAgC,IAAIC,kBAFrC,EAGCC,2CAA2C,IAAIC,6BAHhD,QAIO,yBAJP;AAKA,SACCC,wBAAwB,IAAIC,UAD7B,EAECC,4BAA4B,IAAIC,cAFjC,EAGCC,yBAAyB,IAAIC,WAH9B,EAICC,4BAA4B,IAAIC,cAJjC,QAKO,uBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SACCC,8BADD,E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A,gBAAgB,EAAG;AAJpB,KAMC,cAAC,6BAAD;AACC,IAAA,gCAAgC,MADjC;AAEC,IAAA,iCAAiC,MAFlC;AAGC,IAAA,mBAAmB,EAAGC,mBAHvB;AAIC,IAAA,sBAAsB,EAAGC,sBAJ1B;AAKC,IAAA,WAAW,MALZ;AAMC,IAAA,QAAQ,EAAGC;AANZ,IAND,CAjCF,EAiDGM,gBAAgB,IACjB,cAAC,cAAD;AACC,IAAA,QAAQ,EAAGG,eADZ;AAEC,IAAA,KAAK,EAAGjD,EAAE,CAAE,QAAF,CAFX;AAGC,IAAA,UAAU,EAAGqB,mBAAmB,CAAE2B,eAAF,CAHjC;AAIC,IAAA,gBAAgB,EAAG;AAJpB,KAMC,cAAC,mBAAD;AACC,IAAA,MAAM,EAAGD,kBADV;AAEC,IAAA,QAAQ,EAAGvB,cAAc,CAAEwB,eAAF;AAF1B,IAND,CAlDF,CADD;AAiEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalBorderRadiusControl as BorderRadiusControl,\n\t__experimentalBorderStyleControl as BorderStyleControl,\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n} from '@wordpress/block-editor';\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetSupportedGlobalStylesPanels,\n\tuseColorsPerOrigin,\n\tuseSetting,\n\tuseStyle,\n} from './hooks';\n\nconst MIN_BORDER_WIDTH = 0;\n\nexport function useHasBorderPanel( name ) {\n\tconst controls = [\n\t\tuseHasBorderColorControl( name ),\n\t\tuseHasBorderRadiusControl( name ),\n\t\tuseHasBorderStyleControl( name ),\n\t\tuseHasBorderWidthControl( name ),\n\t];\n\n\treturn controls.some( Boolean );\n}\n\nfunction useHasBorderColorControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.color', name )[ 0 ] &&\n\t\tsupports.includes( 'borderColor' )\n\t);\n}\n\nfunction useHasBorderRadiusControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.radius', name )[ 0 ] &&\n\t\tsupports.includes( 'borderRadius' )\n\t);\n}\n\nfunction useHasBorderStyleControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.style', name )[ 0 ] &&\n\t\tsupports.includes( 'borderStyle' )\n\t);\n}\n\nfunction useHasBorderWidthControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.width', name )[ 0 ] &&\n\t\tsupports.includes( 'borderWidth' )\n\t);\n}\n\nexport default function BorderPanel( { name } ) {\n\t// To better reflect if the user has customized a value we need to\n\t// ensure the style value being checked is from the `user` origin.\n\tconst [ userBorderStyles ] = useStyle( 'border', name, 'user' );\n\tconst createHasValueCallback = ( feature ) => () =>\n\t\t!! userBorderStyles?.[ feature ];\n\n\tconst createResetCallback = ( setStyle ) => () => setStyle( undefined );\n\n\tconst handleOnChange = ( setStyle ) => ( value ) => {\n\t\tsetStyle( value || undefined );\n\t};\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' )[ 0 ] || [\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t],\n\t} );\n\n\t// Border width.\n\tconst showBorderWidth = useHasBorderWidthControl( name );\n\tconst [ borderWidthValue, setBorderWidth ] = useStyle(\n\t\t'border.width',\n\t\tname\n\t);\n\n\t// Border style.\n\tconst showBorderStyle = useHasBorderStyleControl( name );\n\tconst [ borderStyle, setBorderStyle ] = useStyle( 'border.style', name );\n\n\t// When we set a border color or width ensure we have a style so the user\n\t// can see a visible border.\n\tconst handleOnChangeWithStyle = ( setStyle ) => ( value ) => {\n\t\tif ( !! value && ! borderStyle ) {\n\t\t\tsetBorderStyle( 'solid' );\n\t\t}\n\n\t\tsetStyle( value || undefined );\n\t};\n\n\t// Border color.\n\tconst showBorderColor = useHasBorderColorControl( name );\n\tconst [ borderColor, setBorderColor ] = useStyle( 'border.color', name );\n\tconst disableCustomColors = ! useSetting( 'color.custom' )[ 0 ];\n\tconst disableCustomGradients = ! useSetting( 'color.customGradient' )[ 0 ];\n\n\tconst borderColorSettings = [\n\t\t{\n\t\t\tlabel: __( 'Color' ),\n\t\t\tcolors: useColorsPerOrigin( name ),\n\t\t\tcolorValue: borderColor,\n\t\t\tonColorChange: handleOnChangeWithStyle( setBorderColor ),\n\t\t\tclearable: false,\n\t\t},\n\t];\n\n\t// Border radius.\n\tconst showBorderRadius = useHasBorderRadiusControl( name );\n\tconst [ borderRadiusValues, setBorderRadius ] = useStyle(\n\t\t'border.radius',\n\t\tname\n\t);\n\tconst hasBorderRadius = () => {\n\t\tconst borderValues = userBorderStyles?.radius;\n\t\tif ( typeof borderValues === 'object' ) {\n\t\t\treturn Object.entries( borderValues ).some( Boolean );\n\t\t}\n\t\treturn !! borderValues;\n\t};\n\n\tconst resetAll = () => {\n\t\tsetBorderColor( undefined );\n\t\tsetBorderRadius( undefined );\n\t\tsetBorderStyle( undefined );\n\t\tsetBorderWidth( undefined );\n\t};\n\n\treturn (\n\t\t<ToolsPanel label={ __( 'Border' ) } resetAll={ resetAll }>\n\t\t\t{ showBorderWidth && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ createHasValueCallback( 'width' ) }\n\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\tonDeselect={ createResetCallback( setBorderWidth ) }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tvalue={ borderWidthValue }\n\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\tmin={ MIN_BORDER_WIDTH }\n\t\t\t\t\t\tonChange={ handleOnChangeWithStyle( setBorderWidth ) }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderStyle && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ createHasValueCallback( 'style' ) }\n\t\t\t\t\tlabel={ __( 'Style' ) }\n\t\t\t\t\tonDeselect={ createResetCallback( setBorderStyle ) }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderStyleControl\n\t\t\t\t\t\tvalue={ borderStyle }\n\t\t\t\t\t\tonChange={ handleOnChange( setBorderStyle ) }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderColor && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ createHasValueCallback( 'color' ) }\n\t\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\t\tonDeselect={ createResetCallback( setBorderColor ) }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<ColorGradientSettingsDropdown\n\t\t\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\t\tdisableCustomGradients={ disableCustomGradients }\n\t\t\t\t\t\tenableAlpha\n\t\t\t\t\t\tsettings={ borderColorSettings }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderRadius && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasBorderRadius }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ createResetCallback( setBorderRadius ) }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusControl\n\t\t\t\t\t\tvalues={ borderRadiusValues }\n\t\t\t\t\t\tonChange={ handleOnChange( setBorderRadius ) }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</ToolsPanel>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/border-panel.js"],"names":["__experimentalBorderRadiusControl","BorderRadiusControl","__experimentalBorderBoxControl","BorderBoxControl","__experimentalHasSplitBorders","hasSplitBorders","__experimentalIsDefinedBorder","isDefinedBorder","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","useCallback","__","getSupportedGlobalStylesPanels","useColorsPerOrigin","useSetting","useStyle","useHasBorderPanel","name","controls","useHasBorderColorControl","useHasBorderRadiusControl","useHasBorderStyleControl","useHasBorderWidthControl","some","Boolean","supports","includes","applyFallbackStyle","border","style","color","width","applyAllFallbackStyles","top","right","bottom","left","BorderPanel","userBorderStyles","setBorder","colors","showBorderColor","showBorderStyle","showBorderWidth","showBorderRadius","borderRadiusValues","setBorderRadius","hasBorderRadius","borderValues","radius","Object","entries","resetBorder","undefined","resetAll","onBorderChange","newBorder","newBorderWithStyle","updatedBorder","linked","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,iCAAiC,IAAIC,mBAA9C,QAAyE,yBAAzE;AACA,SACCC,8BAA8B,IAAIC,gBADnC,EAECC,6BAA6B,IAAIC,eAFlC,EAGCC,6BAA6B,IAAIC,eAHlC,EAICC,wBAAwB,IAAIC,UAJ7B,EAKCC,4BAA4B,IAAIC,cALjC,QAMO,uBANP;AAOA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SACCC,8BADD,EAECC,kBAFD,EAGCC,UAHD,EAICC,QAJD,QAKO,SALP;AAOA,OAAO,SAASC,iBAAT,CAA4BC,IAA5B,EAAmC;AACzC,QAA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C,cAAC,mBAAD;AACC,IAAA,MAAM,EAAGR,kBADV;AAEC,IAAA,QAAQ,EAAKe,KAAF,IAAa;AACvBd,MAAAA,eAAe,CAAEc,KAAK,IAAIP,SAAX,CAAf;AACA;AAJF,IAND,CAhCF,CADD;AAiDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalBorderRadiusControl as BorderRadiusControl } from '@wordpress/block-editor';\nimport {\n\t__experimentalBorderBoxControl as BorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetSupportedGlobalStylesPanels,\n\tuseColorsPerOrigin,\n\tuseSetting,\n\tuseStyle,\n} from './hooks';\n\nexport function useHasBorderPanel( name ) {\n\tconst controls = [\n\t\tuseHasBorderColorControl( name ),\n\t\tuseHasBorderRadiusControl( name ),\n\t\tuseHasBorderStyleControl( name ),\n\t\tuseHasBorderWidthControl( name ),\n\t];\n\n\treturn controls.some( Boolean );\n}\n\nfunction useHasBorderColorControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.color', name )[ 0 ] &&\n\t\tsupports.includes( 'borderColor' )\n\t);\n}\n\nfunction useHasBorderRadiusControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.radius', name )[ 0 ] &&\n\t\tsupports.includes( 'borderRadius' )\n\t);\n}\n\nfunction useHasBorderStyleControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.style', name )[ 0 ] &&\n\t\tsupports.includes( 'borderStyle' )\n\t);\n}\n\nfunction useHasBorderWidthControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'border.width', name )[ 0 ] &&\n\t\tsupports.includes( 'borderWidth' )\n\t);\n}\n\nfunction applyFallbackStyle( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( ! border.style && ( border.color || border.width ) ) {\n\t\treturn { ...border, style: 'solid' };\n\t}\n\n\treturn border;\n}\n\nfunction applyAllFallbackStyles( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( hasSplitBorders( border ) ) {\n\t\treturn {\n\t\t\ttop: applyFallbackStyle( border.top ),\n\t\t\tright: applyFallbackStyle( border.right ),\n\t\t\tbottom: applyFallbackStyle( border.bottom ),\n\t\t\tleft: applyFallbackStyle( border.left ),\n\t\t};\n\t}\n\n\treturn applyFallbackStyle( border );\n}\n\nexport default function BorderPanel( { name } ) {\n\t// To better reflect if the user has customized a value we need to\n\t// ensure the style value being checked is from the `user` origin.\n\tconst [ userBorderStyles ] = useStyle( 'border', name, 'user' );\n\tconst [ border, setBorder ] = useStyle( 'border', name );\n\tconst colors = useColorsPerOrigin( name );\n\n\tconst showBorderColor = useHasBorderColorControl( name );\n\tconst showBorderStyle = useHasBorderStyleControl( name );\n\tconst showBorderWidth = useHasBorderWidthControl( name );\n\n\t// Border radius.\n\tconst showBorderRadius = useHasBorderRadiusControl( name );\n\tconst [ borderRadiusValues, setBorderRadius ] = useStyle(\n\t\t'border.radius',\n\t\tname\n\t);\n\tconst hasBorderRadius = () => {\n\t\tconst borderValues = userBorderStyles?.radius;\n\t\tif ( typeof borderValues === 'object' ) {\n\t\t\treturn Object.entries( borderValues ).some( Boolean );\n\t\t}\n\t\treturn !! borderValues;\n\t};\n\n\tconst resetBorder = () => {\n\t\tif ( hasBorderRadius() ) {\n\t\t\treturn setBorder( { radius: userBorderStyles.radius } );\n\t\t}\n\n\t\tsetBorder( undefined );\n\t};\n\n\tconst resetAll = useCallback( () => setBorder( undefined ), [ setBorder ] );\n\tconst onBorderChange = useCallback(\n\t\t( newBorder ) => {\n\t\t\t// Ensure we have a visible border style when a border width or\n\t\t\t// color is being selected.\n\t\t\tconst newBorderWithStyle = applyAllFallbackStyles( newBorder );\n\n\t\t\t// As we can't conditionally generate styles based on if other\n\t\t\t// style properties have been set we need to force split border\n\t\t\t// definitions for user set border styles. Border radius is derived\n\t\t\t// from the same property i.e. `border.radius` if it is a string\n\t\t\t// that is used. The longhand border radii styles are only generated\n\t\t\t// if that property is an object.\n\t\t\t//\n\t\t\t// For borders (color, style, and width) those are all properties on\n\t\t\t// the `border` style property. This means if the theme.json defined\n\t\t\t// split borders and the user condenses them into a flat border or\n\t\t\t// vice-versa we'd get both sets of styles which would conflict.\n\t\t\tconst updatedBorder = ! hasSplitBorders( newBorderWithStyle )\n\t\t\t\t? {\n\t\t\t\t\t\ttop: newBorderWithStyle,\n\t\t\t\t\t\tright: newBorderWithStyle,\n\t\t\t\t\t\tbottom: newBorderWithStyle,\n\t\t\t\t\t\tleft: newBorderWithStyle,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tcolor: null,\n\t\t\t\t\t\tstyle: null,\n\t\t\t\t\t\twidth: null,\n\t\t\t\t\t\t...newBorderWithStyle,\n\t\t\t\t };\n\n\t\t\t// As radius is maintained separately to color, style, and width\n\t\t\t// maintain its value. Undefined values here will be cleaned when\n\t\t\t// global styles are saved.\n\t\t\tsetBorder( { radius: border?.radius, ...updatedBorder } );\n\t\t},\n\t\t[ setBorder ]\n\t);\n\n\treturn (\n\t\t<ToolsPanel label={ __( 'Border' ) } resetAll={ resetAll }>\n\t\t\t{ ( showBorderWidth || showBorderColor ) && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => isDefinedBorder( userBorderStyles ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder() }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tenableAlpha={ true }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tshowStyle={ showBorderStyle }\n\t\t\t\t\t\tvalue={ border }\n\t\t\t\t\t\tpopoverClassNames={ {\n\t\t\t\t\t\t\tlinked:\n\t\t\t\t\t\t\t\t'edit-site-global-styles-sidebar__border-box-control__popover',\n\t\t\t\t\t\t\ttop:\n\t\t\t\t\t\t\t\t'edit-site-global-styles-sidebar__border-box-control__popover-top',\n\t\t\t\t\t\t\tright:\n\t\t\t\t\t\t\t\t'edit-site-global-styles-sidebar__border-box-control__popover-right',\n\t\t\t\t\t\t\tbottom:\n\t\t\t\t\t\t\t\t'edit-site-global-styles-sidebar__border-box-control__popover-bottom',\n\t\t\t\t\t\t\tleft:\n\t\t\t\t\t\t\t\t'edit-site-global-styles-sidebar__border-box-control__popover-left',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\t__experimentalHasMultipleOrigins={ true }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={ true }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderRadius && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasBorderRadius }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => setBorderRadius( undefined ) }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusControl\n\t\t\t\t\t\tvalues={ borderRadiusValues }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tsetBorderRadius( value || undefined );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</ToolsPanel>\n\t);\n}\n"]}
|
|
@@ -14,7 +14,7 @@ import { useHasBorderPanel } from './border-panel';
|
|
|
14
14
|
import { useHasColorPanel } from './color-utils';
|
|
15
15
|
import { useHasDimensionsPanel } from './dimensions-panel';
|
|
16
16
|
import { useHasTypographyPanel } from './typography-panel';
|
|
17
|
-
import {
|
|
17
|
+
import { NavigationButtonAsItem } from './navigation-button';
|
|
18
18
|
|
|
19
19
|
function ContextMenu(_ref) {
|
|
20
20
|
let {
|
|
@@ -26,13 +26,13 @@ function ContextMenu(_ref) {
|
|
|
26
26
|
const hasBorderPanel = useHasBorderPanel(name);
|
|
27
27
|
const hasDimensionsPanel = useHasDimensionsPanel(name);
|
|
28
28
|
const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
|
|
29
|
-
return createElement(ItemGroup, null, hasTypographyPanel && createElement(
|
|
29
|
+
return createElement(ItemGroup, null, hasTypographyPanel && createElement(NavigationButtonAsItem, {
|
|
30
30
|
icon: typography,
|
|
31
31
|
path: parentMenu + '/typography'
|
|
32
|
-
}, __('Typography')), hasColorPanel && createElement(
|
|
32
|
+
}, __('Typography')), hasColorPanel && createElement(NavigationButtonAsItem, {
|
|
33
33
|
icon: color,
|
|
34
34
|
path: parentMenu + '/colors'
|
|
35
|
-
}, __('Colors')), hasLayoutPanel && createElement(
|
|
35
|
+
}, __('Colors')), hasLayoutPanel && createElement(NavigationButtonAsItem, {
|
|
36
36
|
icon: layout,
|
|
37
37
|
path: parentMenu + '/layout'
|
|
38
38
|
}, __('Layout')));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/context-menu.js"],"names":["__experimentalItemGroup","ItemGroup","typography","color","layout","__","useHasBorderPanel","useHasColorPanel","useHasDimensionsPanel","useHasTypographyPanel","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/context-menu.js"],"names":["__experimentalItemGroup","ItemGroup","typography","color","layout","__","useHasBorderPanel","useHasColorPanel","useHasDimensionsPanel","useHasTypographyPanel","NavigationButtonAsItem","ContextMenu","name","parentMenu","hasTypographyPanel","hasColorPanel","hasBorderPanel","hasDimensionsPanel","hasLayoutPan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encies\n */\nimport { __experimentalItemGroup as ItemGroup } from '@wordpress/components';\nimport { typography, color, layout } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useHasBorderPanel } from './border-panel';\nimport { useHasColorPanel } from './color-utils';\nimport { useHasDimensionsPanel } from './dimensions-panel';\nimport { useHasTypographyPanel } from './typography-panel';\nimport { NavigationButtonAsItem } from './navigation-button';\n\nfunction ContextMenu( { name, parentMenu = '' } ) {\n\tconst hasTypographyPanel = useHasTypographyPanel( name );\n\tconst hasColorPanel = useHasColorPanel( name );\n\tconst hasBorderPanel = useHasBorderPanel( name );\n\tconst hasDimensionsPanel = useHasDimensionsPanel( name );\n\tconst hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;\n\n\treturn (\n\t\t<ItemGroup>\n\t\t\t{ hasTypographyPanel && (\n\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\ticon={ typography }\n\t\t\t\t\tpath={ parentMenu + '/typography' }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Typography' ) }\n\t\t\t\t</NavigationButtonAsItem>\n\t\t\t) }\n\t\t\t{ hasColorPanel && (\n\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\ticon={ color }\n\t\t\t\t\tpath={ parentMenu + '/colors' }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Colors' ) }\n\t\t\t\t</NavigationButtonAsItem>\n\t\t\t) }\n\t\t\t{ hasLayoutPanel && (\n\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\ticon={ layout }\n\t\t\t\t\tpath={ parentMenu + '/layout' }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Layout' ) }\n\t\t\t\t</NavigationButtonAsItem>\n\t\t\t) }\n\t\t</ItemGroup>\n\t);\n}\n\nexport default ContextMenu;\n"]}
|
|
@@ -3,14 +3,9 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { __experimentalHStack as HStack, __experimentalVStack as VStack, __experimentalSpacer as Spacer, __experimentalHeading as Heading, __experimentalView as View } from '@wordpress/components';
|
|
6
|
+
import { __experimentalHStack as HStack, __experimentalVStack as VStack, __experimentalSpacer as Spacer, __experimentalHeading as Heading, __experimentalView as View, __experimentalNavigatorBackButton as NavigatorBackButton } from '@wordpress/components';
|
|
7
7
|
import { isRTL, __ } from '@wordpress/i18n';
|
|
8
8
|
import { chevronRight, chevronLeft } from '@wordpress/icons';
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { NavigationBackButton } from './navigation-button';
|
|
14
9
|
|
|
15
10
|
function ScreenHeader(_ref) {
|
|
16
11
|
let {
|
|
@@ -18,16 +13,26 @@ function ScreenHeader(_ref) {
|
|
|
18
13
|
description
|
|
19
14
|
} = _ref;
|
|
20
15
|
return createElement(VStack, {
|
|
21
|
-
spacing:
|
|
16
|
+
spacing: 0
|
|
17
|
+
}, createElement(View, null, createElement(Spacer, {
|
|
18
|
+
marginBottom: 0,
|
|
19
|
+
paddingX: 4,
|
|
20
|
+
paddingY: 3
|
|
22
21
|
}, createElement(HStack, {
|
|
23
22
|
spacing: 2
|
|
24
|
-
}, createElement(
|
|
23
|
+
}, createElement(NavigatorBackButton, {
|
|
24
|
+
style: // TODO: This style override is also used in ToolsPanelHeader.
|
|
25
|
+
// It should be supported out-of-the-box by Button.
|
|
26
|
+
{
|
|
27
|
+
minWidth: 24,
|
|
28
|
+
padding: 0
|
|
29
|
+
},
|
|
25
30
|
icon: isRTL() ? chevronRight : chevronLeft,
|
|
26
|
-
|
|
31
|
+
isSmall: true,
|
|
27
32
|
"aria-label": __('Navigate to the previous view')
|
|
28
|
-
})
|
|
33
|
+
}), createElement(Spacer, null, createElement(Heading, {
|
|
29
34
|
level: 5
|
|
30
|
-
}, title))), description && createElement("p", {
|
|
35
|
+
}, title))))), description && createElement("p", {
|
|
31
36
|
className: "edit-site-global-styles-header__description"
|
|
32
37
|
}, description));
|
|
33
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/header.js"],"names":["__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalSpacer","Spacer","__experimentalHeading","Heading","__experimentalView","View","isRTL","__","chevronRight","chevronLeft","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/header.js"],"names":["__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalSpacer","Spacer","__experimentalHeading","Heading","__experimentalView","View","__experimentalNavigatorBackButton","NavigatorBackButton","isRTL","__","chevronRight","chevronLeft","ScreenHeader","title","description","minWidth","padding"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,oBAAoB,IAAIC,MADzB,EAECC,oBAAoB,IAAIC,MAFzB,EAGCC,oBAAoB,IAAIC,MAHzB,EAICC,qBAAqB,IAAIC,OAJ1B,EAKCC,kBAAkB,IAAIC,IALvB,EAMCC,iCAAiC,IAAIC,mBANtC,QAOO,uBAPP;AAQA,SAASC,KAAT,EAAgBC,EAAhB,QAA0B,iBAA1B;AACA,SAASC,YAAT,EAAuBC,WAAvB,QAA0C,kBAA1C;;AAEA,SAASC,YAAT,OAAgD;AAAA,MAAzB;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAAyB;AAC/C,SACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAG;AAAlB,KACC,cAAC,IAAD,QACC,cAAC,MAAD;AAAQ,IAAA,YAAY,EAAG,CAAvB;AAA2B,IAAA,QAAQ,EAAG,CAAtC;AAA0C,IAAA,QAAQ,EAAG;AAArD,KACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAG;AAAlB,KACC,cAAC,mBAAD;AACC,IAAA,KAAK,EACJ;AACA;AACA;AAAEC,MAAAA,QAAQ,EAAE,EAAZ;AAAgBC,MAAAA,OAAO,EAAE;AAAzB,KAJF;AAMC,IAAA,IAAI,EAAGR,KAAK,KAAKE,YAAL,GAAoBC,WANjC;AAOC,IAAA,OAAO,MAPR;AAQC,kBAAaF,EAAE,CAAE,+BAAF;AARhB,IADD,EAWC,cAAC,MAAD,QACC,cAAC,OAAD;AAAS,IAAA,KAAK,EAAG;AAAjB,KAAuBI,KAAvB,CADD,CAXD,CADD,CADD,CADD,EAoBGC,WAAW,IACZ;AAAG,IAAA,SAAS,EAAC;AAAb,KACGA,WADH,CArBF,CADD;AA4BA;;AAED,eAAeF,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalSpacer as Spacer,\n\t__experimentalHeading as Heading,\n\t__experimentalView as View,\n\t__experimentalNavigatorBackButton as NavigatorBackButton,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronRight, chevronLeft } from '@wordpress/icons';\n\nfunction ScreenHeader( { title, description } ) {\n\treturn (\n\t\t<VStack spacing={ 0 }>\n\t\t\t<View>\n\t\t\t\t<Spacer marginBottom={ 0 } paddingX={ 4 } paddingY={ 3 }>\n\t\t\t\t\t<HStack spacing={ 2 }>\n\t\t\t\t\t\t<NavigatorBackButton\n\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t// TODO: This style override is also used in ToolsPanelHeader.\n\t\t\t\t\t\t\t\t// It should be supported out-of-the-box by Button.\n\t\t\t\t\t\t\t\t{ minWidth: 24, padding: 0 }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\taria-label={ __( 'Navigate to the previous view' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Spacer>\n\t\t\t\t\t\t\t<Heading level={ 5 }>{ title }</Heading>\n\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Spacer>\n\t\t\t</View>\n\t\t\t{ description && (\n\t\t\t\t<p className=\"edit-site-global-styles-header__description\">\n\t\t\t\t\t{ description }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport default ScreenHeader;\n"]}
|
|
@@ -25,17 +25,17 @@ function GenericNavigationButton(_ref) {
|
|
|
25
25
|
}), createElement(FlexItem, null, children)), !icon && children);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function
|
|
28
|
+
function NavigationButtonAsItem(props) {
|
|
29
29
|
return createElement(NavigatorButton, _extends({
|
|
30
30
|
as: GenericNavigationButton
|
|
31
31
|
}, props));
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
function NavigationBackButtonAsItem(props) {
|
|
35
35
|
return createElement(NavigatorBackButton, _extends({
|
|
36
36
|
as: GenericNavigationButton
|
|
37
37
|
}, props));
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export {
|
|
40
|
+
export { NavigationButtonAsItem, NavigationBackButtonAsItem };
|
|
41
41
|
//# sourceMappingURL=navigation-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/navigation-button.js"],"names":["__experimentalNavigatorButton","NavigatorButton","__experimentalNavigatorBackButton","NavigatorBackButton","__experimentalItem","Item","FlexItem","__experimentalHStack","HStack","IconWithCurrentColor","GenericNavigationButton","icon","children","props","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/navigation-button.js"],"names":["__experimentalNavigatorButton","NavigatorButton","__experimentalNavigatorBackButton","NavigatorBackButton","__experimentalItem","Item","FlexItem","__experimentalHStack","HStack","IconWithCurrentColor","GenericNavigationButton","icon","children","props","NavigationButtonAsItem","NavigationBackButtonAsItem"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,6BAA6B,IAAIC,eADlC,EAECC,iCAAiC,IAAIC,mBAFtC,EAGCC,kBAAkB,IAAIC,IAHvB,EAICC,QAJD,EAKCC,oBAAoB,IAAIC,MALzB,QAMO,uBANP;AAQA;AACA;AACA;;AACA,SAASC,oBAAT,QAAqC,2BAArC;;AAEA,SAASC,uBAAT,OAAiE;AAAA,MAA/B;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkB,OAAGC;AAArB,GAA+B;AAChE,SACC,cAAC,IAAD,EAAWA,KAAX,EACGF,IAAI,IACL,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC;AAAhB,KACC,cAAC,oBAAD;AAAsB,IAAA,IAAI,EAAGA,IAA7B;AAAoC,IAAA,IAAI,EAAG;AAA3C,IADD,EAEC,cAAC,QAAD,QAAYC,QAAZ,CAFD,CAFF,EAOG,CAAED,IAAF,IAAUC,QAPb,CADD;AAWA;;AAED,SAASE,sBAAT,CAAiCD,KAAjC,EAAyC;AACxC,SAAO,cAAC,eAAD;AAAiB,IAAA,EAAE,EAAGH;AAAtB,KAAqDG,KAArD,EAAP;AACA;;AAED,SAASE,0BAAT,CAAqCF,KAArC,EAA6C;AAC5C,SAAO,cAAC,mBAAD;AAAqB,IAAA,EAAE,EAAGH;AAA1B,KAAyDG,KAAzD,EAAP;AACA;;AAED,SAASC,sBAAT,EAAiCC,0BAAjC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalNavigatorButton as NavigatorButton,\n\t__experimentalNavigatorBackButton as NavigatorBackButton,\n\t__experimentalItem as Item,\n\tFlexItem,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { IconWithCurrentColor } from './icon-with-current-color';\n\nfunction GenericNavigationButton( { icon, children, ...props } ) {\n\treturn (\n\t\t<Item { ...props }>\n\t\t\t{ icon && (\n\t\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t\t<IconWithCurrentColor icon={ icon } size={ 24 } />\n\t\t\t\t\t<FlexItem>{ children }</FlexItem>\n\t\t\t\t</HStack>\n\t\t\t) }\n\t\t\t{ ! icon && children }\n\t\t</Item>\n\t);\n}\n\nfunction NavigationButtonAsItem( props ) {\n\treturn <NavigatorButton as={ GenericNavigationButton } { ...props } />;\n}\n\nfunction NavigationBackButtonAsItem( props ) {\n\treturn <NavigatorBackButton as={ GenericNavigationButton } { ...props } />;\n}\n\nexport { NavigationButtonAsItem, NavigationBackButtonAsItem };\n"]}
|
|
@@ -11,7 +11,7 @@ import { useMemo } from '@wordpress/element';
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import Subtitle from './subtitle';
|
|
14
|
-
import {
|
|
14
|
+
import { NavigationButtonAsItem } from './navigation-button';
|
|
15
15
|
import { useSetting } from './hooks';
|
|
16
16
|
import ColorIndicatorWrapper from './color-indicator-wrapper';
|
|
17
17
|
const EMPTY_COLORS = [];
|
|
@@ -33,7 +33,7 @@ function Palette(_ref) {
|
|
|
33
33
|
}, createElement(Subtitle, null, __('Palette')), createElement(ItemGroup, {
|
|
34
34
|
isBordered: true,
|
|
35
35
|
isSeparated: true
|
|
36
|
-
}, createElement(
|
|
36
|
+
}, createElement(NavigationButtonAsItem, {
|
|
37
37
|
path: screenPath
|
|
38
38
|
}, createElement(HStack, {
|
|
39
39
|
direction: colors.length === 0 ? 'row-reverse' : 'row'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/palette.js"],"names":["__experimentalItemGroup","ItemGroup","FlexItem","__experimentalHStack","HStack","__experimentalZStack","ZStack","__experimentalVStack","VStack","ColorIndicator","__","_n","sprintf","useMemo","Subtitle","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/palette.js"],"names":["__experimentalItemGroup","ItemGroup","FlexItem","__experimentalHStack","HStack","__experimentalZStack","ZStack","__experimentalVStack","VStack","ColorIndicator","__","_n","sprintf","useMemo","Subtitle","NavigationButtonAsItem","useSetting","ColorIndicatorWrapper","EMPTY_COLORS","Palette","name","customColors","themeColors","defaultColors","defaultPaletteEnabled","colors","screenPath","paletteButtonText","length","slice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D,EAAAA,EAAE,CAAE,UAAF,EAAc,WAAd,EAA2Bc,MAAM,CAACG,MAAlC,CAFK,EAGPH,MAAM,CAACG,MAHA,CADV,GAMGlB,EAAE,CAAE,mBAAF,CAPN;AASA,SACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAG;AAAlB,KACC,cAAC,QAAD,QAAYA,EAAE,CAAE,SAAF,CAAd,CADD,EAEC,cAAC,SAAD;AAAW,IAAA,UAAU,MAArB;AAAsB,IAAA,WAAW;AAAjC,KACC,cAAC,sBAAD;AAAwB,IAAA,IAAI,EAAGgB;AAA/B,KACC,cAAC,MAAD;AACC,IAAA,SAAS,EACRD,MAAM,CAACG,MAAP,KAAkB,CAAlB,GAAsB,aAAtB,GAAsC;AAFxC,KAKC,cAAC,MAAD;AAAQ,IAAA,SAAS,EAAG,KAApB;AAA4B,IAAA,MAAM,EAAG,CAAC;AAAtC,KACGH,MAAM,CAACI,KAAP,CAAc,CAAd,EAAiB,CAAjB,EAAqBC,GAArB,CAA0B;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WAC3B,cAAC,qBAAD;AAAuB,MAAA,GAAG,EAAGA;AAA7B,OACC,cAAC,cAAD;AAAgB,MAAA,UAAU,EAAGA;AAA7B,MADD,CAD2B;AAAA,GAA1B,CADH,CALD,EAYC,cAAC,QAAD,QAAYJ,iBAAZ,CAZD,CADD,CADD,CAFD,CADD;AAuBA;;AAED,eAAeR,OAAf","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} from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Subtitle from './subtitle';\nimport { NavigationButtonAsItem } from './navigation-button';\nimport { useSetting } from './hooks';\nimport ColorIndicatorWrapper from './color-indicator-wrapper';\n\nconst EMPTY_COLORS = [];\n\nfunction Palette( { name } ) {\n\tconst [ customColors ] = useSetting( 'color.palette.custom' );\n\tconst [ themeColors ] = useSetting( 'color.palette.theme' );\n\tconst [ defaultColors ] = useSetting( 'color.palette.default' );\n\n\tconst [ defaultPaletteEnabled ] = useSetting(\n\t\t'color.defaultPalette',\n\t\tname\n\t);\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/' + 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 path={ screenPath }>\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.slice( 0, 5 ).map( ( { color } ) => (\n\t\t\t\t\t\t\t\t<ColorIndicatorWrapper key={ color }>\n\t\t\t\t\t\t\t\t\t<ColorIndicator colorValue={ color } />\n\t\t\t\t\t\t\t\t</ColorIndicatorWrapper>\n\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</VStack>\n\t);\n}\n\nexport default Palette;\n"]}
|
|
@@ -20,7 +20,7 @@ import { useHasColorPanel } from './color-utils';
|
|
|
20
20
|
import { useHasDimensionsPanel } from './dimensions-panel';
|
|
21
21
|
import { useHasTypographyPanel } from './typography-panel';
|
|
22
22
|
import ScreenHeader from './header';
|
|
23
|
-
import {
|
|
23
|
+
import { NavigationButtonAsItem } from './navigation-button';
|
|
24
24
|
|
|
25
25
|
function useSortedBlockTypes() {
|
|
26
26
|
const blockItems = useSelect(select => select(blocksStore).getBlockTypes(), []); // Ensure core blocks are prioritized in the returned results,
|
|
@@ -64,7 +64,7 @@ function BlockMenuItem(_ref) {
|
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
return createElement(
|
|
67
|
+
return createElement(NavigationButtonAsItem, {
|
|
68
68
|
path: '/blocks/' + block.name
|
|
69
69
|
}, createElement(HStack, {
|
|
70
70
|
justify: "flex-start"
|