@wordpress/edit-site 4.12.1-next.d6164808d3.0 → 4.14.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/add-new-template/new-template.js +1 -1
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +90 -52
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/index.js +20 -10
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +8 -1
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/editor/index.js +9 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +40 -23
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +6 -2
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +5 -3
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/preview.js +2 -2
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +41 -29
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/index.js +41 -5
- package/build/components/header/index.js.map +1 -1
- package/build/components/list/header.js +15 -2
- package/build/components/list/header.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +10 -4
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +8 -3
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +16 -0
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/index.js +4 -1
- package/build/index.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +2 -2
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +87 -52
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/index.js +20 -9
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +9 -2
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/editor/index.js +10 -5
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +40 -23
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +6 -2
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +6 -4
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/preview.js +2 -2
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +42 -30
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/index.js +42 -7
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/list/header.js +14 -2
- package/build-module/components/list/header.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +11 -5
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +7 -3
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +16 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/index.js +4 -1
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +28 -16
- package/build-style/style.css +28 -16
- package/package.json +29 -29
- package/src/components/add-new-template/new-template.js +2 -0
- package/src/components/add-new-template/utils.js +82 -20
- package/src/components/block-editor/index.js +34 -16
- package/src/components/block-editor/resizable-editor.js +10 -3
- package/src/components/code-editor/style.scss +2 -3
- package/src/components/editor/index.js +12 -5
- package/src/components/global-styles/dimensions-panel.js +52 -31
- package/src/components/global-styles/gradients-palette-panel.js +25 -12
- package/src/components/global-styles/hooks.js +7 -7
- package/src/components/global-styles/preview.js +2 -2
- package/src/components/global-styles/use-global-styles-output.js +66 -57
- package/src/components/global-styles/utils.js +1 -1
- package/src/components/header/index.js +61 -21
- package/src/components/header/style.scss +9 -0
- package/src/components/list/header.js +15 -5
- package/src/components/navigation-sidebar/navigation-panel/index.js +30 -24
- package/src/components/sidebar/index.js +23 -20
- package/src/components/template-part-converter/convert-to-template-part.js +14 -1
- package/src/index.js +4 -0
- package/src/style.scss +1 -0
|
@@ -36,7 +36,11 @@ function GradientPalettePanel(_ref) {
|
|
|
36
36
|
const [baseDefaultGradients] = (0, _hooks.useSetting)('color.gradients.default', name, 'base');
|
|
37
37
|
const [customGradients, setCustomGradients] = (0, _hooks.useSetting)('color.gradients.custom', name);
|
|
38
38
|
const [defaultPaletteEnabled] = (0, _hooks.useSetting)('color.defaultGradients', name);
|
|
39
|
-
const [
|
|
39
|
+
const [customDuotone] = (0, _hooks.useSetting)('color.duotone.custom') || [];
|
|
40
|
+
const [defaultDuotone] = (0, _hooks.useSetting)('color.duotone.default') || [];
|
|
41
|
+
const [themeDuotone] = (0, _hooks.useSetting)('color.duotone.theme') || [];
|
|
42
|
+
const [defaultDuotoneEnabled] = (0, _hooks.useSetting)('color.defaultDuotone');
|
|
43
|
+
const duotonePalette = [...(customDuotone || []), ...(themeDuotone || []), ...(defaultDuotone && defaultDuotoneEnabled ? defaultDuotone : [])];
|
|
40
44
|
return (0, _element.createElement)(_components.__experimentalVStack, {
|
|
41
45
|
className: "edit-site-global-styles-gradient-palette-panel",
|
|
42
46
|
spacing: 10
|
|
@@ -58,7 +62,7 @@ function GradientPalettePanel(_ref) {
|
|
|
58
62
|
paletteLabel: (0, _i18n.__)('Custom'),
|
|
59
63
|
emptyMessage: (0, _i18n.__)('Custom gradients are empty! Add some gradients to create your own palette.'),
|
|
60
64
|
slugPrefix: "custom-"
|
|
61
|
-
}), (0, _element.createElement)("div", null, (0, _element.createElement)(_subtitle.default, null, (0, _i18n.__)('Duotone')), (0, _element.createElement)(_components.__experimentalSpacer, {
|
|
65
|
+
}), !!duotonePalette && !!duotonePalette.length && (0, _element.createElement)("div", null, (0, _element.createElement)(_subtitle.default, null, (0, _i18n.__)('Duotone')), (0, _element.createElement)(_components.__experimentalSpacer, {
|
|
62
66
|
margin: 3
|
|
63
67
|
}), (0, _element.createElement)(_components.DuotonePicker, {
|
|
64
68
|
duotonePalette: duotonePalette,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/gradients-palette-panel.js"],"names":["noop","GradientPalettePanel","name","themeGradients","setThemeGradients","baseThemeGradients","defaultGradients","setDefaultGradients","baseDefaultGradients","customGradients","setCustomGradients","defaultPaletteEnabled","duotonePalette","length"],"mappings":";;;;;;;;;;;AAGA;;AAMA;;AAKA;;AACA;;AAfA;AACA;AACA;;AASA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEe,SAASC,oBAAT,OAA0C;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AACxD,QAAM,CAAEC,cAAF,EAAkBC,iBAAlB,IAAwC,uBAC7C,uBAD6C,EAE7CF,IAF6C,CAA9C;AAIA,QAAM,CAAEG,kBAAF,IAAyB,uBAC9B,uBAD8B,EAE9BH,IAF8B,EAG9B,MAH8B,CAA/B;AAKA,QAAM,CAAEI,gBAAF,EAAoBC,mBAApB,IAA4C,uBACjD,yBADiD,EAEjDL,IAFiD,CAAlD;AAIA,QAAM,CAAEM,oBAAF,IAA2B,uBAChC,yBADgC,EAEhCN,IAFgC,EAGhC,MAHgC,CAAjC;AAKA,QAAM,CAAEO,eAAF,EAAmBC,kBAAnB,IAA0C,uBAC/C,wBAD+C,EAE/CR,IAF+C,CAAhD;AAKA,QAAM,CAAES,qBAAF,IAA4B,uBACjC,wBADiC,EAEjCT,IAFiC,CAAlC;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/gradients-palette-panel.js"],"names":["noop","GradientPalettePanel","name","themeGradients","setThemeGradients","baseThemeGradients","defaultGradients","setDefaultGradients","baseDefaultGradients","customGradients","setCustomGradients","defaultPaletteEnabled","customDuotone","defaultDuotone","themeDuotone","defaultDuotoneEnabled","duotonePalette","length"],"mappings":";;;;;;;;;;;AAGA;;AAMA;;AAKA;;AACA;;AAfA;AACA;AACA;;AASA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEe,SAASC,oBAAT,OAA0C;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AACxD,QAAM,CAAEC,cAAF,EAAkBC,iBAAlB,IAAwC,uBAC7C,uBAD6C,EAE7CF,IAF6C,CAA9C;AAIA,QAAM,CAAEG,kBAAF,IAAyB,uBAC9B,uBAD8B,EAE9BH,IAF8B,EAG9B,MAH8B,CAA/B;AAKA,QAAM,CAAEI,gBAAF,EAAoBC,mBAApB,IAA4C,uBACjD,yBADiD,EAEjDL,IAFiD,CAAlD;AAIA,QAAM,CAAEM,oBAAF,IAA2B,uBAChC,yBADgC,EAEhCN,IAFgC,EAGhC,MAHgC,CAAjC;AAKA,QAAM,CAAEO,eAAF,EAAmBC,kBAAnB,IAA0C,uBAC/C,wBAD+C,EAE/CR,IAF+C,CAAhD;AAKA,QAAM,CAAES,qBAAF,IAA4B,uBACjC,wBADiC,EAEjCT,IAFiC,CAAlC;AAKA,QAAM,CAAEU,aAAF,IAAoB,uBAAY,sBAAZ,KAAwC,EAAlE;AACA,QAAM,CAAEC,cAAF,IAAqB,uBAAY,uBAAZ,KAAyC,EAApE;AACA,QAAM,CAAEC,YAAF,IAAmB,uBAAY,qBAAZ,KAAuC,EAAhE;AACA,QAAM,CAAEC,qBAAF,IAA4B,uBAAY,sBAAZ,CAAlC;AAEA,QAAMC,cAAc,GAAG,CACtB,IAAKJ,aAAa,IAAI,EAAtB,CADsB,EAEtB,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AAoB,EAAG,IAFxB;AAGC,IAAA,mBAAmB,EAAG,IAHvB;AAIC,IAAA,SAAS,EAAG,KAJb;AAKC,IAAA,QAAQ,EAAGhB;AALZ,IAHD,CAlCF,CADD;AAiDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalPaletteEdit as PaletteEdit,\n\t__experimentalSpacer as Spacer,\n\tDuotonePicker,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSetting } from './hooks';\nimport Subtitle from './subtitle';\n\nconst noop = () => {};\n\nexport default function GradientPalettePanel( { name } ) {\n\tconst [ themeGradients, setThemeGradients ] = useSetting(\n\t\t'color.gradients.theme',\n\t\tname\n\t);\n\tconst [ baseThemeGradients ] = useSetting(\n\t\t'color.gradients.theme',\n\t\tname,\n\t\t'base'\n\t);\n\tconst [ defaultGradients, setDefaultGradients ] = useSetting(\n\t\t'color.gradients.default',\n\t\tname\n\t);\n\tconst [ baseDefaultGradients ] = useSetting(\n\t\t'color.gradients.default',\n\t\tname,\n\t\t'base'\n\t);\n\tconst [ customGradients, setCustomGradients ] = useSetting(\n\t\t'color.gradients.custom',\n\t\tname\n\t);\n\n\tconst [ defaultPaletteEnabled ] = useSetting(\n\t\t'color.defaultGradients',\n\t\tname\n\t);\n\n\tconst [ customDuotone ] = useSetting( 'color.duotone.custom' ) || [];\n\tconst [ defaultDuotone ] = useSetting( 'color.duotone.default' ) || [];\n\tconst [ themeDuotone ] = useSetting( 'color.duotone.theme' ) || [];\n\tconst [ defaultDuotoneEnabled ] = useSetting( 'color.defaultDuotone' );\n\n\tconst duotonePalette = [\n\t\t...( customDuotone || [] ),\n\t\t...( themeDuotone || [] ),\n\t\t...( defaultDuotone && defaultDuotoneEnabled ? defaultDuotone : [] ),\n\t];\n\n\treturn (\n\t\t<VStack\n\t\t\tclassName=\"edit-site-global-styles-gradient-palette-panel\"\n\t\t\tspacing={ 10 }\n\t\t>\n\t\t\t{ !! themeGradients && !! themeGradients.length && (\n\t\t\t\t<PaletteEdit\n\t\t\t\t\tcanReset={ themeGradients !== baseThemeGradients }\n\t\t\t\t\tcanOnlyChangeValues\n\t\t\t\t\tgradients={ themeGradients }\n\t\t\t\t\tonChange={ setThemeGradients }\n\t\t\t\t\tpaletteLabel={ __( 'Theme' ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ !! defaultGradients &&\n\t\t\t\t!! defaultGradients.length &&\n\t\t\t\t!! defaultPaletteEnabled && (\n\t\t\t\t\t<PaletteEdit\n\t\t\t\t\t\tcanReset={ defaultGradients !== baseDefaultGradients }\n\t\t\t\t\t\tcanOnlyChangeValues\n\t\t\t\t\t\tgradients={ defaultGradients }\n\t\t\t\t\t\tonChange={ setDefaultGradients }\n\t\t\t\t\t\tpaletteLabel={ __( 'Default' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t<PaletteEdit\n\t\t\t\tgradients={ customGradients }\n\t\t\t\tonChange={ setCustomGradients }\n\t\t\t\tpaletteLabel={ __( 'Custom' ) }\n\t\t\t\temptyMessage={ __(\n\t\t\t\t\t'Custom gradients are empty! Add some gradients to create your own palette.'\n\t\t\t\t) }\n\t\t\t\tslugPrefix=\"custom-\"\n\t\t\t/>\n\t\t\t{ !! duotonePalette && !! duotonePalette.length && (\n\t\t\t\t<div>\n\t\t\t\t\t<Subtitle>{ __( 'Duotone' ) }</Subtitle>\n\t\t\t\t\t<Spacer margin={ 3 } />\n\t\t\t\t\t<DuotonePicker\n\t\t\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\t\t\tdisableCustomDuotone={ true }\n\t\t\t\t\t\tdisableCustomColors={ true }\n\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\tonChange={ noop }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n"]}
|
|
@@ -63,7 +63,8 @@ function useSetting(path, blockName) {
|
|
|
63
63
|
|
|
64
64
|
const setSetting = newValue => {
|
|
65
65
|
setUserConfig(currentConfig => {
|
|
66
|
-
|
|
66
|
+
// Deep clone `currentConfig` to avoid mutating it later.
|
|
67
|
+
const newUserConfig = JSON.parse(JSON.stringify(currentConfig));
|
|
67
68
|
const pathToSet = _blocks.__EXPERIMENTAL_PATHS_WITH_MERGE[path] ? fullPath + '.custom' : fullPath;
|
|
68
69
|
(0, _lodash.set)(newUserConfig, pathToSet, newValue);
|
|
69
70
|
return newUserConfig;
|
|
@@ -126,7 +127,8 @@ function useStyle(path, blockName) {
|
|
|
126
127
|
|
|
127
128
|
const setStyle = newValue => {
|
|
128
129
|
setUserConfig(currentConfig => {
|
|
129
|
-
|
|
130
|
+
// Deep clone `currentConfig` to avoid mutating it later.
|
|
131
|
+
const newUserConfig = JSON.parse(JSON.stringify(currentConfig));
|
|
130
132
|
(0, _lodash.set)(newUserConfig, finalPath, (0, _utils.getPresetVariableFromValue)(mergedConfig.settings, blockName, path, newValue));
|
|
131
133
|
return newUserConfig;
|
|
132
134
|
});
|
|
@@ -186,7 +188,7 @@ function getSupportedGlobalStylesPanels(name) {
|
|
|
186
188
|
|
|
187
189
|
|
|
188
190
|
if (_blocks.__EXPERIMENTAL_STYLE_PROPERTY[styleName].requiresOptOut) {
|
|
189
|
-
if (
|
|
191
|
+
if (_blocks.__EXPERIMENTAL_STYLE_PROPERTY[styleName].support[0] in blockType.supports && (0, _lodash.get)(blockType.supports, _blocks.__EXPERIMENTAL_STYLE_PROPERTY[styleName].support) !== false) {
|
|
190
192
|
return supportKeys.push(styleName);
|
|
191
193
|
}
|
|
192
194
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/hooks.js"],"names":["EMPTY_CONFIG","settings","styles","useGlobalStylesReset","user","config","setUserConfig","GlobalStylesContext","canReset","useSetting","path","blockName","source","merged","mergedConfig","base","baseConfig","userConfig","fullPath","setSetting","newValue","currentConfig","newUserConfig","pathToSet","PATHS_WITH_MERGE","getSettingValueForContext","name","currentPath","getSettingValue","configToUse","result","custom","theme","default","resultWithFallback","useStyle","finalPath","setStyle","ROOT_BLOCK_SUPPORTS","getSupportedGlobalStylesPanels","blockType","supportKeys","supports","spacing","blockGap","__experimentalSkipSerialization","some","spacingType","push","Object","keys","STYLE_PROPERTY","forEach","styleName","support","requiresOptOut","useColorsPerOrigin","customColors","themeColors","defaultColors","shouldDisplayDefaultColors","length","colors","useGradientsPerOrigin","customGradients","themeGradients","defaultGradients","shouldDisplayDefaultGradients","gradients"],"mappings":";;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AASA;;AACA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;AAIA,MAAMA,YAAY,GAAG;AAAEC,EAAAA,QAAQ,EAAE,EAAZ;AAAgBC,EAAAA,MAAM,EAAE;AAAxB,CAArB;;AAEO,MAAMC,oBAAoB,GAAG,MAAM;AACzC,QAAM;AAAEC,IAAAA,IAAI,EAAEC,MAAR;AAAgBC,IAAAA;AAAhB,MAAkC,yBAAYC,4BAAZ,CAAxC;AACA,QAAMC,QAAQ,GAAG,CAAC,CAAEH,MAAH,IAAa,CAAE,qBAASA,MAAT,EAAiBL,YAAjB,CAAhC;AACA,SAAO,CACNQ,QADM,EAEN,0BACC,MAAMF,aAAa,CAAE,MAAMN,YAAR,CADpB,EAEC,CAAEM,aAAF,CAFD,CAFM,CAAP;AAOA,CAVM;;;;AAYA,SAASG,UAAT,CAAqBC,IAArB,EAA2BC,SAA3B,EAAuD;AAAA;;AAAA,MAAjBC,MAAiB,uEAAR,KAAQ;AAC7D,QAAM;AACLC,IAAAA,MAAM,EAAEC,YADH;AAELC,IAAAA,IAAI,EAAEC,UAFD;AAGLZ,IAAAA,IAAI,EAAEa,UAHD;AAILX,IAAAA;AAJK,MAKF,yBAAYC,4BAAZ,CALJ;AAOA,QAAMW,QAAQ,GAAG,CAAEP,SAAF,GACb,YAAYD,IAAM,E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,QAAKF,eAAe,IAAIA,eAAe,CAACH,MAAxC,EAAiD;AAChD/B,MAAAA,MAAM,CAACkB,IAAP,CAAa;AACZtB,QAAAA,IAAI,EAAE,cACL,QADK,EAEL,gDAFK,CADM;AAKZ0C,QAAAA,SAAS,EAAEJ;AALC,OAAb;AAOA;;AACD,WAAOlC,MAAP;AACA,GAlCM,EAkCJ,CAAEkC,eAAF,EAAmBC,cAAnB,EAAmCC,gBAAnC,CAlCI,CAAP;AAmCA","sourcesContent":["/**\n * External dependencies\n */\nimport { get, cloneDeep, set, isEqual, has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useContext, useCallback, useMemo } from '@wordpress/element';\nimport {\n\tgetBlockType,\n\t__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromVariable, getPresetVariableFromValue } from './utils';\nimport { GlobalStylesContext } from './context';\n\nconst EMPTY_CONFIG = { settings: {}, styles: {} };\n\nexport const useGlobalStylesReset = () => {\n\tconst { user: config, setUserConfig } = useContext( GlobalStylesContext );\n\tconst canReset = !! config && ! isEqual( config, EMPTY_CONFIG );\n\treturn [\n\t\tcanReset,\n\t\tuseCallback(\n\t\t\t() => setUserConfig( () => EMPTY_CONFIG ),\n\t\t\t[ setUserConfig ]\n\t\t),\n\t];\n};\n\nexport function useSetting( path, blockName, source = 'all' ) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\n\tconst fullPath = ! blockName\n\t\t? `settings.${ path }`\n\t\t: `settings.blocks.${ blockName }.${ path }`;\n\n\tconst setSetting = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\tconst newUserConfig = cloneDeep( currentConfig );\n\t\t\tconst pathToSet = PATHS_WITH_MERGE[ path ]\n\t\t\t\t? fullPath + '.custom'\n\t\t\t\t: fullPath;\n\t\t\tset( newUserConfig, pathToSet, newValue );\n\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\tconst getSettingValueForContext = ( name ) => {\n\t\tconst currentPath = ! name\n\t\t\t? `settings.${ path }`\n\t\t\t: `settings.blocks.${ name }.${ path }`;\n\n\t\tconst getSettingValue = ( configToUse ) => {\n\t\t\tconst result = get( configToUse, currentPath );\n\t\t\tif ( PATHS_WITH_MERGE[ path ] ) {\n\t\t\t\treturn result?.custom ?? result?.theme ?? result?.default;\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\n\t\tlet result;\n\t\tswitch ( source ) {\n\t\t\tcase 'all':\n\t\t\t\tresult = getSettingValue( mergedConfig );\n\t\t\t\tbreak;\n\t\t\tcase 'user':\n\t\t\t\tresult = getSettingValue( userConfig );\n\t\t\t\tbreak;\n\t\t\tcase 'base':\n\t\t\t\tresult = getSettingValue( baseConfig );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow 'Unsupported source';\n\t\t}\n\n\t\treturn result;\n\t};\n\n\t// Unlike styles settings get inherited from top level settings.\n\tconst resultWithFallback =\n\t\tgetSettingValueForContext( blockName ) ?? getSettingValueForContext();\n\n\treturn [ resultWithFallback, setSetting ];\n}\n\nexport function useStyle( path, blockName, source = 'all' ) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\tconst finalPath = ! blockName\n\t\t? `styles.${ path }`\n\t\t: `styles.blocks.${ blockName }.${ path }`;\n\n\tconst setStyle = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\tconst newUserConfig = cloneDeep( currentConfig );\n\t\t\tset(\n\t\t\t\tnewUserConfig,\n\t\t\t\tfinalPath,\n\t\t\t\tgetPresetVariableFromValue(\n\t\t\t\t\tmergedConfig.settings,\n\t\t\t\t\tblockName,\n\t\t\t\t\tpath,\n\t\t\t\t\tnewValue\n\t\t\t\t)\n\t\t\t);\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\tlet result;\n\tswitch ( source ) {\n\t\tcase 'all':\n\t\t\tresult = getValueFromVariable(\n\t\t\t\tmergedConfig,\n\t\t\t\tblockName,\n\t\t\t\tget( userConfig, finalPath ) ?? get( baseConfig, finalPath )\n\t\t\t);\n\t\t\tbreak;\n\t\tcase 'user':\n\t\t\tresult = getValueFromVariable(\n\t\t\t\tmergedConfig,\n\t\t\t\tblockName,\n\t\t\t\tget( userConfig, finalPath )\n\t\t\t);\n\t\t\tbreak;\n\t\tcase 'base':\n\t\t\tresult = getValueFromVariable(\n\t\t\t\tbaseConfig,\n\t\t\t\tblockName,\n\t\t\t\tget( baseConfig, finalPath )\n\t\t\t);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow 'Unsupported source';\n\t}\n\n\treturn [ result, setStyle ];\n}\n\nconst ROOT_BLOCK_SUPPORTS = [\n\t'background',\n\t'backgroundColor',\n\t'color',\n\t'linkColor',\n\t'buttonColor',\n\t'fontFamily',\n\t'fontSize',\n\t'fontStyle',\n\t'fontWeight',\n\t'lineHeight',\n\t'textDecoration',\n\t'textTransform',\n\t'padding',\n\t'contentSize',\n\t'wideSize',\n\t'blockGap',\n];\n\nexport function getSupportedGlobalStylesPanels( name ) {\n\tif ( ! name ) {\n\t\treturn ROOT_BLOCK_SUPPORTS;\n\t}\n\n\tconst blockType = getBlockType( name );\n\n\tif ( ! blockType ) {\n\t\treturn [];\n\t}\n\n\tconst supportKeys = [];\n\n\t// Check for blockGap support.\n\t// Block spacing support doesn't map directly to a single style property, so needs to be handled separately.\n\t// Also, only allow `blockGap` support if serialization has not been skipped, to be sure global spacing can be applied.\n\tif (\n\t\tblockType?.supports?.spacing?.blockGap &&\n\t\tblockType?.supports?.spacing?.__experimentalSkipSerialization !==\n\t\t\ttrue &&\n\t\t! blockType?.supports?.spacing?.__experimentalSkipSerialization?.some?.(\n\t\t\t( spacingType ) => spacingType === 'blockGap'\n\t\t)\n\t) {\n\t\tsupportKeys.push( 'blockGap' );\n\t}\n\n\tObject.keys( STYLE_PROPERTY ).forEach( ( styleName ) => {\n\t\tif ( ! STYLE_PROPERTY[ styleName ].support ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Opting out means that, for certain support keys like background color,\n\t\t// blocks have to explicitly set the support value false. If the key is\n\t\t// unset, we still enable it.\n\t\tif ( STYLE_PROPERTY[ styleName ].requiresOptOut ) {\n\t\t\tif (\n\t\t\t\thas(\n\t\t\t\t\tblockType.supports,\n\t\t\t\t\tSTYLE_PROPERTY[ styleName ].support[ 0 ]\n\t\t\t\t) &&\n\t\t\t\tget(\n\t\t\t\t\tblockType.supports,\n\t\t\t\t\tSTYLE_PROPERTY[ styleName ].support\n\t\t\t\t) !== false\n\t\t\t) {\n\t\t\t\treturn supportKeys.push( styleName );\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tget(\n\t\t\t\tblockType.supports,\n\t\t\t\tSTYLE_PROPERTY[ styleName ].support,\n\t\t\t\tfalse\n\t\t\t)\n\t\t) {\n\t\t\treturn supportKeys.push( styleName );\n\t\t}\n\t} );\n\n\treturn supportKeys;\n}\n\nexport function useColorsPerOrigin( name ) {\n\tconst [ customColors ] = useSetting( 'color.palette.custom', name );\n\tconst [ themeColors ] = useSetting( 'color.palette.theme', name );\n\tconst [ defaultColors ] = useSetting( 'color.palette.default', name );\n\tconst [ shouldDisplayDefaultColors ] = useSetting( 'color.defaultPalette' );\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [ customColors, themeColors, defaultColors ] );\n}\n\nexport function useGradientsPerOrigin( name ) {\n\tconst [ customGradients ] = useSetting( 'color.gradients.custom', name );\n\tconst [ themeGradients ] = useSetting( 'color.gradients.theme', name );\n\tconst [ defaultGradients ] = useSetting( 'color.gradients.default', name );\n\tconst [ shouldDisplayDefaultGradients ] = useSetting(\n\t\t'color.defaultGradients'\n\t);\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [ customGradients, themeGradients, defaultGradients ] );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/hooks.js"],"names":["EMPTY_CONFIG","settings","styles","useGlobalStylesReset","user","config","setUserConfig","GlobalStylesContext","canReset","useSetting","path","blockName","source","merged","mergedConfig","base","baseConfig","userConfig","fullPath","setSetting","newValue","currentConfig","newUserConfig","JSON","parse","stringify","pathToSet","PATHS_WITH_MERGE","getSettingValueForContext","name","currentPath","getSettingValue","configToUse","result","custom","theme","default","resultWithFallback","useStyle","finalPath","setStyle","ROOT_BLOCK_SUPPORTS","getSupportedGlobalStylesPanels","blockType","supportKeys","supports","spacing","blockGap","__experimentalSkipSerialization","some","spacingType","push","Object","keys","STYLE_PROPERTY","forEach","styleName","support","requiresOptOut","useColorsPerOrigin","customColors","themeColors","defaultColors","shouldDisplayDefaultColors","length","colors","useGradientsPerOrigin","customGradients","themeGradients","defaultGradients","shouldDisplayDefaultGradients","gradients"],"mappings":";;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AASA;;AACA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;AAIA,MAAMA,YAAY,GAAG;AAAEC,EAAAA,QAAQ,EAAE,EAAZ;AAAgBC,EAAAA,MAAM,EAAE;AAAxB,CAArB;;AAEO,MAAMC,oBAAoB,GAAG,MAAM;AACzC,QAAM;AAAEC,IAAAA,IAAI,EAAEC,MAAR;AAAgBC,IAAAA;AAAhB,MAAkC,yBAAYC,4BAAZ,CAAxC;AACA,QAAMC,QAAQ,GAAG,CAAC,CAAEH,MAAH,IAAa,CAAE,qBAASA,MAAT,EAAiBL,YAAjB,CAAhC;AACA,SAAO,CACNQ,QADM,EAEN,0BACC,MAAMF,aAAa,CAAE,MAAMN,YAAR,CADpB,EAEC,CAAEM,aAAF,CAFD,CAFM,CAAP;AAOA,CAVM;;;;AAYA,SAASG,UAA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G,EAAf;;AACA,QAAKmC,cAAc,IAAIA,cAAc,CAACJ,MAAtC,EAA+C;AAC9C/B,MAAAA,MAAM,CAACkB,IAAP,CAAa;AACZtB,QAAAA,IAAI,EAAE,cACL,OADK,EAEL,8CAFK,CADM;AAKZ0C,QAAAA,SAAS,EAAEH;AALC,OAAb;AAOA;;AACD,QACCE,6BAA6B,IAC7BD,gBADA,IAEAA,gBAAgB,CAACL,MAHlB,EAIE;AACD/B,MAAAA,MAAM,CAACkB,IAAP,CAAa;AACZtB,QAAAA,IAAI,EAAE,cACL,SADK,EAEL,8CAFK,CADM;AAKZ0C,QAAAA,SAAS,EAAEF;AALC,OAAb;AAOA;;AACD,QAAKF,eAAe,IAAIA,eAAe,CAACH,MAAxC,EAAiD;AAChD/B,MAAAA,MAAM,CAACkB,IAAP,CAAa;AACZtB,QAAAA,IAAI,EAAE,cACL,QADK,EAEL,gDAFK,CADM;AAKZ0C,QAAAA,SAAS,EAAEJ;AALC,OAAb;AAOA;;AACD,WAAOlC,MAAP;AACA,GAlCM,EAkCJ,CAAEkC,eAAF,EAAmBC,cAAnB,EAAmCC,gBAAnC,CAlCI,CAAP;AAmCA","sourcesContent":["/**\n * External dependencies\n */\nimport { get, set, isEqual } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useContext, useCallback, useMemo } from '@wordpress/element';\nimport {\n\tgetBlockType,\n\t__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromVariable, getPresetVariableFromValue } from './utils';\nimport { GlobalStylesContext } from './context';\n\nconst EMPTY_CONFIG = { settings: {}, styles: {} };\n\nexport const useGlobalStylesReset = () => {\n\tconst { user: config, setUserConfig } = useContext( GlobalStylesContext );\n\tconst canReset = !! config && ! isEqual( config, EMPTY_CONFIG );\n\treturn [\n\t\tcanReset,\n\t\tuseCallback(\n\t\t\t() => setUserConfig( () => EMPTY_CONFIG ),\n\t\t\t[ setUserConfig ]\n\t\t),\n\t];\n};\n\nexport function useSetting( path, blockName, source = 'all' ) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\n\tconst fullPath = ! blockName\n\t\t? `settings.${ path }`\n\t\t: `settings.blocks.${ blockName }.${ path }`;\n\n\tconst setSetting = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\t// Deep clone `currentConfig` to avoid mutating it later.\n\t\t\tconst newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );\n\t\t\tconst pathToSet = PATHS_WITH_MERGE[ path ]\n\t\t\t\t? fullPath + '.custom'\n\t\t\t\t: fullPath;\n\t\t\tset( newUserConfig, pathToSet, newValue );\n\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\tconst getSettingValueForContext = ( name ) => {\n\t\tconst currentPath = ! name\n\t\t\t? `settings.${ path }`\n\t\t\t: `settings.blocks.${ name }.${ path }`;\n\n\t\tconst getSettingValue = ( configToUse ) => {\n\t\t\tconst result = get( configToUse, currentPath );\n\t\t\tif ( PATHS_WITH_MERGE[ path ] ) {\n\t\t\t\treturn result?.custom ?? result?.theme ?? result?.default;\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\n\t\tlet result;\n\t\tswitch ( source ) {\n\t\t\tcase 'all':\n\t\t\t\tresult = getSettingValue( mergedConfig );\n\t\t\t\tbreak;\n\t\t\tcase 'user':\n\t\t\t\tresult = getSettingValue( userConfig );\n\t\t\t\tbreak;\n\t\t\tcase 'base':\n\t\t\t\tresult = getSettingValue( baseConfig );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow 'Unsupported source';\n\t\t}\n\n\t\treturn result;\n\t};\n\n\t// Unlike styles settings get inherited from top level settings.\n\tconst resultWithFallback =\n\t\tgetSettingValueForContext( blockName ) ?? getSettingValueForContext();\n\n\treturn [ resultWithFallback, setSetting ];\n}\n\nexport function useStyle( path, blockName, source = 'all' ) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\tconst finalPath = ! blockName\n\t\t? `styles.${ path }`\n\t\t: `styles.blocks.${ blockName }.${ path }`;\n\n\tconst setStyle = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\t// Deep clone `currentConfig` to avoid mutating it later.\n\t\t\tconst newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );\n\t\t\tset(\n\t\t\t\tnewUserConfig,\n\t\t\t\tfinalPath,\n\t\t\t\tgetPresetVariableFromValue(\n\t\t\t\t\tmergedConfig.settings,\n\t\t\t\t\tblockName,\n\t\t\t\t\tpath,\n\t\t\t\t\tnewValue\n\t\t\t\t)\n\t\t\t);\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\tlet result;\n\tswitch ( source ) {\n\t\tcase 'all':\n\t\t\tresult = getValueFromVariable(\n\t\t\t\tmergedConfig,\n\t\t\t\tblockName,\n\t\t\t\tget( userConfig, finalPath ) ?? get( baseConfig, finalPath )\n\t\t\t);\n\t\t\tbreak;\n\t\tcase 'user':\n\t\t\tresult = getValueFromVariable(\n\t\t\t\tmergedConfig,\n\t\t\t\tblockName,\n\t\t\t\tget( userConfig, finalPath )\n\t\t\t);\n\t\t\tbreak;\n\t\tcase 'base':\n\t\t\tresult = getValueFromVariable(\n\t\t\t\tbaseConfig,\n\t\t\t\tblockName,\n\t\t\t\tget( baseConfig, finalPath )\n\t\t\t);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow 'Unsupported source';\n\t}\n\n\treturn [ result, setStyle ];\n}\n\nconst ROOT_BLOCK_SUPPORTS = [\n\t'background',\n\t'backgroundColor',\n\t'color',\n\t'linkColor',\n\t'buttonColor',\n\t'fontFamily',\n\t'fontSize',\n\t'fontStyle',\n\t'fontWeight',\n\t'lineHeight',\n\t'textDecoration',\n\t'textTransform',\n\t'padding',\n\t'contentSize',\n\t'wideSize',\n\t'blockGap',\n];\n\nexport function getSupportedGlobalStylesPanels( name ) {\n\tif ( ! name ) {\n\t\treturn ROOT_BLOCK_SUPPORTS;\n\t}\n\n\tconst blockType = getBlockType( name );\n\n\tif ( ! blockType ) {\n\t\treturn [];\n\t}\n\n\tconst supportKeys = [];\n\n\t// Check for blockGap support.\n\t// Block spacing support doesn't map directly to a single style property, so needs to be handled separately.\n\t// Also, only allow `blockGap` support if serialization has not been skipped, to be sure global spacing can be applied.\n\tif (\n\t\tblockType?.supports?.spacing?.blockGap &&\n\t\tblockType?.supports?.spacing?.__experimentalSkipSerialization !==\n\t\t\ttrue &&\n\t\t! blockType?.supports?.spacing?.__experimentalSkipSerialization?.some?.(\n\t\t\t( spacingType ) => spacingType === 'blockGap'\n\t\t)\n\t) {\n\t\tsupportKeys.push( 'blockGap' );\n\t}\n\n\tObject.keys( STYLE_PROPERTY ).forEach( ( styleName ) => {\n\t\tif ( ! STYLE_PROPERTY[ styleName ].support ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Opting out means that, for certain support keys like background color,\n\t\t// blocks have to explicitly set the support value false. If the key is\n\t\t// unset, we still enable it.\n\t\tif ( STYLE_PROPERTY[ styleName ].requiresOptOut ) {\n\t\t\tif (\n\t\t\t\tSTYLE_PROPERTY[ styleName ].support[ 0 ] in\n\t\t\t\t\tblockType.supports &&\n\t\t\t\tget(\n\t\t\t\t\tblockType.supports,\n\t\t\t\t\tSTYLE_PROPERTY[ styleName ].support\n\t\t\t\t) !== false\n\t\t\t) {\n\t\t\t\treturn supportKeys.push( styleName );\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tget(\n\t\t\t\tblockType.supports,\n\t\t\t\tSTYLE_PROPERTY[ styleName ].support,\n\t\t\t\tfalse\n\t\t\t)\n\t\t) {\n\t\t\treturn supportKeys.push( styleName );\n\t\t}\n\t} );\n\n\treturn supportKeys;\n}\n\nexport function useColorsPerOrigin( name ) {\n\tconst [ customColors ] = useSetting( 'color.palette.custom', name );\n\tconst [ themeColors ] = useSetting( 'color.palette.theme', name );\n\tconst [ defaultColors ] = useSetting( 'color.palette.default', name );\n\tconst [ shouldDisplayDefaultColors ] = useSetting( 'color.defaultPalette' );\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [ customColors, themeColors, defaultColors ] );\n}\n\nexport function useGradientsPerOrigin( name ) {\n\tconst [ customGradients ] = useSetting( 'color.gradients.custom', name );\n\tconst [ themeGradients ] = useSetting( 'color.gradients.theme', name );\n\tconst [ defaultGradients ] = useSetting( 'color.gradients.default', name );\n\tconst [ shouldDisplayDefaultGradients ] = useSetting(\n\t\t'color.defaultGradients'\n\t);\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [ customGradients, themeGradients, defaultGradients ] );\n}\n"]}
|
|
@@ -79,12 +79,12 @@ const StylesPreview = _ref => {
|
|
|
79
79
|
color
|
|
80
80
|
} = _ref2;
|
|
81
81
|
return color !== backgroundColor && color !== headingColor;
|
|
82
|
-
}).slice(0, 2); // Reset leaked styles from WP common.css.
|
|
82
|
+
}).slice(0, 2); // Reset leaked styles from WP common.css and remove main content layout padding.
|
|
83
83
|
|
|
84
84
|
const editorStyles = (0, _element.useMemo)(() => {
|
|
85
85
|
if (styles) {
|
|
86
86
|
return [...styles, {
|
|
87
|
-
css: 'body{min-width: 0;}',
|
|
87
|
+
css: 'body{min-width: 0;padding: 0;}',
|
|
88
88
|
isGlobalStyles: true
|
|
89
89
|
}];
|
|
90
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/preview.js"],"names":["firstFrame","start","opacity","display","hover","secondFrame","normalizedWidth","normalizedHeight","normalizedColorSwatchSize","StylesPreview","label","isFocused","fontWeight","fontFamily","headingFontFamily","headingFontWeight","textColor","headingColor","linkColor","backgroundColor","gradientValue","styles","disableMotion","coreColors","themeColors","customColors","isHovered","setIsHovered","containerResizeListener","width","ratio","paletteColors","concat","highlightedColors","filter","color","slice","editorStyles","css","isGlobalStyles","height","visibility","background","cursor","overflow","fontSize","map","slug","borderRadius","padding","boxSizing","lineHeight","index","flexGrow"],"mappings":";;;;;;;AAaA;;AAVA;;AAIA;;AAKA;;AAMA;;AACA;;AAnBA;AACA;AACA;;AAaA;AACA;AACA;AAIA,MAAMA,UAAU,GAAG;AAClBC,EAAAA,KAAK,EAAE;AACNC,IAAAA,OAAO,EAAE,CADH;AAENC,IAAAA,OAAO,EAAE;AAFH,GADW;AAKlBC,EAAAA,KAAK,EAAE;AACNF,IAAAA,OAAO,EAAE,CADH;AAENC,IAAAA,OAAO,EAAE;AAFH;AALW,CAAnB;AAWA,MAAME,WAAW,GAAG;AACnBD,EAAAA,KAAK,EAAE;AACNF,IAAAA,OAAO,EAAE,CADH;AAENC,IAAAA,OAAO,EAAE;AAFH,GADY;AAKnBF,EAAAA,KAAK,EAAE;AACNC,IAAAA,OAAO,EAAE,CADH;AAENC,IAAAA,OAAO,EAAE;AAFH;AALY,CAApB;AAWA,MAAMG,eAAe,GAAG,GAAxB;AACA,MAAMC,gBAAgB,GAAG,GAAzB;AAEA,MAAMC,yBAAyB,GAAG,EAAlC;;AAEA,MAAMC,aAAa,GAAG,QAA4B;AAAA,MAA1B;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAA0B;AACjD,QAAM,CAAEC,UAAF,IAAiB,qBAAU,uBAAV,CAAvB;AACA,QAAM,CAAEC,UAAU,GAAG,OAAf,IAA2B,qBAAU,uBAAV,CAAjC;AACA,QAAM,CAAEC,iBAAiB,GAAGD,UAAtB,IAAqC,qBAC1C,mCAD0C,CAA3C;AAGA,QAAM,CAAEE,iBAAiB,GAAGH,UAAtB,IAAqC,qBAC1C,mCAD0C,CAA3C;AAGA,QAAM,CAAEI,SAAS,GAAG,OAAd,IAA0B,qBAAU,YAAV,CAAhC;AACA,QAA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;AAEPjB,MAAAA,UAAU,EAAEC,iBAFL;AAGPqB,MAAAA,KAAK,EAAElB,YAHA;AAIPL,MAAAA,UAAU,EAAEG,iBAJL;AAKPoC,MAAAA,UAAU,EAAE;AALL;AADT,KASGzC,KATH,CAXF,EAuBC,4BAAC,gCAAD;AAAQ,IAAA,OAAO,EAAG,IAAIoB,KAAtB;AAA8B,IAAA,OAAO,EAAC;AAAtC,KACC;AACC,IAAA,KAAK,EAAG;AACPjB,MAAAA,UADO;AAEPgC,MAAAA,QAAQ,EAAE,KAAKf,KAFR;AAGPK,MAAAA,KAAK,EAAEnB;AAHA;AADT,UADD,EAUC;AACC,IAAA,KAAK,EAAG;AACPH,MAAAA,UADO;AAEPgC,MAAAA,QAAQ,EAAE,KAAKf,KAFR;AAGPK,MAAAA,KAAK,EAAEjB;AAHA;AADT,UAVD,CAvBD,EA2CGa,aAAa,IACd,4BAAC,gCAAD;AAAQ,IAAA,OAAO,EAAG;AAAlB,KACGA,aAAa,CACbK,KADA,CACO,CADP,EACU,CADV,EAEAU,GAFA,CAEK,QAAaM,KAAb;AAAA,QAAE;AAAEjB,MAAAA;AAAF,KAAF;AAAA,WACL;AACC,MAAA,GAAG,EAAGiB,KADP;AAEC,MAAA,KAAK,EAAG;AACPZ,QAAAA,MAAM,EAAE,KAAKV,KADN;AAEPD,QAAAA,KAAK,EAAE,KAAKC,KAFL;AAGPY,QAAAA,UAAU,EAAEP,KAHL;AAIPkB,QAAAA,QAAQ,EAAE;AAJH;AAFT,MADK;AAAA,GAFL,CADH,CA5CF,CAPD,CA3DD,CAZD,CADD;AAgJA,CAhMD;;eAkMe5C,a","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__unstableIframe as Iframe,\n\t__unstableEditorStyles as EditorStyles,\n} from '@wordpress/block-editor';\nimport {\n\t__unstableMotion as motion,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useReducedMotion, useResizeObserver } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSetting, useStyle } from './hooks';\nimport { useGlobalStylesOutput } from './use-global-styles-output';\n\nconst firstFrame = {\n\tstart: {\n\t\topacity: 1,\n\t\tdisplay: 'block',\n\t},\n\thover: {\n\t\topacity: 0,\n\t\tdisplay: 'none',\n\t},\n};\n\nconst secondFrame = {\n\thover: {\n\t\topacity: 1,\n\t\tdisplay: 'block',\n\t},\n\tstart: {\n\t\topacity: 0,\n\t\tdisplay: 'none',\n\t},\n};\n\nconst normalizedWidth = 248;\nconst normalizedHeight = 152;\n\nconst normalizedColorSwatchSize = 32;\n\nconst StylesPreview = ( { label, isFocused } ) => {\n\tconst [ fontWeight ] = useStyle( 'typography.fontWeight' );\n\tconst [ fontFamily = 'serif' ] = useStyle( 'typography.fontFamily' );\n\tconst [ headingFontFamily = fontFamily ] = useStyle(\n\t\t'elements.h1.typography.fontFamily'\n\t);\n\tconst [ headingFontWeight = fontWeight ] = useStyle(\n\t\t'elements.h1.typography.fontWeight'\n\t);\n\tconst [ textColor = 'black' ] = useStyle( 'color.text' );\n\tconst [ headingColor = textColor ] = useStyle( 'elements.h1.color.text' );\n\tconst [ linkColor = 'blue' ] = useStyle( 'elements.link.color.text' );\n\tconst [ backgroundColor = 'white' ] = useStyle( 'color.background' );\n\tconst [ gradientValue ] = useStyle( 'color.gradient' );\n\tconst [ styles ] = useGlobalStylesOutput();\n\tconst disableMotion = useReducedMotion();\n\tconst [ coreColors ] = useSetting( 'color.palette.core' );\n\tconst [ themeColors ] = useSetting( 'color.palette.theme' );\n\tconst [ customColors ] = useSetting( 'color.palette.custom' );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst [ containerResizeListener, { width } ] = useResizeObserver();\n\tconst ratio = width ? width / normalizedWidth : 1;\n\n\tconst paletteColors = ( themeColors ?? [] )\n\t\t.concat( customColors ?? [] )\n\t\t.concat( coreColors ?? [] );\n\tconst highlightedColors = paletteColors\n\t\t.filter(\n\t\t\t// we exclude these two colors because they are already visible in the preview.\n\t\t\t( { color } ) => color !== backgroundColor && color !== headingColor\n\t\t)\n\t\t.slice( 0, 2 );\n\n\t// Reset leaked styles from WP common.css.\n\tconst editorStyles = useMemo( () => {\n\t\tif ( styles ) {\n\t\t\treturn [\n\t\t\t\t...styles,\n\t\t\t\t{\n\t\t\t\t\tcss: 'body{min-width: 0;}',\n\t\t\t\t\tisGlobalStyles: true,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn styles;\n\t}, [ styles ] );\n\n\treturn (\n\t\t<Iframe\n\t\t\tclassName=\"edit-site-global-styles-preview__iframe\"\n\t\t\thead={ <EditorStyles styles={ editorStyles } /> }\n\t\t\tstyle={ {\n\t\t\t\theight: normalizedHeight * ratio,\n\t\t\t\tvisibility: ! width ? 'hidden' : 'visible',\n\t\t\t} }\n\t\t\tonMouseEnter={ () => setIsHovered( true ) }\n\t\t\tonMouseLeave={ () => setIsHovered( false ) }\n\t\t\ttabIndex={ -1 }\n\t\t>\n\t\t\t{ containerResizeListener }\n\t\t\t<motion.div\n\t\t\t\tstyle={ {\n\t\t\t\t\theight: normalizedHeight * ratio,\n\t\t\t\t\twidth: '100%',\n\t\t\t\t\tbackground: gradientValue ?? backgroundColor,\n\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t} }\n\t\t\t\tinitial=\"start\"\n\t\t\t\tanimate={\n\t\t\t\t\t( isHovered || isFocused ) && ! disableMotion\n\t\t\t\t\t\t? 'hover'\n\t\t\t\t\t\t: 'start'\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ firstFrame }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tspacing={ 10 * ratio }\n\t\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tfontFamily: headingFontFamily,\n\t\t\t\t\t\t\t\tfontSize: 65 * ratio,\n\t\t\t\t\t\t\t\tcolor: headingColor,\n\t\t\t\t\t\t\t\tfontWeight: headingFontWeight,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tAa\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<VStack spacing={ 4 * ratio }>\n\t\t\t\t\t\t\t{ highlightedColors.map( ( { slug, color } ) => (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\theight:\n\t\t\t\t\t\t\t\t\t\t\tnormalizedColorSwatchSize * ratio,\n\t\t\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\t\t\tnormalizedColorSwatchSize * ratio,\n\t\t\t\t\t\t\t\t\t\tbackground: color,\n\t\t\t\t\t\t\t\t\t\tborderRadius:\n\t\t\t\t\t\t\t\t\t\t\t( normalizedColorSwatchSize *\n\t\t\t\t\t\t\t\t\t\t\t\tratio ) /\n\t\t\t\t\t\t\t\t\t\t\t2,\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</HStack>\n\t\t\t\t</motion.div>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ secondFrame }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<VStack\n\t\t\t\t\t\tspacing={ 3 * ratio }\n\t\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\tpadding: 10 * ratio,\n\t\t\t\t\t\t\tboxSizing: 'border-box',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tfontSize: 35 * ratio,\n\t\t\t\t\t\t\t\t\tfontFamily: headingFontFamily,\n\t\t\t\t\t\t\t\t\tcolor: headingColor,\n\t\t\t\t\t\t\t\t\tfontWeight: headingFontWeight,\n\t\t\t\t\t\t\t\t\tlineHeight: '1em',\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<HStack spacing={ 2 * ratio } justify=\"flex-start\">\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tfontFamily,\n\t\t\t\t\t\t\t\t\tfontSize: 24 * ratio,\n\t\t\t\t\t\t\t\t\tcolor: textColor,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tAa\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tfontFamily,\n\t\t\t\t\t\t\t\t\tfontSize: 24 * ratio,\n\t\t\t\t\t\t\t\t\tcolor: linkColor,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tAa\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t{ paletteColors && (\n\t\t\t\t\t\t\t<HStack spacing={ 0 }>\n\t\t\t\t\t\t\t\t{ paletteColors\n\t\t\t\t\t\t\t\t\t.slice( 0, 4 )\n\t\t\t\t\t\t\t\t\t.map( ( { color }, index ) => (\n\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\theight: 10 * ratio,\n\t\t\t\t\t\t\t\t\t\t\t\twidth: 30 * ratio,\n\t\t\t\t\t\t\t\t\t\t\t\tbackground: color,\n\t\t\t\t\t\t\t\t\t\t\t\tflexGrow: 1,\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</VStack>\n\t\t\t\t</motion.div>\n\t\t\t</motion.div>\n\t\t</Iframe>\n\t);\n};\n\nexport default StylesPreview;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/preview.js"],"names":["firstFrame","start","opacity","display","hover","secondFrame","normalizedWidth","normalizedHeight","normalizedColorSwatchSize","StylesPreview","label","isFocused","fontWeight","fontFamily","headingFontFamily","headingFontWeight","textColor","headingColor","linkColor","backgroundColor","gradientValue","styles","disableMotion","coreColors","themeColors","customColors","isHovered","setIsHovered","containerResizeListener","width","ratio","paletteColors","concat","highlightedColors","filter","color","slice","editorStyles","css","isGlobalStyles","height","visibility","background","cursor","overflow","fontSize","map","slug","borderRadius","padding","boxSizing","lineHeight","index","flexGrow"],"mappings":";;;;;;;AAaA;;AAVA;;AAIA;;AAKA;;AAMA;;AACA;;AAnBA;AACA;AACA;;AAaA;AACA;AACA;AAIA,MAAMA,UAAU,GAAG;AAClBC,EAAAA,KAAK,EAAE;AACNC,IAAAA,OAAO,EAAE,CADH;AAENC,IAAAA,OAAO,EAAE;AAFH,GADW;AAKlBC,EAAAA,KAAK,EAAE;AACNF,IAAAA,OAA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MAAAA,UADO;AAEPgC,MAAAA,QAAQ,EAAE,KAAKf,KAFR;AAGPK,MAAAA,KAAK,EAAEjB;AAHA;AADT,UAVD,CAvBD,EA2CGa,aAAa,IACd,4BAAC,gCAAD;AAAQ,IAAA,OAAO,EAAG;AAAlB,KACGA,aAAa,CACbK,KADA,CACO,CADP,EACU,CADV,EAEAU,GAFA,CAEK,QAAaM,KAAb;AAAA,QAAE;AAAEjB,MAAAA;AAAF,KAAF;AAAA,WACL;AACC,MAAA,GAAG,EAAGiB,KADP;AAEC,MAAA,KAAK,EAAG;AACPZ,QAAAA,MAAM,EAAE,KAAKV,KADN;AAEPD,QAAAA,KAAK,EAAE,KAAKC,KAFL;AAGPY,QAAAA,UAAU,EAAEP,KAHL;AAIPkB,QAAAA,QAAQ,EAAE;AAJH;AAFT,MADK;AAAA,GAFL,CADH,CA5CF,CAPD,CA3DD,CAZD,CADD;AAgJA,CAhMD;;eAkMe5C,a","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__unstableIframe as Iframe,\n\t__unstableEditorStyles as EditorStyles,\n} from '@wordpress/block-editor';\nimport {\n\t__unstableMotion as motion,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useReducedMotion, useResizeObserver } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSetting, useStyle } from './hooks';\nimport { useGlobalStylesOutput } from './use-global-styles-output';\n\nconst firstFrame = {\n\tstart: {\n\t\topacity: 1,\n\t\tdisplay: 'block',\n\t},\n\thover: {\n\t\topacity: 0,\n\t\tdisplay: 'none',\n\t},\n};\n\nconst secondFrame = {\n\thover: {\n\t\topacity: 1,\n\t\tdisplay: 'block',\n\t},\n\tstart: {\n\t\topacity: 0,\n\t\tdisplay: 'none',\n\t},\n};\n\nconst normalizedWidth = 248;\nconst normalizedHeight = 152;\n\nconst normalizedColorSwatchSize = 32;\n\nconst StylesPreview = ( { label, isFocused } ) => {\n\tconst [ fontWeight ] = useStyle( 'typography.fontWeight' );\n\tconst [ fontFamily = 'serif' ] = useStyle( 'typography.fontFamily' );\n\tconst [ headingFontFamily = fontFamily ] = useStyle(\n\t\t'elements.h1.typography.fontFamily'\n\t);\n\tconst [ headingFontWeight = fontWeight ] = useStyle(\n\t\t'elements.h1.typography.fontWeight'\n\t);\n\tconst [ textColor = 'black' ] = useStyle( 'color.text' );\n\tconst [ headingColor = textColor ] = useStyle( 'elements.h1.color.text' );\n\tconst [ linkColor = 'blue' ] = useStyle( 'elements.link.color.text' );\n\tconst [ backgroundColor = 'white' ] = useStyle( 'color.background' );\n\tconst [ gradientValue ] = useStyle( 'color.gradient' );\n\tconst [ styles ] = useGlobalStylesOutput();\n\tconst disableMotion = useReducedMotion();\n\tconst [ coreColors ] = useSetting( 'color.palette.core' );\n\tconst [ themeColors ] = useSetting( 'color.palette.theme' );\n\tconst [ customColors ] = useSetting( 'color.palette.custom' );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst [ containerResizeListener, { width } ] = useResizeObserver();\n\tconst ratio = width ? width / normalizedWidth : 1;\n\n\tconst paletteColors = ( themeColors ?? [] )\n\t\t.concat( customColors ?? [] )\n\t\t.concat( coreColors ?? [] );\n\tconst highlightedColors = paletteColors\n\t\t.filter(\n\t\t\t// we exclude these two colors because they are already visible in the preview.\n\t\t\t( { color } ) => color !== backgroundColor && color !== headingColor\n\t\t)\n\t\t.slice( 0, 2 );\n\n\t// Reset leaked styles from WP common.css and remove main content layout padding.\n\tconst editorStyles = useMemo( () => {\n\t\tif ( styles ) {\n\t\t\treturn [\n\t\t\t\t...styles,\n\t\t\t\t{\n\t\t\t\t\tcss: 'body{min-width: 0;padding: 0;}',\n\t\t\t\t\tisGlobalStyles: true,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn styles;\n\t}, [ styles ] );\n\n\treturn (\n\t\t<Iframe\n\t\t\tclassName=\"edit-site-global-styles-preview__iframe\"\n\t\t\thead={ <EditorStyles styles={ editorStyles } /> }\n\t\t\tstyle={ {\n\t\t\t\theight: normalizedHeight * ratio,\n\t\t\t\tvisibility: ! width ? 'hidden' : 'visible',\n\t\t\t} }\n\t\t\tonMouseEnter={ () => setIsHovered( true ) }\n\t\t\tonMouseLeave={ () => setIsHovered( false ) }\n\t\t\ttabIndex={ -1 }\n\t\t>\n\t\t\t{ containerResizeListener }\n\t\t\t<motion.div\n\t\t\t\tstyle={ {\n\t\t\t\t\theight: normalizedHeight * ratio,\n\t\t\t\t\twidth: '100%',\n\t\t\t\t\tbackground: gradientValue ?? backgroundColor,\n\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t} }\n\t\t\t\tinitial=\"start\"\n\t\t\t\tanimate={\n\t\t\t\t\t( isHovered || isFocused ) && ! disableMotion\n\t\t\t\t\t\t? 'hover'\n\t\t\t\t\t\t: 'start'\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ firstFrame }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tspacing={ 10 * ratio }\n\t\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tfontFamily: headingFontFamily,\n\t\t\t\t\t\t\t\tfontSize: 65 * ratio,\n\t\t\t\t\t\t\t\tcolor: headingColor,\n\t\t\t\t\t\t\t\tfontWeight: headingFontWeight,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tAa\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<VStack spacing={ 4 * ratio }>\n\t\t\t\t\t\t\t{ highlightedColors.map( ( { slug, color } ) => (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\theight:\n\t\t\t\t\t\t\t\t\t\t\tnormalizedColorSwatchSize * ratio,\n\t\t\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\t\t\tnormalizedColorSwatchSize * ratio,\n\t\t\t\t\t\t\t\t\t\tbackground: color,\n\t\t\t\t\t\t\t\t\t\tborderRadius:\n\t\t\t\t\t\t\t\t\t\t\t( normalizedColorSwatchSize *\n\t\t\t\t\t\t\t\t\t\t\t\tratio ) /\n\t\t\t\t\t\t\t\t\t\t\t2,\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</HStack>\n\t\t\t\t</motion.div>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ secondFrame }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<VStack\n\t\t\t\t\t\tspacing={ 3 * ratio }\n\t\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\tpadding: 10 * ratio,\n\t\t\t\t\t\t\tboxSizing: 'border-box',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tfontSize: 35 * ratio,\n\t\t\t\t\t\t\t\t\tfontFamily: headingFontFamily,\n\t\t\t\t\t\t\t\t\tcolor: headingColor,\n\t\t\t\t\t\t\t\t\tfontWeight: headingFontWeight,\n\t\t\t\t\t\t\t\t\tlineHeight: '1em',\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<HStack spacing={ 2 * ratio } justify=\"flex-start\">\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tfontFamily,\n\t\t\t\t\t\t\t\t\tfontSize: 24 * ratio,\n\t\t\t\t\t\t\t\t\tcolor: textColor,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tAa\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tfontFamily,\n\t\t\t\t\t\t\t\t\tfontSize: 24 * ratio,\n\t\t\t\t\t\t\t\t\tcolor: linkColor,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tAa\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t{ paletteColors && (\n\t\t\t\t\t\t\t<HStack spacing={ 0 }>\n\t\t\t\t\t\t\t\t{ paletteColors\n\t\t\t\t\t\t\t\t\t.slice( 0, 4 )\n\t\t\t\t\t\t\t\t\t.map( ( { color }, index ) => (\n\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\theight: 10 * ratio,\n\t\t\t\t\t\t\t\t\t\t\t\twidth: 30 * ratio,\n\t\t\t\t\t\t\t\t\t\t\t\tbackground: color,\n\t\t\t\t\t\t\t\t\t\t\t\tflexGrow: 1,\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</VStack>\n\t\t\t\t</motion.div>\n\t\t\t</motion.div>\n\t\t</Iframe>\n\t);\n};\n\nexport default StylesPreview;\n"]}
|
|
@@ -210,7 +210,7 @@ function getStylesDeclarations() {
|
|
|
210
210
|
|
|
211
211
|
const pathToValue = value;
|
|
212
212
|
|
|
213
|
-
if (
|
|
213
|
+
if (pathToValue[0] === 'elements' || useEngine) {
|
|
214
214
|
return declarations;
|
|
215
215
|
}
|
|
216
216
|
|
|
@@ -317,8 +317,8 @@ function getLayoutStyles(_ref6) {
|
|
|
317
317
|
spacingStyles
|
|
318
318
|
} = _ref7;
|
|
319
319
|
|
|
320
|
-
// Allow
|
|
321
|
-
if (!hasBlockGapSupport && '
|
|
320
|
+
// Allow outputting fallback gap styles for flex layout type when block gap support isn't available.
|
|
321
|
+
if (!hasBlockGapSupport && 'flex' !== name) {
|
|
322
322
|
return;
|
|
323
323
|
}
|
|
324
324
|
|
|
@@ -392,7 +392,7 @@ function getLayoutStyles(_ref6) {
|
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
const getNodesWithStyles = (tree, blockSelectors) => {
|
|
395
|
-
var _tree$styles3;
|
|
395
|
+
var _tree$styles$blocks, _tree$styles3;
|
|
396
396
|
|
|
397
397
|
const nodes = [];
|
|
398
398
|
|
|
@@ -412,9 +412,11 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
412
412
|
});
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
-
|
|
415
|
+
Object.entries(_blocks.__EXPERIMENTAL_ELEMENTS).forEach(_ref11 => {
|
|
416
416
|
var _tree$styles;
|
|
417
417
|
|
|
418
|
+
let [name, selector] = _ref11;
|
|
419
|
+
|
|
418
420
|
if (!!((_tree$styles = tree.styles) !== null && _tree$styles !== void 0 && _tree$styles.elements[name])) {
|
|
419
421
|
var _tree$styles2;
|
|
420
422
|
|
|
@@ -425,9 +427,10 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
425
427
|
}
|
|
426
428
|
}); // Iterate over blocks: they can have styles & elements.
|
|
427
429
|
|
|
428
|
-
|
|
429
|
-
var _blockSelectors$block;
|
|
430
|
+
Object.entries((_tree$styles$blocks = (_tree$styles3 = tree.styles) === null || _tree$styles3 === void 0 ? void 0 : _tree$styles3.blocks) !== null && _tree$styles$blocks !== void 0 ? _tree$styles$blocks : {}).forEach(_ref12 => {
|
|
431
|
+
var _blockSelectors$block, _node$elements;
|
|
430
432
|
|
|
433
|
+
let [blockName, node] = _ref12;
|
|
431
434
|
const blockStyles = pickStyleKeys(node);
|
|
432
435
|
|
|
433
436
|
if (!!blockStyles && !!(blockSelectors !== null && blockSelectors !== void 0 && (_blockSelectors$block = blockSelectors[blockName]) !== null && _blockSelectors$block !== void 0 && _blockSelectors$block.selector)) {
|
|
@@ -441,7 +444,9 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
441
444
|
});
|
|
442
445
|
}
|
|
443
446
|
|
|
444
|
-
(
|
|
447
|
+
Object.entries((_node$elements = node === null || node === void 0 ? void 0 : node.elements) !== null && _node$elements !== void 0 ? _node$elements : {}).forEach(_ref13 => {
|
|
448
|
+
let [elementName, value] = _ref13;
|
|
449
|
+
|
|
445
450
|
if (!!value && !!(blockSelectors !== null && blockSelectors !== void 0 && blockSelectors[blockName]) && !!(_blocks.__EXPERIMENTAL_ELEMENTS !== null && _blocks.__EXPERIMENTAL_ELEMENTS !== void 0 && _blocks.__EXPERIMENTAL_ELEMENTS[elementName])) {
|
|
446
451
|
nodes.push({
|
|
447
452
|
styles: value,
|
|
@@ -460,7 +465,7 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
460
465
|
exports.getNodesWithStyles = getNodesWithStyles;
|
|
461
466
|
|
|
462
467
|
const getNodesWithSettings = (tree, blockSelectors) => {
|
|
463
|
-
var _tree$settings3, _tree$settings4;
|
|
468
|
+
var _tree$settings3, _tree$settings$blocks, _tree$settings4;
|
|
464
469
|
|
|
465
470
|
const nodes = [];
|
|
466
471
|
|
|
@@ -471,10 +476,10 @@ const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
471
476
|
const pickPresets = treeToPickFrom => {
|
|
472
477
|
const presets = {};
|
|
473
478
|
|
|
474
|
-
_utils.PRESET_METADATA.forEach(
|
|
479
|
+
_utils.PRESET_METADATA.forEach(_ref14 => {
|
|
475
480
|
let {
|
|
476
481
|
path
|
|
477
|
-
} =
|
|
482
|
+
} = _ref14;
|
|
478
483
|
const value = (0, _lodash.get)(treeToPickFrom, path, false);
|
|
479
484
|
|
|
480
485
|
if (value !== false) {
|
|
@@ -498,7 +503,8 @@ const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
498
503
|
} // Blocks.
|
|
499
504
|
|
|
500
505
|
|
|
501
|
-
|
|
506
|
+
Object.entries((_tree$settings$blocks = (_tree$settings4 = tree.settings) === null || _tree$settings4 === void 0 ? void 0 : _tree$settings4.blocks) !== null && _tree$settings$blocks !== void 0 ? _tree$settings$blocks : {}).forEach(_ref15 => {
|
|
507
|
+
let [blockName, node] = _ref15;
|
|
502
508
|
const blockPresets = pickPresets(node);
|
|
503
509
|
const blockCustom = node.custom;
|
|
504
510
|
|
|
@@ -518,12 +524,12 @@ exports.getNodesWithSettings = getNodesWithSettings;
|
|
|
518
524
|
const toCustomProperties = (tree, blockSelectors) => {
|
|
519
525
|
const settings = getNodesWithSettings(tree, blockSelectors);
|
|
520
526
|
let ruleset = '';
|
|
521
|
-
settings.forEach(
|
|
527
|
+
settings.forEach(_ref16 => {
|
|
522
528
|
let {
|
|
523
529
|
presets,
|
|
524
530
|
custom,
|
|
525
531
|
selector
|
|
526
|
-
} =
|
|
532
|
+
} = _ref16;
|
|
527
533
|
const declarations = getPresetsDeclarations(presets, tree === null || tree === void 0 ? void 0 : tree.settings);
|
|
528
534
|
const customProps = flattenTree(custom, '--wp--custom--', '--');
|
|
529
535
|
|
|
@@ -571,11 +577,17 @@ const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallback
|
|
|
571
577
|
}
|
|
572
578
|
|
|
573
579
|
if (useRootPaddingAlign) {
|
|
574
|
-
ruleset +=
|
|
580
|
+
ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
|
|
581
|
+
.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
|
|
582
|
+
.has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }
|
|
583
|
+
.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
|
|
584
|
+
.has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }
|
|
585
|
+
.has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
|
|
586
|
+
.has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0;`;
|
|
575
587
|
}
|
|
576
588
|
|
|
577
589
|
ruleset += '}';
|
|
578
|
-
nodesWithStyles.forEach(
|
|
590
|
+
nodesWithStyles.forEach(_ref17 => {
|
|
579
591
|
let {
|
|
580
592
|
selector,
|
|
581
593
|
duotoneSelector,
|
|
@@ -583,13 +595,13 @@ const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallback
|
|
|
583
595
|
fallbackGapValue,
|
|
584
596
|
hasLayoutSupport,
|
|
585
597
|
featureSelectors
|
|
586
|
-
} =
|
|
598
|
+
} = _ref17;
|
|
587
599
|
|
|
588
600
|
// Process styles for block support features with custom feature level
|
|
589
601
|
// CSS selectors set.
|
|
590
602
|
if (featureSelectors) {
|
|
591
|
-
Object.entries(featureSelectors).forEach(
|
|
592
|
-
let [featureName, featureSelector] =
|
|
603
|
+
Object.entries(featureSelectors).forEach(_ref18 => {
|
|
604
|
+
let [featureName, featureSelector] = _ref18;
|
|
593
605
|
|
|
594
606
|
if (styles !== null && styles !== void 0 && styles[featureName]) {
|
|
595
607
|
const featureStyles = {
|
|
@@ -641,14 +653,14 @@ const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallback
|
|
|
641
653
|
} // Check for pseudo selector in `styles` and handle separately.
|
|
642
654
|
|
|
643
655
|
|
|
644
|
-
const pseudoSelectorStyles = Object.entries(styles).filter(
|
|
645
|
-
let [key] =
|
|
656
|
+
const pseudoSelectorStyles = Object.entries(styles).filter(_ref19 => {
|
|
657
|
+
let [key] = _ref19;
|
|
646
658
|
return key.startsWith(':');
|
|
647
659
|
});
|
|
648
660
|
|
|
649
661
|
if (pseudoSelectorStyles !== null && pseudoSelectorStyles !== void 0 && pseudoSelectorStyles.length) {
|
|
650
|
-
pseudoSelectorStyles.forEach(
|
|
651
|
-
let [pseudoKey, pseudoStyle] =
|
|
662
|
+
pseudoSelectorStyles.forEach(_ref20 => {
|
|
663
|
+
let [pseudoKey, pseudoStyle] = _ref20;
|
|
652
664
|
const pseudoDeclarations = getStylesDeclarations(pseudoStyle);
|
|
653
665
|
|
|
654
666
|
if (!(pseudoDeclarations !== null && pseudoDeclarations !== void 0 && pseudoDeclarations.length)) {
|
|
@@ -684,11 +696,11 @@ const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallback
|
|
|
684
696
|
ruleset = ruleset + `.wp-site-blocks > * + * { margin-block-start: ${gapValue}; }`;
|
|
685
697
|
}
|
|
686
698
|
|
|
687
|
-
nodesWithSettings.forEach(
|
|
699
|
+
nodesWithSettings.forEach(_ref21 => {
|
|
688
700
|
let {
|
|
689
701
|
selector,
|
|
690
702
|
presets
|
|
691
|
-
} =
|
|
703
|
+
} = _ref21;
|
|
692
704
|
|
|
693
705
|
if (_utils.ROOT_BLOCK_SELECTOR === selector) {
|
|
694
706
|
// Do not add extra specificity for top-level classes.
|
|
@@ -708,10 +720,10 @@ exports.toStyles = toStyles;
|
|
|
708
720
|
|
|
709
721
|
function toSvgFilters(tree, blockSelectors) {
|
|
710
722
|
const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
|
|
711
|
-
return nodesWithSettings.flatMap(
|
|
723
|
+
return nodesWithSettings.flatMap(_ref22 => {
|
|
712
724
|
let {
|
|
713
725
|
presets
|
|
714
|
-
} =
|
|
726
|
+
} = _ref22;
|
|
715
727
|
return getPresetsSvgFilters(presets);
|
|
716
728
|
});
|
|
717
729
|
}
|
|
@@ -728,10 +740,10 @@ const getBlockSelectors = blockTypes => {
|
|
|
728
740
|
const fallbackGapValue = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports4 = blockType.supports) === null || _blockType$supports4 === void 0 ? void 0 : (_blockType$supports4$ = _blockType$supports4.spacing) === null || _blockType$supports4$ === void 0 ? void 0 : (_blockType$supports4$2 = _blockType$supports4$.blockGap) === null || _blockType$supports4$2 === void 0 ? void 0 : _blockType$supports4$2.__experimentalDefault; // For each block support feature add any custom selectors.
|
|
729
741
|
|
|
730
742
|
const featureSelectors = {};
|
|
731
|
-
Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(
|
|
743
|
+
Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref23 => {
|
|
732
744
|
var _blockType$supports5, _blockType$supports5$;
|
|
733
745
|
|
|
734
|
-
let [featureKey, featureName] =
|
|
746
|
+
let [featureKey, featureName] = _ref23;
|
|
735
747
|
const featureSelector = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports5 = blockType.supports) === null || _blockType$supports5 === void 0 ? void 0 : (_blockType$supports5$ = _blockType$supports5[featureKey]) === null || _blockType$supports5$ === void 0 ? void 0 : _blockType$supports5$.__experimentalSelector;
|
|
736
748
|
|
|
737
749
|
if (featureSelector) {
|