@wordpress/edit-site 4.9.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 +6 -0
- package/build/components/add-new-template/add-custom-generic-template-modal.js +84 -0
- package/build/components/add-new-template/add-custom-generic-template-modal.js.map +1 -0
- package/build/components/add-new-template/add-custom-template-modal.js +82 -61
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template.js +94 -81
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +574 -57
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/index.js +1 -3
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/code-editor/index.js +17 -4
- package/build/components/code-editor/index.js.map +1 -1
- package/build/components/editor/index.js +16 -0
- package/build/components/editor/index.js.map +1 -1
- package/build/components/error-boundary/index.js +6 -0
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +191 -21
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +4 -2
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/hooks.js +11 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +13 -17
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +59 -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-link-color.js +48 -14
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- 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 +298 -61
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +49 -3
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/index.js +22 -10
- 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/keyboard-shortcut-help-modal/index.js +1 -3
- package/build/components/keyboard-shortcut-help-modal/index.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/edit-template-title.js +11 -3
- package/build/components/template-details/edit-template-title.js.map +1 -1
- package/build/components/template-details/index.js +2 -21
- 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/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/template-part-edit.js +86 -0
- package/build/hooks/template-part-edit.js.map +1 -0
- package/build/store/selectors.js +4 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js +77 -0
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +1 -0
- package/build-module/components/add-new-template/add-custom-template-modal.js +82 -61
- 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 +96 -84
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +555 -50
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/index.js +1 -2
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/code-editor/index.js +18 -5
- package/build-module/components/code-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +16 -0
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +5 -0
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +191 -22
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +4 -2
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +11 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +14 -19
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +59 -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-link-color.js +47 -14
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- 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 +294 -69
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +47 -4
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/index.js +25 -12
- 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/keyboard-shortcut-help-modal/index.js +1 -2
- package/build-module/components/keyboard-shortcut-help-modal/index.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/edit-template-title.js +12 -3
- package/build-module/components/template-details/edit-template-title.js.map +1 -1
- package/build-module/components/template-details/index.js +3 -22
- 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-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +67 -0
- package/build-module/hooks/template-part-edit.js.map +1 -0
- package/build-module/store/selectors.js +5 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +55 -48
- package/build-style/style.css +55 -48
- package/package.json +29 -29
- package/src/components/add-new-template/add-custom-generic-template-modal.js +97 -0
- package/src/components/add-new-template/add-custom-template-modal.js +93 -68
- package/src/components/add-new-template/new-template.js +126 -95
- package/src/components/add-new-template/style.scss +41 -8
- package/src/components/add-new-template/utils.js +622 -80
- package/src/components/block-editor/index.js +0 -2
- package/src/components/code-editor/index.js +15 -5
- package/src/components/editor/index.js +11 -0
- package/src/components/error-boundary/index.js +5 -0
- package/src/components/global-styles/dimensions-panel.js +214 -24
- package/src/components/global-styles/global-styles-provider.js +8 -9
- package/src/components/global-styles/hooks.js +18 -0
- package/src/components/global-styles/screen-color-palette.js +25 -27
- package/src/components/global-styles/screen-colors.js +55 -7
- package/src/components/global-styles/screen-heading-color.js +201 -0
- package/src/components/global-styles/screen-link-color.js +65 -23
- 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 +14 -11
- package/src/components/global-styles/test/typography-utils.js +130 -0
- package/src/components/global-styles/test/use-global-styles-output.js +296 -2
- 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 +387 -89
- package/src/components/global-styles/utils.js +43 -2
- package/src/components/header/index.js +37 -13
- package/src/components/header/style.scss +5 -3
- package/src/components/header/undo-redo/redo.js +6 -2
- package/src/components/keyboard-shortcut-help-modal/index.js +1 -2
- package/src/components/keyboard-shortcut-help-modal/style.scss +0 -5
- package/src/components/list/actions/index.js +3 -1
- package/src/components/list/style.scss +0 -8
- 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/style.scss +4 -0
- package/src/components/sidebar/template-card/template-actions.js +3 -1
- package/src/components/template-details/edit-template-title.js +10 -2
- package/src/components/template-details/index.js +7 -22
- package/src/components/template-details/template-areas.js +3 -1
- package/src/components/template-part-converter/convert-to-template-part.js +3 -1
- package/src/components/test/error-boundary.js +38 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/template-part-edit.js +82 -0
- package/src/store/selectors.js +11 -5
- package/src/style.scss +0 -1
- package/build/components/edit-template-part-menu-button/index.js +0 -90
- package/build/components/edit-template-part-menu-button/index.js.map +0 -1
- package/build-module/components/edit-template-part-menu-button/index.js +0 -72
- package/build-module/components/edit-template-part-menu-button/index.js.map +0 -1
- package/src/components/edit-template-part-menu-button/index.js +0 -82
|
@@ -12,6 +12,8 @@ var _blockEditor = require("@wordpress/block-editor");
|
|
|
12
12
|
|
|
13
13
|
var _components = require("@wordpress/components");
|
|
14
14
|
|
|
15
|
+
var _i18n = require("@wordpress/i18n");
|
|
16
|
+
|
|
15
17
|
var _hooks = require("./hooks");
|
|
16
18
|
|
|
17
19
|
/**
|
|
@@ -51,8 +53,16 @@ function TypographyPanel(_ref) {
|
|
|
51
53
|
name,
|
|
52
54
|
element
|
|
53
55
|
} = _ref;
|
|
56
|
+
const [selectedLevel, setCurrentTab] = (0, _element.useState)('heading');
|
|
54
57
|
const supports = (0, _hooks.getSupportedGlobalStylesPanels)(name);
|
|
55
|
-
|
|
58
|
+
let prefix = '';
|
|
59
|
+
|
|
60
|
+
if (element === 'heading') {
|
|
61
|
+
prefix = `elements.${selectedLevel}.`;
|
|
62
|
+
} else if (element && element !== 'text') {
|
|
63
|
+
prefix = `elements.${element}.`;
|
|
64
|
+
}
|
|
65
|
+
|
|
56
66
|
const [fontSizes] = (0, _hooks.useSetting)('typography.fontSizes', name);
|
|
57
67
|
const disableCustomFontSizes = !(0, _hooks.useSetting)('typography.customFontSize', name)[0];
|
|
58
68
|
const [fontFamilies] = (0, _hooks.useSetting)('typography.fontFamilies', name);
|
|
@@ -61,6 +71,14 @@ function TypographyPanel(_ref) {
|
|
|
61
71
|
const hasLineHeightEnabled = useHasLineHeightControl(name);
|
|
62
72
|
const hasAppearanceControl = useHasAppearanceControl(name);
|
|
63
73
|
const hasLetterSpacingControl = useHasLetterSpacingControl(name);
|
|
74
|
+
/* Disable font size controls when the option to style all headings is selected. */
|
|
75
|
+
|
|
76
|
+
let hasFontSizeEnabled = supports.includes('fontSize');
|
|
77
|
+
|
|
78
|
+
if (element === 'heading' && selectedLevel === 'heading') {
|
|
79
|
+
hasFontSizeEnabled = false;
|
|
80
|
+
}
|
|
81
|
+
|
|
64
82
|
const [fontFamily, setFontFamily] = (0, _hooks.useStyle)(prefix + 'typography.fontFamily', name);
|
|
65
83
|
const [fontSize, setFontSize] = (0, _hooks.useStyle)(prefix + 'typography.fontSize', name);
|
|
66
84
|
const [fontStyle, setFontStyle] = (0, _hooks.useStyle)(prefix + 'typography.fontStyle', name);
|
|
@@ -88,22 +106,59 @@ function TypographyPanel(_ref) {
|
|
|
88
106
|
letterSpacing,
|
|
89
107
|
...extraStyles
|
|
90
108
|
}
|
|
91
|
-
}, "Aa"),
|
|
109
|
+
}, "Aa"), element === 'heading' && (0, _element.createElement)("div", null, (0, _element.createElement)("h4", null, (0, _i18n.__)('Select heading level')), (0, _element.createElement)(_components.__experimentalToggleGroupControl, {
|
|
110
|
+
label: (0, _i18n.__)('Select heading level'),
|
|
111
|
+
hideLabelFromVision: true,
|
|
112
|
+
value: selectedLevel,
|
|
113
|
+
onChange: setCurrentTab,
|
|
114
|
+
isBlock: true,
|
|
115
|
+
size: "__unstable-large"
|
|
116
|
+
}, (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
117
|
+
value: "heading"
|
|
118
|
+
/* translators: 'All' refers to selecting all heading levels
|
|
119
|
+
and applying the same style to h1-h6. */
|
|
120
|
+
,
|
|
121
|
+
label: (0, _i18n.__)('All')
|
|
122
|
+
}), (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
123
|
+
value: "h1",
|
|
124
|
+
label: (0, _i18n.__)('H1')
|
|
125
|
+
}), (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
126
|
+
value: "h2",
|
|
127
|
+
label: (0, _i18n.__)('H2')
|
|
128
|
+
}), (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
129
|
+
value: "h3",
|
|
130
|
+
label: (0, _i18n.__)('H3')
|
|
131
|
+
}), (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
132
|
+
value: "h4",
|
|
133
|
+
label: (0, _i18n.__)('H4')
|
|
134
|
+
}), (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
135
|
+
value: "h5",
|
|
136
|
+
label: (0, _i18n.__)('H5')
|
|
137
|
+
}), (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
138
|
+
value: "h6",
|
|
139
|
+
label: (0, _i18n.__)('H6')
|
|
140
|
+
}))), supports.includes('fontFamily') && (0, _element.createElement)(_blockEditor.__experimentalFontFamilyControl, {
|
|
92
141
|
fontFamilies: fontFamilies,
|
|
93
142
|
value: fontFamily,
|
|
94
|
-
onChange: setFontFamily
|
|
95
|
-
|
|
143
|
+
onChange: setFontFamily,
|
|
144
|
+
size: "__unstable-large"
|
|
145
|
+
}), hasFontSizeEnabled && (0, _element.createElement)(_components.FontSizePicker, {
|
|
96
146
|
value: fontSize,
|
|
97
147
|
onChange: setFontSize,
|
|
98
148
|
fontSizes: fontSizes,
|
|
99
|
-
disableCustomFontSizes: disableCustomFontSizes
|
|
100
|
-
|
|
149
|
+
disableCustomFontSizes: disableCustomFontSizes,
|
|
150
|
+
size: "__unstable-large"
|
|
151
|
+
}), hasLineHeightEnabled && (0, _element.createElement)("div", {
|
|
152
|
+
className: "edit-site-typography-panel__half-width-control"
|
|
153
|
+
}, (0, _element.createElement)(_components.__experimentalSpacer, {
|
|
101
154
|
marginBottom: 6
|
|
102
155
|
}, (0, _element.createElement)(_blockEditor.LineHeightControl, {
|
|
103
156
|
__nextHasNoMarginBottom: true,
|
|
157
|
+
__unstableInputWidth: "auto",
|
|
104
158
|
value: lineHeight,
|
|
105
|
-
onChange: setLineHeight
|
|
106
|
-
|
|
159
|
+
onChange: setLineHeight,
|
|
160
|
+
size: "__unstable-large"
|
|
161
|
+
}))), hasAppearanceControl && (0, _element.createElement)(_blockEditor.__experimentalFontAppearanceControl, {
|
|
107
162
|
value: {
|
|
108
163
|
fontStyle,
|
|
109
164
|
fontWeight
|
|
@@ -117,10 +172,16 @@ function TypographyPanel(_ref) {
|
|
|
117
172
|
setFontWeight(newFontWeight);
|
|
118
173
|
},
|
|
119
174
|
hasFontStyles: hasFontStyles,
|
|
120
|
-
hasFontWeights: hasFontWeights
|
|
121
|
-
|
|
175
|
+
hasFontWeights: hasFontWeights,
|
|
176
|
+
size: "__unstable-large",
|
|
177
|
+
__nextUnconstrainedWidth: true
|
|
178
|
+
}), hasLetterSpacingControl && (0, _element.createElement)("div", {
|
|
179
|
+
className: "edit-site-typography-panel__half-width-control"
|
|
180
|
+
}, (0, _element.createElement)(_blockEditor.__experimentalLetterSpacingControl, {
|
|
122
181
|
value: letterSpacing,
|
|
123
|
-
onChange: setLetterSpacing
|
|
124
|
-
|
|
182
|
+
onChange: setLetterSpacing,
|
|
183
|
+
size: "__unstable-large",
|
|
184
|
+
__unstableInputWidth: "auto"
|
|
185
|
+
})));
|
|
125
186
|
}
|
|
126
187
|
//# sourceMappingURL=typography-panel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/typography-panel.js"],"names":["useHasTypographyPanel","name","hasLineHeight","useHasLineHeightControl","hasFontAppearance","useHasAppearanceControl","hasLetterSpacing","useHasLetterSpacingControl","supports","includes","hasFontStyles","hasFontWeights","TypographyPanel","element","prefix","fontSizes","disableCustomFontSizes","fontFamilies","hasLineHeightEnabled","hasAppearanceControl","hasLetterSpacingControl","fontFamily","setFontFamily","fontSize","setFontSize","fontStyle","setFontStyle","fontWeight","setFontWeight","lineHeight","setLineHeight","letterSpacing","setLetterSpacing","backgroundColor","gradientValue","color","extraStyles","textDecoration","background","newFontStyle","newFontWeight"],"mappings":";;;;;;;;;;AAGA;;AAMA;;AASA;;AAlBA;AACA;AACA;;AAaA;AACA;AACA;AAGO,SAASA,qBAAT,CAAgCC,IAAhC,EAAuC;AAC7C,QAAMC,aAAa,GAAGC,uBAAuB,C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,IAAA,YAAY,EAAG;AAAvB,KACC,4BAAC,8BAAD;AACC,IAAA,uBAAuB,EAAG,IAD3B;AAEC,IAAA,KAAK,EAAGW,UAFT;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IADD,CAjCF,EAyCGX,oBAAoB,IACrB,4BAAC,gDAAD;AACC,IAAA,KAAK,EAAG;AACPM,MAAAA,SADO;AAEPE,MAAAA;AAFO,KADT;AAKC,IAAA,QAAQ,EAAG,SAGJ;AAAA,UAHM;AACZF,QAAAA,SAAS,EAAEc,YADC;AAEZZ,QAAAA,UAAU,EAAEa;AAFA,OAGN;AACNd,MAAAA,YAAY,CAAEa,YAAF,CAAZ;AACAX,MAAAA,aAAa,CAAEY,aAAF,CAAb;AACA,KAXF;AAYC,IAAA,aAAa,EAAG9B,aAZjB;AAaC,IAAA,cAAc,EAAGC;AAblB,IA1CF,EA0DGS,uBAAuB,IACxB,4BAAC,+CAAD;AACC,IAAA,KAAK,EAAGW,aADT;AAEC,IAAA,QAAQ,EAAGC;AAFZ,IA3DF,CADD;AAmEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tLineHeightControl,\n\t__experimentalFontFamilyControl as FontFamilyControl,\n\t__experimentalFontAppearanceControl as FontAppearanceControl,\n\t__experimentalLetterSpacingControl as LetterSpacingControl,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\tFontSizePicker,\n\t__experimentalSpacer as Spacer,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { getSupportedGlobalStylesPanels, useSetting, useStyle } from './hooks';\n\nexport function useHasTypographyPanel( name ) {\n\tconst hasLineHeight = useHasLineHeightControl( name );\n\tconst hasFontAppearance = useHasAppearanceControl( name );\n\tconst hasLetterSpacing = useHasLetterSpacingControl( name );\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\thasLineHeight ||\n\t\thasFontAppearance ||\n\t\thasLetterSpacing ||\n\t\tsupports.includes( 'fontSize' )\n\t);\n}\n\nfunction useHasLineHeightControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'typography.lineHeight', name )[ 0 ] &&\n\t\tsupports.includes( 'lineHeight' )\n\t);\n}\n\nfunction useHasAppearanceControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst hasFontStyles =\n\t\tuseSetting( 'typography.fontStyle', name )[ 0 ] &&\n\t\tsupports.includes( 'fontStyle' );\n\tconst hasFontWeights =\n\t\tuseSetting( 'typography.fontWeight', name )[ 0 ] &&\n\t\tsupports.includes( 'fontWeight' );\n\treturn hasFontStyles || hasFontWeights;\n}\n\nfunction useHasLetterSpacingControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'typography.letterSpacing', name )[ 0 ] &&\n\t\tsupports.includes( 'letterSpacing' )\n\t);\n}\n\nexport default function TypographyPanel( { name, element } ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst prefix =\n\t\telement === 'text' || ! element ? '' : `elements.${ element }.`;\n\tconst [ fontSizes ] = useSetting( 'typography.fontSizes', name );\n\tconst disableCustomFontSizes = ! useSetting(\n\t\t'typography.customFontSize',\n\t\tname\n\t)[ 0 ];\n\tconst [ fontFamilies ] = useSetting( 'typography.fontFamilies', name );\n\tconst hasFontStyles =\n\t\tuseSetting( 'typography.fontStyle', name )[ 0 ] &&\n\t\tsupports.includes( 'fontStyle' );\n\tconst hasFontWeights =\n\t\tuseSetting( 'typography.fontWeight', name )[ 0 ] &&\n\t\tsupports.includes( 'fontWeight' );\n\tconst hasLineHeightEnabled = useHasLineHeightControl( name );\n\tconst hasAppearanceControl = useHasAppearanceControl( name );\n\tconst hasLetterSpacingControl = useHasLetterSpacingControl( name );\n\n\tconst [ fontFamily, setFontFamily ] = useStyle(\n\t\tprefix + 'typography.fontFamily',\n\t\tname\n\t);\n\tconst [ fontSize, setFontSize ] = useStyle(\n\t\tprefix + 'typography.fontSize',\n\t\tname\n\t);\n\n\tconst [ fontStyle, setFontStyle ] = useStyle(\n\t\tprefix + 'typography.fontStyle',\n\t\tname\n\t);\n\tconst [ fontWeight, setFontWeight ] = useStyle(\n\t\tprefix + 'typography.fontWeight',\n\t\tname\n\t);\n\tconst [ lineHeight, setLineHeight ] = useStyle(\n\t\tprefix + 'typography.lineHeight',\n\t\tname\n\t);\n\tconst [ letterSpacing, setLetterSpacing ] = useStyle(\n\t\tprefix + 'typography.letterSpacing',\n\t\tname\n\t);\n\tconst [ backgroundColor ] = useStyle( prefix + 'color.background', name );\n\tconst [ gradientValue ] = useStyle( prefix + 'color.gradient', name );\n\tconst [ color ] = useStyle( prefix + 'color.text', name );\n\tconst extraStyles =\n\t\telement === 'link'\n\t\t\t? {\n\t\t\t\t\ttextDecoration: 'underline',\n\t\t\t }\n\t\t\t: {};\n\n\treturn (\n\t\t<PanelBody className=\"edit-site-typography-panel\" initialOpen={ true }>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-typography-panel__preview\"\n\t\t\t\tstyle={ {\n\t\t\t\t\tfontFamily: fontFamily ?? 'serif',\n\t\t\t\t\tbackground: gradientValue ?? backgroundColor,\n\t\t\t\t\tcolor,\n\t\t\t\t\tfontSize,\n\t\t\t\t\tfontStyle,\n\t\t\t\t\tfontWeight,\n\t\t\t\t\tletterSpacing,\n\t\t\t\t\t...extraStyles,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\tAa\n\t\t\t</div>\n\n\t\t\t{ supports.includes( 'fontFamily' ) && (\n\t\t\t\t<FontFamilyControl\n\t\t\t\t\tfontFamilies={ fontFamilies }\n\t\t\t\t\tvalue={ fontFamily }\n\t\t\t\t\tonChange={ setFontFamily }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ supports.includes( 'fontSize' ) && (\n\t\t\t\t<FontSizePicker\n\t\t\t\t\tvalue={ fontSize }\n\t\t\t\t\tonChange={ setFontSize }\n\t\t\t\t\tfontSizes={ fontSizes }\n\t\t\t\t\tdisableCustomFontSizes={ disableCustomFontSizes }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasLineHeightEnabled && (\n\t\t\t\t<Spacer marginBottom={ 6 }>\n\t\t\t\t\t<LineHeightControl\n\t\t\t\t\t\t__nextHasNoMarginBottom={ true }\n\t\t\t\t\t\tvalue={ lineHeight }\n\t\t\t\t\t\tonChange={ setLineHeight }\n\t\t\t\t\t/>\n\t\t\t\t</Spacer>\n\t\t\t) }\n\t\t\t{ hasAppearanceControl && (\n\t\t\t\t<FontAppearanceControl\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\tfontStyle,\n\t\t\t\t\t\tfontWeight,\n\t\t\t\t\t} }\n\t\t\t\t\tonChange={ ( {\n\t\t\t\t\t\tfontStyle: newFontStyle,\n\t\t\t\t\t\tfontWeight: newFontWeight,\n\t\t\t\t\t} ) => {\n\t\t\t\t\t\tsetFontStyle( newFontStyle );\n\t\t\t\t\t\tsetFontWeight( newFontWeight );\n\t\t\t\t\t} }\n\t\t\t\t\thasFontStyles={ hasFontStyles }\n\t\t\t\t\thasFontWeights={ hasFontWeights }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasLetterSpacingControl && (\n\t\t\t\t<LetterSpacingControl\n\t\t\t\t\tvalue={ letterSpacing }\n\t\t\t\t\tonChange={ setLetterSpacing }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</PanelBody>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/typography-panel.js"],"names":["useHasTypographyPanel","name","hasLineHeight","useHasLineHeightControl","hasFontAppearance","useHasAppearanceControl","hasLetterSpacing","useHasLetterSpacingControl","supports","includes","hasFontStyles","hasFontWeights","TypographyPanel","element","selectedLevel","setCurrentTab","prefix","fontSizes","disableCustomFontSizes","fontFamilies","hasLineHeightEnabled","hasAppearanceControl","hasLetterSpacingControl","hasFontSizeEnabled","fontFamily","setFontFamily","fontSize","setFontSize","fontStyle","setFontStyle","fontWeight","setFontWeight","lineHeight","setLineHeight","letterSpacing","setLetterSpacing","backgroundColor","gradientValue","color","extraStyles","textDecoration","background","newFontStyle","newFontWeight"],"mappings":";;;;;;;;AAiBA;;AAdA;;AAMA;;AAOA;;AAKA;;AArBA;AACA;AACA;;AAgBA;AACA;AACA;AAGO,SAASA,qBAAT,CAAgCC,IAAhC,EAAuC;AAC7C,QAAMC,aAAa,GAAGC,uBAAuB,CAAEF,IAAF,CAA7C;AACA,QAAMG,iBAAiB,GAAGC,uBAAuB,CAAEJ,IAAF,CAAjD;AACA,QAAMK,gBAAgB,GAAGC,0BAA0B,CAAEN,IAAF,CAAnD;AACA,QAAMO,QAAQ,GAAG,2CAAgCP,IAAhC,CAAjB;AACA,SACCC,aAAa,IACbE,iBADA,IAEAE,gBAFA,IAGAE,QAAQ,CAACC,QAAT,CAAmB,UAAnB,CAJD;AAMA;;AAED,SAASN,uBAAT,CAAkCF,IAAlC,EAAyC;AACxC,QAAMO,QAAQ,GAAG,2CAAgCP,IAAhC,CAAjB;AACA,SACC,uBAAY,uBAAZ,EAAqCA,IAArC,EAA6C,CAA7C,KACAO,QAAQ,CAACC,QAAT,CAAmB,YAAnB,CAFD;AAIA;;AAED,SAASJ,uBAAT,CAAkCJ,IAAlC,EAAyC;AACxC,QAAMO,QAAQ,GAAG,2CAAgCP,IAAhC,CAAjB;AACA,QAAMS,aAAa,GAClB,uBAAY,sBAAZ,EAAoCT,IAApC,EAA4C,CAA5C,KACAO,QAAQ,CAACC,QAAT,CAAmB,WAAnB,CAFD;AAGA,QAAME,cAAc,GACnB,uBAAY,uBAAZ,EAAqCV,IAArC,EAA6C,CAA7C,KACAO,QAAQ,CAACC,QAAT,CAAmB,YAAnB,CAFD;AAGA,SAAOC,aAAa,IAAIC,cAAxB;AACA;;AAED,SAASJ,0BAAT,CAAqCN,IAArC,EAA4C;AAC3C,QAAMO,QAAQ,GAAG,2CAAgCP,IAAhC,CAAjB;AACA,SACC,uBAAY,0BAAZ,EAAwCA,IAA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AAK,EAAGY,aADT;AAEC,IAAA,QAAQ,EAAGC,gBAFZ;AAGC,IAAA,IAAI,EAAC,kBAHN;AAIC,IAAA,oBAAoB,EAAC;AAJtB,IADD,CA9GF,CADD;AA0HA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tLineHeightControl,\n\t__experimentalFontFamilyControl as FontFamilyControl,\n\t__experimentalFontAppearanceControl as FontAppearanceControl,\n\t__experimentalLetterSpacingControl as LetterSpacingControl,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\tFontSizePicker,\n\t__experimentalSpacer as Spacer,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport { getSupportedGlobalStylesPanels, useSetting, useStyle } from './hooks';\n\nexport function useHasTypographyPanel( name ) {\n\tconst hasLineHeight = useHasLineHeightControl( name );\n\tconst hasFontAppearance = useHasAppearanceControl( name );\n\tconst hasLetterSpacing = useHasLetterSpacingControl( name );\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\thasLineHeight ||\n\t\thasFontAppearance ||\n\t\thasLetterSpacing ||\n\t\tsupports.includes( 'fontSize' )\n\t);\n}\n\nfunction useHasLineHeightControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'typography.lineHeight', name )[ 0 ] &&\n\t\tsupports.includes( 'lineHeight' )\n\t);\n}\n\nfunction useHasAppearanceControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst hasFontStyles =\n\t\tuseSetting( 'typography.fontStyle', name )[ 0 ] &&\n\t\tsupports.includes( 'fontStyle' );\n\tconst hasFontWeights =\n\t\tuseSetting( 'typography.fontWeight', name )[ 0 ] &&\n\t\tsupports.includes( 'fontWeight' );\n\treturn hasFontStyles || hasFontWeights;\n}\n\nfunction useHasLetterSpacingControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'typography.letterSpacing', name )[ 0 ] &&\n\t\tsupports.includes( 'letterSpacing' )\n\t);\n}\n\nexport default function TypographyPanel( { name, element } ) {\n\tconst [ selectedLevel, setCurrentTab ] = useState( 'heading' );\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tlet prefix = '';\n\tif ( element === 'heading' ) {\n\t\tprefix = `elements.${ selectedLevel }.`;\n\t} else if ( element && element !== 'text' ) {\n\t\tprefix = `elements.${ element }.`;\n\t}\n\tconst [ fontSizes ] = useSetting( 'typography.fontSizes', name );\n\tconst disableCustomFontSizes = ! useSetting(\n\t\t'typography.customFontSize',\n\t\tname\n\t)[ 0 ];\n\tconst [ fontFamilies ] = useSetting( 'typography.fontFamilies', name );\n\tconst hasFontStyles =\n\t\tuseSetting( 'typography.fontStyle', name )[ 0 ] &&\n\t\tsupports.includes( 'fontStyle' );\n\tconst hasFontWeights =\n\t\tuseSetting( 'typography.fontWeight', name )[ 0 ] &&\n\t\tsupports.includes( 'fontWeight' );\n\tconst hasLineHeightEnabled = useHasLineHeightControl( name );\n\tconst hasAppearanceControl = useHasAppearanceControl( name );\n\tconst hasLetterSpacingControl = useHasLetterSpacingControl( name );\n\n\t/* Disable font size controls when the option to style all headings is selected. */\n\tlet hasFontSizeEnabled = supports.includes( 'fontSize' );\n\tif ( element === 'heading' && selectedLevel === 'heading' ) {\n\t\thasFontSizeEnabled = false;\n\t}\n\n\tconst [ fontFamily, setFontFamily ] = useStyle(\n\t\tprefix + 'typography.fontFamily',\n\t\tname\n\t);\n\tconst [ fontSize, setFontSize ] = useStyle(\n\t\tprefix + 'typography.fontSize',\n\t\tname\n\t);\n\n\tconst [ fontStyle, setFontStyle ] = useStyle(\n\t\tprefix + 'typography.fontStyle',\n\t\tname\n\t);\n\tconst [ fontWeight, setFontWeight ] = useStyle(\n\t\tprefix + 'typography.fontWeight',\n\t\tname\n\t);\n\tconst [ lineHeight, setLineHeight ] = useStyle(\n\t\tprefix + 'typography.lineHeight',\n\t\tname\n\t);\n\tconst [ letterSpacing, setLetterSpacing ] = useStyle(\n\t\tprefix + 'typography.letterSpacing',\n\t\tname\n\t);\n\tconst [ backgroundColor ] = useStyle( prefix + 'color.background', name );\n\tconst [ gradientValue ] = useStyle( prefix + 'color.gradient', name );\n\tconst [ color ] = useStyle( prefix + 'color.text', name );\n\tconst extraStyles =\n\t\telement === 'link'\n\t\t\t? {\n\t\t\t\t\ttextDecoration: 'underline',\n\t\t\t }\n\t\t\t: {};\n\n\treturn (\n\t\t<PanelBody className=\"edit-site-typography-panel\" initialOpen={ true }>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-typography-panel__preview\"\n\t\t\t\tstyle={ {\n\t\t\t\t\tfontFamily: fontFamily ?? 'serif',\n\t\t\t\t\tbackground: gradientValue ?? backgroundColor,\n\t\t\t\t\tcolor,\n\t\t\t\t\tfontSize,\n\t\t\t\t\tfontStyle,\n\t\t\t\t\tfontWeight,\n\t\t\t\t\tletterSpacing,\n\t\t\t\t\t...extraStyles,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\tAa\n\t\t\t</div>\n\t\t\t{ element === 'heading' && (\n\t\t\t\t<div>\n\t\t\t\t\t<h4>{ __( 'Select heading level' ) }</h4>\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\tlabel={ __( 'Select heading level' ) }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tvalue={ selectedLevel }\n\t\t\t\t\t\tonChange={ setCurrentTab }\n\t\t\t\t\t\tisBlock\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"heading\"\n\t\t\t\t\t\t\t/* translators: 'All' refers to selecting all heading levels \n\t\t\t\t\t\t\tand applying the same style to h1-h6. */\n\t\t\t\t\t\t\tlabel={ __( 'All' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"h1\"\n\t\t\t\t\t\t\tlabel={ __( 'H1' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"h2\"\n\t\t\t\t\t\t\tlabel={ __( 'H2' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"h3\"\n\t\t\t\t\t\t\tlabel={ __( 'H3' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"h4\"\n\t\t\t\t\t\t\tlabel={ __( 'H4' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"h5\"\n\t\t\t\t\t\t\tlabel={ __( 'H5' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tvalue=\"h6\"\n\t\t\t\t\t\t\tlabel={ __( 'H6' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ supports.includes( 'fontFamily' ) && (\n\t\t\t\t<FontFamilyControl\n\t\t\t\t\tfontFamilies={ fontFamilies }\n\t\t\t\t\tvalue={ fontFamily }\n\t\t\t\t\tonChange={ setFontFamily }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasFontSizeEnabled && (\n\t\t\t\t<FontSizePicker\n\t\t\t\t\tvalue={ fontSize }\n\t\t\t\t\tonChange={ setFontSize }\n\t\t\t\t\tfontSizes={ fontSizes }\n\t\t\t\t\tdisableCustomFontSizes={ disableCustomFontSizes }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasLineHeightEnabled && (\n\t\t\t\t<div className=\"edit-site-typography-panel__half-width-control\">\n\t\t\t\t\t<Spacer marginBottom={ 6 }>\n\t\t\t\t\t\t<LineHeightControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom={ true }\n\t\t\t\t\t\t\t__unstableInputWidth=\"auto\"\n\t\t\t\t\t\t\tvalue={ lineHeight }\n\t\t\t\t\t\t\tonChange={ setLineHeight }\n\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Spacer>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ hasAppearanceControl && (\n\t\t\t\t<FontAppearanceControl\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\tfontStyle,\n\t\t\t\t\t\tfontWeight,\n\t\t\t\t\t} }\n\t\t\t\t\tonChange={ ( {\n\t\t\t\t\t\tfontStyle: newFontStyle,\n\t\t\t\t\t\tfontWeight: newFontWeight,\n\t\t\t\t\t} ) => {\n\t\t\t\t\t\tsetFontStyle( newFontStyle );\n\t\t\t\t\t\tsetFontWeight( newFontWeight );\n\t\t\t\t\t} }\n\t\t\t\t\thasFontStyles={ hasFontStyles }\n\t\t\t\t\thasFontWeights={ hasFontWeights }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t__nextUnconstrainedWidth\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasLetterSpacingControl && (\n\t\t\t\t<div className=\"edit-site-typography-panel__half-width-control\">\n\t\t\t\t\t<LetterSpacingControl\n\t\t\t\t\t\tvalue={ letterSpacing }\n\t\t\t\t\t\tonChange={ setLetterSpacing }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t__unstableInputWidth=\"auto\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</PanelBody>\n\t);\n}\n"]}
|
|
@@ -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,gCAAgC,GAAG,GAAzC;AACA,QAAMC,oBAAoB,GAAG,CAA7B,CAZwE,CAcxE;AACA;;AACA,MAAK,WAAUT,MAAV,aAAUA,MAAV,uBAAUA,MAAM,CAAEI,KAAlB,CAAL,EAA+B;AAC9B,WAAOD,WAAP;AACA;;AAED,QAAMO,qBAAqB,GAAG,CAAAV,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEI,KAAR,KAAiB,EAA/C,CApBwE,CAsBxE;;AACA,MAAIO,kBAAkB,GAAGD,qBAAH,aAAGA,qBAAH,uBAAGA,qBAAqB,CAAEE,GAAhD;AACA,MAAIC,kBAAkB,GAAGH,qBAAH,aAAGA,qBAAH,uBAAGA,qBAAqB,CAAEI,GAAhD;AACA,QAAMC,aAAa,GAAGC,yBAAyB,CAAEb,WAAF,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,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,IAAAA,SAAF;AAAa,OAAGC;AAAhB,GAA0B;AAChE,SACC,4BAAC,yCAAD;AACC,IAAA,SAAS,EAAG,CACX,mDADW,EAEXD,SAFW,EAIVE,MAJU,CAIFC,OAJE,EAKVC,IALU,CAKJ,GALI;AADb,KAOMH,KAPN,EADD;AAWA;;AAED,SAASI,cAAT,QAAoC;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AACnC,QAAMC,UAAU,GAAGD,IAAI,KAAKE,SAAT,GAAqB,EAArB,GAA0B,aAAaF,IAA1D;AAEA,SACC,qDACC,4BAAC,4BAAD;AAA8B,IAAA,IAAI,EAAGC,UAAU,GAAG;AAAlD,KACC,4BAAC,yBAAD;AAAkB,IAAA,IAAI,EAAGD;AAAzB,IADD,CADD,EAKC,4BAAC,4BAAD;AACC,IAAA,IAAI,E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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"]}
|