@wordpress/edit-site 4.14.11 → 4.14.13

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.
@@ -7,7 +7,7 @@ describe( 'typography utils', () => {
7
7
  describe( 'getTypographyFontSizeValue', () => {
8
8
  [
9
9
  {
10
- message: 'Default return non-fluid value.',
10
+ message: 'returns value when fluid typography is deactivated',
11
11
  preset: {
12
12
  size: '28px',
13
13
  },
@@ -16,7 +16,7 @@ describe( 'typography utils', () => {
16
16
  },
17
17
 
18
18
  {
19
- message: 'Default return value where font size is 0.',
19
+ message: 'returns value where font size is 0',
20
20
  preset: {
21
21
  size: 0,
22
22
  },
@@ -25,7 +25,7 @@ describe( 'typography utils', () => {
25
25
  },
26
26
 
27
27
  {
28
- message: "Default return value where font size is '0'.",
28
+ message: "returns value where font size is '0'",
29
29
  preset: {
30
30
  size: '0',
31
31
  },
@@ -34,17 +34,16 @@ describe( 'typography utils', () => {
34
34
  },
35
35
 
36
36
  {
37
- message:
38
- 'Default return non-fluid value where `size` is undefined.',
37
+ message: 'returns value where `size` is `null`.',
39
38
  preset: {
40
- size: undefined,
39
+ size: null,
41
40
  },
42
- typographySettings: undefined,
43
- expected: undefined,
41
+ typographySettings: null,
42
+ expected: null,
44
43
  },
45
44
 
46
45
  {
47
- message: 'return non-fluid value when fluid is `false`.',
46
+ message: 'returns value when fluid is `false`',
48
47
  preset: {
49
48
  size: '28px',
50
49
  fluid: false,
@@ -56,84 +55,94 @@ describe( 'typography utils', () => {
56
55
  },
57
56
 
58
57
  {
59
- message:
60
- 'Should coerce integer to `px` and return fluid value.',
58
+ message: 'returns already clamped value',
61
59
  preset: {
62
- size: 33,
63
- fluid: true,
60
+ size: 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
61
+ fluid: false,
64
62
  },
65
63
  typographySettings: {
66
64
  fluid: true,
67
65
  },
68
66
  expected:
69
- 'clamp(24.75px, 1.547rem + ((1vw - 7.68px) * 2.975), 49.5px)',
67
+ 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
70
68
  },
71
69
 
72
70
  {
73
- message: 'coerce float to `px` and return fluid value.',
71
+ message: 'returns value with unsupported unit',
74
72
  preset: {
75
- size: 100.23,
73
+ size: '1000%',
74
+ fluid: false,
75
+ },
76
+ typographySettings: {
76
77
  fluid: true,
77
78
  },
79
+ expected: '1000%',
80
+ },
81
+
82
+ {
83
+ message: 'returns clamp value with rem min and max units',
84
+ preset: {
85
+ size: '1.75rem',
86
+ },
78
87
  typographySettings: {
79
88
  fluid: true,
80
89
  },
81
90
  expected:
82
- 'clamp(75.173px, 4.698rem + ((1vw - 7.68px) * 9.035), 150.345px)',
91
+ 'clamp(1.313rem, 1.313rem + ((1vw - 0.48rem) * 0.84), 1.75rem)',
83
92
  },
84
93
 
85
94
  {
86
- message: 'return incoming value when already clamped.',
95
+ message: 'returns clamp value with eem min and max units',
87
96
  preset: {
88
- size: 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
89
- fluid: false,
97
+ size: '1.75em',
90
98
  },
91
99
  typographySettings: {
92
100
  fluid: true,
93
101
  },
94
102
  expected:
95
- 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
103
+ 'clamp(1.313em, 1.313rem + ((1vw - 0.48em) * 0.84), 1.75em)',
96
104
  },
97
105
 
98
106
  {
99
- message: 'return incoming value with unsupported unit.',
107
+ message: 'returns clamp value for floats',
100
108
  preset: {
101
- size: '1000%',
102
- fluid: false,
109
+ size: '100.175px',
103
110
  },
104
111
  typographySettings: {
105
112
  fluid: true,
106
113
  },
107
- expected: '1000%',
114
+ expected:
115
+ 'clamp(75.131px, 4.696rem + ((1vw - 7.68px) * 3.01), 100.175px)',
108
116
  },
109
117
 
110
118
  {
111
- message: 'return fluid value.',
119
+ message: 'coerces integer to `px` and returns clamp value',
112
120
  preset: {
113
- size: '1.75rem',
121
+ size: 33,
122
+ fluid: true,
114
123
  },
115
124
  typographySettings: {
116
125
  fluid: true,
117
126
  },
118
127
  expected:
119
- 'clamp(1.313rem, 1.313rem + ((1vw - 0.48rem) * 2.523), 2.625rem)',
128
+ 'clamp(24.75px, 1.547rem + ((1vw - 7.68px) * 0.992), 33px)',
120
129
  },
121
130
 
122
131
  {
123
- message: 'return fluid value for floats with units.',
132
+ message: 'coerces float to `px` and returns clamp value',
124
133
  preset: {
125
- size: '100.175px',
134
+ size: 100.23,
135
+ fluid: true,
126
136
  },
127
137
  typographySettings: {
128
138
  fluid: true,
129
139
  },
130
140
  expected:
131
- 'clamp(75.131px, 4.696rem + ((1vw - 7.68px) * 9.03), 150.263px)',
141
+ 'clamp(75.173px, 4.698rem + ((1vw - 7.68px) * 3.012), 100.23px)',
132
142
  },
133
143
 
134
144
  {
135
- message:
136
- 'Should return default fluid values with empty fluid array.',
145
+ message: 'returns clamp value when `fluid` is empty array',
137
146
  preset: {
138
147
  size: '28px',
139
148
  fluid: [],
@@ -142,11 +151,11 @@ describe( 'typography utils', () => {
142
151
  fluid: true,
143
152
  },
144
153
  expected:
145
- 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
154
+ 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 0.841), 28px)',
146
155
  },
147
156
 
148
157
  {
149
- message: 'return default fluid values with null value.',
158
+ message: 'returns clamp value when `fluid` is `null`',
150
159
  preset: {
151
160
  size: '28px',
152
161
  fluid: null,
@@ -155,12 +164,12 @@ describe( 'typography utils', () => {
155
164
  fluid: true,
156
165
  },
157
166
  expected:
158
- 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
167
+ 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 0.841), 28px)',
159
168
  },
160
169
 
161
170
  {
162
171
  message:
163
- 'return clamped value if min font size is greater than max.',
172
+ 'returns clamp value if min font size is greater than max',
164
173
  preset: {
165
174
  size: '3rem',
166
175
  fluid: {
@@ -176,7 +185,7 @@ describe( 'typography utils', () => {
176
185
  },
177
186
 
178
187
  {
179
- message: 'return size with invalid fluid units.',
188
+ message: 'returns value with invalid min/max fluid units',
180
189
  preset: {
181
190
  size: '10em',
182
191
  fluid: {
@@ -192,20 +201,30 @@ describe( 'typography utils', () => {
192
201
 
193
202
  {
194
203
  message:
195
- 'return clamped using font size where no min is given and size is less than default min size.',
204
+ 'returns value when size is < lower bounds and no fluid min/max set',
196
205
  preset: {
197
206
  size: '3px',
198
207
  },
199
208
  typographySettings: {
200
209
  fluid: true,
201
210
  },
202
- expected:
203
- 'clamp(3px, 0.188rem + ((1vw - 7.68px) * 0.18), 4.5px)',
211
+ expected: '3px',
204
212
  },
205
213
 
206
214
  {
207
215
  message:
208
- 'return fluid clamp value with different min max units.',
216
+ 'returns value when size is equal to lower bounds and no fluid min/max set',
217
+ preset: {
218
+ size: '14px',
219
+ },
220
+ typographySettings: {
221
+ fluid: true,
222
+ },
223
+ expected: '14px',
224
+ },
225
+
226
+ {
227
+ message: 'returns clamp value with different min max units',
209
228
  preset: {
210
229
  size: '28px',
211
230
  fluid: {
@@ -219,10 +238,9 @@ describe( 'typography utils', () => {
219
238
  expected:
220
239
  'clamp(20px, 1.25rem + ((1vw - 7.68px) * 93.75), 50rem)',
221
240
  },
222
- //
241
+
223
242
  {
224
- message:
225
- ' Should return clamp value with default fluid max value.',
243
+ message: 'returns clamp value where no fluid max size is set',
226
244
  preset: {
227
245
  size: '28px',
228
246
  fluid: {
@@ -233,12 +251,11 @@ describe( 'typography utils', () => {
233
251
  fluid: true,
234
252
  },
235
253
  expected:
236
- 'clamp(2.6rem, 2.6rem + ((1vw - 0.48rem) * 0.048), 42px)',
254
+ 'clamp(2.6rem, 2.6rem + ((1vw - 0.48rem) * -1.635), 28px)',
237
255
  },
238
256
 
239
257
  {
240
- message:
241
- 'Should return clamp value with default fluid min value.',
258
+ message: 'returns clamp value where no fluid min size is set',
242
259
  preset: {
243
260
  size: '28px',
244
261
  fluid: {
@@ -253,90 +270,57 @@ describe( 'typography utils', () => {
253
270
  },
254
271
 
255
272
  {
256
- message: 'adjust computed min in px to min limit.',
257
- preset: {
258
- size: '14px',
259
- },
260
- typographySettings: {
261
- fluid: true,
262
- },
263
- expected:
264
- 'clamp(14px, 0.875rem + ((1vw - 7.68px) * 0.841), 21px)',
265
- },
266
-
267
- {
268
- message: 'adjust computed min in rem to min limit.',
269
- preset: {
270
- size: '1.1rem',
271
- },
272
- typographySettings: {
273
- fluid: true,
274
- },
275
- expected:
276
- 'clamp(0.875rem, 0.875rem + ((1vw - 0.48rem) * 1.49), 1.65rem)',
277
- },
278
-
279
- {
280
- message: 'adjust computed min in em to min limit.',
281
- preset: {
282
- size: '1.1em',
283
- },
284
- typographySettings: {
285
- fluid: true,
286
- },
287
- expected:
288
- 'clamp(0.875em, 0.875rem + ((1vw - 0.48em) * 1.49), 1.65em)',
289
- },
290
-
291
- {
292
- message: 'adjust fluid min value in px to min limit',
273
+ message:
274
+ 'should not apply lower bound test when fluid values are set',
293
275
  preset: {
294
- size: '20px',
276
+ size: '1.5rem',
295
277
  fluid: {
296
- min: '12px',
278
+ min: '0.5rem',
279
+ max: '5rem',
297
280
  },
298
281
  },
299
282
  typographySettings: {
300
283
  fluid: true,
301
284
  },
302
285
  expected:
303
- 'clamp(14px, 0.875rem + ((1vw - 7.68px) * 1.923), 30px)',
286
+ 'clamp(0.5rem, 0.5rem + ((1vw - 0.48rem) * 8.654), 5rem)',
304
287
  },
305
288
 
306
289
  {
307
- message: 'adjust fluid min value in rem to min limit.',
290
+ message:
291
+ 'should not apply lower bound test when only fluid min is set',
308
292
  preset: {
309
- size: '1.5rem',
293
+ size: '20px',
310
294
  fluid: {
311
- min: '0.5rem',
295
+ min: '12px',
312
296
  },
313
297
  },
314
298
  typographySettings: {
315
299
  fluid: true,
316
300
  },
317
301
  expected:
318
- 'clamp(0.875rem, 0.875rem + ((1vw - 0.48rem) * 2.644), 2.25rem)',
302
+ 'clamp(12px, 0.75rem + ((1vw - 7.68px) * 0.962), 20px)',
319
303
  },
320
304
 
321
305
  {
322
- message: 'adjust fluid min value but honor max value.',
306
+ message:
307
+ 'should not apply lower bound test when only fluid max is set',
323
308
  preset: {
324
- size: '1.5rem',
309
+ size: '0.875rem',
325
310
  fluid: {
326
- min: '0.5rem',
327
- max: '5rem',
311
+ max: '20rem',
328
312
  },
329
313
  },
330
314
  typographySettings: {
331
315
  fluid: true,
332
316
  },
333
317
  expected:
334
- 'clamp(0.875rem, 0.875rem + ((1vw - 0.48rem) * 7.933), 5rem)',
318
+ 'clamp(0.875rem, 0.875rem + ((1vw - 0.48rem) * 36.779), 20rem)',
335
319
  },
336
320
 
337
321
  {
338
322
  message:
339
- 'return a fluid font size a min and max font sizes are equal.',
323
+ 'returns clamp value when min and max font sizes are equal',
340
324
  preset: {
341
325
  size: '4rem',
342
326
  fluid: {
@@ -711,7 +711,7 @@ describe( 'global styles renderer', () => {
711
711
  },
712
712
  typography: {
713
713
  fontFamily: 'sans-serif',
714
- fontSize: '14px',
714
+ fontSize: '15px',
715
715
  },
716
716
  };
717
717
 
@@ -725,7 +725,7 @@ describe( 'global styles renderer', () => {
725
725
  '--wp--style--root--padding-left: 33px',
726
726
  'background-color: var(--wp--preset--color--light-green-cyan)',
727
727
  'font-family: sans-serif',
728
- 'font-size: 14px',
728
+ 'font-size: 15px',
729
729
  ] );
730
730
  } );
731
731
 
@@ -739,7 +739,7 @@ describe( 'global styles renderer', () => {
739
739
  'padding-bottom: 33px',
740
740
  'padding-left: 33px',
741
741
  'font-family: sans-serif',
742
- 'font-size: 14px',
742
+ 'font-size: 15px',
743
743
  ] );
744
744
  } );
745
745
 
@@ -757,7 +757,7 @@ describe( 'global styles renderer', () => {
757
757
  'padding-bottom: 33px',
758
758
  'padding-left: 33px',
759
759
  'font-family: sans-serif',
760
- 'font-size: 14px',
760
+ 'font-size: 15px',
761
761
  ] );
762
762
  } );
763
763
 
@@ -782,7 +782,7 @@ describe( 'global styles renderer', () => {
782
782
  'padding-bottom: 33px',
783
783
  'padding-left: 33px',
784
784
  'font-family: sans-serif',
785
- 'font-size: clamp(14px, 0.875rem + ((1vw - 7.68px) * 0.841), 21px)',
785
+ 'font-size: clamp(14px, 0.875rem + ((1vw - 7.68px) * 0.12), 15px)',
786
786
  ] );
787
787
  } );
788
788
 
@@ -807,7 +807,7 @@ describe( 'global styles renderer', () => {
807
807
  'padding-bottom: 33px',
808
808
  'padding-left: 33px',
809
809
  'font-family: sans-serif',
810
- 'font-size: 14px',
810
+ 'font-size: 15px',
811
811
  ] );
812
812
  } );
813
813
  } );
@@ -845,8 +845,44 @@ export const getBlockSelectors = ( blockTypes ) => {
845
845
  return result;
846
846
  };
847
847
 
848
+ /**
849
+ * If there is a separator block whose color is defined in theme.json via background,
850
+ * update the separator color to the same value by using border color.
851
+ *
852
+ * @param {Object} config Theme.json configuration file object.
853
+ * @return {Object} configTheme.json configuration file object updated.
854
+ */
855
+ function updateConfigWithSeparator( config ) {
856
+ const needsSeparatorStyleUpdate =
857
+ config.styles?.blocks[ 'core/separator' ] &&
858
+ config.styles?.blocks[ 'core/separator' ].color?.background &&
859
+ ! config.styles?.blocks[ 'core/separator' ].color?.text &&
860
+ ! config.styles?.blocks[ 'core/separator' ].border?.color;
861
+ if ( needsSeparatorStyleUpdate ) {
862
+ return {
863
+ ...config,
864
+ styles: {
865
+ ...config.styles,
866
+ blocks: {
867
+ ...config.styles.blocks,
868
+ 'core/separator': {
869
+ ...config.styles.blocks[ 'core/separator' ],
870
+ color: {
871
+ ...config.styles.blocks[ 'core/separator' ].color,
872
+ text: config.styles?.blocks[ 'core/separator' ]
873
+ .color.background,
874
+ },
875
+ },
876
+ },
877
+ },
878
+ };
879
+ }
880
+ return config;
881
+ }
882
+
848
883
  export function useGlobalStylesOutput() {
849
- const { merged: mergedConfig } = useContext( GlobalStylesContext );
884
+ let { merged: mergedConfig } = useContext( GlobalStylesContext );
885
+
850
886
  const [ blockGap ] = useSetting( 'spacing.blockGap' );
851
887
  const hasBlockGapSupport = blockGap !== null;
852
888
  const hasFallbackGapSupport = ! hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
@@ -859,7 +895,7 @@ export function useGlobalStylesOutput() {
859
895
  if ( ! mergedConfig?.styles || ! mergedConfig?.settings ) {
860
896
  return [];
861
897
  }
862
-
898
+ mergedConfig = updateConfigWithSeparator( mergedConfig );
863
899
  const blockSelectors = getBlockSelectors( getBlockTypes() );
864
900
  const customProperties = toCustomProperties(
865
901
  mergedConfig,
@@ -60,8 +60,8 @@ export default function Header( {
60
60
  listViewShortcut,
61
61
  isLoaded,
62
62
  isVisualMode,
63
- settings,
64
63
  blockEditorMode,
64
+ homeUrl,
65
65
  } = useSelect( ( select ) => {
66
66
  const {
67
67
  __experimentalGetPreviewDeviceType,
@@ -70,7 +70,6 @@ export default function Header( {
70
70
  isInserterOpened,
71
71
  isListViewOpened,
72
72
  getEditorMode,
73
- getSettings,
74
73
  } = select( editSiteStore );
75
74
  const { getEditedEntityRecord } = select( coreStore );
76
75
  const { __experimentalGetTemplateInfo: getTemplateInfo } =
@@ -83,6 +82,10 @@ export default function Header( {
83
82
  const record = getEditedEntityRecord( 'postType', postType, postId );
84
83
  const _isLoaded = !! postId;
85
84
 
85
+ const {
86
+ getUnstableBase, // Site index.
87
+ } = select( coreStore );
88
+
86
89
  return {
87
90
  deviceType: __experimentalGetPreviewDeviceType(),
88
91
  entityTitle: getTemplateInfo( record ).title,
@@ -95,8 +98,8 @@ export default function Header( {
95
98
  'core/edit-site/toggle-list-view'
96
99
  ),
97
100
  isVisualMode: getEditorMode() === 'visual',
98
- settings: getSettings(),
99
101
  blockEditorMode: __unstableGetEditorMode(),
102
+ homeUrl: getUnstableBase()?.home,
100
103
  };
101
104
  }, [] );
102
105
 
@@ -256,7 +259,7 @@ export default function Header( {
256
259
  >
257
260
  <MenuGroup>
258
261
  <MenuItem
259
- href={ settings?.siteUrl }
262
+ href={ homeUrl }
260
263
  target="_blank"
261
264
  icon={ external }
262
265
  >