@wordpress/block-editor 11.8.0 → 12.0.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/README.md +15 -3
- package/build/components/block-info-slot-fill/index.js +47 -0
- package/build/components/block-info-slot-fill/index.js.map +1 -0
- package/build/components/block-inspector/index.js +4 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.native.js +3 -4
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-toolbar/index.js +2 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +83 -9
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +11 -28
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/editor-styles/index.js +4 -3
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +21 -14
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -32
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +12 -12
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.native.js +174 -0
- package/build/components/global-styles/color-panel.native.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +6 -6
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +1 -1
- package/build/components/global-styles/effects-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +78 -14
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +9 -9
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +87 -77
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/index.js +7 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +12 -7
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/index.js +2 -1
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +2 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/list-view/block-select-button.js +7 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +12 -21
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +37 -10
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +10 -4
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -1
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -1
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/media-replace-flow/index.js +5 -5
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +12 -4
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +2 -7
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/hooks/duotone.js +29 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/utils.js +15 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +10 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +7 -0
- package/build/store/actions.js.map +1 -1
- package/build/utils/object.js +5 -5
- package/build/utils/object.js.map +1 -1
- package/build/utils/transform-styles/index.js +2 -2
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build/utils/use-should-contextual-toolbar-show.js +68 -0
- package/build/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-module/components/block-info-slot-fill/index.js +34 -0
- package/build-module/components/block-info-slot-fill/index.js.map +1 -0
- package/build-module/components/block-inspector/index.js +3 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.native.js +3 -4
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +2 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +79 -9
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +10 -27
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/editor-styles/index.js +4 -3
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +21 -14
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +2 -32
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +13 -13
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.native.js +150 -0
- package/build-module/components/global-styles/color-panel.native.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +7 -7
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +2 -2
- package/build-module/components/global-styles/effects-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +78 -16
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +10 -10
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +87 -77
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +12 -6
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -1
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +7 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +14 -22
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +36 -10
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +11 -5
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -1
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -1
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +5 -5
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +12 -4
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +1 -5
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/hooks/duotone.js +28 -5
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/utils.js +16 -4
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +7 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +7 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/object.js +4 -4
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +2 -2
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-module/utils/use-should-contextual-toolbar-show.js +56 -0
- package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-style/content-rtl.css +9 -6
- package/build-style/content.css +9 -6
- package/build-style/style-rtl.css +223 -46
- package/build-style/style.css +223 -46
- package/package.json +32 -32
- package/src/components/block-info-slot-fill/index.js +24 -0
- package/src/components/block-inspector/index.js +3 -0
- package/src/components/block-list/block.native.js +2 -3
- package/src/components/block-list/content.scss +16 -15
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +9 -9
- package/src/components/block-mover/style.scss +10 -4
- package/src/components/block-mover/test/index.native.js +4 -4
- package/src/components/block-toolbar/index.js +4 -3
- package/src/components/block-toolbar/style.scss +56 -33
- package/src/components/block-tools/block-contextual-toolbar.js +94 -11
- package/src/components/block-tools/selected-block-popover.js +11 -44
- package/src/components/block-tools/style.scss +157 -3
- package/src/components/editor-styles/index.js +9 -5
- package/src/components/font-sizes/fluid-utils.js +31 -14
- package/src/components/font-sizes/test/fluid-utils.js +5 -16
- package/src/components/global-styles/border-panel.js +1 -30
- package/src/components/global-styles/color-panel.js +13 -13
- package/src/components/global-styles/color-panel.native.js +207 -0
- package/src/components/global-styles/dimensions-panel.js +17 -7
- package/src/components/global-styles/effects-panel.js +2 -2
- package/src/components/global-styles/filters-panel.js +90 -17
- package/src/components/global-styles/style.scss +2 -1
- package/src/components/global-styles/test/typography-utils.js +63 -22
- package/src/components/global-styles/test/use-global-styles-output.js +126 -4
- package/src/components/global-styles/typography-panel.js +37 -11
- package/src/components/global-styles/use-global-styles-output.js +64 -64
- package/src/components/index.js +1 -0
- package/src/components/inserter/block-types-tab.js +9 -6
- package/src/components/inserter/index.js +1 -1
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/components/list-view/block-select-button.js +6 -1
- package/src/components/list-view/block.js +23 -31
- package/src/components/list-view/drop-indicator.js +67 -22
- package/src/components/list-view/index.js +8 -1
- package/src/components/list-view/leaf.js +1 -0
- package/src/components/list-view/style.scss +15 -3
- package/src/components/list-view/use-block-selection.js +1 -1
- package/src/components/media-replace-flow/README.md +3 -2
- package/src/components/media-replace-flow/index.js +4 -5
- package/src/components/navigable-toolbar/index.js +12 -3
- package/src/components/off-canvas-editor/appender.js +1 -4
- package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -3
- package/src/hooks/duotone.js +46 -25
- package/src/hooks/test/anchor.js +113 -0
- package/src/hooks/test/color.js +0 -9
- package/src/hooks/test/use-typography-props.js +2 -2
- package/src/hooks/test/utils.js +20 -101
- package/src/hooks/utils.js +20 -3
- package/src/private-apis.js +6 -0
- package/src/store/actions.js +7 -0
- package/src/utils/object.js +4 -4
- package/src/utils/test/object.js +21 -21
- package/src/utils/transform-styles/index.js +2 -2
- package/src/utils/use-should-contextual-toolbar-show.js +75 -0
- package/tsconfig.json +1 -0
- package/build/hooks/color-panel.native.js +0 -77
- package/build/hooks/color-panel.native.js.map +0 -1
- package/build-module/hooks/color-panel.native.js +0 -62
- package/build-module/hooks/color-panel.native.js.map +0 -1
- package/src/hooks/color-panel.native.js +0 -63
|
@@ -89,6 +89,9 @@
|
|
|
89
89
|
* Block Toolbar when contextual.
|
|
90
90
|
*/
|
|
91
91
|
|
|
92
|
+
// Base left position for the toolbar when fixed.
|
|
93
|
+
@include editor-left(".block-editor-block-contextual-toolbar.is-fixed");
|
|
94
|
+
|
|
92
95
|
.block-editor-block-contextual-toolbar {
|
|
93
96
|
// Block UI appearance.
|
|
94
97
|
display: inline-flex;
|
|
@@ -104,11 +107,9 @@
|
|
|
104
107
|
&.is-fixed {
|
|
105
108
|
position: sticky;
|
|
106
109
|
top: 0;
|
|
107
|
-
width: 100%;
|
|
108
110
|
z-index: z-index(".block-editor-block-popover");
|
|
109
|
-
// Fill up when empty
|
|
110
|
-
min-height: $block-toolbar-height;
|
|
111
111
|
display: block;
|
|
112
|
+
width: 100%;
|
|
112
113
|
|
|
113
114
|
border: none;
|
|
114
115
|
border-bottom: $border-width solid $gray-200;
|
|
@@ -119,6 +120,159 @@
|
|
|
119
120
|
border-right-color: $gray-200;
|
|
120
121
|
}
|
|
121
122
|
}
|
|
123
|
+
|
|
124
|
+
// on desktop and tablet viewports the toolbar is fixed
|
|
125
|
+
// on top of interface header
|
|
126
|
+
|
|
127
|
+
@include break-medium() {
|
|
128
|
+
&.is-fixed {
|
|
129
|
+
|
|
130
|
+
// leave room for block inserter
|
|
131
|
+
margin-left: $grid-unit-80;
|
|
132
|
+
// position on top of interface header
|
|
133
|
+
position: fixed;
|
|
134
|
+
top: $admin-bar-height + $grid-unit;
|
|
135
|
+
// Don't fill up when empty
|
|
136
|
+
min-height: initial;
|
|
137
|
+
// remove the border
|
|
138
|
+
border-bottom: none;
|
|
139
|
+
// has to be flex for collapse button to fit
|
|
140
|
+
display: flex;
|
|
141
|
+
|
|
142
|
+
&.is-collapsed {
|
|
143
|
+
width: initial;
|
|
144
|
+
margin-left: $grid-unit-80 * 3 + $grid-unit-30;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.is-fullscreen-mode & {
|
|
148
|
+
// leave room for block inserter
|
|
149
|
+
margin-left: $grid-unit-80 + $grid-unit-70;
|
|
150
|
+
top: $grid-unit;
|
|
151
|
+
&.is-collapsed {
|
|
152
|
+
width: initial;
|
|
153
|
+
margin-left: $grid-unit-80 * 4 + $grid-unit-30;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
& > .block-editor-block-toolbar__group-collapse-fixed-toolbar {
|
|
158
|
+
border: none;
|
|
159
|
+
|
|
160
|
+
// Add a border as separator in the block toolbar.
|
|
161
|
+
&::after {
|
|
162
|
+
content: "";
|
|
163
|
+
width: $border-width;
|
|
164
|
+
height: 24px;
|
|
165
|
+
margin-top: $grid-unit + $grid-unit-05;
|
|
166
|
+
margin-bottom: $grid-unit + $grid-unit-05;
|
|
167
|
+
background-color: $gray-300;
|
|
168
|
+
position: absolute;
|
|
169
|
+
left: 44px;
|
|
170
|
+
top: -1px;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
& > .block-editor-block-toolbar__group-expand-fixed-toolbar {
|
|
175
|
+
border: none;
|
|
176
|
+
|
|
177
|
+
// Add a border as separator in the block toolbar.
|
|
178
|
+
&::before {
|
|
179
|
+
content: "";
|
|
180
|
+
width: $border-width;
|
|
181
|
+
margin-top: $grid-unit + $grid-unit-05;
|
|
182
|
+
margin-bottom: $grid-unit + $grid-unit-05;
|
|
183
|
+
background-color: $gray-300;
|
|
184
|
+
position: relative;
|
|
185
|
+
left: -12px; //the padding of buttons
|
|
186
|
+
height: 24px;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.show-icon-labels & {
|
|
191
|
+
|
|
192
|
+
margin-left: $grid-unit-80;
|
|
193
|
+
|
|
194
|
+
&.is-collapsed {
|
|
195
|
+
margin-left: $grid-unit-80 * 6;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.is-fullscreen-mode & {
|
|
199
|
+
margin-left: $grid-unit-80 + $grid-unit-80;
|
|
200
|
+
&.is-collapsed {
|
|
201
|
+
margin-left: $grid-unit-80 * 7;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
.block-editor-block-parent-selector .block-editor-block-parent-selector__button::after {
|
|
207
|
+
left: 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.block-editor-block-toolbar__block-controls .block-editor-block-mover {
|
|
211
|
+
border-left: none;
|
|
212
|
+
&::before {
|
|
213
|
+
content: "";
|
|
214
|
+
width: $border-width;
|
|
215
|
+
margin-top: $grid-unit + $grid-unit-05;
|
|
216
|
+
margin-bottom: $grid-unit + $grid-unit-05;
|
|
217
|
+
background-color: $gray-300;
|
|
218
|
+
position: relative;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
&.is-fixed .block-editor-block-parent-selector {
|
|
225
|
+
.block-editor-block-parent-selector__button {
|
|
226
|
+
position: relative;
|
|
227
|
+
top: -1px;
|
|
228
|
+
border: 0;
|
|
229
|
+
padding-right: 6px;
|
|
230
|
+
padding-left: 6px;
|
|
231
|
+
&::after {
|
|
232
|
+
content: "\00B7";
|
|
233
|
+
font-size: 16px;
|
|
234
|
+
line-height: $grid-unit-40 + $grid-unit-10;
|
|
235
|
+
position: absolute;
|
|
236
|
+
left: $grid-unit-40 + $grid-unit-15 + 2px;
|
|
237
|
+
bottom: $grid-unit-05;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
&:not(.is-fixed) .block-editor-block-parent-selector {
|
|
243
|
+
position: absolute;
|
|
244
|
+
top: -$border-width;
|
|
245
|
+
left: calc(-#{$grid-unit-60} - #{$grid-unit-10} - #{$border-width});
|
|
246
|
+
|
|
247
|
+
.show-icon-labels & {
|
|
248
|
+
position: relative;
|
|
249
|
+
left: auto;
|
|
250
|
+
top: auto;
|
|
251
|
+
margin-top: -$border-width;
|
|
252
|
+
margin-left: -$border-width;
|
|
253
|
+
margin-bottom: -$border-width;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// on tablet vewports the toolbar is fixed
|
|
259
|
+
// on top of interface header and covers the whole header
|
|
260
|
+
// except for the inserter on the left
|
|
261
|
+
@include break-medium() {
|
|
262
|
+
&.is-fixed {
|
|
263
|
+
width: 100%;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// on desktop viewports the toolbar is fixed
|
|
268
|
+
// on top of interface header and leaves room
|
|
269
|
+
// for the block inserter the publish button
|
|
270
|
+
@include break-large() {
|
|
271
|
+
&.is-fixed {
|
|
272
|
+
width: initial;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
122
276
|
}
|
|
123
277
|
|
|
124
278
|
/**
|
|
@@ -68,29 +68,33 @@ function useDarkThemeBodyClassName( styles ) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
export default function EditorStyles( { styles } ) {
|
|
71
|
+
const stylesArray = useMemo(
|
|
72
|
+
() => Object.values( styles ?? [] ),
|
|
73
|
+
[ styles ]
|
|
74
|
+
);
|
|
71
75
|
const transformedStyles = useMemo(
|
|
72
76
|
() =>
|
|
73
77
|
transformStyles(
|
|
74
|
-
|
|
78
|
+
stylesArray.filter( ( style ) => style?.css ),
|
|
75
79
|
EDITOR_STYLES_SELECTOR
|
|
76
80
|
),
|
|
77
|
-
[
|
|
81
|
+
[ stylesArray ]
|
|
78
82
|
);
|
|
79
83
|
|
|
80
84
|
const transformedSvgs = useMemo(
|
|
81
85
|
() =>
|
|
82
|
-
|
|
86
|
+
stylesArray
|
|
83
87
|
.filter( ( style ) => style.__unstableType === 'svgs' )
|
|
84
88
|
.map( ( style ) => style.assets )
|
|
85
89
|
.join( '' ),
|
|
86
|
-
[
|
|
90
|
+
[ stylesArray ]
|
|
87
91
|
);
|
|
88
92
|
|
|
89
93
|
return (
|
|
90
94
|
<>
|
|
91
95
|
{ /* Use an empty style element to have a document reference,
|
|
92
96
|
but this could be any element. */ }
|
|
93
|
-
<style ref={ useDarkThemeBodyClassName(
|
|
97
|
+
<style ref={ useDarkThemeBodyClassName( stylesArray ) } />
|
|
94
98
|
{ transformedStyles.map( ( css, index ) => (
|
|
95
99
|
<style key={ index }>{ css }</style>
|
|
96
100
|
) ) }
|
|
@@ -6,18 +6,17 @@
|
|
|
6
6
|
|
|
7
7
|
// Defaults.
|
|
8
8
|
const DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';
|
|
9
|
-
const DEFAULT_MINIMUM_VIEWPORT_WIDTH = '
|
|
9
|
+
const DEFAULT_MINIMUM_VIEWPORT_WIDTH = '320px';
|
|
10
10
|
const DEFAULT_SCALE_FACTOR = 1;
|
|
11
|
-
const
|
|
11
|
+
const DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25;
|
|
12
|
+
const DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75;
|
|
12
13
|
const DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Computes a fluid font-size value that uses clamp(). A minimum and maximum
|
|
16
17
|
* font size OR a single font size can be specified.
|
|
17
18
|
*
|
|
18
|
-
* If a single font size is specified, it is scaled up and down
|
|
19
|
-
* minimumFontSizeFactor and maximumFontSizeFactor to arrive at the minimum and
|
|
20
|
-
* maximum sizes.
|
|
19
|
+
* If a single font size is specified, it is scaled up and down using a logarithmic scale.
|
|
21
20
|
*
|
|
22
21
|
* @example
|
|
23
22
|
* ```js
|
|
@@ -33,14 +32,13 @@ const DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';
|
|
|
33
32
|
* ```
|
|
34
33
|
*
|
|
35
34
|
* @param {Object} args
|
|
36
|
-
* @param {?string} args.minimumViewPortWidth
|
|
37
|
-
* @param {?string} args.maximumViewPortWidth
|
|
38
|
-
* @param {string|number} [args.fontSize]
|
|
39
|
-
* @param {?string} args.maximumFontSize
|
|
40
|
-
* @param {?string} args.minimumFontSize
|
|
41
|
-
* @param {?number} args.scaleFactor
|
|
42
|
-
* @param {?
|
|
43
|
-
* @param {?string} args.minimumFontSizeLimit The smallest a calculated font size may be. Optional.
|
|
35
|
+
* @param {?string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.
|
|
36
|
+
* @param {?string} args.maximumViewPortWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.
|
|
37
|
+
* @param {string|number} [args.fontSize] Size to derive maximumFontSize and minimumFontSize from, if necessary. Optional if minimumFontSize and maximumFontSize are specified.
|
|
38
|
+
* @param {?string} args.maximumFontSize Maximum font size for any clamp() calculation. Optional.
|
|
39
|
+
* @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.
|
|
40
|
+
* @param {?number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.
|
|
41
|
+
* @param {?string} args.minimumFontSizeLimit The smallest a calculated font size may be. Optional.
|
|
44
42
|
*
|
|
45
43
|
* @return {string|null} A font-size value using clamp().
|
|
46
44
|
*/
|
|
@@ -51,7 +49,6 @@ export function getComputedFluidTypographyValue( {
|
|
|
51
49
|
minimumViewPortWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,
|
|
52
50
|
maximumViewPortWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,
|
|
53
51
|
scaleFactor = DEFAULT_SCALE_FACTOR,
|
|
54
|
-
minimumFontSizeFactor = DEFAULT_MINIMUM_FONT_SIZE_FACTOR,
|
|
55
52
|
minimumFontSizeLimit,
|
|
56
53
|
} ) {
|
|
57
54
|
// Validate incoming settings and set defaults.
|
|
@@ -106,6 +103,26 @@ export function getComputedFluidTypographyValue( {
|
|
|
106
103
|
* the given font size multiplied by the min font size scale factor.
|
|
107
104
|
*/
|
|
108
105
|
if ( ! minimumFontSize ) {
|
|
106
|
+
const fontSizeValueInPx =
|
|
107
|
+
fontSizeParsed.unit === 'px'
|
|
108
|
+
? fontSizeParsed.value
|
|
109
|
+
: fontSizeParsed.value * 16;
|
|
110
|
+
|
|
111
|
+
/*
|
|
112
|
+
* The scale factor is a multiplier that affects how quickly the curve will move towards the minimum,
|
|
113
|
+
* that is, how quickly the size factor reaches 0 given increasing font size values.
|
|
114
|
+
* For a - b * log2(), lower values of b will make the curve move towards the minimum faster.
|
|
115
|
+
* The scale factor is constrained between min and max values.
|
|
116
|
+
*/
|
|
117
|
+
const minimumFontSizeFactor = Math.min(
|
|
118
|
+
Math.max(
|
|
119
|
+
1 - 0.075 * Math.log2( fontSizeValueInPx ),
|
|
120
|
+
DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN
|
|
121
|
+
),
|
|
122
|
+
DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
// Calculates the minimum font size.
|
|
109
126
|
const calculatedMinimumFontSize = roundToPrecision(
|
|
110
127
|
fontSizeParsed.value * minimumFontSizeFactor,
|
|
111
128
|
3
|
|
@@ -24,7 +24,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
24
24
|
maximumFontSize: '45px',
|
|
25
25
|
} );
|
|
26
26
|
expect( fluidTypographyValues ).toBe(
|
|
27
|
-
'clamp(20px, 1.25rem + ((1vw -
|
|
27
|
+
'clamp(20px, 1.25rem + ((1vw - 3.2px) * 1.953), 45px)'
|
|
28
28
|
);
|
|
29
29
|
} );
|
|
30
30
|
|
|
@@ -33,7 +33,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
33
33
|
fontSize: '30px',
|
|
34
34
|
} );
|
|
35
35
|
expect( fluidTypographyValues ).toBe(
|
|
36
|
-
'clamp(
|
|
36
|
+
'clamp(18.959px, 1.185rem + ((1vw - 3.2px) * 0.863), 30px)'
|
|
37
37
|
);
|
|
38
38
|
} );
|
|
39
39
|
|
|
@@ -42,7 +42,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
42
42
|
fontSize: '30px',
|
|
43
43
|
} );
|
|
44
44
|
expect( fluidTypographyValues ).toBe(
|
|
45
|
-
'clamp(
|
|
45
|
+
'clamp(18.959px, 1.185rem + ((1vw - 3.2px) * 0.863), 30px)'
|
|
46
46
|
);
|
|
47
47
|
} );
|
|
48
48
|
|
|
@@ -53,7 +53,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
53
53
|
maximumViewPortWidth: '1000px',
|
|
54
54
|
} );
|
|
55
55
|
expect( fluidTypographyValues ).toBe(
|
|
56
|
-
'clamp(
|
|
56
|
+
'clamp(18.959px, 1.185rem + ((1vw - 5px) * 2.208), 30px)'
|
|
57
57
|
);
|
|
58
58
|
} );
|
|
59
59
|
|
|
@@ -63,18 +63,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
63
63
|
scaleFactor: '2',
|
|
64
64
|
} );
|
|
65
65
|
expect( fluidTypographyValues ).toBe(
|
|
66
|
-
'clamp(
|
|
67
|
-
);
|
|
68
|
-
} );
|
|
69
|
-
|
|
70
|
-
it( 'should return a fluid font size when given a min and max font size factor', () => {
|
|
71
|
-
const fluidTypographyValues = getComputedFluidTypographyValue( {
|
|
72
|
-
fontSize: '30px',
|
|
73
|
-
minimumFontSizeFactor: '0.5',
|
|
74
|
-
maximumFontSizeFactor: '2',
|
|
75
|
-
} );
|
|
76
|
-
expect( fluidTypographyValues ).toBe(
|
|
77
|
-
'clamp(15px, 0.938rem + ((1vw - 7.68px) * 1.803), 30px)'
|
|
66
|
+
'clamp(18.959px, 1.185rem + ((1vw - 3.2px) * 1.725), 30px)'
|
|
78
67
|
);
|
|
79
68
|
} );
|
|
80
69
|
|
|
@@ -45,35 +45,6 @@ function useHasBorderWidthControl( settings ) {
|
|
|
45
45
|
return settings?.border?.width;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function applyFallbackStyle( border ) {
|
|
49
|
-
if ( ! border ) {
|
|
50
|
-
return border;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if ( ! border.style && ( border.color || border.width ) ) {
|
|
54
|
-
return { ...border, style: 'solid' };
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return border;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function applyAllFallbackStyles( border ) {
|
|
61
|
-
if ( ! border ) {
|
|
62
|
-
return border;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if ( hasSplitBorders( border ) ) {
|
|
66
|
-
return {
|
|
67
|
-
top: applyFallbackStyle( border.top ),
|
|
68
|
-
right: applyFallbackStyle( border.right ),
|
|
69
|
-
bottom: applyFallbackStyle( border.bottom ),
|
|
70
|
-
left: applyFallbackStyle( border.left ),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return applyFallbackStyle( border );
|
|
75
|
-
}
|
|
76
|
-
|
|
77
48
|
function BorderToolsPanel( {
|
|
78
49
|
resetAllFilter,
|
|
79
50
|
onChange,
|
|
@@ -186,7 +157,7 @@ export default function BorderPanel( {
|
|
|
186
157
|
const onBorderChange = ( newBorder ) => {
|
|
187
158
|
// Ensure we have a visible border style when a border width or
|
|
188
159
|
// color is being selected.
|
|
189
|
-
const updatedBorder =
|
|
160
|
+
const updatedBorder = { ...newBorder };
|
|
190
161
|
|
|
191
162
|
if ( hasSplitBorders( updatedBorder ) ) {
|
|
192
163
|
[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {
|
|
@@ -28,7 +28,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
28
28
|
import ColorGradientControl from '../colors-gradients/control';
|
|
29
29
|
import { useColorsPerOrigin, useGradientsPerOrigin } from './hooks';
|
|
30
30
|
import { getValueFromVariable } from './utils';
|
|
31
|
-
import {
|
|
31
|
+
import { setImmutably } from '../../utils/object';
|
|
32
32
|
|
|
33
33
|
export function useHasColorPanel( settings ) {
|
|
34
34
|
const hasTextPanel = useHasTextPanel( settings );
|
|
@@ -330,7 +330,7 @@ export default function ColorPanel( {
|
|
|
330
330
|
const hasTextColor = () => !! userTextColor;
|
|
331
331
|
const setTextColor = ( newColor ) => {
|
|
332
332
|
onChange(
|
|
333
|
-
|
|
333
|
+
setImmutably(
|
|
334
334
|
value,
|
|
335
335
|
[ 'color', 'text' ],
|
|
336
336
|
encodeColorValue( newColor )
|
|
@@ -347,7 +347,7 @@ export default function ColorPanel( {
|
|
|
347
347
|
const userGradient = decodeValue( value?.color?.gradient );
|
|
348
348
|
const hasBackground = () => !! userBackgroundColor || !! userGradient;
|
|
349
349
|
const setBackgroundColor = ( newColor ) => {
|
|
350
|
-
const newValue =
|
|
350
|
+
const newValue = setImmutably(
|
|
351
351
|
value,
|
|
352
352
|
[ 'color', 'background' ],
|
|
353
353
|
encodeColorValue( newColor )
|
|
@@ -356,7 +356,7 @@ export default function ColorPanel( {
|
|
|
356
356
|
onChange( newValue );
|
|
357
357
|
};
|
|
358
358
|
const setGradient = ( newGradient ) => {
|
|
359
|
-
const newValue =
|
|
359
|
+
const newValue = setImmutably(
|
|
360
360
|
value,
|
|
361
361
|
[ 'color', 'gradient' ],
|
|
362
362
|
encodeGradientValue( newGradient )
|
|
@@ -365,7 +365,7 @@ export default function ColorPanel( {
|
|
|
365
365
|
onChange( newValue );
|
|
366
366
|
};
|
|
367
367
|
const resetBackground = () => {
|
|
368
|
-
const newValue =
|
|
368
|
+
const newValue = setImmutably(
|
|
369
369
|
value,
|
|
370
370
|
[ 'color', 'background' ],
|
|
371
371
|
undefined
|
|
@@ -382,7 +382,7 @@ export default function ColorPanel( {
|
|
|
382
382
|
const userLinkColor = decodeValue( value?.elements?.link?.color?.text );
|
|
383
383
|
const setLinkColor = ( newColor ) => {
|
|
384
384
|
onChange(
|
|
385
|
-
|
|
385
|
+
setImmutably(
|
|
386
386
|
value,
|
|
387
387
|
[ 'elements', 'link', 'color', 'text' ],
|
|
388
388
|
encodeColorValue( newColor )
|
|
@@ -397,7 +397,7 @@ export default function ColorPanel( {
|
|
|
397
397
|
);
|
|
398
398
|
const setHoverLinkColor = ( newColor ) => {
|
|
399
399
|
onChange(
|
|
400
|
-
|
|
400
|
+
setImmutably(
|
|
401
401
|
value,
|
|
402
402
|
[ 'elements', 'link', ':hover', 'color', 'text' ],
|
|
403
403
|
encodeColorValue( newColor )
|
|
@@ -406,12 +406,12 @@ export default function ColorPanel( {
|
|
|
406
406
|
};
|
|
407
407
|
const hasLink = () => !! userLinkColor || !! userHoverLinkColor;
|
|
408
408
|
const resetLink = () => {
|
|
409
|
-
let newValue =
|
|
409
|
+
let newValue = setImmutably(
|
|
410
410
|
value,
|
|
411
411
|
[ 'elements', 'link', ':hover', 'color', 'text' ],
|
|
412
412
|
undefined
|
|
413
413
|
);
|
|
414
|
-
newValue =
|
|
414
|
+
newValue = setImmutably(
|
|
415
415
|
newValue,
|
|
416
416
|
[ 'elements', 'link', 'color', 'text' ],
|
|
417
417
|
undefined
|
|
@@ -591,7 +591,7 @@ export default function ColorPanel( {
|
|
|
591
591
|
elementGradientUserColor
|
|
592
592
|
);
|
|
593
593
|
const resetElement = () => {
|
|
594
|
-
const newValue =
|
|
594
|
+
const newValue = setImmutably(
|
|
595
595
|
value,
|
|
596
596
|
[ 'elements', name, 'color', 'background' ],
|
|
597
597
|
undefined
|
|
@@ -603,7 +603,7 @@ export default function ColorPanel( {
|
|
|
603
603
|
|
|
604
604
|
const setElementTextColor = ( newTextColor ) => {
|
|
605
605
|
onChange(
|
|
606
|
-
|
|
606
|
+
setImmutably(
|
|
607
607
|
value,
|
|
608
608
|
[ 'elements', name, 'color', 'text' ],
|
|
609
609
|
encodeColorValue( newTextColor )
|
|
@@ -611,7 +611,7 @@ export default function ColorPanel( {
|
|
|
611
611
|
);
|
|
612
612
|
};
|
|
613
613
|
const setElementBackgroundColor = ( newBackgroundColor ) => {
|
|
614
|
-
const newValue =
|
|
614
|
+
const newValue = setImmutably(
|
|
615
615
|
value,
|
|
616
616
|
[ 'elements', name, 'color', 'background' ],
|
|
617
617
|
encodeColorValue( newBackgroundColor )
|
|
@@ -620,7 +620,7 @@ export default function ColorPanel( {
|
|
|
620
620
|
onChange( newValue );
|
|
621
621
|
};
|
|
622
622
|
const setElementGradient = ( newGradient ) => {
|
|
623
|
-
const newValue =
|
|
623
|
+
const newValue = setImmutably(
|
|
624
624
|
value,
|
|
625
625
|
[ 'elements', name, 'color', 'gradient' ],
|
|
626
626
|
encodeGradientValue( newGradient )
|