@wordpress/edit-site 6.8.6 → 6.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/editor-canvas-container/index.js +1 -1
- package/build/components/editor-canvas-container/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-card.js +1 -1
- package/build/components/global-styles/font-library-modal/font-card.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +4 -4
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/index.js +1 -1
- package/build/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +5 -5
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-sizes/font-size.js +15 -6
- package/build/components/global-styles/font-sizes/font-size.js.map +1 -1
- package/build/components/global-styles/header.js +1 -1
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/navigation-button.js +2 -2
- package/build/components/global-styles/navigation-button.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +1 -2
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/shadows-edit-panel.js +4 -1
- package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +6 -19
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles-sidebar/index.js +1 -1
- package/build/components/global-styles-sidebar/index.js.map +1 -1
- package/build/components/page-patterns/fields.js +2 -4
- package/build/components/page-patterns/fields.js.map +1 -1
- package/build/components/resizable-frame/index.js +25 -7
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/routes/link.js +6 -3
- package/build/components/routes/link.js.map +1 -1
- package/build/components/save-panel/index.js +2 -4
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar-button/index.js +2 -4
- package/build/components/sidebar-button/index.js.map +1 -1
- package/build/components/sidebar-dataviews/add-new-view.js +4 -8
- package/build/components/sidebar-dataviews/add-new-view.js.map +1 -1
- package/build/components/site-hub/index.js +12 -24
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/categories.js +70 -0
- package/build/components/style-book/categories.js.map +1 -0
- package/build/components/style-book/constants.js +151 -0
- package/build/components/style-book/constants.js.map +1 -0
- package/build/components/style-book/examples.js +58 -0
- package/build/components/style-book/examples.js.map +1 -0
- package/build/components/style-book/index.js +52 -133
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/style-book/types.js +6 -0
- package/build/components/style-book/types.js.map +1 -0
- package/build/store/selectors.js +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +1 -1
- package/build-module/components/editor-canvas-container/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-card.js +1 -1
- package/build-module/components/global-styles/font-library-modal/font-card.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-collection.js +5 -5
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +5 -5
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-sizes/font-size.js +16 -7
- package/build-module/components/global-styles/font-sizes/font-size.js.map +1 -1
- package/build-module/components/global-styles/header.js +2 -2
- 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/screen-revisions/index.js +1 -2
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/shadows-edit-panel.js +4 -1
- package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +3 -16
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles-sidebar/index.js +1 -1
- package/build-module/components/global-styles-sidebar/index.js.map +1 -1
- package/build-module/components/page-patterns/fields.js +2 -4
- package/build-module/components/page-patterns/fields.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +26 -8
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/routes/link.js +6 -3
- package/build-module/components/routes/link.js.map +1 -1
- package/build-module/components/save-panel/index.js +2 -4
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar-button/index.js +2 -4
- package/build-module/components/sidebar-button/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/add-new-view.js +4 -8
- package/build-module/components/sidebar-dataviews/add-new-view.js.map +1 -1
- package/build-module/components/site-hub/index.js +12 -24
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/categories.js +64 -0
- package/build-module/components/style-book/categories.js.map +1 -0
- package/build-module/components/style-book/constants.js +145 -0
- package/build-module/components/style-book/constants.js.map +1 -0
- package/build-module/components/style-book/examples.js +52 -0
- package/build-module/components/style-book/examples.js.map +1 -0
- package/build-module/components/style-book/index.js +51 -132
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/style-book/types.js +2 -0
- package/build-module/components/style-book/types.js.map +1 -0
- package/build-module/store/selectors.js +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/posts-rtl.css +32 -12
- package/build-style/posts.css +32 -12
- package/build-style/style-rtl.css +44 -21
- package/build-style/style.css +44 -21
- package/package.json +41 -41
- package/src/components/editor-canvas-container/index.js +1 -1
- package/src/components/editor-canvas-container/style.scss +2 -2
- package/src/components/global-styles/font-library-modal/font-card.js +1 -1
- package/src/components/global-styles/font-library-modal/font-collection.js +8 -10
- package/src/components/global-styles/font-library-modal/index.js +1 -1
- package/src/components/global-styles/font-library-modal/installed-fonts.js +9 -11
- package/src/components/global-styles/font-library-modal/style.scss +5 -1
- package/src/components/global-styles/font-sizes/font-size.js +15 -8
- package/src/components/global-styles/header.js +2 -2
- package/src/components/global-styles/navigation-button.js +3 -4
- package/src/components/global-styles/screen-revisions/index.js +1 -2
- package/src/components/global-styles/shadows-edit-panel.js +5 -1
- package/src/components/global-styles/ui.js +5 -19
- package/src/components/global-styles-sidebar/index.js +1 -1
- package/src/components/global-styles-sidebar/style.scss +1 -8
- package/src/components/layout/style.scss +7 -2
- package/src/components/page-patterns/fields.js +1 -2
- package/src/components/resizable-frame/index.js +14 -8
- package/src/components/routes/link.js +6 -3
- package/src/components/save-panel/index.js +1 -2
- package/src/components/sidebar-button/index.js +1 -2
- package/src/components/sidebar-dataviews/add-new-view.js +2 -4
- package/src/components/site-hub/index.js +6 -12
- package/src/components/style-book/categories.ts +91 -0
- package/src/components/style-book/constants.ts +191 -0
- package/src/components/style-book/examples.ts +63 -0
- package/src/components/style-book/index.js +76 -163
- package/src/components/style-book/style.scss +9 -5
- package/src/components/style-book/test/categories.js +171 -0
- package/src/components/style-book/types.ts +27 -0
- package/src/store/selectors.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","useSelect","useDispatch","Button","__experimentalHStack","HStack","VisuallyHidden","__","store","coreStore","decodeEntities","memo","forwardRef","useContext","search","commandsStore","displayShortcut","filterURLForDisplay","privateApis","routerPrivateApis","editSiteStore","SiteIcon","unlock","useHistory","SidebarNavigationContext","jsx","_jsx","jsxs","_jsxs","SiteHub","isTransparent","ref","dashboardLink","homeUrl","siteTitle","select","getSettings","getEntityRecord","_site","__experimentalDashboardLink","home","title","url","open","openCommandCenter","className","children","justify","spacing","__next40pxDefaultSize","href","label","style","transform","borderRadius","variant","target","as","expanded","icon","onClick","shortcut","primary","SiteHubMobile","history","navigate","push"],"sources":["@wordpress/edit-site/src/components/site-hub/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { memo, forwardRef, useContext } from '@wordpress/element';\nimport { search } from '@wordpress/icons';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { filterURLForDisplay } from '@wordpress/url';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport SiteIcon from '../site-icon';\nimport { unlock } from '../../lock-unlock';\nconst { useHistory } = unlock( routerPrivateApis );\nimport { SidebarNavigationContext } from '../sidebar';\n\nconst SiteHub = memo(\n\tforwardRef( ( { isTransparent }, ref ) => {\n\t\tconst { dashboardLink, homeUrl, siteTitle } = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\tconst _site = getEntityRecord( 'root', 'site' );\n\t\t\treturn {\n\t\t\t\tdashboardLink:\n\t\t\t\t\tgetSettings().__experimentalDashboardLink || 'index.php',\n\t\t\t\thomeUrl: getEntityRecord( 'root', '__unstableBase' )?.home,\n\t\t\t\tsiteTitle:\n\t\t\t\t\t! _site?.title && !! _site?.url\n\t\t\t\t\t\t? filterURLForDisplay( _site?.url )\n\t\t\t\t\t\t: _site?.title,\n\t\t\t};\n\t\t}, [] );\n\t\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\n\t\treturn (\n\t\t\t<div className=\"edit-site-site-hub\">\n\t\t\t\t<HStack justify=\"flex-start\" spacing=\"0\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'edit-site-site-hub__view-mode-toggle-container',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'has-transparent-background': isTransparent,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\thref={ dashboardLink }\n\t\t\t\t\t\t\tlabel={ __( 'Go to the Dashboard' ) }\n\t\t\t\t\t\t\tclassName=\"edit-site-layout__view-mode-toggle\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\ttransform: 'scale(0.5)',\n\t\t\t\t\t\t\t\tborderRadius: 4,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<SiteIcon className=\"edit-site-layout__view-mode-toggle-icon\" />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<HStack>\n\t\t\t\t\t\t<div className=\"edit-site-site-hub__title\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\t\thref={ homeUrl }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ decodeEntities( siteTitle ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tspacing={ 0 }\n\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t\tclassName=\"edit-site-site-hub__actions\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t\t\t\tclassName=\"edit-site-site-hub_toggle-command-center\"\n\t\t\t\t\t\t\t\ticon={ search }\n\t\t\t\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\t\t\t\tlabel={ __( 'Open command palette' ) }\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</HStack>\n\t\t\t\t</HStack>\n\t\t\t</div>\n\t\t);\n\t} )\n);\n\nexport default SiteHub;\n\nexport const SiteHubMobile = memo(\n\tforwardRef( ( { isTransparent }, ref ) => {\n\t\tconst history = useHistory();\n\t\tconst { navigate } = useContext( SidebarNavigationContext );\n\n\t\tconst { homeUrl, siteTitle } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\tconst _site = getEntityRecord( 'root', 'site' );\n\t\t\treturn {\n\t\t\t\thomeUrl: getEntityRecord( 'root', '__unstableBase' )?.home,\n\t\t\t\tsiteTitle:\n\t\t\t\t\t! _site?.title && !! _site?.url\n\t\t\t\t\t\t? filterURLForDisplay( _site?.url )\n\t\t\t\t\t\t: _site?.title,\n\t\t\t};\n\t\t}, [] );\n\t\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\n\t\treturn (\n\t\t\t<div className=\"edit-site-site-hub\">\n\t\t\t\t<HStack justify=\"flex-start\" spacing=\"0\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'edit-site-site-hub__view-mode-toggle-container',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'has-transparent-background': isTransparent,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\tlabel={ __( 'Go to Site Editor' ) }\n\t\t\t\t\t\t\tclassName=\"edit-site-layout__view-mode-toggle\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\ttransform: 'scale(0.5)',\n\t\t\t\t\t\t\t\tborderRadius: 4,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\thistory.push( {} );\n\t\t\t\t\t\t\t\tnavigate( 'back' );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<SiteIcon className=\"edit-site-layout__view-mode-toggle-icon\" />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<HStack>\n\t\t\t\t\t\t<div className=\"edit-site-site-hub__title\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\t\thref={ homeUrl }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\tlabel={ __( 'View site (opens in a new tab)' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ decodeEntities( siteTitle ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tspacing={ 0 }\n\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t\tclassName=\"edit-site-site-hub__actions\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t\t\t\tclassName=\"edit-site-site-hub_toggle-command-center\"\n\t\t\t\t\t\t\t\ticon={ search }\n\t\t\t\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\t\t\t\tlabel={ __( 'Open command palette' ) }\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</HStack>\n\t\t\t\t</HStack>\n\t\t\t</div>\n\t\t);\n\t} )\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,cAAc,QACR,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,IAAI,EAAEC,UAAU,EAAEC,UAAU,QAAQ,oBAAoB;AACjE,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASN,KAAK,IAAIO,aAAa,QAAQ,qBAAqB;AAC5D,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;;AAEpE;AACA;AACA;AACA,SAASX,KAAK,IAAIY,aAAa,QAAQ,aAAa;AACpD,OAAOC,QAAQ,MAAM,cAAc;AACnC,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,MAAM;EAAEC;AAAW,CAAC,GAAGD,MAAM,CAAEH,iBAAkB,CAAC;AAClD,SAASK,wBAAwB,QAAQ,YAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEtD,MAAMC,OAAO,GAAGlB,IAAI,CACnBC,UAAU,CAAE,CAAE;EA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ACfI,OAAO,CAACE,IAAI,CAAE,CAAC,CAAE,CAAC;YAClBD,QAAQ,CAAE,MAAO,CAAC;UACnB,CAAG;UAAAnB,QAAA,eAEHpB,IAAA,CAACL,QAAQ;YAACwB,SAAS,EAAC;UAAyC,CAAE;QAAC,CACzD;MAAC,CACL,CAAC,eAENjB,KAAA,CAACvB,MAAM;QAAAyC,QAAA,gBACNpB,IAAA;UAAKmB,SAAS,EAAC,2BAA2B;UAAAC,QAAA,eACzCpB,IAAA,CAACvB;UACA;UAAA;YACA8C,qBAAqB,EAAG,KAAO;YAC/BM,OAAO,EAAC,MAAM;YACdL,IAAI,EAAGjB,OAAS;YAChBuB,MAAM,EAAC,QAAQ;YACfL,KAAK,EAAG5C,EAAE,CAAE,gCAAiC,CAAG;YAAAuC,QAAA,EAE9CpC,cAAc,CAAEwB,SAAU;UAAC,CACtB;QAAC,CACL,CAAC,eACNR,IAAA,CAACrB,MAAM;UACN2C,OAAO,EAAG,CAAG;UACbU,QAAQ,EAAG,KAAO;UAClBb,SAAS,EAAC,6BAA6B;UAAAC,QAAA,eAEvCpB,IAAA,CAACvB;UACA;UAAA;YACA8C,qBAAqB,EAAG,KAAO;YAC/BJ,SAAS,EAAC,0CAA0C;YACpDc,IAAI,EAAG7C,MAAQ;YACf8C,OAAO,EAAGA,CAAA,KAAMhB,iBAAiB,CAAC,CAAG;YACrCO,KAAK,EAAG5C,EAAE,CAAE,sBAAuB,CAAG;YACtCsD,QAAQ,EAAG7C,eAAe,CAAC8C,OAAO,CAAE,GAAI;UAAG,CAC3C;QAAC,CACK,CAAC;MAAA,CACF,CAAC;IAAA,CACF;EAAC,CACL,CAAC;AAER,CAAE,CACH,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","useSelect","useDispatch","Button","__experimentalHStack","HStack","VisuallyHidden","__","store","coreStore","decodeEntities","memo","forwardRef","useContext","search","commandsStore","displayShortcut","filterURLForDisplay","privateApis","routerPrivateApis","editSiteStore","SiteIcon","unlock","useHistory","SidebarNavigationContext","jsx","_jsx","jsxs","_jsxs","SiteHub","isTransparent","ref","dashboardLink","homeUrl","siteTitle","select","getSettings","getEntityRecord","_site","__experimentalDashboardLink","home","title","url","open","openCommandCenter","className","children","justify","spacing","__next40pxDefaultSize","href","label","style","transform","borderRadius","variant","target","as","expanded","icon","onClick","shortcut","primary","SiteHubMobile","history","navigate","push"],"sources":["@wordpress/edit-site/src/components/site-hub/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { memo, forwardRef, useContext } from '@wordpress/element';\nimport { search } from '@wordpress/icons';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { filterURLForDisplay } from '@wordpress/url';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport SiteIcon from '../site-icon';\nimport { unlock } from '../../lock-unlock';\nconst { useHistory } = unlock( routerPrivateApis );\nimport { SidebarNavigationContext } from '../sidebar';\n\nconst SiteHub = memo(\n\tforwardRef( ( { isTransparent }, ref ) => {\n\t\tconst { dashboardLink, homeUrl, siteTitle } = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\tconst _site = getEntityRecord( 'root', 'site' );\n\t\t\treturn {\n\t\t\t\tdashboardLink:\n\t\t\t\t\tgetSettings().__experimentalDashboardLink || 'index.php',\n\t\t\t\thomeUrl: getEntityRecord( 'root', '__unstableBase' )?.home,\n\t\t\t\tsiteTitle:\n\t\t\t\t\t! _site?.title && !! _site?.url\n\t\t\t\t\t\t? filterURLForDisplay( _site?.url )\n\t\t\t\t\t\t: _site?.title,\n\t\t\t};\n\t\t}, [] );\n\t\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\n\t\treturn (\n\t\t\t<div className=\"edit-site-site-hub\">\n\t\t\t\t<HStack justify=\"flex-start\" spacing=\"0\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'edit-site-site-hub__view-mode-toggle-container',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'has-transparent-background': isTransparent,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\thref={ dashboardLink }\n\t\t\t\t\t\t\tlabel={ __( 'Go to the Dashboard' ) }\n\t\t\t\t\t\t\tclassName=\"edit-site-layout__view-mode-toggle\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\ttransform: 'scale(0.5)',\n\t\t\t\t\t\t\t\tborderRadius: 4,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<SiteIcon className=\"edit-site-layout__view-mode-toggle-icon\" />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<HStack>\n\t\t\t\t\t\t<div className=\"edit-site-site-hub__title\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\t\thref={ homeUrl }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ decodeEntities( siteTitle ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tspacing={ 0 }\n\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t\tclassName=\"edit-site-site-hub__actions\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tclassName=\"edit-site-site-hub_toggle-command-center\"\n\t\t\t\t\t\t\t\ticon={ search }\n\t\t\t\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\t\t\t\tlabel={ __( 'Open command palette' ) }\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</HStack>\n\t\t\t\t</HStack>\n\t\t\t</div>\n\t\t);\n\t} )\n);\n\nexport default SiteHub;\n\nexport const SiteHubMobile = memo(\n\tforwardRef( ( { isTransparent }, ref ) => {\n\t\tconst history = useHistory();\n\t\tconst { navigate } = useContext( SidebarNavigationContext );\n\n\t\tconst { homeUrl, siteTitle } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\tconst _site = getEntityRecord( 'root', 'site' );\n\t\t\treturn {\n\t\t\t\thomeUrl: getEntityRecord( 'root', '__unstableBase' )?.home,\n\t\t\t\tsiteTitle:\n\t\t\t\t\t! _site?.title && !! _site?.url\n\t\t\t\t\t\t? filterURLForDisplay( _site?.url )\n\t\t\t\t\t\t: _site?.title,\n\t\t\t};\n\t\t}, [] );\n\t\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\n\t\treturn (\n\t\t\t<div className=\"edit-site-site-hub\">\n\t\t\t\t<HStack justify=\"flex-start\" spacing=\"0\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'edit-site-site-hub__view-mode-toggle-container',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'has-transparent-background': isTransparent,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\tlabel={ __( 'Go to Site Editor' ) }\n\t\t\t\t\t\t\tclassName=\"edit-site-layout__view-mode-toggle\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\ttransform: 'scale(0.5)',\n\t\t\t\t\t\t\t\tborderRadius: 4,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\thistory.push( {} );\n\t\t\t\t\t\t\t\tnavigate( 'back' );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<SiteIcon className=\"edit-site-layout__view-mode-toggle-icon\" />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<HStack>\n\t\t\t\t\t\t<div className=\"edit-site-site-hub__title\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\t\thref={ homeUrl }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\tlabel={ __( 'View site (opens in a new tab)' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ decodeEntities( siteTitle ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tspacing={ 0 }\n\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t\tclassName=\"edit-site-site-hub__actions\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tclassName=\"edit-site-site-hub_toggle-command-center\"\n\t\t\t\t\t\t\t\ticon={ search }\n\t\t\t\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\t\t\t\tlabel={ __( 'Open command palette' ) }\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</HStack>\n\t\t\t\t</HStack>\n\t\t\t</div>\n\t\t);\n\t} )\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,cAAc,QACR,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,IAAI,EAAEC,UAAU,EAAEC,UAAU,QAAQ,oBAAoB;AACjE,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASN,KAAK,IAAIO,aAAa,QAAQ,qBAAqB;AAC5D,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;;AAEpE;AACA;AACA;AACA,SAASX,KAAK,IAAIY,aAAa,QAAQ,aAAa;AACpD,OAAOC,QAAQ,MAAM,cAAc;AACnC,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,MAAM;EAAEC;AAAW,CAAC,GAAGD,MAAM,CAAEH,iBAAkB,CAAC;AAClD,SAASK,wBAAwB,QAAQ,YAAY;AAAC,S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al dependencies
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { STYLE_BOOK_CATEGORIES, STYLE_BOOK_THEME_SUBCATEGORIES } from './constants';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Returns category examples for a given category definition and list of examples.
|
|
14
|
+
* @param {StyleBookCategory} categoryDefinition The category definition.
|
|
15
|
+
* @param {BlockExample[]} examples An array of block examples.
|
|
16
|
+
* @return {CategoryExamples|undefined} An object containing the category examples.
|
|
17
|
+
*/
|
|
18
|
+
export function getExamplesByCategory(categoryDefinition, examples) {
|
|
19
|
+
if (!categoryDefinition?.slug || !examples?.length) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (categoryDefinition?.subcategories?.length) {
|
|
23
|
+
return categoryDefinition.subcategories.reduce((acc, subcategoryDefinition) => {
|
|
24
|
+
const subcategoryExamples = getExamplesByCategory(subcategoryDefinition, examples);
|
|
25
|
+
if (subcategoryExamples) {
|
|
26
|
+
acc.subcategories = [...acc.subcategories, subcategoryExamples];
|
|
27
|
+
}
|
|
28
|
+
return acc;
|
|
29
|
+
}, {
|
|
30
|
+
title: categoryDefinition.title,
|
|
31
|
+
slug: categoryDefinition.slug,
|
|
32
|
+
subcategories: []
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const blocksToInclude = categoryDefinition?.blocks || [];
|
|
36
|
+
const blocksToExclude = categoryDefinition?.exclude || [];
|
|
37
|
+
const categoryExamples = examples.filter(example => {
|
|
38
|
+
return !blocksToExclude.includes(example.name) && (example.category === categoryDefinition.slug || blocksToInclude.includes(example.name));
|
|
39
|
+
});
|
|
40
|
+
if (!categoryExamples.length) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
title: categoryDefinition.title,
|
|
45
|
+
slug: categoryDefinition.slug,
|
|
46
|
+
examples: categoryExamples
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns category examples for a given category definition and list of examples.
|
|
52
|
+
*
|
|
53
|
+
* @return {StyleBookCategory[]} An array of top-level category definitions.
|
|
54
|
+
*/
|
|
55
|
+
export function getTopLevelStyleBookCategories() {
|
|
56
|
+
const reservedCategories = [...STYLE_BOOK_THEME_SUBCATEGORIES, ...STYLE_BOOK_CATEGORIES].map(({
|
|
57
|
+
slug
|
|
58
|
+
}) => slug);
|
|
59
|
+
const extraCategories = getCategories().filter(({
|
|
60
|
+
slug
|
|
61
|
+
}) => !reservedCategories.includes(slug));
|
|
62
|
+
return [...STYLE_BOOK_CATEGORIES, ...extraCategories];
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=categories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getCategories","STYLE_BOOK_CATEGORIES","STYLE_BOOK_THEME_SUBCATEGORIES","getExamplesByCategory","categoryDefinition","examples","slug","length","subcategories","reduce","acc","subcategoryDefinition","subcategoryExamples","title","blocksToInclude","blocks","blocksToExclude","exclude","categoryExamples","filter","example","includes","name","category","getTopLevelStyleBookCategories","reservedCategories","map","extraCategories"],"sources":["@wordpress/edit-site/src/components/style-book/categories.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getCategories } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tBlockExample,\n\tStyleBookCategory,\n\tCategoryExamples,\n} from './types';\nimport {\n\tSTYLE_BOOK_CATEGORIES,\n\tSTYLE_BOOK_THEME_SUBCATEGORIES,\n} from './constants';\n\n/**\n * Returns category examples for a given category definition and list of examples.\n * @param {StyleBookCategory} categoryDefinition The category definition.\n * @param {BlockExample[]} examples An array of block examples.\n * @return {CategoryExamples|undefined} An object containing the category examples.\n */\nexport function getExamplesByCategory(\n\tcategoryDefinition: StyleBookCategory,\n\texamples: BlockExample[]\n): CategoryExamples | undefined {\n\tif ( ! categoryDefinition?.slug || ! examples?.length ) {\n\t\treturn;\n\t}\n\n\tif ( categoryDefinition?.subcategories?.length ) {\n\t\treturn categoryDefinition.subcategories.reduce(\n\t\t\t( acc, subcategoryDefinition ) => {\n\t\t\t\tconst subcategoryExamples = getExamplesByCategory(\n\t\t\t\t\tsubcategoryDefinition,\n\t\t\t\t\texamples\n\t\t\t\t);\n\t\t\t\tif ( subcategoryExamples ) {\n\t\t\t\t\tacc.subcategories = [\n\t\t\t\t\t\t...acc.subcategories,\n\t\t\t\t\t\tsubcategoryExamples,\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: categoryDefinition.title,\n\t\t\t\tslug: categoryDefinition.slug,\n\t\t\t\tsubcategories: [],\n\t\t\t}\n\t\t);\n\t}\n\n\tconst blocksToInclude = categoryDefinition?.blocks || [];\n\tconst blocksToExclude = categoryDefinition?.exclude || [];\n\tconst categoryExamples = examples.filter( ( example ) => {\n\t\treturn (\n\t\t\t! blocksToExclude.includes( example.name ) &&\n\t\t\t( example.category === categoryDefinition.slug ||\n\t\t\t\tblocksToInclude.includes( example.name ) )\n\t\t);\n\t} );\n\n\tif ( ! categoryExamples.length ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\ttitle: categoryDefinition.title,\n\t\tslug: categoryDefinition.slug,\n\t\texamples: categoryExamples,\n\t};\n}\n\n/**\n * Returns category examples for a given category definition and list of examples.\n *\n * @return {StyleBookCategory[]} An array of top-level category definitions.\n */\nexport function getTopLevelStyleBookCategories(): StyleBookCategory[] {\n\tconst reservedCategories = [\n\t\t...STYLE_BOOK_THEME_SUBCATEGORIES,\n\t\t...STYLE_BOOK_CATEGORIES,\n\t].map( ( { slug } ) => slug );\n\tconst extraCategories = getCategories().filter(\n\t\t( { slug } ) => ! reservedCategories.includes( slug )\n\t);\n\treturn [ ...STYLE_BOOK_CATEGORIES, ...extraCategories ];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,mBAAmB;;AAEjD;AACA;AACA;;AAMA,SACCC,q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kBAAkB,CAACE,IAAI;IAC7BD,QAAQ,EAAEa;EACX,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,8BAA8BA,CAAA,EAAwB;EACrE,MAAMC,kBAAkB,GAAG,CAC1B,GAAGvB,8BAA8B,EACjC,GAAGD,qBAAqB,CACxB,CAACyB,GAAG,CAAE,CAAE;IAAEpB;EAAK,CAAC,KAAMA,IAAK,CAAC;EAC7B,MAAMqB,eAAe,GAAG3B,aAAa,CAAC,CAAC,CAACmB,MAAM,CAC7C,CAAE;IAAEb;EAAK,CAAC,KAAM,CAAEmB,kBAAkB,CAACJ,QAAQ,CAAEf,IAAK,CACrD,CAAC;EACD,OAAO,CAAE,GAAGL,qBAAqB,EAAE,GAAG0B,eAAe,CAAE;AACxD","ignoreList":[]}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const STYLE_BOOK_THEME_SUBCATEGORIES = [{
|
|
11
|
+
slug: 'site-identity',
|
|
12
|
+
title: __('Site Identity'),
|
|
13
|
+
blocks: ['core/site-logo', 'core/site-title', 'core/site-tagline']
|
|
14
|
+
}, {
|
|
15
|
+
slug: 'design',
|
|
16
|
+
title: __('Design'),
|
|
17
|
+
blocks: ['core/navigation', 'core/avatar', 'core/post-time-to-read'],
|
|
18
|
+
exclude: ['core/home-link', 'core/navigation-link']
|
|
19
|
+
}, {
|
|
20
|
+
slug: 'posts',
|
|
21
|
+
title: __('Posts'),
|
|
22
|
+
blocks: ['core/post-title', 'core/post-excerpt', 'core/post-author', 'core/post-author-name', 'core/post-author-biography', 'core/post-date', 'core/post-terms', 'core/term-description', 'core/query-title', 'core/query-no-results', 'core/query-pagination', 'core/query-numbers']
|
|
23
|
+
}, {
|
|
24
|
+
slug: 'comments',
|
|
25
|
+
title: __('Comments'),
|
|
26
|
+
blocks: ['core/comments-title', 'core/comments-pagination', 'core/comments-pagination-numbers', 'core/comments', 'core/comments-author-name', 'core/comment-content', 'core/comment-date', 'core/comment-edit-link', 'core/comment-reply-link', 'core/comment-template', 'core/post-comments-count', 'core/post-comments-link']
|
|
27
|
+
}];
|
|
28
|
+
export const STYLE_BOOK_CATEGORIES = [{
|
|
29
|
+
slug: 'text',
|
|
30
|
+
title: __('Text'),
|
|
31
|
+
blocks: ['core/post-content', 'core/home-link', 'core/navigation-link']
|
|
32
|
+
}, {
|
|
33
|
+
slug: 'colors',
|
|
34
|
+
title: __('Colors'),
|
|
35
|
+
blocks: ['custom/colors']
|
|
36
|
+
}, {
|
|
37
|
+
slug: 'theme',
|
|
38
|
+
title: __('Theme'),
|
|
39
|
+
subcategories: STYLE_BOOK_THEME_SUBCATEGORIES
|
|
40
|
+
}, {
|
|
41
|
+
slug: 'media',
|
|
42
|
+
title: __('Media'),
|
|
43
|
+
blocks: ['core/post-featured-image']
|
|
44
|
+
}, {
|
|
45
|
+
slug: 'widgets',
|
|
46
|
+
title: __('Widgets'),
|
|
47
|
+
blocks: []
|
|
48
|
+
}, {
|
|
49
|
+
slug: 'embed',
|
|
50
|
+
title: __('Embeds'),
|
|
51
|
+
include: []
|
|
52
|
+
}];
|
|
53
|
+
|
|
54
|
+
// The content area of the Style Book is rendered within an iframe so that global styles
|
|
55
|
+
// are applied to elements within the entire content area. To support elements that are
|
|
56
|
+
// not part of the block previews, such as headings and layout for the block previews,
|
|
57
|
+
// additional CSS rules need to be passed into the iframe. These are hard-coded below.
|
|
58
|
+
// Note that button styles are unset, and then focus rules from the `Button` component are
|
|
59
|
+
// applied to the `button` element, targeted via `.edit-site-style-book__example`.
|
|
60
|
+
// This is to ensure that browser default styles for buttons are not applied to the previews.
|
|
61
|
+
export const STYLE_BOOK_IFRAME_STYLES = `
|
|
62
|
+
// Forming a "block formatting context" to prevent margin collapsing.
|
|
63
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
|
|
64
|
+
.is-root-container {
|
|
65
|
+
display: flow-root;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
body {
|
|
69
|
+
position: relative;
|
|
70
|
+
padding: 32px !important;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.edit-site-style-book__examples {
|
|
74
|
+
max-width: 1200px;
|
|
75
|
+
margin: 0 auto;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.edit-site-style-book__example {
|
|
79
|
+
max-width: 900px;
|
|
80
|
+
border-radius: 2px;
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
gap: 40px;
|
|
85
|
+
padding: 16px;
|
|
86
|
+
width: 100%;
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
scroll-margin-top: 32px;
|
|
89
|
+
scroll-margin-bottom: 32px;
|
|
90
|
+
margin: 0 auto 40px auto;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.edit-site-style-book__example.is-selected {
|
|
94
|
+
box-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.edit-site-style-book__example:focus:not(:disabled) {
|
|
98
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
99
|
+
outline: 3px solid transparent;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.edit-site-style-book__examples.is-wide .edit-site-style-book__example {
|
|
103
|
+
flex-direction: row;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.edit-site-style-book__subcategory-title,
|
|
107
|
+
.edit-site-style-book__example-title {
|
|
108
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
109
|
+
font-size: 11px;
|
|
110
|
+
font-weight: 500;
|
|
111
|
+
line-height: normal;
|
|
112
|
+
margin: 0;
|
|
113
|
+
text-align: left;
|
|
114
|
+
text-transform: uppercase;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.edit-site-style-book__subcategory-title {
|
|
118
|
+
font-size: 16px;
|
|
119
|
+
margin-bottom: 40px;
|
|
120
|
+
border-bottom: 1px solid #ddd;
|
|
121
|
+
padding-bottom: 8px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.edit-site-style-book__examples.is-wide .edit-site-style-book__example-title {
|
|
125
|
+
text-align: right;
|
|
126
|
+
width: 120px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.edit-site-style-book__example-preview {
|
|
130
|
+
width: 100%;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.edit-site-style-book__example-preview .block-editor-block-list__insertion-point,
|
|
134
|
+
.edit-site-style-book__example-preview .block-list-appender {
|
|
135
|
+
display: none;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.edit-site-style-book__example-preview .is-root-container > .wp-block:first-child {
|
|
139
|
+
margin-top: 0;
|
|
140
|
+
}
|
|
141
|
+
.edit-site-style-book__example-preview .is-root-container > .wp-block:last-child {
|
|
142
|
+
margin-bottom: 0;
|
|
143
|
+
}
|
|
144
|
+
`;
|
|
145
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__","STYLE_BOOK_THEME_SUBCATEGORIES","slug","title","blocks","exclude","STYLE_BOOK_CATEGORIES","subcategories","include","STYLE_BOOK_IFRAME_STYLES"],"sources":["@wordpress/edit-site/src/components/style-book/constants.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { StyleBookCategory } from './types';\n\nexport const STYLE_BOOK_THEME_SUBCATEGORIES: Omit<\n\tStyleBookCategory,\n\t'subcategories'\n>[] = [\n\t{\n\t\tslug: 'site-identity',\n\t\ttitle: __( 'Site Identity' ),\n\t\tblocks: [ 'core/site-logo', 'core/site-title', 'core/site-tagline' ],\n\t},\n\t{\n\t\tslug: 'design',\n\t\ttitle: __( 'Design' ),\n\t\tblocks: [ 'core/navigation', 'core/avatar', 'core/post-time-to-read' ],\n\t\texclude: [ 'core/home-link', 'core/navigation-link' ],\n\t},\n\t{\n\t\tslug: 'posts',\n\t\ttitle: __( 'Posts' ),\n\t\tblocks: [\n\t\t\t'core/post-title',\n\t\t\t'core/post-excerpt',\n\t\t\t'core/post-author',\n\t\t\t'core/post-author-name',\n\t\t\t'core/post-author-biography',\n\t\t\t'core/post-date',\n\t\t\t'core/post-terms',\n\t\t\t'core/term-description',\n\t\t\t'core/query-title',\n\t\t\t'core/query-no-results',\n\t\t\t'core/query-pagination',\n\t\t\t'core/query-numbers',\n\t\t],\n\t},\n\t{\n\t\tslug: 'comments',\n\t\ttitle: __( 'Comments' ),\n\t\tblocks: [\n\t\t\t'core/comments-title',\n\t\t\t'core/comments-pagination',\n\t\t\t'core/comments-pagination-numbers',\n\t\t\t'core/comments',\n\t\t\t'core/comments-author-name',\n\t\t\t'core/comment-content',\n\t\t\t'core/comment-date',\n\t\t\t'core/comment-edit-link',\n\t\t\t'core/comment-reply-link',\n\t\t\t'core/comment-template',\n\t\t\t'core/post-comments-count',\n\t\t\t'core/post-comments-link',\n\t\t],\n\t},\n];\n\nexport const STYLE_BOOK_CATEGORIES: StyleBookCategory[] = [\n\t{\n\t\tslug: 'text',\n\t\ttitle: __( 'Text' ),\n\t\tblocks: [\n\t\t\t'core/post-content',\n\t\t\t'core/home-link',\n\t\t\t'core/navigation-link',\n\t\t],\n\t},\n\t{\n\t\tslug: 'colors',\n\t\ttitle: __( 'Colors' ),\n\t\tblocks: [ 'custom/colors' ],\n\t},\n\t{\n\t\tslug: 'theme',\n\t\ttitle: __( 'Theme' ),\n\t\tsubcategories: STYLE_BOOK_THEME_SUBCATEGORIES,\n\t},\n\t{\n\t\tslug: 'media',\n\t\ttitle: __( 'Media' ),\n\t\tblocks: [ 'core/post-featured-image' ],\n\t},\n\t{\n\t\tslug: 'widgets',\n\t\ttitle: __( 'Widgets' ),\n\t\tblocks: [],\n\t},\n\t{\n\t\tslug: 'embed',\n\t\ttitle: __( 'Embeds' ),\n\t\tinclude: [],\n\t},\n];\n\n// The content area of the Style Book is rendered within an iframe so that global styles\n// are applied to elements within the entire content area. To support elements that are\n// not part of the block previews, such as headings and layout for the block previews,\n// additional CSS rules need to be passed into the iframe. These are hard-coded below.\n// Note that button styles are unset, and then focus rules from the `Button` component are\n// applied to the `button` element, targeted via `.edit-site-style-book__example`.\n// This is to ensure that browser default styles for buttons are not applied to the previews.\nexport const STYLE_BOOK_IFRAME_STYLES = `\n\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t.is-root-container {\n\t\tdisplay: flow-root;\n\t}\n\t\n\tbody {\n\t\tposition: relative;\n\t\tpadding: 32px !important;\n\t}\n\n\t.edit-site-style-book__examples {\n\t\tmax-width: 1200px;\n\t\tmargin: 0 auto;\n\t}\n\n\t.edit-site-style-book__example {\n\t max-width: 900px;\n\t\tborder-radius: 2px;\n\t\tcursor: pointer;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tgap: 40px;\n\t\tpadding: 16px;\n\t\twidth: 100%;\n\t\tbox-sizing: border-box;\n\t\tscroll-margin-top: 32px;\n\t\tscroll-margin-bottom: 32px;\n\t\tmargin: 0 auto 40px auto;\n\t}\n\n\t.edit-site-style-book__example.is-selected {\n\t\tbox-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));\n\t}\n\n\t.edit-site-style-book__example:focus:not(:disabled) {\n\t\tbox-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));\n\t\toutline: 3px solid transparent;\n\t}\n\n\t.edit-site-style-book__examples.is-wide .edit-site-style-book__example {\n\t\tflex-direction: row;\n\t}\n\t\n\t.edit-site-style-book__subcategory-title,\n\t.edit-site-style-book__example-title {\n\t\tfont-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n\t\tfont-size: 11px;\n\t\tfont-weight: 500;\n\t\tline-height: normal;\n\t\tmargin: 0;\n\t\ttext-align: left;\n\t\ttext-transform: uppercase;\n\t}\n\t\n\t.edit-site-style-book__subcategory-title {\n\t\tfont-size: 16px;\n\t\tmargin-bottom: 40px;\n \tborder-bottom: 1px solid #ddd;\n \tpadding-bottom: 8px;\n\t}\n\n\t.edit-site-style-book__examples.is-wide .edit-site-style-book__example-title {\n\t\ttext-align: right;\n\t\twidth: 120px;\n\t}\n\n\t.edit-site-style-book__example-preview {\n\t\twidth: 100%;\n\t}\n\n\t.edit-site-style-book__example-preview .block-editor-block-list__insertion-point,\n\t.edit-site-style-book__example-preview .block-list-appender {\n\t\tdisplay: none;\n\t}\n\n\t.edit-site-style-book__example-preview .is-root-container > .wp-block:first-child {\n\t\tmargin-top: 0;\n\t}\n\t.edit-site-style-book__example-preview .is-root-container > .wp-block:last-child {\n\t\tmargin-bottom: 0;\n\t}\n`;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAGA,OAAO,MAAMC,8BAGV,GAAG,CACL;EACCC,IAAI,EAAE,eAAe;EACrBC,KAAK,EAAEH,EAAE,CAAE,eAAgB,CAAC;EAC5BI,MAAM,EAAE,CAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB;AACnE,CAAC,EACD;EACCF,IAAI,EAAE,QAAQ;EACdC,KAAK,EAAEH,EAAE,CAAE,QAAS,CAAC;EACrBI,MAAM,EAAE,CAAE,iBAAiB,EAAE,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AAU,CAAC;EACtBI,MAAM,EAAE;AACT,CAAC,EACD;EACCF,IAAI,EAAE,OAAO;EACbC,KAAK,EAAEH,EAAE,CAAE,QAAS,CAAC;EACrBQ,OAAO,EAAE;AACV,CAAC,CACD;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAI;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
5
|
+
import { getBlockType, getBlockTypes, getBlockFromExample, createBlock } from '@wordpress/blocks';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns a list of examples for registered block types.
|
|
13
|
+
*
|
|
14
|
+
* @return {BlockExample[]} An array of block examples.
|
|
15
|
+
*/
|
|
16
|
+
export function getExamples() {
|
|
17
|
+
const nonHeadingBlockExamples = getBlockTypes().filter(blockType => {
|
|
18
|
+
const {
|
|
19
|
+
name,
|
|
20
|
+
example,
|
|
21
|
+
supports
|
|
22
|
+
} = blockType;
|
|
23
|
+
return name !== 'core/heading' && !!example && supports.inserter !== false;
|
|
24
|
+
}).map(blockType => ({
|
|
25
|
+
name: blockType.name,
|
|
26
|
+
title: blockType.title,
|
|
27
|
+
category: blockType.category,
|
|
28
|
+
blocks: getBlockFromExample(blockType.name, blockType.example)
|
|
29
|
+
}));
|
|
30
|
+
const isHeadingBlockRegistered = !!getBlockType('core/heading');
|
|
31
|
+
if (!isHeadingBlockRegistered) {
|
|
32
|
+
return nonHeadingBlockExamples;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Use our own example for the Heading block so that we can show multiple
|
|
36
|
+
// heading levels.
|
|
37
|
+
const headingsExample = {
|
|
38
|
+
name: 'core/heading',
|
|
39
|
+
title: __('Headings'),
|
|
40
|
+
category: 'text',
|
|
41
|
+
blocks: [1, 2, 3, 4, 5, 6].map(level => {
|
|
42
|
+
return createBlock('core/heading', {
|
|
43
|
+
content: sprintf(
|
|
44
|
+
// translators: %d: heading level e.g: "1", "2", "3"
|
|
45
|
+
__('Heading %d'), level),
|
|
46
|
+
level
|
|
47
|
+
});
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
return [headingsExample, ...nonHeadingBlockExamples];
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=examples.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__","sprintf","getBlockType","getBlockTypes","getBlockFromExample","createBlock","getExamples","nonHeadingBlockExamples","filter","blockType","name","example","supports","inserter","map","title","category","blocks","isHeadingBlockRegistered","headingsExample","level","content"],"sources":["@wordpress/edit-site/src/components/style-book/examples.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tgetBlockType,\n\tgetBlockTypes,\n\tgetBlockFromExample,\n\tcreateBlock,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport type { BlockExample } from './types';\n\n/**\n * Returns a list of examples for registered block types.\n *\n * @return {BlockExample[]} An array of block examples.\n */\nexport function getExamples(): BlockExample[] {\n\tconst nonHeadingBlockExamples = getBlockTypes()\n\t\t.filter( ( blockType ) => {\n\t\t\tconst { name, example, supports } = blockType;\n\t\t\treturn (\n\t\t\t\tname !== 'core/heading' &&\n\t\t\t\t!! example &&\n\t\t\t\tsupports.inserter !== false\n\t\t\t);\n\t\t} )\n\t\t.map( ( blockType ) => ( {\n\t\t\tname: blockType.name,\n\t\t\ttitle: blockType.title,\n\t\t\tcategory: blockType.category,\n\t\t\tblocks: getBlockFromExample( blockType.name, blockType.example ),\n\t\t} ) );\n\tconst isHeadingBlockRegistered = !! getBlockType( 'core/heading' );\n\n\tif ( ! isHeadingBlockRegistered ) {\n\t\treturn nonHeadingBlockExamples;\n\t}\n\n\t// Use our own example for the Heading block so that we can show multiple\n\t// heading levels.\n\tconst headingsExample = {\n\t\tname: 'core/heading',\n\t\ttitle: __( 'Headings' ),\n\t\tcategory: 'text',\n\t\tblocks: [ 1, 2, 3, 4, 5, 6 ].map( ( level ) => {\n\t\t\treturn createBlock( 'core/heading', {\n\t\t\t\tcontent: sprintf(\n\t\t\t\t\t// translators: %d: heading level e.g: \"1\", \"2\", \"3\"\n\t\t\t\t\t__( 'Heading %d' ),\n\t\t\t\t\tlevel\n\t\t\t\t),\n\t\t\t\tlevel,\n\t\t\t} );\n\t\t} ),\n\t};\n\n\treturn [ headingsExample, ...nonHeadingBlockExamples ];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SACCC,YAAY,EACZC,aAAa,EACbC,mBAAmB,EACnBC,WAAW,QACL,mBAAmB;;AAE1B;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAA,EAAmB;EAC7C,MAAMC,uBAAuB,GAAGJ,aAAa,CAAC,CAAC,CAC7CK,MAAM,CAAIC,SAAS,IAAM;IACzB,MAAM;MAAEC,IAAI;MAAEC,OAAO;MAAEC;IAAS,CAAC,GAAGH,SAAS;IAC7C,OACCC,IAAI,KAAK,cAAc,IACvB,CAAC,CAAEC,OAAO,IACVC,QAAQ,CAACC,QAAQ,KAAK,KAAK;EAE7B,CAAE,CAAC,CACFC,GAAG,CAAIL,SAAS,KAAQ;IACxBC,IAAI,EAAED,SAAS,CAACC,IAAI;IACpBK,KAAK,EAAEN,SAAS,CAACM,KAAK;IACtBC,QAAQ,EAAEP,SAAS,CAACO,QAAQ;IAC5BC,MAAM,EAAEb,mBAAmB,CAAEK,SAAS,CAACC,IAAI,EAAED,SAAS,CAACE,OAAQ;EAChE,CAAC,CAAG,CAAC;EACN,MAAMO,wBAAwB,GAAG,CAAC,CAAEhB,YAAY,CAAE,cAAe,CAAC;EAElE,IAAK,CAAEgB,wBAAwB,EAAG;IACjC,OAAOX,uBAAuB;EAC/B;;EAEA;EACA;EACA,MAAMY,eAAe,GAAG;IACvBT,IAAI,EAAE,cAAc;IACpBK,KAAK,EAAEf,EAAE,CAAE,UAAW,CAAC;IACvBgB,QAAQ,EAAE,MAAM;IAChBC,MAAM,EAAE,CAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE,CAACH,GAAG,CAAIM,KAAK,IAAM;MAC9C,OAAOf,WAAW,CAAE,cAAc,EAAE;QACnCgB,OAAO,EAAEpB,OAAO;QACf;QACAD,EAAE,CAAE,YAAa,CAAC,EAClBoB,KACD,CAAC;QACDA;MACD,CAAE,CAAC;IACJ,CAAE;EACH,CAAC;EAED,OAAO,CAAED,eAAe,EAAE,GAAGZ,uBAAuB,CAAE;AACvD","ignoreList":[]}
|
|
@@ -8,7 +8,6 @@ import clsx from 'clsx';
|
|
|
8
8
|
*/
|
|
9
9
|
import { Disabled, Composite, privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
10
10
|
import { __, sprintf } from '@wordpress/i18n';
|
|
11
|
-
import { getCategories, getBlockType, getBlockTypes, getBlockFromExample, createBlock } from '@wordpress/blocks';
|
|
12
11
|
import { BlockList, privateApis as blockEditorPrivateApis, store as blockEditorStore, __unstableEditorStyles as EditorStyles, __unstableIframe as Iframe } from '@wordpress/block-editor';
|
|
13
12
|
import { privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
14
13
|
import { useSelect } from '@wordpress/data';
|
|
@@ -21,6 +20,9 @@ import { ENTER, SPACE } from '@wordpress/keycodes';
|
|
|
21
20
|
*/
|
|
22
21
|
import { unlock } from '../../lock-unlock';
|
|
23
22
|
import EditorCanvasContainer from '../editor-canvas-container';
|
|
23
|
+
import { STYLE_BOOK_IFRAME_STYLES } from './constants';
|
|
24
|
+
import { getExamplesByCategory, getTopLevelStyleBookCategories } from './categories';
|
|
25
|
+
import { getExamples } from './examples';
|
|
24
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
27
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
28
|
const {
|
|
@@ -35,117 +37,9 @@ const {
|
|
|
35
37
|
const {
|
|
36
38
|
Tabs
|
|
37
39
|
} = unlock(componentsPrivateApis);
|
|
38
|
-
|
|
39
|
-
// The content area of the Style Book is rendered within an iframe so that global styles
|
|
40
|
-
// are applied to elements within the entire content area. To support elements that are
|
|
41
|
-
// not part of the block previews, such as headings and layout for the block previews,
|
|
42
|
-
// additional CSS rules need to be passed into the iframe. These are hard-coded below.
|
|
43
|
-
// Note that button styles are unset, and then focus rules from the `Button` component are
|
|
44
|
-
// applied to the `button` element, targeted via `.edit-site-style-book__example`.
|
|
45
|
-
// This is to ensure that browser default styles for buttons are not applied to the previews.
|
|
46
|
-
const STYLE_BOOK_IFRAME_STYLES = `
|
|
47
|
-
.edit-site-style-book__examples {
|
|
48
|
-
max-width: 900px;
|
|
49
|
-
margin: 0 auto;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.edit-site-style-book__example {
|
|
53
|
-
border-radius: 2px;
|
|
54
|
-
cursor: pointer;
|
|
55
|
-
display: flex;
|
|
56
|
-
flex-direction: column;
|
|
57
|
-
gap: 40px;
|
|
58
|
-
margin-bottom: 40px;
|
|
59
|
-
padding: 16px;
|
|
60
|
-
width: 100%;
|
|
61
|
-
box-sizing: border-box;
|
|
62
|
-
scroll-margin-top: 32px;
|
|
63
|
-
scroll-margin-bottom: 32px;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.edit-site-style-book__example.is-selected {
|
|
67
|
-
box-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.edit-site-style-book__example:focus:not(:disabled) {
|
|
71
|
-
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
72
|
-
outline: 3px solid transparent;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.edit-site-style-book__examples.is-wide .edit-site-style-book__example {
|
|
76
|
-
flex-direction: row;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.edit-site-style-book__example-title {
|
|
80
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
81
|
-
font-size: 11px;
|
|
82
|
-
font-weight: 500;
|
|
83
|
-
line-height: normal;
|
|
84
|
-
margin: 0;
|
|
85
|
-
text-align: left;
|
|
86
|
-
text-transform: uppercase;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.edit-site-style-book__examples.is-wide .edit-site-style-book__example-title {
|
|
90
|
-
text-align: right;
|
|
91
|
-
width: 120px;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.edit-site-style-book__example-preview {
|
|
95
|
-
width: 100%;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.edit-site-style-book__example-preview .block-editor-block-list__insertion-point,
|
|
99
|
-
.edit-site-style-book__example-preview .block-list-appender {
|
|
100
|
-
display: none;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.edit-site-style-book__example-preview .is-root-container > .wp-block:first-child {
|
|
104
|
-
margin-top: 0;
|
|
105
|
-
}
|
|
106
|
-
.edit-site-style-book__example-preview .is-root-container > .wp-block:last-child {
|
|
107
|
-
margin-bottom: 0;
|
|
108
|
-
}
|
|
109
|
-
`;
|
|
110
40
|
function isObjectEmpty(object) {
|
|
111
41
|
return !object || Object.keys(object).length === 0;
|
|
112
42
|
}
|
|
113
|
-
function getExamples() {
|
|
114
|
-
const nonHeadingBlockExamples = getBlockTypes().filter(blockType => {
|
|
115
|
-
const {
|
|
116
|
-
name,
|
|
117
|
-
example,
|
|
118
|
-
supports
|
|
119
|
-
} = blockType;
|
|
120
|
-
return name !== 'core/heading' && !!example && supports.inserter !== false;
|
|
121
|
-
}).map(blockType => ({
|
|
122
|
-
name: blockType.name,
|
|
123
|
-
title: blockType.title,
|
|
124
|
-
category: blockType.category,
|
|
125
|
-
blocks: getBlockFromExample(blockType.name, blockType.example)
|
|
126
|
-
}));
|
|
127
|
-
const isHeadingBlockRegistered = !!getBlockType('core/heading');
|
|
128
|
-
if (!isHeadingBlockRegistered) {
|
|
129
|
-
return nonHeadingBlockExamples;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Use our own example for the Heading block so that we can show multiple
|
|
133
|
-
// heading levels.
|
|
134
|
-
const headingsExample = {
|
|
135
|
-
name: 'core/heading',
|
|
136
|
-
title: __('Headings'),
|
|
137
|
-
category: 'text',
|
|
138
|
-
blocks: [1, 2, 3, 4, 5, 6].map(level => {
|
|
139
|
-
return createBlock('core/heading', {
|
|
140
|
-
content: sprintf(
|
|
141
|
-
// translators: %d: heading level e.g: "1", "2", "3"
|
|
142
|
-
__('Heading %d'), level),
|
|
143
|
-
level
|
|
144
|
-
});
|
|
145
|
-
})
|
|
146
|
-
};
|
|
147
|
-
return [headingsExample, ...nonHeadingBlockExamples];
|
|
148
|
-
}
|
|
149
43
|
function StyleBook({
|
|
150
44
|
enableResizing = true,
|
|
151
45
|
isSelected,
|
|
@@ -160,11 +54,7 @@ function StyleBook({
|
|
|
160
54
|
const [textColor] = useGlobalStyle('color.text');
|
|
161
55
|
const [backgroundColor] = useGlobalStyle('color.background');
|
|
162
56
|
const [examples] = useState(getExamples);
|
|
163
|
-
const tabs = useMemo(() =>
|
|
164
|
-
name: category.slug,
|
|
165
|
-
title: category.title,
|
|
166
|
-
icon: category.icon
|
|
167
|
-
})), [examples]);
|
|
57
|
+
const tabs = useMemo(() => getTopLevelStyleBookCategories().filter(category => examples.some(example => example.category === category.slug)), [examples]);
|
|
168
58
|
const {
|
|
169
59
|
base: baseConfig
|
|
170
60
|
} = useContext(GlobalStylesContext);
|
|
@@ -200,16 +90,19 @@ function StyleBook({
|
|
|
200
90
|
children: [resizeObserver, showTabs ? /*#__PURE__*/_jsx("div", {
|
|
201
91
|
className: "edit-site-style-book__tabs",
|
|
202
92
|
children: /*#__PURE__*/_jsxs(Tabs, {
|
|
203
|
-
children: [/*#__PURE__*/_jsx(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
children: tab.
|
|
207
|
-
|
|
93
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
94
|
+
className: "edit-site-style-book__tablist-container",
|
|
95
|
+
children: /*#__PURE__*/_jsx(Tabs.TabList, {
|
|
96
|
+
children: tabs.map(tab => /*#__PURE__*/_jsx(Tabs.Tab, {
|
|
97
|
+
tabId: tab.slug,
|
|
98
|
+
children: tab.title
|
|
99
|
+
}, tab.slug))
|
|
100
|
+
})
|
|
208
101
|
}), tabs.map(tab => /*#__PURE__*/_jsx(Tabs.TabPanel, {
|
|
209
|
-
tabId: tab.
|
|
102
|
+
tabId: tab.slug,
|
|
210
103
|
focusable: false,
|
|
211
104
|
children: /*#__PURE__*/_jsx(StyleBookBody, {
|
|
212
|
-
category: tab.
|
|
105
|
+
category: tab.slug,
|
|
213
106
|
examples: examples,
|
|
214
107
|
isSelected: isSelected,
|
|
215
108
|
onSelect: onSelect,
|
|
@@ -217,7 +110,7 @@ function StyleBook({
|
|
|
217
110
|
sizes: sizes,
|
|
218
111
|
title: tab.title
|
|
219
112
|
})
|
|
220
|
-
}, tab.
|
|
113
|
+
}, tab.slug))]
|
|
221
114
|
})
|
|
222
115
|
}) : /*#__PURE__*/_jsx(StyleBookBody, {
|
|
223
116
|
examples: examples,
|
|
@@ -271,7 +164,6 @@ const StyleBookBody = ({
|
|
|
271
164
|
},
|
|
272
165
|
readonly: true
|
|
273
166
|
};
|
|
274
|
-
const buttonModeStyles = onClick ? 'body { cursor: pointer; } body * { pointer-events: none; }' : '';
|
|
275
167
|
return /*#__PURE__*/_jsxs(Iframe, {
|
|
276
168
|
className: clsx('edit-site-style-book__iframe', {
|
|
277
169
|
'is-focused': isFocused && !!onClick,
|
|
@@ -282,12 +174,8 @@ const StyleBookBody = ({
|
|
|
282
174
|
...(onClick ? buttonModeProps : {}),
|
|
283
175
|
children: [/*#__PURE__*/_jsx(EditorStyles, {
|
|
284
176
|
styles: settings.styles
|
|
285
|
-
}), /*#__PURE__*/
|
|
286
|
-
children:
|
|
287
|
-
// Forming a "block formatting context" to prevent margin collapsing.
|
|
288
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
|
|
289
|
-
`.is-root-container { display: flow-root; }
|
|
290
|
-
body { position: relative; padding: 32px !important; }` + STYLE_BOOK_IFRAME_STYLES + buttonModeStyles
|
|
177
|
+
}), /*#__PURE__*/_jsxs("style", {
|
|
178
|
+
children: [STYLE_BOOK_IFRAME_STYLES, !!onClick && 'body { cursor: pointer; } body * { pointer-events: none; }']
|
|
291
179
|
}), /*#__PURE__*/_jsx(Examples, {
|
|
292
180
|
className: clsx('edit-site-style-book__examples', {
|
|
293
181
|
'is-wide': sizes.width > 600
|
|
@@ -310,12 +198,16 @@ const Examples = memo(({
|
|
|
310
198
|
isSelected,
|
|
311
199
|
onSelect
|
|
312
200
|
}) => {
|
|
313
|
-
|
|
201
|
+
const categoryDefinition = category ? getTopLevelStyleBookCategories().find(_category => _category.slug === category) : null;
|
|
202
|
+
const filteredExamples = categoryDefinition ? getExamplesByCategory(categoryDefinition, examples) : {
|
|
203
|
+
examples
|
|
204
|
+
};
|
|
205
|
+
return /*#__PURE__*/_jsxs(Composite, {
|
|
314
206
|
orientation: "vertical",
|
|
315
207
|
className: className,
|
|
316
208
|
"aria-label": label,
|
|
317
209
|
role: "grid",
|
|
318
|
-
children: examples
|
|
210
|
+
children: [!!filteredExamples?.examples?.length && filteredExamples.examples.map(example => /*#__PURE__*/_jsx(Example, {
|
|
319
211
|
id: `example-${example.name}`,
|
|
320
212
|
title: example.title,
|
|
321
213
|
blocks: example.blocks,
|
|
@@ -323,9 +215,36 @@ const Examples = memo(({
|
|
|
323
215
|
onClick: () => {
|
|
324
216
|
onSelect?.(example.name);
|
|
325
217
|
}
|
|
326
|
-
}, example.name))
|
|
218
|
+
}, example.name)), !!filteredExamples?.subcategories?.length && filteredExamples.subcategories.map(subcategory => /*#__PURE__*/_jsxs(Composite.Group, {
|
|
219
|
+
className: "edit-site-style-book__subcategory",
|
|
220
|
+
children: [/*#__PURE__*/_jsx(Composite.GroupLabel, {
|
|
221
|
+
children: /*#__PURE__*/_jsx("h2", {
|
|
222
|
+
className: "edit-site-style-book__subcategory-title",
|
|
223
|
+
children: subcategory.title
|
|
224
|
+
})
|
|
225
|
+
}), /*#__PURE__*/_jsx(Subcategory, {
|
|
226
|
+
examples: subcategory.examples,
|
|
227
|
+
isSelected: isSelected,
|
|
228
|
+
onSelect: onSelect
|
|
229
|
+
})]
|
|
230
|
+
}, `subcategory-${subcategory.slug}`))]
|
|
327
231
|
});
|
|
328
232
|
});
|
|
233
|
+
const Subcategory = ({
|
|
234
|
+
examples,
|
|
235
|
+
isSelected,
|
|
236
|
+
onSelect
|
|
237
|
+
}) => {
|
|
238
|
+
return !!examples?.length && examples.map(example => /*#__PURE__*/_jsx(Example, {
|
|
239
|
+
id: `example-${example.name}`,
|
|
240
|
+
title: example.title,
|
|
241
|
+
blocks: example.blocks,
|
|
242
|
+
isSelected: isSelected(example.name),
|
|
243
|
+
onClick: () => {
|
|
244
|
+
onSelect?.(example.name);
|
|
245
|
+
}
|
|
246
|
+
}, example.name));
|
|
247
|
+
};
|
|
329
248
|
const Example = ({
|
|
330
249
|
id,
|
|
331
250
|
title,
|