@wordpress/edit-site 4.11.0 → 4.12.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/add-new-template/add-custom-template-modal.js +4 -2
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template.js +22 -2
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +152 -28
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +6 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +1 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +1 -1
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +51 -7
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +157 -0
- package/build/components/global-styles/screen-heading-color.js.map +1 -0
- package/build/components/global-styles/screen-typography-element.js +4 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +5 -0
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +73 -12
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +217 -0
- package/build/components/global-styles/typography-utils.js.map +1 -0
- package/build/components/global-styles/ui.js +11 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +61 -40
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +17 -2
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/index.js +15 -4
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/undo-redo/redo.js +2 -1
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/list/actions/index.js +1 -1
- package/build/components/list/actions/index.js.map +1 -1
- package/build/components/save-button/index.js +2 -3
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +2 -2
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build/components/sidebar/template-card/template-actions.js +1 -1
- package/build/components/sidebar/template-card/template-actions.js.map +1 -1
- package/build/components/template-details/index.js +1 -1
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +1 -1
- package/build/components/template-details/template-areas.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +4 -1
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +4 -2
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +21 -3
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +147 -26
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +6 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +1 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +1 -1
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +51 -7
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +143 -0
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -0
- package/build-module/components/global-styles/screen-typography-element.js +4 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +5 -0
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +74 -13
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +204 -0
- package/build-module/components/global-styles/typography-utils.js.map +1 -0
- package/build-module/components/global-styles/ui.js +10 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +61 -44
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +16 -2
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/index.js +17 -6
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/undo-redo/redo.js +3 -2
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/list/actions/index.js +1 -1
- package/build-module/components/list/actions/index.js.map +1 -1
- package/build-module/components/save-button/index.js +3 -4
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +3 -3
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build-module/components/sidebar/template-card/template-actions.js +1 -1
- package/build-module/components/sidebar/template-card/template-actions.js.map +1 -1
- package/build-module/components/template-details/index.js +1 -1
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +1 -1
- package/build-module/components/template-details/template-areas.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +3 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-style/style-rtl.css +13 -4
- package/build-style/style.css +13 -4
- package/package.json +29 -29
- package/src/components/add-new-template/add-custom-template-modal.js +12 -3
- package/src/components/add-new-template/new-template.js +40 -20
- package/src/components/add-new-template/utils.js +145 -16
- package/src/components/global-styles/dimensions-panel.js +5 -3
- package/src/components/global-styles/hooks.js +1 -0
- package/src/components/global-styles/screen-color-palette.js +1 -1
- package/src/components/global-styles/screen-colors.js +46 -4
- package/src/components/global-styles/screen-heading-color.js +201 -0
- package/src/components/global-styles/screen-typography-element.js +4 -0
- package/src/components/global-styles/screen-typography.js +6 -0
- package/src/components/global-styles/style.scss +13 -6
- package/src/components/global-styles/test/typography-utils.js +130 -0
- package/src/components/global-styles/test/use-global-styles-output.js +66 -3
- package/src/components/global-styles/typography-panel.js +85 -16
- package/src/components/global-styles/typography-utils.js +228 -0
- package/src/components/global-styles/ui.js +13 -0
- package/src/components/global-styles/use-global-styles-output.js +79 -48
- package/src/components/global-styles/utils.js +10 -0
- package/src/components/header/index.js +28 -3
- package/src/components/header/undo-redo/redo.js +6 -2
- package/src/components/list/actions/index.js +3 -1
- package/src/components/save-button/index.js +10 -13
- package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -5
- package/src/components/sidebar/template-card/template-actions.js +3 -1
- package/src/components/template-details/index.js +3 -1
- package/src/components/template-details/template-areas.js +3 -1
- package/src/components/template-part-converter/convert-to-template-part.js +3 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getComputedFluidTypographyValue = getComputedFluidTypographyValue;
|
|
7
|
+
exports.getTypographyFontSizeValue = getTypographyFontSizeValue;
|
|
8
|
+
exports.getTypographyValueAndUnit = getTypographyValueAndUnit;
|
|
9
|
+
exports.roundToPrecision = roundToPrecision;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The fluid utilities must match the backend equivalent.
|
|
13
|
+
* See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php
|
|
14
|
+
* ---------------------------------------------------------------
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Returns a font-size value based on a given font-size preset.
|
|
19
|
+
* Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} preset
|
|
22
|
+
* @param {string} preset.size A default font size.
|
|
23
|
+
* @param {string} preset.name A font size name, displayed in the UI.
|
|
24
|
+
* @param {string} preset.slug A font size slug.
|
|
25
|
+
* @param {Object} preset.fluid
|
|
26
|
+
* @param {string|undefined} preset.fluid.max A maximum font size value.
|
|
27
|
+
* @param {string|undefined} preset.fluid.min A minimum font size value.
|
|
28
|
+
* @param {Object} typographySettings
|
|
29
|
+
* @param {boolean} typographySettings.fluid Whether fluid typography is enabled.
|
|
30
|
+
*
|
|
31
|
+
* @return {string} An font-size value
|
|
32
|
+
*/
|
|
33
|
+
function getTypographyFontSizeValue(preset, typographySettings) {
|
|
34
|
+
const {
|
|
35
|
+
size: defaultSize
|
|
36
|
+
} = preset;
|
|
37
|
+
|
|
38
|
+
if (true !== (typographySettings === null || typographySettings === void 0 ? void 0 : typographySettings.fluid)) {
|
|
39
|
+
return defaultSize;
|
|
40
|
+
} // Defaults.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
const DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';
|
|
44
|
+
const DEFAULT_MINIMUM_VIEWPORT_WIDTH = '768px';
|
|
45
|
+
const DEFAULT_MINIMUM_FONT_SIZE_FACTOR = 0.75;
|
|
46
|
+
const DEFAULT_MAXIMUM_FONT_SIZE_FACTOR = 1.5;
|
|
47
|
+
const DEFAULT_SCALE_FACTOR = 1; // Font sizes.
|
|
48
|
+
// A font size has explicitly bypassed fluid calculations.
|
|
49
|
+
|
|
50
|
+
if (false === (preset === null || preset === void 0 ? void 0 : preset.fluid)) {
|
|
51
|
+
return defaultSize;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const fluidFontSizeSettings = (preset === null || preset === void 0 ? void 0 : preset.fluid) || {}; // Try to grab explicit min and max fluid font sizes.
|
|
55
|
+
|
|
56
|
+
let minimumFontSizeRaw = fluidFontSizeSettings === null || fluidFontSizeSettings === void 0 ? void 0 : fluidFontSizeSettings.min;
|
|
57
|
+
let maximumFontSizeRaw = fluidFontSizeSettings === null || fluidFontSizeSettings === void 0 ? void 0 : fluidFontSizeSettings.max;
|
|
58
|
+
const preferredSize = getTypographyValueAndUnit(defaultSize); // Protect against unsupported units.
|
|
59
|
+
|
|
60
|
+
if (!(preferredSize !== null && preferredSize !== void 0 && preferredSize.unit)) {
|
|
61
|
+
return defaultSize;
|
|
62
|
+
} // If no fluid min or max font sizes are available, create some using min/max font size factors.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
if (!minimumFontSizeRaw) {
|
|
66
|
+
minimumFontSizeRaw = preferredSize.value * DEFAULT_MINIMUM_FONT_SIZE_FACTOR + preferredSize.unit;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!maximumFontSizeRaw) {
|
|
70
|
+
maximumFontSizeRaw = preferredSize.value * DEFAULT_MAXIMUM_FONT_SIZE_FACTOR + preferredSize.unit;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const fluidFontSizeValue = getComputedFluidTypographyValue({
|
|
74
|
+
maximumViewPortWidth: DEFAULT_MAXIMUM_VIEWPORT_WIDTH,
|
|
75
|
+
minimumViewPortWidth: DEFAULT_MINIMUM_VIEWPORT_WIDTH,
|
|
76
|
+
maximumFontSize: maximumFontSizeRaw,
|
|
77
|
+
minimumFontSize: minimumFontSizeRaw,
|
|
78
|
+
scaleFactor: DEFAULT_SCALE_FACTOR
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
if (!!fluidFontSizeValue) {
|
|
82
|
+
return fluidFontSizeValue;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return defaultSize;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Internal implementation of clamp() based on available min/max viewport width, and min/max font sizes.
|
|
89
|
+
*
|
|
90
|
+
* @param {Object} args
|
|
91
|
+
* @param {string} args.maximumViewPortWidth Maximum size up to which type will have fluidity.
|
|
92
|
+
* @param {string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity.
|
|
93
|
+
* @param {string} args.maximumFontSize Maximum font size for any clamp() calculation.
|
|
94
|
+
* @param {string} args.minimumFontSize Minimum font size for any clamp() calculation.
|
|
95
|
+
* @param {number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries.
|
|
96
|
+
*
|
|
97
|
+
* @return {string|null} A font-size value using clamp().
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
function getComputedFluidTypographyValue(_ref) {
|
|
102
|
+
let {
|
|
103
|
+
maximumViewPortWidth,
|
|
104
|
+
minimumViewPortWidth,
|
|
105
|
+
maximumFontSize,
|
|
106
|
+
minimumFontSize,
|
|
107
|
+
scaleFactor
|
|
108
|
+
} = _ref;
|
|
109
|
+
// Grab the minimum font size and normalize it in order to use the value for calculations.
|
|
110
|
+
const minimumFontSizeParsed = getTypographyValueAndUnit(minimumFontSize); // We get a 'preferred' unit to keep units consistent when calculating,
|
|
111
|
+
// otherwise the result will not be accurate.
|
|
112
|
+
|
|
113
|
+
const fontSizeUnit = (minimumFontSizeParsed === null || minimumFontSizeParsed === void 0 ? void 0 : minimumFontSizeParsed.unit) || 'rem'; // Grab the maximum font size and normalize it in order to use the value for calculations.
|
|
114
|
+
|
|
115
|
+
const maximumFontSizeParsed = getTypographyValueAndUnit(maximumFontSize, {
|
|
116
|
+
coerceTo: fontSizeUnit
|
|
117
|
+
}); // Protect against unsupported units.
|
|
118
|
+
|
|
119
|
+
if (!minimumFontSizeParsed || !maximumFontSizeParsed) {
|
|
120
|
+
return null;
|
|
121
|
+
} // Use rem for accessible fluid target font scaling.
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
const minimumFontSizeRem = getTypographyValueAndUnit(minimumFontSize, {
|
|
125
|
+
coerceTo: 'rem'
|
|
126
|
+
}); // Viewport widths defined for fluid typography. Normalize units
|
|
127
|
+
|
|
128
|
+
const maximumViewPortWidthParsed = getTypographyValueAndUnit(maximumViewPortWidth, {
|
|
129
|
+
coerceTo: fontSizeUnit
|
|
130
|
+
});
|
|
131
|
+
const minumumViewPortWidthParsed = getTypographyValueAndUnit(minimumViewPortWidth, {
|
|
132
|
+
coerceTo: fontSizeUnit
|
|
133
|
+
}); // Protect against unsupported units.
|
|
134
|
+
|
|
135
|
+
if (!maximumViewPortWidthParsed || !minumumViewPortWidthParsed || !minimumFontSizeRem) {
|
|
136
|
+
return null;
|
|
137
|
+
} // Build CSS rule.
|
|
138
|
+
// Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
const minViewPortWidthOffsetValue = roundToPrecision(minumumViewPortWidthParsed.value / 100, 3);
|
|
142
|
+
const viewPortWidthOffset = minViewPortWidthOffsetValue + fontSizeUnit;
|
|
143
|
+
let linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / (maximumViewPortWidthParsed.value - minumumViewPortWidthParsed.value));
|
|
144
|
+
linearFactor = roundToPrecision(linearFactor, 3) || 1;
|
|
145
|
+
const linearFactorScaled = linearFactor * scaleFactor;
|
|
146
|
+
const fluidTargetFontSize = `${minimumFontSizeRem.value}${minimumFontSizeRem.unit} + ((1vw - ${viewPortWidthOffset}) * ${linearFactorScaled})`;
|
|
147
|
+
return `clamp(${minimumFontSize}, ${fluidTargetFontSize}, ${maximumFontSize})`;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
*
|
|
151
|
+
* @param {string} rawValue Raw size value from theme.json.
|
|
152
|
+
* @param {Object|undefined} options Calculation options.
|
|
153
|
+
*
|
|
154
|
+
* @return {{ unit: string, value: number }|null} An object consisting of `'value'` and `'unit'` properties.
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
function getTypographyValueAndUnit(rawValue) {
|
|
159
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
160
|
+
|
|
161
|
+
if (!rawValue) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const {
|
|
166
|
+
coerceTo,
|
|
167
|
+
rootSizeValue,
|
|
168
|
+
acceptableUnits
|
|
169
|
+
} = {
|
|
170
|
+
coerceTo: '',
|
|
171
|
+
// Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`.
|
|
172
|
+
rootSizeValue: 16,
|
|
173
|
+
acceptableUnits: ['rem', 'px', 'em'],
|
|
174
|
+
...options
|
|
175
|
+
};
|
|
176
|
+
const acceptableUnitsGroup = acceptableUnits === null || acceptableUnits === void 0 ? void 0 : acceptableUnits.join('|');
|
|
177
|
+
const regexUnits = new RegExp(`^(\\d*\\.?\\d+)(${acceptableUnitsGroup}){1,1}$`);
|
|
178
|
+
const matches = rawValue.match(regexUnits); // We need a number value and a unit.
|
|
179
|
+
|
|
180
|
+
if (!matches || matches.length < 3) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
let [, value, unit] = matches;
|
|
185
|
+
let returnValue = parseFloat(value);
|
|
186
|
+
|
|
187
|
+
if ('px' === coerceTo && ('em' === unit || 'rem' === unit)) {
|
|
188
|
+
returnValue = returnValue * rootSizeValue;
|
|
189
|
+
unit = coerceTo;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if ('px' === unit && ('em' === coerceTo || 'rem' === coerceTo)) {
|
|
193
|
+
returnValue = returnValue / rootSizeValue;
|
|
194
|
+
unit = coerceTo;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
value: returnValue,
|
|
199
|
+
unit
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Returns a value rounded to defined precision.
|
|
204
|
+
* Returns `undefined` if the value is not a valid finite number.
|
|
205
|
+
*
|
|
206
|
+
* @param {number} value Raw value.
|
|
207
|
+
* @param {number} digits The number of digits to appear after the decimal point
|
|
208
|
+
*
|
|
209
|
+
* @return {number|undefined} Value rounded to standard precision.
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
function roundToPrecision(value) {
|
|
214
|
+
let digits = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
|
|
215
|
+
return Number.isFinite(value) ? parseFloat(value.toFixed(digits)) : undefined;
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=typography-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/typography-utils.js"],"names":["getTypographyFontSizeValue","preset","typographySettings","size","defaultSize","fluid","DEFAULT_MAXIMUM_VIEWPORT_WIDTH","DEFAULT_MINIMUM_VIEWPORT_WIDTH","DEFAULT_MINIMUM_FONT_SIZE_FACTOR","DEFAULT_MAXIMUM_FONT_SIZE_FACTOR","DEFAULT_SCALE_FACTOR","fluidFontSizeSettings","minimumFontSizeRaw","min","maximumFontSizeRaw","max","preferredSize","getTypographyValueAndUnit","unit","value","fluidFontSizeValue","getComputedFluidTypographyValue","maximumViewPortWidth","minimumViewPortWidth","maximumFontSize","minimumFontSize","scaleFactor","minimumFontSizeParsed","fontSizeUnit","maximumFontSizeParsed","coerceTo","minimumFontSizeRem","maximumViewPortWidthParsed","minumumViewPortWidthParsed","minViewPortWidthOffsetValue","roundToPrecision","viewPortWidthOffset","linearFactor","linearFactorScaled","fluidTargetFontSize","rawValue","options","rootSizeValue","acceptableUnits","acceptableUnitsGroup","join","regexUnits","RegExp","matches","match","length","returnValue","parseFloat","digits","Number","isFinite","toFixed","undefined"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,0BAAT,CAAqCC,MAArC,EAA6CC,kBAA7C,EAAkE;AACxE,QAAM;AAAEC,IAAAA,IAAI,EAAEC;AAAR,MAAwBH,MAA9B;;AAEA,MAAK,UAASC,kBAAT,aAASA,kBAAT,uBAASA,kBAAkB,CAAEG,KAA7B,CAAL,EAA0C;AACzC,WAAOD,WAAP;AACA,GALuE,CAOxE;;;AACA,QAAME,8BAA8B,GAAG,QAAvC;AACA,QAAMC,8BAA8B,GAAG,OAAvC;AACA,QAAMC,gCAAgC,GAAG,IAAzC;AACA,QAAMC,g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AAEE,OAAF,IAAaA,OAAO,CAACE,MAAR,GAAiB,CAAnC,EAAuC;AACtC,WAAO,IAAP;AACA;;AAED,MAAI,GAAI/B,KAAJ,EAAWD,IAAX,IAAoB8B,OAAxB;AAEA,MAAIG,WAAW,GAAGC,UAAU,CAAEjC,KAAF,CAA5B;;AAEA,MAAK,SAASW,QAAT,KAAuB,SAASZ,IAAT,IAAiB,UAAUA,IAAlD,CAAL,EAAgE;AAC/DiC,IAAAA,WAAW,GAAGA,WAAW,GAAGT,aAA5B;AACAxB,IAAAA,IAAI,GAAGY,QAAP;AACA;;AAED,MAAK,SAASZ,IAAT,KAAmB,SAASY,QAAT,IAAqB,UAAUA,QAAlD,CAAL,EAAoE;AACnEqB,IAAAA,WAAW,GAAGA,WAAW,GAAGT,aAA5B;AACAxB,IAAAA,IAAI,GAAGY,QAAP;AACA;;AAED,SAAO;AACNX,IAAAA,KAAK,EAAEgC,WADD;AAENjC,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASiB,gBAAT,CAA2BhB,KAA3B,EAA+C;AAAA,MAAbkC,MAAa,uEAAJ,CAAI;AACrD,SAAOC,MAAM,CAACC,QAAP,CAAiBpC,KAAjB,IACJiC,UAAU,CAAEjC,KAAK,CAACqC,OAAN,CAAeH,MAAf,CAAF,CADN,GAEJI,SAFH;AAGA","sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n/**\n * Returns a font-size value based on a given font-size preset.\n * Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.\n *\n * @param {Object} preset\n * @param {string} preset.size A default font size.\n * @param {string} preset.name A font size name, displayed in the UI.\n * @param {string} preset.slug A font size slug.\n * @param {Object} preset.fluid\n * @param {string|undefined} preset.fluid.max A maximum font size value.\n * @param {string|undefined} preset.fluid.min A minimum font size value.\n * @param {Object} typographySettings\n * @param {boolean} typographySettings.fluid Whether fluid typography is enabled.\n *\n * @return {string} An font-size value\n */\nexport function getTypographyFontSizeValue( preset, typographySettings ) {\n\tconst { size: defaultSize } = preset;\n\n\tif ( true !== typographySettings?.fluid ) {\n\t\treturn defaultSize;\n\t}\n\n\t// Defaults.\n\tconst DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';\n\tconst DEFAULT_MINIMUM_VIEWPORT_WIDTH = '768px';\n\tconst DEFAULT_MINIMUM_FONT_SIZE_FACTOR = 0.75;\n\tconst DEFAULT_MAXIMUM_FONT_SIZE_FACTOR = 1.5;\n\tconst DEFAULT_SCALE_FACTOR = 1;\n\n\t// Font sizes.\n\t// A font size has explicitly bypassed fluid calculations.\n\tif ( false === preset?.fluid ) {\n\t\treturn defaultSize;\n\t}\n\n\tconst fluidFontSizeSettings = preset?.fluid || {};\n\n\t// Try to grab explicit min and max fluid font sizes.\n\tlet minimumFontSizeRaw = fluidFontSizeSettings?.min;\n\tlet maximumFontSizeRaw = fluidFontSizeSettings?.max;\n\tconst preferredSize = getTypographyValueAndUnit( defaultSize );\n\n\t// Protect against unsupported units.\n\tif ( ! preferredSize?.unit ) {\n\t\treturn defaultSize;\n\t}\n\n\t// If no fluid min or max font sizes are available, create some using min/max font size factors.\n\tif ( ! minimumFontSizeRaw ) {\n\t\tminimumFontSizeRaw =\n\t\t\tpreferredSize.value * DEFAULT_MINIMUM_FONT_SIZE_FACTOR +\n\t\t\tpreferredSize.unit;\n\t}\n\n\tif ( ! maximumFontSizeRaw ) {\n\t\tmaximumFontSizeRaw =\n\t\t\tpreferredSize.value * DEFAULT_MAXIMUM_FONT_SIZE_FACTOR +\n\t\t\tpreferredSize.unit;\n\t}\n\n\tconst fluidFontSizeValue = getComputedFluidTypographyValue( {\n\t\tmaximumViewPortWidth: DEFAULT_MAXIMUM_VIEWPORT_WIDTH,\n\t\tminimumViewPortWidth: DEFAULT_MINIMUM_VIEWPORT_WIDTH,\n\t\tmaximumFontSize: maximumFontSizeRaw,\n\t\tminimumFontSize: minimumFontSizeRaw,\n\t\tscaleFactor: DEFAULT_SCALE_FACTOR,\n\t} );\n\n\tif ( !! fluidFontSizeValue ) {\n\t\treturn fluidFontSizeValue;\n\t}\n\n\treturn defaultSize;\n}\n\n/**\n * Internal implementation of clamp() based on available min/max viewport width, and min/max font sizes.\n *\n * @param {Object} args\n * @param {string} args.maximumViewPortWidth Maximum size up to which type will have fluidity.\n * @param {string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity.\n * @param {string} args.maximumFontSize Maximum font size for any clamp() calculation.\n * @param {string} args.minimumFontSize Minimum font size for any clamp() calculation.\n * @param {number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries.\n *\n * @return {string|null} A font-size value using clamp().\n */\nexport function getComputedFluidTypographyValue( {\n\tmaximumViewPortWidth,\n\tminimumViewPortWidth,\n\tmaximumFontSize,\n\tminimumFontSize,\n\tscaleFactor,\n} ) {\n\t// Grab the minimum font size and normalize it in order to use the value for calculations.\n\tconst minimumFontSizeParsed = getTypographyValueAndUnit( minimumFontSize );\n\n\t// We get a 'preferred' unit to keep units consistent when calculating,\n\t// otherwise the result will not be accurate.\n\tconst fontSizeUnit = minimumFontSizeParsed?.unit || 'rem';\n\n\t// Grab the maximum font size and normalize it in order to use the value for calculations.\n\tconst maximumFontSizeParsed = getTypographyValueAndUnit( maximumFontSize, {\n\t\tcoerceTo: fontSizeUnit,\n\t} );\n\n\t// Protect against unsupported units.\n\tif ( ! minimumFontSizeParsed || ! maximumFontSizeParsed ) {\n\t\treturn null;\n\t}\n\n\t// Use rem for accessible fluid target font scaling.\n\tconst minimumFontSizeRem = getTypographyValueAndUnit( minimumFontSize, {\n\t\tcoerceTo: 'rem',\n\t} );\n\n\t// Viewport widths defined for fluid typography. Normalize units\n\tconst maximumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tmaximumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\tconst minumumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tminimumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\n\t// Protect against unsupported units.\n\tif (\n\t\t! maximumViewPortWidthParsed ||\n\t\t! minumumViewPortWidthParsed ||\n\t\t! minimumFontSizeRem\n\t) {\n\t\treturn null;\n\t}\n\n\t// Build CSS rule.\n\t// Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.\n\tconst minViewPortWidthOffsetValue = roundToPrecision(\n\t\tminumumViewPortWidthParsed.value / 100,\n\t\t3\n\t);\n\n\tconst viewPortWidthOffset = minViewPortWidthOffsetValue + fontSizeUnit;\n\tlet linearFactor =\n\t\t100 *\n\t\t( ( maximumFontSizeParsed.value - minimumFontSizeParsed.value ) /\n\t\t\t( maximumViewPortWidthParsed.value -\n\t\t\t\tminumumViewPortWidthParsed.value ) );\n\tlinearFactor = roundToPrecision( linearFactor, 3 ) || 1;\n\tconst linearFactorScaled = linearFactor * scaleFactor;\n\tconst fluidTargetFontSize = `${ minimumFontSizeRem.value }${ minimumFontSizeRem.unit } + ((1vw - ${ viewPortWidthOffset }) * ${ linearFactorScaled })`;\n\n\treturn `clamp(${ minimumFontSize }, ${ fluidTargetFontSize }, ${ maximumFontSize })`;\n}\n\n/**\n *\n * @param {string} rawValue Raw size value from theme.json.\n * @param {Object|undefined} options Calculation options.\n *\n * @return {{ unit: string, value: number }|null} An object consisting of `'value'` and `'unit'` properties.\n */\nexport function getTypographyValueAndUnit( rawValue, options = {} ) {\n\tif ( ! rawValue ) {\n\t\treturn null;\n\t}\n\n\tconst { coerceTo, rootSizeValue, acceptableUnits } = {\n\t\tcoerceTo: '',\n\t\t// Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( \"html\" ) ).fontSize`.\n\t\trootSizeValue: 16,\n\t\tacceptableUnits: [ 'rem', 'px', 'em' ],\n\t\t...options,\n\t};\n\n\tconst acceptableUnitsGroup = acceptableUnits?.join( '|' );\n\tconst regexUnits = new RegExp(\n\t\t`^(\\\\d*\\\\.?\\\\d+)(${ acceptableUnitsGroup }){1,1}$`\n\t);\n\n\tconst matches = rawValue.match( regexUnits );\n\n\t// We need a number value and a unit.\n\tif ( ! matches || matches.length < 3 ) {\n\t\treturn null;\n\t}\n\n\tlet [ , value, unit ] = matches;\n\n\tlet returnValue = parseFloat( value );\n\n\tif ( 'px' === coerceTo && ( 'em' === unit || 'rem' === unit ) ) {\n\t\treturnValue = returnValue * rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\tif ( 'px' === unit && ( 'em' === coerceTo || 'rem' === coerceTo ) ) {\n\t\treturnValue = returnValue / rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\treturn {\n\t\tvalue: returnValue,\n\t\tunit,\n\t};\n}\n\n/**\n * Returns a value rounded to defined precision.\n * Returns `undefined` if the value is not a valid finite number.\n *\n * @param {number} value Raw value.\n * @param {number} digits The number of digits to appear after the decimal point\n *\n * @return {number|undefined} Value rounded to standard precision.\n */\nexport function roundToPrecision( value, digits = 3 ) {\n\treturn Number.isFinite( value )\n\t\t? parseFloat( value.toFixed( digits ) )\n\t\t: undefined;\n}\n"]}
|
|
@@ -35,6 +35,8 @@ var _screenTextColor = _interopRequireDefault(require("./screen-text-color"));
|
|
|
35
35
|
|
|
36
36
|
var _screenLinkColor = _interopRequireDefault(require("./screen-link-color"));
|
|
37
37
|
|
|
38
|
+
var _screenHeadingColor = _interopRequireDefault(require("./screen-heading-color"));
|
|
39
|
+
|
|
38
40
|
var _screenButtonColor = _interopRequireDefault(require("./screen-button-color"));
|
|
39
41
|
|
|
40
42
|
var _screenLayout = _interopRequireDefault(require("./screen-layout"));
|
|
@@ -77,6 +79,11 @@ function ContextScreens(_ref2) {
|
|
|
77
79
|
}, (0, _element.createElement)(_screenTypographyElement.default, {
|
|
78
80
|
name: name,
|
|
79
81
|
element: "link"
|
|
82
|
+
})), (0, _element.createElement)(GlobalStylesNavigationScreen, {
|
|
83
|
+
path: parentMenu + '/typography/heading'
|
|
84
|
+
}, (0, _element.createElement)(_screenTypographyElement.default, {
|
|
85
|
+
name: name,
|
|
86
|
+
element: "heading"
|
|
80
87
|
})), (0, _element.createElement)(GlobalStylesNavigationScreen, {
|
|
81
88
|
path: parentMenu + '/typography/button'
|
|
82
89
|
}, (0, _element.createElement)(_screenTypographyElement.default, {
|
|
@@ -102,6 +109,10 @@ function ContextScreens(_ref2) {
|
|
|
102
109
|
path: parentMenu + '/colors/link'
|
|
103
110
|
}, (0, _element.createElement)(_screenLinkColor.default, {
|
|
104
111
|
name: name
|
|
112
|
+
})), (0, _element.createElement)(GlobalStylesNavigationScreen, {
|
|
113
|
+
path: parentMenu + '/colors/heading'
|
|
114
|
+
}, (0, _element.createElement)(_screenHeadingColor.default, {
|
|
115
|
+
name: name
|
|
105
116
|
})), (0, _element.createElement)(GlobalStylesNavigationScreen, {
|
|
106
117
|
path: parentMenu + '/colors/button'
|
|
107
118
|
}, (0, _element.createElement)(_screenButtonColor.default, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/ui.js"],"names":["GlobalStylesNavigationScreen","className","props","filter","Boolean","join","ContextScreens","name","parentMenu","undefined","GlobalStylesUI","blocks","map","block"],"mappings":";;;;;;;;;;;;;AAGA;;AAIA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/ui.js"],"names":["GlobalStylesNavigationScreen","className","props","filter","Boolean","join","ContextScreens","name","parentMenu","undefined","GlobalStylesUI","blocks","map","block"],"mappings":";;;;;;;;;;;;;AAGA;;AAIA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAzBA;AACA;AACA;;AAOA;AACA;AACA;AAgBA,SAASA,4BAAT,OAAiE;AAAA,MAA1B;AAAEC,IAA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BAAC,8BAAD,OADD,CARD,EAYC,4BAAC,4BAAD;AAA8B,IAAA,IAAI,EAAC;AAAnC,KACC,4BAAC,wBAAD,OADD,CAZD,EAgBGA,MAAM,CAACC,GAAP,CAAcC,KAAF,IACb,4BAAC,4BAAD;AACC,IAAA,GAAG,EAAG,gBAAgBA,KAAK,CAACN,IAD7B;AAEC,IAAA,IAAI,EAAG,aAAaM,KAAK,CAACN;AAF3B,KAIC,4BAAC,oBAAD;AAAa,IAAA,IAAI,EAAGM,KAAK,CAACN;AAA1B,IAJD,CADC,CAhBH,EAyBC,4BAAC,cAAD,OAzBD,EA2BGI,MAAM,CAACC,GAAP,CAAcC,KAAF,IACb,4BAAC,cAAD;AACC,IAAA,GAAG,EAAG,mBAAmBA,KAAK,CAACN,IADhC;AAEC,IAAA,IAAI,EAAGM,KAAK,CAACN;AAFd,IADC,CA3BH,CADD;AAoCA;;eAEcG,c","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalNavigatorProvider as NavigatorProvider,\n\t__experimentalNavigatorScreen as NavigatorScreen,\n} from '@wordpress/components';\nimport { getBlockTypes } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ScreenRoot from './screen-root';\nimport ScreenBlockList from './screen-block-list';\nimport ScreenBlock from './screen-block';\nimport ScreenTypography from './screen-typography';\nimport ScreenTypographyElement from './screen-typography-element';\nimport ScreenColors from './screen-colors';\nimport ScreenColorPalette from './screen-color-palette';\nimport ScreenBackgroundColor from './screen-background-color';\nimport ScreenTextColor from './screen-text-color';\nimport ScreenLinkColor from './screen-link-color';\nimport ScreenHeadingColor from './screen-heading-color';\nimport ScreenButtonColor from './screen-button-color';\nimport ScreenLayout from './screen-layout';\nimport ScreenStyleVariations from './screen-style-variations';\n\nfunction GlobalStylesNavigationScreen( { className, ...props } ) {\n\treturn (\n\t\t<NavigatorScreen\n\t\t\tclassName={ [\n\t\t\t\t'edit-site-global-styles-sidebar__navigator-screen',\n\t\t\t\tclassName,\n\t\t\t]\n\t\t\t\t.filter( Boolean )\n\t\t\t\t.join( ' ' ) }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nfunction ContextScreens( { name } ) {\n\tconst parentMenu = name === undefined ? '' : '/blocks/' + name;\n\n\treturn (\n\t\t<>\n\t\t\t<GlobalStylesNavigationScreen path={ parentMenu + '/typography' }>\n\t\t\t\t<ScreenTypography name={ name } />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t<GlobalStylesNavigationScreen\n\t\t\t\tpath={ parentMenu + '/typography/text' }\n\t\t\t>\n\t\t\t\t<ScreenTypographyElement name={ name } element=\"text\" />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t<GlobalStylesNavigationScreen\n\t\t\t\tpath={ parentMenu + '/typography/link' }\n\t\t\t>\n\t\t\t\t<ScreenTypographyElement name={ name } element=\"link\" />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t<GlobalStylesNavigationScreen\n\t\t\t\tpath={ parentMenu + '/typography/heading' }\n\t\t\t>\n\t\t\t\t<ScreenTypographyElement name={ name } element=\"heading\" />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t<GlobalStylesNavigationScreen\n\t\t\t\tpath={ parentMenu + '/typography/button' }\n\t\t\t>\n\t\t\t\t<ScreenTypographyElement name={ name } element=\"button\" />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t<GlobalStylesNavigationScreen path={ parentMenu + '/colors' }>\n\t\t\t\t<ScreenColors name={ name } />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t<GlobalStylesNavigationScreen\n\t\t\t\tpath={ parentMenu + '/colors/palette' }\n\t\t\t>\n\t\t\t\t<ScreenColorPalette name={ name } />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t<GlobalStylesNavigationScreen\n\t\t\t\tpath={ parentMenu + '/colors/background' }\n\t\t\t>\n\t\t\t\t<ScreenBackgroundColor name={ name } />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t<GlobalStylesNavigationScreen path={ parentMenu + '/colors/text' }>\n\t\t\t\t<ScreenTextColor name={ name } />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t<GlobalStylesNavigationScreen path={ parentMenu + '/colors/link' }>\n\t\t\t\t<ScreenLinkColor name={ name } />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t<GlobalStylesNavigationScreen\n\t\t\t\tpath={ parentMenu + '/colors/heading' }\n\t\t\t>\n\t\t\t\t<ScreenHeadingColor name={ name } />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t<GlobalStylesNavigationScreen\n\t\t\t\tpath={ parentMenu + '/colors/button' }\n\t\t\t>\n\t\t\t\t<ScreenButtonColor name={ name } />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t<GlobalStylesNavigationScreen path={ parentMenu + '/layout' }>\n\t\t\t\t<ScreenLayout name={ name } />\n\t\t\t</GlobalStylesNavigationScreen>\n\t\t</>\n\t);\n}\n\nfunction GlobalStylesUI() {\n\tconst blocks = getBlockTypes();\n\n\treturn (\n\t\t<NavigatorProvider\n\t\t\tclassName=\"edit-site-global-styles-sidebar__navigator-provider\"\n\t\t\tinitialPath=\"/\"\n\t\t>\n\t\t\t<GlobalStylesNavigationScreen path=\"/\">\n\t\t\t\t<ScreenRoot />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t<GlobalStylesNavigationScreen path=\"/variations\">\n\t\t\t\t<ScreenStyleVariations />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t<GlobalStylesNavigationScreen path=\"/blocks\">\n\t\t\t\t<ScreenBlockList />\n\t\t\t</GlobalStylesNavigationScreen>\n\n\t\t\t{ blocks.map( ( block ) => (\n\t\t\t\t<GlobalStylesNavigationScreen\n\t\t\t\t\tkey={ 'menu-block-' + block.name }\n\t\t\t\t\tpath={ '/blocks/' + block.name }\n\t\t\t\t>\n\t\t\t\t\t<ScreenBlock name={ block.name } />\n\t\t\t\t</GlobalStylesNavigationScreen>\n\t\t\t) ) }\n\n\t\t\t<ContextScreens />\n\n\t\t\t{ blocks.map( ( block ) => (\n\t\t\t\t<ContextScreens\n\t\t\t\t\tkey={ 'screens-block-' + block.name }\n\t\t\t\t\tname={ block.name }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</NavigatorProvider>\n\t);\n}\n\nexport default GlobalStylesUI;\n"]}
|
|
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getBlockSelectors = void 0;
|
|
7
7
|
exports.getLayoutStyles = getLayoutStyles;
|
|
8
|
-
exports.
|
|
8
|
+
exports.getNodesWithStyles = exports.getNodesWithSettings = void 0;
|
|
9
|
+
exports.getStylesDeclarations = getStylesDeclarations;
|
|
10
|
+
exports.toStyles = exports.toCustomProperties = void 0;
|
|
9
11
|
exports.toSvgFilters = toSvgFilters;
|
|
10
12
|
exports.useGlobalStylesOutput = useGlobalStylesOutput;
|
|
11
13
|
|
|
@@ -15,6 +17,8 @@ var _lodash = require("lodash");
|
|
|
15
17
|
|
|
16
18
|
var _blocks = require("@wordpress/blocks");
|
|
17
19
|
|
|
20
|
+
var _data = require("@wordpress/data");
|
|
21
|
+
|
|
18
22
|
var _styleEngine = require("@wordpress/style-engine");
|
|
19
23
|
|
|
20
24
|
var _blockEditor = require("@wordpress/block-editor");
|
|
@@ -50,7 +54,7 @@ function compileStyleValue(uncompiledValue) {
|
|
|
50
54
|
const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
|
|
51
55
|
const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
|
|
52
56
|
|
|
53
|
-
if (
|
|
57
|
+
if (uncompiledValue !== null && uncompiledValue !== void 0 && uncompiledValue.startsWith(VARIABLE_REFERENCE_PREFIX)) {
|
|
54
58
|
const variable = uncompiledValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
|
|
55
59
|
return `var(--wp--${variable})`;
|
|
56
60
|
}
|
|
@@ -61,13 +65,15 @@ function compileStyleValue(uncompiledValue) {
|
|
|
61
65
|
* Transform given preset tree into a set of style declarations.
|
|
62
66
|
*
|
|
63
67
|
* @param {Object} blockPresets
|
|
68
|
+
* @param {Object} mergedSettings Merged theme.json settings.
|
|
64
69
|
*
|
|
65
|
-
* @return {Array} An array of style declarations.
|
|
70
|
+
* @return {Array<Object>} An array of style declarations.
|
|
66
71
|
*/
|
|
67
72
|
|
|
68
73
|
|
|
69
74
|
function getPresetsDeclarations() {
|
|
70
75
|
let blockPresets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
76
|
+
let mergedSettings = arguments.length > 1 ? arguments[1] : undefined;
|
|
71
77
|
return (0, _lodash.reduce)(_utils.PRESET_METADATA, (declarations, _ref) => {
|
|
72
78
|
let {
|
|
73
79
|
path,
|
|
@@ -79,10 +85,10 @@ function getPresetsDeclarations() {
|
|
|
79
85
|
['default', 'theme', 'custom'].forEach(origin => {
|
|
80
86
|
if (presetByOrigin[origin]) {
|
|
81
87
|
presetByOrigin[origin].forEach(value => {
|
|
82
|
-
if (valueKey) {
|
|
88
|
+
if (valueKey && !valueFunc) {
|
|
83
89
|
declarations.push(`--wp--preset--${cssVarInfix}--${(0, _lodash.kebabCase)(value.slug)}: ${value[valueKey]}`);
|
|
84
90
|
} else if (valueFunc && typeof valueFunc === 'function') {
|
|
85
|
-
declarations.push(`--wp--preset--${cssVarInfix}--${(0, _lodash.kebabCase)(value.slug)}: ${valueFunc(value)}`);
|
|
91
|
+
declarations.push(`--wp--preset--${cssVarInfix}--${(0, _lodash.kebabCase)(value.slug)}: ${valueFunc(value, mergedSettings)}`);
|
|
86
92
|
}
|
|
87
93
|
});
|
|
88
94
|
}
|
|
@@ -203,7 +209,12 @@ function getStylesDeclarations() {
|
|
|
203
209
|
return declarations;
|
|
204
210
|
}
|
|
205
211
|
|
|
206
|
-
const styleValue = (0, _lodash.get)(blockStyles, pathToValue);
|
|
212
|
+
const styleValue = (0, _lodash.get)(blockStyles, pathToValue); // Root-level padding styles don't currently support strings with CSS shorthand values.
|
|
213
|
+
// This may change: https://github.com/WordPress/gutenberg/issues/40132.
|
|
214
|
+
|
|
215
|
+
if (key === '--wp--style--root--padding' && (typeof styleValue === 'string' || !useRootPaddingAlign)) {
|
|
216
|
+
return declarations;
|
|
217
|
+
}
|
|
207
218
|
|
|
208
219
|
if (!!properties && typeof styleValue !== 'string') {
|
|
209
220
|
Object.entries(properties).forEach(entry => {
|
|
@@ -218,26 +229,22 @@ function getStylesDeclarations() {
|
|
|
218
229
|
const cssProperty = name.startsWith('--') ? name : (0, _lodash.kebabCase)(name);
|
|
219
230
|
declarations.push(`${cssProperty}: ${compileStyleValue((0, _lodash.get)(styleValue, [prop]))}`);
|
|
220
231
|
});
|
|
221
|
-
} else if (key === '--wp--style--root--padding' && typeof styleValue === 'string') {
|
|
222
|
-
// Root-level padding styles don't currently support strings with CSS shorthand values.
|
|
223
|
-
// This may change: https://github.com/WordPress/gutenberg/issues/40132.
|
|
224
|
-
return declarations;
|
|
225
232
|
} else if ((0, _lodash.get)(blockStyles, pathToValue, false)) {
|
|
226
233
|
const cssProperty = key.startsWith('--') ? key : (0, _lodash.kebabCase)(key);
|
|
227
234
|
declarations.push(`${cssProperty}: ${compileStyleValue((0, _lodash.get)(blockStyles, pathToValue))}`);
|
|
228
235
|
}
|
|
229
236
|
|
|
230
237
|
return declarations;
|
|
231
|
-
}, []);
|
|
232
|
-
|
|
233
|
-
if (isRoot && useRootPaddingAlign) {
|
|
234
|
-
return output;
|
|
235
|
-
} // The goal is to move everything to server side generated engine styles
|
|
238
|
+
}, []); // The goal is to move everything to server side generated engine styles
|
|
236
239
|
// This is temporary as we absorb more and more styles into the engine.
|
|
237
240
|
|
|
238
|
-
|
|
239
241
|
const extraRules = (0, _styleEngine.getCSSRules)(blockStyles);
|
|
240
242
|
extraRules.forEach(rule => {
|
|
243
|
+
// Don't output padding properties if padding variables are set.
|
|
244
|
+
if (isRoot && useRootPaddingAlign && rule.key.startsWith('padding')) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
241
248
|
const cssProperty = rule.key.startsWith('--') ? rule.key : (0, _lodash.kebabCase)(rule.key);
|
|
242
249
|
output.push(`${cssProperty}: ${compileStyleValue(rule.value)}`);
|
|
243
250
|
});
|
|
@@ -306,7 +313,15 @@ function getLayoutStyles(_ref6) {
|
|
|
306
313
|
}
|
|
307
314
|
|
|
308
315
|
if (declarations.length) {
|
|
309
|
-
|
|
316
|
+
let combinedSelector = '';
|
|
317
|
+
|
|
318
|
+
if (!hasBlockGapSupport) {
|
|
319
|
+
// For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
|
|
320
|
+
combinedSelector = selector === _utils.ROOT_BLOCK_SELECTOR ? `:where(.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''})` : `:where(${selector}.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''})`;
|
|
321
|
+
} else {
|
|
322
|
+
combinedSelector = selector === _utils.ROOT_BLOCK_SELECTOR ? `${selector} .${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}` : `${selector}.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}`;
|
|
323
|
+
}
|
|
324
|
+
|
|
310
325
|
ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
|
|
311
326
|
}
|
|
312
327
|
});
|
|
@@ -356,7 +371,7 @@ function getLayoutStyles(_ref6) {
|
|
|
356
371
|
}
|
|
357
372
|
|
|
358
373
|
const getNodesWithStyles = (tree, blockSelectors) => {
|
|
359
|
-
var _tree$
|
|
374
|
+
var _tree$styles3;
|
|
360
375
|
|
|
361
376
|
const nodes = [];
|
|
362
377
|
|
|
@@ -376,16 +391,20 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
376
391
|
});
|
|
377
392
|
}
|
|
378
393
|
|
|
379
|
-
(0, _lodash.forEach)(
|
|
380
|
-
|
|
394
|
+
(0, _lodash.forEach)(_blocks.__EXPERIMENTAL_ELEMENTS, (selector, name) => {
|
|
395
|
+
var _tree$styles;
|
|
396
|
+
|
|
397
|
+
if (!!((_tree$styles = tree.styles) !== null && _tree$styles !== void 0 && _tree$styles.elements[name])) {
|
|
398
|
+
var _tree$styles2;
|
|
399
|
+
|
|
381
400
|
nodes.push({
|
|
382
|
-
styles:
|
|
383
|
-
selector
|
|
401
|
+
styles: (_tree$styles2 = tree.styles) === null || _tree$styles2 === void 0 ? void 0 : _tree$styles2.elements[name],
|
|
402
|
+
selector
|
|
384
403
|
});
|
|
385
404
|
}
|
|
386
405
|
}); // Iterate over blocks: they can have styles & elements.
|
|
387
406
|
|
|
388
|
-
(0, _lodash.forEach)((_tree$
|
|
407
|
+
(0, _lodash.forEach)((_tree$styles3 = tree.styles) === null || _tree$styles3 === void 0 ? void 0 : _tree$styles3.blocks, (node, blockName) => {
|
|
389
408
|
var _blockSelectors$block;
|
|
390
409
|
|
|
391
410
|
const blockStyles = pickStyleKeys(node);
|
|
@@ -484,7 +503,7 @@ const toCustomProperties = (tree, blockSelectors) => {
|
|
|
484
503
|
custom,
|
|
485
504
|
selector
|
|
486
505
|
} = _ref12;
|
|
487
|
-
const declarations = getPresetsDeclarations(presets);
|
|
506
|
+
const declarations = getPresetsDeclarations(presets, tree === null || tree === void 0 ? void 0 : tree.settings);
|
|
488
507
|
const customProps = flattenTree(custom, '--wp--custom--', '--');
|
|
489
508
|
|
|
490
509
|
if (customProps.length > 0) {
|
|
@@ -500,9 +519,10 @@ const toCustomProperties = (tree, blockSelectors) => {
|
|
|
500
519
|
|
|
501
520
|
exports.toCustomProperties = toCustomProperties;
|
|
502
521
|
|
|
503
|
-
const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport)
|
|
522
|
+
const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport) {
|
|
504
523
|
var _tree$settings5;
|
|
505
524
|
|
|
525
|
+
let disableLayoutStyles = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
506
526
|
const nodesWithStyles = getNodesWithStyles(tree, blockSelectors);
|
|
507
527
|
const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
|
|
508
528
|
const useRootPaddingAlign = tree === null || tree === void 0 ? void 0 : (_tree$settings5 = tree.settings) === null || _tree$settings5 === void 0 ? void 0 : _tree$settings5.useRootPaddingAwareAlignments;
|
|
@@ -570,7 +590,7 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
|
|
|
570
590
|
} // Process blockGap and layout styles.
|
|
571
591
|
|
|
572
592
|
|
|
573
|
-
if (_utils.ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport) {
|
|
593
|
+
if (!disableLayoutStyles && (_utils.ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport)) {
|
|
574
594
|
ruleset += getLayoutStyles({
|
|
575
595
|
tree,
|
|
576
596
|
style: styles,
|
|
@@ -624,10 +644,10 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
|
|
|
624
644
|
ruleset = ruleset + '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';
|
|
625
645
|
|
|
626
646
|
if (hasBlockGapSupport) {
|
|
627
|
-
var _tree$
|
|
647
|
+
var _tree$styles4, _tree$styles4$spacing;
|
|
628
648
|
|
|
629
649
|
// Use fallback of `0.5em` just in case, however if there is blockGap support, there should nearly always be a real value.
|
|
630
|
-
const gapValue = (0, _blockEditor.__experimentalGetGapCSSValue)(tree === null || tree === void 0 ? void 0 : (_tree$
|
|
650
|
+
const gapValue = (0, _blockEditor.__experimentalGetGapCSSValue)(tree === null || tree === void 0 ? void 0 : (_tree$styles4 = tree.styles) === null || _tree$styles4 === void 0 ? void 0 : (_tree$styles4$spacing = _tree$styles4.spacing) === null || _tree$styles4$spacing === void 0 ? void 0 : _tree$styles4$spacing.blockGap) || '0.5em';
|
|
631
651
|
ruleset = ruleset + '.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }';
|
|
632
652
|
ruleset = ruleset + `.wp-site-blocks > * + * { margin-block-start: ${gapValue}; }`;
|
|
633
653
|
}
|
|
@@ -701,9 +721,6 @@ const getBlockSelectors = blockTypes => {
|
|
|
701
721
|
exports.getBlockSelectors = getBlockSelectors;
|
|
702
722
|
|
|
703
723
|
function useGlobalStylesOutput() {
|
|
704
|
-
const [stylesheets, setStylesheets] = (0, _element.useState)([]);
|
|
705
|
-
const [settings, setSettings] = (0, _element.useState)({});
|
|
706
|
-
const [svgFilters, setSvgFilters] = (0, _element.useState)({});
|
|
707
724
|
const {
|
|
708
725
|
merged: mergedConfig
|
|
709
726
|
} = (0, _element.useContext)(_context.GlobalStylesContext);
|
|
@@ -711,25 +728,29 @@ function useGlobalStylesOutput() {
|
|
|
711
728
|
const hasBlockGapSupport = blockGap !== null;
|
|
712
729
|
const hasFallbackGapSupport = !hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
|
|
713
730
|
|
|
714
|
-
(0,
|
|
731
|
+
const disableLayoutStyles = (0, _data.useSelect)(select => {
|
|
732
|
+
const {
|
|
733
|
+
getSettings
|
|
734
|
+
} = select(_blockEditor.store);
|
|
735
|
+
return !!getSettings().disableLayoutStyles;
|
|
736
|
+
});
|
|
737
|
+
return (0, _element.useMemo)(() => {
|
|
715
738
|
if (!(mergedConfig !== null && mergedConfig !== void 0 && mergedConfig.styles) || !(mergedConfig !== null && mergedConfig !== void 0 && mergedConfig.settings)) {
|
|
716
|
-
return;
|
|
739
|
+
return [];
|
|
717
740
|
}
|
|
718
741
|
|
|
719
742
|
const blockSelectors = getBlockSelectors((0, _blocks.getBlockTypes)());
|
|
720
743
|
const customProperties = toCustomProperties(mergedConfig, blockSelectors);
|
|
721
|
-
const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport);
|
|
744
|
+
const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles);
|
|
722
745
|
const filters = toSvgFilters(mergedConfig, blockSelectors);
|
|
723
|
-
|
|
746
|
+
const stylesheets = [{
|
|
724
747
|
css: customProperties,
|
|
725
748
|
isGlobalStyles: true
|
|
726
749
|
}, {
|
|
727
750
|
css: globalStyles,
|
|
728
751
|
isGlobalStyles: true
|
|
729
|
-
}]
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
}, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig]);
|
|
733
|
-
return [stylesheets, settings, svgFilters, hasBlockGapSupport];
|
|
752
|
+
}];
|
|
753
|
+
return [stylesheets, mergedConfig.settings, filters];
|
|
754
|
+
}, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig, disableLayoutStyles]);
|
|
734
755
|
}
|
|
735
756
|
//# sourceMappingURL=use-global-styles-output.js.map
|