@wordpress/block-editor 15.6.1-next.36001005c.0 → 15.6.1
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/build/components/background-image-control/index.js +2 -2
- package/build/components/background-image-control/index.js.map +2 -2
- package/build/components/block-list/block.js +3 -3
- package/build/components/block-list/block.js.map +2 -2
- package/build/components/block-list/index.js +2 -2
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +0 -1
- package/build/components/block-quick-navigation/index.js.map +2 -2
- package/build/components/global-styles/border-panel.js +1 -2
- package/build/components/global-styles/border-panel.js.map +2 -2
- package/build/components/global-styles/color-panel.js +1 -2
- package/build/components/global-styles/color-panel.js.map +2 -2
- package/build/components/global-styles/dimensions-panel.js +2 -3
- package/build/components/global-styles/dimensions-panel.js.map +2 -2
- package/build/components/global-styles/filters-panel.js +1 -2
- package/build/components/global-styles/filters-panel.js.map +2 -2
- package/build/components/global-styles/get-block-css-selector.js +78 -0
- package/build/components/global-styles/get-block-css-selector.js.map +7 -0
- package/build/components/global-styles/hooks.js +95 -23
- package/build/components/global-styles/hooks.js.map +2 -2
- package/build/components/global-styles/index.js +14 -0
- package/build/components/global-styles/index.js.map +2 -2
- package/build/components/global-styles/typography-panel.js +19 -3
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/global-styles/typography-utils.js +49 -2
- package/build/components/global-styles/typography-utils.js.map +2 -2
- package/build/components/global-styles/use-global-styles-output.js +998 -0
- package/build/components/global-styles/use-global-styles-output.js.map +7 -0
- package/build/components/global-styles/utils.js +377 -0
- package/build/components/global-styles/utils.js.map +2 -2
- package/build/components/rich-text/index.js +8 -7
- package/build/components/rich-text/index.js.map +2 -2
- package/build/hooks/block-bindings.js +111 -170
- package/build/hooks/block-bindings.js.map +2 -2
- package/build/hooks/block-style-variation.js +10 -6
- package/build/hooks/block-style-variation.js.map +2 -2
- package/build/hooks/custom-class-name.js +1 -1
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/duotone.js +3 -3
- package/build/hooks/duotone.js.map +2 -2
- package/build/hooks/fit-text.js +31 -18
- package/build/hooks/fit-text.js.map +2 -2
- package/build/hooks/font-size.js +6 -5
- package/build/hooks/font-size.js.map +2 -2
- package/build/hooks/metadata.js +48 -2
- package/build/hooks/metadata.js.map +2 -2
- package/build/hooks/typography.js +11 -4
- package/build/hooks/typography.js.map +3 -3
- package/build/hooks/use-typography-props.js +2 -2
- package/build/hooks/use-typography-props.js.map +2 -2
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/selectors.js +38 -13
- package/build/store/selectors.js.map +2 -2
- package/build/store/utils.js +2 -1
- package/build/store/utils.js.map +2 -2
- package/build/utils/fit-text-utils.js +4 -4
- package/build/utils/fit-text-utils.js.map +2 -2
- package/build-module/components/background-image-control/index.js +1 -1
- package/build-module/components/background-image-control/index.js.map +2 -2
- package/build-module/components/block-list/block.js +3 -3
- package/build-module/components/block-list/block.js.map +2 -2
- package/build-module/components/block-list/index.js +2 -2
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +0 -1
- package/build-module/components/block-quick-navigation/index.js.map +2 -2
- package/build-module/components/global-styles/border-panel.js +1 -2
- package/build-module/components/global-styles/border-panel.js.map +2 -2
- package/build-module/components/global-styles/color-panel.js +1 -2
- package/build-module/components/global-styles/color-panel.js.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.js +1 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
- package/build-module/components/global-styles/filters-panel.js +1 -2
- package/build-module/components/global-styles/filters-panel.js.map +2 -2
- package/build-module/components/global-styles/get-block-css-selector.js +54 -0
- package/build-module/components/global-styles/get-block-css-selector.js.map +7 -0
- package/build-module/components/global-styles/hooks.js +95 -27
- package/build-module/components/global-styles/hooks.js.map +2 -2
- package/build-module/components/global-styles/index.js +14 -0
- package/build-module/components/global-styles/index.js.map +2 -2
- package/build-module/components/global-styles/typography-panel.js +19 -3
- package/build-module/components/global-styles/typography-panel.js.map +2 -2
- package/build-module/components/global-styles/typography-utils.js +49 -1
- package/build-module/components/global-styles/typography-utils.js.map +2 -2
- package/build-module/components/global-styles/use-global-styles-output.js +979 -0
- package/build-module/components/global-styles/use-global-styles-output.js.map +7 -0
- package/build-module/components/global-styles/utils.js +364 -0
- package/build-module/components/global-styles/utils.js.map +2 -2
- package/build-module/components/rich-text/index.js +8 -7
- package/build-module/components/rich-text/index.js.map +2 -2
- package/build-module/hooks/block-bindings.js +112 -172
- package/build-module/hooks/block-bindings.js.map +2 -2
- package/build-module/hooks/block-style-variation.js +12 -4
- package/build-module/hooks/block-style-variation.js.map +2 -2
- package/build-module/hooks/custom-class-name.js +1 -1
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/duotone.js +3 -3
- package/build-module/hooks/duotone.js.map +2 -2
- package/build-module/hooks/fit-text.js +32 -19
- package/build-module/hooks/fit-text.js.map +2 -2
- package/build-module/hooks/font-size.js +5 -4
- package/build-module/hooks/font-size.js.map +2 -2
- package/build-module/hooks/metadata.js +46 -1
- package/build-module/hooks/metadata.js.map +2 -2
- package/build-module/hooks/typography.js +11 -4
- package/build-module/hooks/typography.js.map +3 -3
- package/build-module/hooks/use-typography-props.js +1 -1
- package/build-module/hooks/use-typography-props.js.map +2 -2
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/selectors.js +39 -14
- package/build-module/store/selectors.js.map +2 -2
- package/build-module/store/utils.js +3 -2
- package/build-module/store/utils.js.map +2 -2
- package/build-module/utils/fit-text-utils.js +4 -4
- package/build-module/utils/fit-text-utils.js.map +2 -2
- package/build-style/style-rtl.css +6 -10
- package/build-style/style.css +6 -10
- package/package.json +35 -36
- package/src/components/background-image-control/index.js +1 -1
- package/src/components/block-card/style.scss +1 -1
- package/src/components/block-list/block.js +1 -1
- package/src/components/block-list/index.js +2 -2
- package/src/components/block-navigation/style.scss +1 -1
- package/src/components/block-quick-navigation/index.js +0 -1
- package/src/components/block-switcher/style.scss +1 -1
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/global-styles/border-panel.js +1 -2
- package/src/components/global-styles/color-panel.js +1 -2
- package/src/components/global-styles/color-panel.native.js +1 -1
- package/src/components/global-styles/dimensions-panel.js +1 -2
- package/src/components/global-styles/filters-panel.js +1 -2
- package/src/components/global-styles/get-block-css-selector.js +114 -0
- package/src/components/global-styles/hooks.js +108 -29
- package/src/components/global-styles/index.js +8 -0
- package/src/components/global-styles/test/typography-utils.js +806 -0
- package/src/components/global-styles/test/use-global-styles-output.js +1131 -0
- package/src/components/global-styles/test/utils.js +442 -1
- package/src/components/global-styles/typography-panel.js +27 -3
- package/src/components/global-styles/typography-utils.js +133 -0
- package/src/components/global-styles/use-global-styles-output.js +1487 -0
- package/src/components/global-styles/utils.js +537 -0
- package/src/components/inserter/style.scss +2 -2
- package/src/components/multi-selection-inspector/style.scss +1 -1
- package/src/components/rich-text/index.js +8 -14
- package/src/hooks/block-bindings.js +79 -153
- package/src/hooks/block-style-variation.js +12 -4
- package/src/hooks/custom-class-name.js +1 -1
- package/src/hooks/duotone.js +3 -3
- package/src/hooks/fit-text.js +37 -28
- package/src/hooks/font-size.js +8 -4
- package/src/hooks/metadata.js +89 -0
- package/src/hooks/test/metadata.js +316 -0
- package/src/hooks/typography.js +15 -4
- package/src/hooks/use-typography-props.js +1 -1
- package/src/store/private-selectors.js +2 -2
- package/src/store/selectors.js +59 -21
- package/src/store/test/selectors.js +1 -1
- package/src/store/utils.js +2 -1
- package/src/style.scss +0 -1
- package/src/utils/fit-text-utils.js +4 -16
- package/tsconfig.json +0 -1
- package/src/components/block-quick-navigation/style.scss +0 -5
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
+
getTypographyFontSizeValue,
|
|
6
|
+
getFluidTypographyOptionsFromSettings,
|
|
5
7
|
getMergedFontFamiliesAndFontFamilyFaces,
|
|
6
8
|
findNearestFontWeight,
|
|
7
9
|
findNearestFontStyle,
|
|
@@ -9,6 +11,717 @@ import {
|
|
|
9
11
|
} from '../typography-utils';
|
|
10
12
|
|
|
11
13
|
describe( 'typography utils', () => {
|
|
14
|
+
describe( 'getTypographyFontSizeValue', () => {
|
|
15
|
+
[
|
|
16
|
+
{
|
|
17
|
+
message:
|
|
18
|
+
'should return value when fluid typography is not active',
|
|
19
|
+
preset: {
|
|
20
|
+
size: '28px',
|
|
21
|
+
},
|
|
22
|
+
typographySettings: undefined,
|
|
23
|
+
expected: '28px',
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
{
|
|
27
|
+
message: 'should return value where font size is 0',
|
|
28
|
+
preset: {
|
|
29
|
+
size: 0,
|
|
30
|
+
},
|
|
31
|
+
typographySettings: {
|
|
32
|
+
fluid: true,
|
|
33
|
+
},
|
|
34
|
+
expected: 0,
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
{
|
|
38
|
+
message: "should return value where font size is '0'",
|
|
39
|
+
preset: {
|
|
40
|
+
size: '0',
|
|
41
|
+
},
|
|
42
|
+
typographySettings: {
|
|
43
|
+
fluid: true,
|
|
44
|
+
},
|
|
45
|
+
expected: '0',
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
{
|
|
49
|
+
message: 'should return value where `size` is `null`.',
|
|
50
|
+
preset: {
|
|
51
|
+
size: null,
|
|
52
|
+
},
|
|
53
|
+
typographySettings: {
|
|
54
|
+
fluid: true,
|
|
55
|
+
},
|
|
56
|
+
expected: null,
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
{
|
|
60
|
+
message: 'should return value when fluid is `false`',
|
|
61
|
+
preset: {
|
|
62
|
+
size: '28px',
|
|
63
|
+
fluid: false,
|
|
64
|
+
},
|
|
65
|
+
settings: {
|
|
66
|
+
typography: {
|
|
67
|
+
fluid: true,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
expected: '28px',
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
{
|
|
74
|
+
message: 'should return value when fluid config is empty`',
|
|
75
|
+
preset: {
|
|
76
|
+
size: '28px',
|
|
77
|
+
},
|
|
78
|
+
settings: {
|
|
79
|
+
typography: {
|
|
80
|
+
fluid: {},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
expected: '28px',
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
{
|
|
87
|
+
message:
|
|
88
|
+
'should return clamp value with `minViewportWidth` override',
|
|
89
|
+
preset: {
|
|
90
|
+
size: '28px',
|
|
91
|
+
},
|
|
92
|
+
settings: {
|
|
93
|
+
typography: {
|
|
94
|
+
fluid: {
|
|
95
|
+
minViewportWidth: '500px',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
expected:
|
|
100
|
+
'clamp(17.905px, 1.119rem + ((1vw - 5px) * 0.918), 28px)',
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
{
|
|
104
|
+
message:
|
|
105
|
+
'should return clamp value with `maxViewportWidth` override',
|
|
106
|
+
preset: {
|
|
107
|
+
size: '28px',
|
|
108
|
+
},
|
|
109
|
+
settings: {
|
|
110
|
+
typography: {
|
|
111
|
+
fluid: {
|
|
112
|
+
maxViewportWidth: '500px',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
expected:
|
|
117
|
+
'clamp(17.905px, 1.119rem + ((1vw - 3.2px) * 5.608), 28px)',
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
{
|
|
121
|
+
message:
|
|
122
|
+
'should return clamp value with `layout.wideSize` override',
|
|
123
|
+
preset: {
|
|
124
|
+
size: '28px',
|
|
125
|
+
},
|
|
126
|
+
settings: {
|
|
127
|
+
typography: {
|
|
128
|
+
fluid: true,
|
|
129
|
+
},
|
|
130
|
+
layout: {
|
|
131
|
+
wideSize: '500px',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
expected:
|
|
135
|
+
'clamp(17.905px, 1.119rem + ((1vw - 3.2px) * 5.608), 28px)',
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
{
|
|
139
|
+
message:
|
|
140
|
+
'should return clamp value with `maxViewportWidth` preferred over fallback `layout.wideSize` value',
|
|
141
|
+
preset: {
|
|
142
|
+
size: '28px',
|
|
143
|
+
},
|
|
144
|
+
settings: {
|
|
145
|
+
typography: {
|
|
146
|
+
fluid: {
|
|
147
|
+
maxViewportWidth: '1000px',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
layout: {
|
|
151
|
+
wideSize: '500px',
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
expected:
|
|
155
|
+
'clamp(17.905px, 1.119rem + ((1vw - 3.2px) * 1.485), 28px)',
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
{
|
|
159
|
+
message: 'should return already clamped value',
|
|
160
|
+
preset: {
|
|
161
|
+
size: 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
|
|
162
|
+
},
|
|
163
|
+
settings: {
|
|
164
|
+
typography: {
|
|
165
|
+
fluid: true,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
expected:
|
|
169
|
+
'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
{
|
|
173
|
+
message: 'should return value with unsupported unit',
|
|
174
|
+
preset: {
|
|
175
|
+
size: '1000%',
|
|
176
|
+
},
|
|
177
|
+
settings: {
|
|
178
|
+
typography: {
|
|
179
|
+
fluid: true,
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
expected: '1000%',
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
{
|
|
186
|
+
message: 'should return clamp value with rem min and max units',
|
|
187
|
+
preset: {
|
|
188
|
+
size: '1.75rem',
|
|
189
|
+
},
|
|
190
|
+
settings: {
|
|
191
|
+
typography: {
|
|
192
|
+
fluid: true,
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
expected:
|
|
196
|
+
'clamp(1.119rem, 1.119rem + ((1vw - 0.2rem) * 0.789), 1.75rem)',
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
{
|
|
200
|
+
message:
|
|
201
|
+
'should override default max viewport width fluid typography settings',
|
|
202
|
+
preset: {
|
|
203
|
+
size: '1.75rem',
|
|
204
|
+
},
|
|
205
|
+
settings: {
|
|
206
|
+
typography: {
|
|
207
|
+
fluid: {
|
|
208
|
+
maxViewportWidth: '1200px',
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
expected:
|
|
213
|
+
'clamp(1.119rem, 1.119rem + ((1vw - 0.2rem) * 1.147), 1.75rem)',
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
{
|
|
217
|
+
message:
|
|
218
|
+
'should override default min viewport width fluid typography settings',
|
|
219
|
+
preset: {
|
|
220
|
+
size: '1.75rem',
|
|
221
|
+
},
|
|
222
|
+
settings: {
|
|
223
|
+
typography: {
|
|
224
|
+
fluid: {
|
|
225
|
+
minViewportWidth: '800px',
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
expected:
|
|
230
|
+
'clamp(1.119rem, 1.119rem + ((1vw - 0.5rem) * 1.262), 1.75rem)',
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
{
|
|
234
|
+
message: 'should return clamp value with em min and max units',
|
|
235
|
+
preset: {
|
|
236
|
+
size: '1.75em',
|
|
237
|
+
},
|
|
238
|
+
settings: {
|
|
239
|
+
typography: {
|
|
240
|
+
fluid: true,
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
expected:
|
|
244
|
+
'clamp(1.119em, 1.119rem + ((1vw - 0.2em) * 0.789), 1.75em)',
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
{
|
|
248
|
+
message: 'should return clamp value for floats',
|
|
249
|
+
preset: {
|
|
250
|
+
size: '70.175px',
|
|
251
|
+
},
|
|
252
|
+
settings: {
|
|
253
|
+
typography: {
|
|
254
|
+
fluid: true,
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
expected:
|
|
258
|
+
'clamp(37.897px, 2.369rem + ((1vw - 3.2px) * 2.522), 70.175px)',
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
{
|
|
262
|
+
message:
|
|
263
|
+
'should coerce integer to `px` and returns clamp value',
|
|
264
|
+
preset: {
|
|
265
|
+
size: 33,
|
|
266
|
+
fluid: true,
|
|
267
|
+
},
|
|
268
|
+
settings: {
|
|
269
|
+
typography: {
|
|
270
|
+
fluid: true,
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
expected:
|
|
274
|
+
'clamp(20.515px, 1.282rem + ((1vw - 3.2px) * 0.975), 33px)',
|
|
275
|
+
},
|
|
276
|
+
|
|
277
|
+
{
|
|
278
|
+
message: 'should coerce float to `px` and returns clamp value',
|
|
279
|
+
preset: {
|
|
280
|
+
size: 70.175,
|
|
281
|
+
fluid: true,
|
|
282
|
+
},
|
|
283
|
+
settings: {
|
|
284
|
+
typography: {
|
|
285
|
+
fluid: true,
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
expected:
|
|
289
|
+
'clamp(37.897px, 2.369rem + ((1vw - 3.2px) * 2.522), 70.175px)',
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
{
|
|
293
|
+
message:
|
|
294
|
+
'should return clamp value when `fluid` is empty array',
|
|
295
|
+
preset: {
|
|
296
|
+
size: '28px',
|
|
297
|
+
fluid: [],
|
|
298
|
+
},
|
|
299
|
+
settings: {
|
|
300
|
+
typography: {
|
|
301
|
+
fluid: true,
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
expected:
|
|
305
|
+
'clamp(17.905px, 1.119rem + ((1vw - 3.2px) * 0.789), 28px)',
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
{
|
|
309
|
+
message: 'should return clamp value when `fluid` is `null`',
|
|
310
|
+
preset: {
|
|
311
|
+
size: '28px',
|
|
312
|
+
fluid: null,
|
|
313
|
+
},
|
|
314
|
+
settings: {
|
|
315
|
+
typography: {
|
|
316
|
+
fluid: true,
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
expected:
|
|
320
|
+
'clamp(17.905px, 1.119rem + ((1vw - 3.2px) * 0.789), 28px)',
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
{
|
|
324
|
+
message:
|
|
325
|
+
'returns clamp value where min and max fluid values defined',
|
|
326
|
+
preset: {
|
|
327
|
+
size: '80px',
|
|
328
|
+
fluid: {
|
|
329
|
+
min: '70px',
|
|
330
|
+
max: '125px',
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
settings: {
|
|
334
|
+
typography: {
|
|
335
|
+
fluid: true,
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
expected:
|
|
339
|
+
'clamp(70px, 4.375rem + ((1vw - 3.2px) * 4.297), 125px)',
|
|
340
|
+
},
|
|
341
|
+
|
|
342
|
+
{
|
|
343
|
+
message:
|
|
344
|
+
'should apply maxViewportWidth as maximum viewport width',
|
|
345
|
+
preset: {
|
|
346
|
+
size: '80px',
|
|
347
|
+
fluid: {
|
|
348
|
+
min: '70px',
|
|
349
|
+
max: '125px',
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
settings: {
|
|
353
|
+
typography: {
|
|
354
|
+
fluid: {
|
|
355
|
+
maxViewportWidth: '1100px',
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
expected:
|
|
360
|
+
'clamp(70px, 4.375rem + ((1vw - 3.2px) * 7.051), 125px)',
|
|
361
|
+
},
|
|
362
|
+
|
|
363
|
+
{
|
|
364
|
+
message: 'returns clamp value where max is equal to size',
|
|
365
|
+
preset: {
|
|
366
|
+
size: '7.8125rem',
|
|
367
|
+
fluid: {
|
|
368
|
+
min: '4.375rem',
|
|
369
|
+
max: '7.8125rem',
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
settings: {
|
|
373
|
+
typography: {
|
|
374
|
+
fluid: true,
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
expected:
|
|
378
|
+
'clamp(4.375rem, 4.375rem + ((1vw - 0.2rem) * 4.298), 7.8125rem)',
|
|
379
|
+
},
|
|
380
|
+
|
|
381
|
+
{
|
|
382
|
+
message:
|
|
383
|
+
'should return clamp value if min font size is greater than max',
|
|
384
|
+
preset: {
|
|
385
|
+
size: '3rem',
|
|
386
|
+
fluid: {
|
|
387
|
+
min: '5rem',
|
|
388
|
+
max: '32px',
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
settings: {
|
|
392
|
+
typography: {
|
|
393
|
+
fluid: true,
|
|
394
|
+
},
|
|
395
|
+
},
|
|
396
|
+
expected: 'clamp(5rem, 5rem + ((1vw - 0.2rem) * -3.75), 32px)',
|
|
397
|
+
},
|
|
398
|
+
|
|
399
|
+
{
|
|
400
|
+
message: 'should return value with invalid min/max fluid units',
|
|
401
|
+
preset: {
|
|
402
|
+
size: '10em',
|
|
403
|
+
fluid: {
|
|
404
|
+
min: '20vw',
|
|
405
|
+
max: '50%',
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
settings: {
|
|
409
|
+
typography: {
|
|
410
|
+
fluid: true,
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
expected: '10em',
|
|
414
|
+
},
|
|
415
|
+
|
|
416
|
+
{
|
|
417
|
+
message:
|
|
418
|
+
'should return value when size is < lower bounds and no fluid min/max set',
|
|
419
|
+
preset: {
|
|
420
|
+
size: '3px',
|
|
421
|
+
},
|
|
422
|
+
settings: {
|
|
423
|
+
typography: {
|
|
424
|
+
fluid: true,
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
expected: '3px',
|
|
428
|
+
},
|
|
429
|
+
|
|
430
|
+
{
|
|
431
|
+
message:
|
|
432
|
+
'should return value when size is equal to lower bounds and no fluid min/max set',
|
|
433
|
+
preset: {
|
|
434
|
+
size: '14px',
|
|
435
|
+
},
|
|
436
|
+
settings: {
|
|
437
|
+
typography: {
|
|
438
|
+
fluid: true,
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
expected: '14px',
|
|
442
|
+
},
|
|
443
|
+
|
|
444
|
+
{
|
|
445
|
+
message:
|
|
446
|
+
'should return clamp value with different min max units',
|
|
447
|
+
preset: {
|
|
448
|
+
size: '28px',
|
|
449
|
+
fluid: {
|
|
450
|
+
min: '20px',
|
|
451
|
+
max: '50rem',
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
settings: {
|
|
455
|
+
typography: {
|
|
456
|
+
fluid: true,
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
expected:
|
|
460
|
+
'clamp(20px, 1.25rem + ((1vw - 3.2px) * 60.938), 50rem)',
|
|
461
|
+
},
|
|
462
|
+
|
|
463
|
+
{
|
|
464
|
+
message:
|
|
465
|
+
'should return clamp value where no fluid max size is set',
|
|
466
|
+
preset: {
|
|
467
|
+
size: '50px',
|
|
468
|
+
fluid: {
|
|
469
|
+
min: '2.6rem',
|
|
470
|
+
},
|
|
471
|
+
},
|
|
472
|
+
settings: {
|
|
473
|
+
typography: {
|
|
474
|
+
fluid: true,
|
|
475
|
+
},
|
|
476
|
+
},
|
|
477
|
+
expected:
|
|
478
|
+
'clamp(2.6rem, 2.6rem + ((1vw - 0.2rem) * 0.656), 50px)',
|
|
479
|
+
},
|
|
480
|
+
|
|
481
|
+
{
|
|
482
|
+
message:
|
|
483
|
+
'should return clamp value where no fluid min size is set',
|
|
484
|
+
preset: {
|
|
485
|
+
size: '28px',
|
|
486
|
+
fluid: {
|
|
487
|
+
max: '80px',
|
|
488
|
+
},
|
|
489
|
+
},
|
|
490
|
+
settings: {
|
|
491
|
+
typography: {
|
|
492
|
+
fluid: true,
|
|
493
|
+
},
|
|
494
|
+
},
|
|
495
|
+
expected:
|
|
496
|
+
'clamp(17.905px, 1.119rem + ((1vw - 3.2px) * 4.851), 80px)',
|
|
497
|
+
},
|
|
498
|
+
|
|
499
|
+
{
|
|
500
|
+
message:
|
|
501
|
+
'should not apply lower bound test when fluid values are set',
|
|
502
|
+
preset: {
|
|
503
|
+
size: '1.5rem',
|
|
504
|
+
fluid: {
|
|
505
|
+
min: '0.5rem',
|
|
506
|
+
max: '5rem',
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
settings: {
|
|
510
|
+
typography: {
|
|
511
|
+
fluid: true,
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
expected:
|
|
515
|
+
'clamp(0.5rem, 0.5rem + ((1vw - 0.2rem) * 5.625), 5rem)',
|
|
516
|
+
},
|
|
517
|
+
|
|
518
|
+
{
|
|
519
|
+
message:
|
|
520
|
+
'should not apply lower bound test when only fluid min is set',
|
|
521
|
+
preset: {
|
|
522
|
+
size: '20px',
|
|
523
|
+
fluid: {
|
|
524
|
+
min: '12px',
|
|
525
|
+
},
|
|
526
|
+
},
|
|
527
|
+
settings: {
|
|
528
|
+
typography: {
|
|
529
|
+
fluid: true,
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
expected:
|
|
533
|
+
'clamp(12px, 0.75rem + ((1vw - 3.2px) * 0.625), 20px)',
|
|
534
|
+
},
|
|
535
|
+
|
|
536
|
+
{
|
|
537
|
+
message:
|
|
538
|
+
'should not apply lower bound test when only fluid max is set',
|
|
539
|
+
preset: {
|
|
540
|
+
size: '0.875rem',
|
|
541
|
+
fluid: {
|
|
542
|
+
max: '20rem',
|
|
543
|
+
},
|
|
544
|
+
},
|
|
545
|
+
settings: {
|
|
546
|
+
typography: {
|
|
547
|
+
fluid: true,
|
|
548
|
+
},
|
|
549
|
+
},
|
|
550
|
+
expected:
|
|
551
|
+
'clamp(0.875rem, 0.875rem + ((1vw - 0.2rem) * 23.906), 20rem)',
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
message:
|
|
555
|
+
'should return clamp value when min and max font sizes are equal',
|
|
556
|
+
preset: {
|
|
557
|
+
size: '4rem',
|
|
558
|
+
fluid: {
|
|
559
|
+
min: '30px',
|
|
560
|
+
max: '30px',
|
|
561
|
+
},
|
|
562
|
+
},
|
|
563
|
+
settings: {
|
|
564
|
+
typography: {
|
|
565
|
+
fluid: true,
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
expected: 'clamp(30px, 1.875rem + ((1vw - 3.2px) * 1), 30px)',
|
|
569
|
+
},
|
|
570
|
+
|
|
571
|
+
{
|
|
572
|
+
message:
|
|
573
|
+
'should use default min font size value where min font size unit in fluid config is not supported',
|
|
574
|
+
preset: {
|
|
575
|
+
size: '15px',
|
|
576
|
+
},
|
|
577
|
+
settings: {
|
|
578
|
+
typography: {
|
|
579
|
+
fluid: {
|
|
580
|
+
minFontSize: '16%',
|
|
581
|
+
},
|
|
582
|
+
},
|
|
583
|
+
},
|
|
584
|
+
expected:
|
|
585
|
+
'clamp(14px, 0.875rem + ((1vw - 3.2px) * 0.078), 15px)',
|
|
586
|
+
},
|
|
587
|
+
|
|
588
|
+
// Equivalent custom config PHP unit tests in `test_should_convert_font_sizes_to_fluid_values()`.
|
|
589
|
+
{
|
|
590
|
+
message: 'should return clamp value using custom fluid config',
|
|
591
|
+
preset: {
|
|
592
|
+
size: '17px',
|
|
593
|
+
},
|
|
594
|
+
settings: {
|
|
595
|
+
typography: {
|
|
596
|
+
fluid: {
|
|
597
|
+
minFontSize: '16px',
|
|
598
|
+
},
|
|
599
|
+
},
|
|
600
|
+
},
|
|
601
|
+
expected: 'clamp(16px, 1rem + ((1vw - 3.2px) * 0.078), 17px)',
|
|
602
|
+
},
|
|
603
|
+
|
|
604
|
+
{
|
|
605
|
+
message:
|
|
606
|
+
'should return value when font size <= custom min font size bound',
|
|
607
|
+
preset: {
|
|
608
|
+
size: '15px',
|
|
609
|
+
},
|
|
610
|
+
settings: {
|
|
611
|
+
typography: {
|
|
612
|
+
fluid: {
|
|
613
|
+
minFontSize: '16px',
|
|
614
|
+
},
|
|
615
|
+
},
|
|
616
|
+
},
|
|
617
|
+
expected: '15px',
|
|
618
|
+
},
|
|
619
|
+
|
|
620
|
+
{
|
|
621
|
+
message:
|
|
622
|
+
'should apply scaled min font size for em values when custom min font size is not set',
|
|
623
|
+
preset: {
|
|
624
|
+
size: '12rem',
|
|
625
|
+
},
|
|
626
|
+
settings: {
|
|
627
|
+
typography: {
|
|
628
|
+
fluid: true,
|
|
629
|
+
},
|
|
630
|
+
},
|
|
631
|
+
expected:
|
|
632
|
+
'clamp(5.174rem, 5.174rem + ((1vw - 0.2rem) * 8.533), 12rem)',
|
|
633
|
+
},
|
|
634
|
+
|
|
635
|
+
{
|
|
636
|
+
message:
|
|
637
|
+
'should apply scaled min font size for px values when custom min font size is not set',
|
|
638
|
+
preset: {
|
|
639
|
+
size: '200px',
|
|
640
|
+
},
|
|
641
|
+
settings: {
|
|
642
|
+
typography: {
|
|
643
|
+
fluid: true,
|
|
644
|
+
},
|
|
645
|
+
},
|
|
646
|
+
expected:
|
|
647
|
+
'clamp(85.342px, 5.334rem + ((1vw - 3.2px) * 8.958), 200px)',
|
|
648
|
+
},
|
|
649
|
+
|
|
650
|
+
{
|
|
651
|
+
message:
|
|
652
|
+
'should not apply scaled min font size for minimum font size when custom min font size is set',
|
|
653
|
+
preset: {
|
|
654
|
+
size: '200px',
|
|
655
|
+
fluid: {
|
|
656
|
+
min: '100px',
|
|
657
|
+
},
|
|
658
|
+
},
|
|
659
|
+
settings: {
|
|
660
|
+
typography: {
|
|
661
|
+
fluid: true,
|
|
662
|
+
},
|
|
663
|
+
},
|
|
664
|
+
expected:
|
|
665
|
+
'clamp(100px, 6.25rem + ((1vw - 3.2px) * 7.813), 200px)',
|
|
666
|
+
},
|
|
667
|
+
|
|
668
|
+
{
|
|
669
|
+
message: 'should apply all custom fluid typography settings',
|
|
670
|
+
preset: {
|
|
671
|
+
size: '17px',
|
|
672
|
+
},
|
|
673
|
+
settings: {
|
|
674
|
+
typography: {
|
|
675
|
+
fluid: {
|
|
676
|
+
minFontSize: '16px',
|
|
677
|
+
maxViewportWidth: '1200px',
|
|
678
|
+
minViewportWidth: '640px',
|
|
679
|
+
},
|
|
680
|
+
},
|
|
681
|
+
},
|
|
682
|
+
expected: 'clamp(16px, 1rem + ((1vw - 6.4px) * 0.179), 17px)',
|
|
683
|
+
},
|
|
684
|
+
|
|
685
|
+
// Individual preset settings override global settings.
|
|
686
|
+
{
|
|
687
|
+
message:
|
|
688
|
+
'should convert individual preset size to fluid if fluid is disabled in global settings',
|
|
689
|
+
preset: {
|
|
690
|
+
size: '17px',
|
|
691
|
+
fluid: true,
|
|
692
|
+
},
|
|
693
|
+
settings: {
|
|
694
|
+
typography: {},
|
|
695
|
+
},
|
|
696
|
+
expected:
|
|
697
|
+
'clamp(14px, 0.875rem + ((1vw - 3.2px) * 0.234), 17px)',
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
message:
|
|
701
|
+
'should use individual preset settings if fluid is disabled in global settings',
|
|
702
|
+
preset: {
|
|
703
|
+
size: '17px',
|
|
704
|
+
fluid: {
|
|
705
|
+
min: '16px',
|
|
706
|
+
max: '26px',
|
|
707
|
+
},
|
|
708
|
+
},
|
|
709
|
+
settings: {
|
|
710
|
+
typography: {
|
|
711
|
+
fluid: false,
|
|
712
|
+
},
|
|
713
|
+
},
|
|
714
|
+
expected: 'clamp(16px, 1rem + ((1vw - 3.2px) * 0.781), 26px)',
|
|
715
|
+
},
|
|
716
|
+
].forEach( ( { message, preset, settings, expected } ) => {
|
|
717
|
+
it( `${ message }`, () => {
|
|
718
|
+
expect( getTypographyFontSizeValue( preset, settings ) ).toBe(
|
|
719
|
+
expected
|
|
720
|
+
);
|
|
721
|
+
} );
|
|
722
|
+
} );
|
|
723
|
+
} );
|
|
724
|
+
|
|
12
725
|
describe( 'getMergedFontFamiliesAndFontFamilyFaces', () => {
|
|
13
726
|
[
|
|
14
727
|
{
|
|
@@ -653,4 +1366,97 @@ describe( 'typography utils', () => {
|
|
|
653
1366
|
}
|
|
654
1367
|
);
|
|
655
1368
|
} );
|
|
1369
|
+
|
|
1370
|
+
describe( 'typography utils', () => {
|
|
1371
|
+
[
|
|
1372
|
+
{
|
|
1373
|
+
message:
|
|
1374
|
+
'should return `undefined` when settings is `undefined`',
|
|
1375
|
+
settings: undefined,
|
|
1376
|
+
expected: { fluid: undefined },
|
|
1377
|
+
},
|
|
1378
|
+
|
|
1379
|
+
{
|
|
1380
|
+
message:
|
|
1381
|
+
'should return `undefined` when typography is `undefined`',
|
|
1382
|
+
settings: {},
|
|
1383
|
+
expected: { fluid: undefined },
|
|
1384
|
+
},
|
|
1385
|
+
|
|
1386
|
+
{
|
|
1387
|
+
message:
|
|
1388
|
+
'should return `undefined` when typography.fluid is `undefined`',
|
|
1389
|
+
settings: { typography: {} },
|
|
1390
|
+
expected: { fluid: undefined },
|
|
1391
|
+
},
|
|
1392
|
+
|
|
1393
|
+
{
|
|
1394
|
+
message:
|
|
1395
|
+
'should return `false` when typography.fluid is disabled by `false`',
|
|
1396
|
+
settings: { typography: { fluid: false } },
|
|
1397
|
+
expected: { fluid: false },
|
|
1398
|
+
},
|
|
1399
|
+
|
|
1400
|
+
{
|
|
1401
|
+
message: 'should return `{}` when typography.fluid is empty',
|
|
1402
|
+
settings: { typography: { fluid: {} } },
|
|
1403
|
+
expected: { fluid: {} },
|
|
1404
|
+
},
|
|
1405
|
+
|
|
1406
|
+
{
|
|
1407
|
+
message:
|
|
1408
|
+
'should return false when typography.fluid is disabled and layout.wideSize is defined',
|
|
1409
|
+
settings: {
|
|
1410
|
+
typography: { fluid: false },
|
|
1411
|
+
layout: { wideSize: '1000rem' },
|
|
1412
|
+
},
|
|
1413
|
+
expected: { fluid: false },
|
|
1414
|
+
},
|
|
1415
|
+
|
|
1416
|
+
{
|
|
1417
|
+
message:
|
|
1418
|
+
'should return true when fluid is enabled by a boolean',
|
|
1419
|
+
settings: { typography: { fluid: true } },
|
|
1420
|
+
expected: { fluid: true },
|
|
1421
|
+
},
|
|
1422
|
+
|
|
1423
|
+
{
|
|
1424
|
+
message:
|
|
1425
|
+
'should return fluid settings with merged `layout.wideSize`',
|
|
1426
|
+
settings: {
|
|
1427
|
+
typography: { fluid: { minFontSize: '16px' } },
|
|
1428
|
+
layout: { wideSize: '1000rem' },
|
|
1429
|
+
},
|
|
1430
|
+
expected: {
|
|
1431
|
+
fluid: { maxViewportWidth: '1000rem', minFontSize: '16px' },
|
|
1432
|
+
},
|
|
1433
|
+
},
|
|
1434
|
+
|
|
1435
|
+
{
|
|
1436
|
+
message:
|
|
1437
|
+
'should prioritize fluid `maxViewportWidth` over `layout.wideSize`',
|
|
1438
|
+
settings: {
|
|
1439
|
+
typography: { fluid: { maxViewportWidth: '10px' } },
|
|
1440
|
+
layout: { wideSize: '1000rem' },
|
|
1441
|
+
},
|
|
1442
|
+
expected: { fluid: { maxViewportWidth: '10px' } },
|
|
1443
|
+
},
|
|
1444
|
+
{
|
|
1445
|
+
message: 'should not merge `layout.wideSize` if it is fluid',
|
|
1446
|
+
settings: {
|
|
1447
|
+
typography: { fluid: { minFontSize: '16px' } },
|
|
1448
|
+
layout: { wideSize: 'clamp(1000px, 85vw, 2000px)' },
|
|
1449
|
+
},
|
|
1450
|
+
expected: {
|
|
1451
|
+
fluid: { minFontSize: '16px' },
|
|
1452
|
+
},
|
|
1453
|
+
},
|
|
1454
|
+
].forEach( ( { message, settings, expected } ) => {
|
|
1455
|
+
it( `${ message }`, () => {
|
|
1456
|
+
expect(
|
|
1457
|
+
getFluidTypographyOptionsFromSettings( settings )
|
|
1458
|
+
).toEqual( expected );
|
|
1459
|
+
} );
|
|
1460
|
+
} );
|
|
1461
|
+
} );
|
|
656
1462
|
} );
|