@@ -19,7 +19,7 @@ import {
19
19
/**
20
20
* WordPress dependencies
21
21
*/
22
- import { __ } from '@wordpress/i18n'
22
+ import { __ , sprintf } from '@wordpress/i18n'
23
23
// import { RawHTML } from '@wordpress/element'
24
24
// import { createBlock, serialize } from '@wordpress/blocks'
25
25
@@ -139,16 +139,20 @@ const StyleGuide = props => {
139
139
const {
140
140
colors,
141
141
colorSchemes = DUMMY_COLOR_SCHEMES ,
142
+ typography = {
143
+ desktop : [ ] , tablet : [ ] , mobile : [ ] ,
144
+ } ,
145
+ designSystemStyles = '' ,
142
146
} = designSystem
143
147
144
148
return (
145
149
< >
146
150
< div className = "ugb-style-guide" >
147
151
< div className = "ugb-style-guide__content" ref = { contentRef } >
148
-
152
+ < style > { designSystemStyles } </ style >
149
153
< h1 className = "ugb-style-guide__section-title ugb-style-guide__title" > { __ ( 'Colors' , i18n ) } </ h1 >
150
154
151
- { /* TODO: Kae: the color schemes should always output at least 2 entries: 1 base color scheme and 1 background color scheme even at their default states. */ }
155
+ { /* TODO: Kae: the color schemes should always output at least 2 entries: 1 base color scheme and 1 background color scheme even at their default states. className="ugb-style-guide__typography-preview" data-device="desktop" */ }
152
156
{ colorSchemes && < >
153
157
< h2 className = "ugb-style-guide__section-subheading ugb-style-guide__title" > { __ ( 'Color Schemes' , i18n ) } </ h2 >
154
158
< div className = "ugb-style-guide__columns ugb-style-guide__color-schemes" >
@@ -158,10 +162,10 @@ const StyleGuide = props => {
158
162
< h2 className = "ugb-style-guide__color-scheme-title ugb-style-guide__title ugb-style-guide__color-label" > { colorScheme . name } </ h2 >
159
163
< div className = "ugb-style-guide__color-scheme ugb-style-guide__color-container" style = { { backgroundColor : colorScheme . backgroundColor . color } } >
160
164
{ /* TODO: Kae: the fonts and sizes here should be based on the design system */ }
161
- < div className = "ugb-style-guide__color-scheme__subtitle" style = { { color : colorScheme . accentColor . color } } > { __ ( 'Subtitle' , i18n ) } </ div >
162
- < div className = "ugb-style-guide__color-scheme__heading" style = { { color : colorScheme . headingColor . color } } > { __ ( 'Headings' , i18n ) } </ div >
165
+ < div className = "ugb-style-guide__color-scheme__subtitle stk-subtitle ugb-style-guide__typography-preview" data-device = "desktop " style = { { color : colorScheme . accentColor . color } } > { __ ( 'Subtitle' , i18n ) } </ div >
166
+ < h2 className = "ugb-style-guide__color-scheme__heading ugb-style-guide__typography-preview" data-device = "desktop" style = { { color : colorScheme . headingColor . color } } > { __ ( 'Headings' , i18n ) } </ h2 >
163
167
164
- < div className = "ugb-style-guide__color-scheme__body" style = { { color : colorScheme . textColor . color } } >
168
+ < p className = "ugb-style-guide__color-scheme__body ugb-style-guide__typography-preview" data-device = "desktop " style = { { color : colorScheme . textColor . color } } >
165
169
{ LONG_TEXT [ i % 6 ] }
166
170
167
171
{ LONG_TEXT [ ( i + 1 ) % 6 ] }
@@ -175,7 +179,7 @@ const StyleGuide = props => {
175
179
} } >
176
180
{ __ ( 'Link' , i18n ) }
177
181
</ a >
178
- </ div >
182
+ </ p >
179
183
180
184
{ /* TODO: Kae: the button looks here should be based on the design system */ }
181
185
< div className = "ugb-style-guide__color-scheme__links" >
@@ -185,14 +189,14 @@ const StyleGuide = props => {
185
189
color : colorScheme . buttonTextColor . color ,
186
190
'--hover-background-color' : colorScheme . buttonColor . hoverColor || colorScheme . buttonColor . color ,
187
191
'--hover-color' : colorScheme . buttonTextColor . hoverColor || colorScheme . buttonTextColor . color ,
188
- } } > { __ ( 'Button' , i18n ) } </ button >
192
+ } } > < span className = "stk-button__inner-text ugb-style-guide__typography-preview" data-device = "desktop" > { __ ( 'Button' , i18n ) } </ span > </ button >
189
193
190
194
< button className = "ugb-style-guide__color-scheme__button--outline" style = { {
191
195
borderColor : colorScheme . buttonOutlineColor . color ,
192
196
color : colorScheme . buttonOutlineColor . color ,
193
197
'--hover-border-color' : colorScheme . buttonOutlineColor . hoverColor || colorScheme . buttonOutlineColor . color ,
194
198
'--hover-color' : colorScheme . buttonOutlineColor . hoverColor || colorScheme . buttonOutlineColor . color ,
195
- } } > { __ ( 'Button' , i18n ) } </ button >
199
+ } } > < span className = "stk-button__inner-text ugb-style-guide__typography-preview" data-device = "desktop" > { __ ( 'Button' , i18n ) } </ span > </ button >
196
200
197
201
</ div >
198
202
</ div >
@@ -242,140 +246,78 @@ const StyleGuide = props => {
242
246
243
247
< div className = "ugb-style-guide__column" >
244
248
< h2 className = "ugb-style-guide__section-subheading ugb-style-guide__title" > { __ ( 'Desktop' , i18n ) } </ h2 >
245
- < div className = "ugb-style-guide__typography-container" >
246
- < h1 > { __ ( 'Heading 1' , i18n ) } </ h1 >
247
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
248
- </ div >
249
- < div className = "ugb-style-guide__typography-container" >
250
- < h2 > { __ ( 'Heading 2' , i18n ) } </ h2 >
251
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
252
- </ div >
253
- < div className = "ugb-style-guide__typography-container" >
254
- < h3 > { __ ( 'Heading 3' , i18n ) } </ h3 >
255
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
256
- </ div >
257
- < div className = "ugb-style-guide__typography-container" >
258
- < h4 > { __ ( 'Heading 4' , i18n ) } </ h4 >
259
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
260
- </ div >
261
- < div className = "ugb-style-guide__typography-container" >
262
- < h5 > { __ ( 'Heading 5' , i18n ) } </ h5 >
263
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
264
- </ div >
265
- < div className = "ugb-style-guide__typography-container" >
266
- < h6 > { __ ( 'Heading 6' , i18n ) } </ h6 >
267
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
268
- </ div >
269
- < div className = "ugb-style-guide__typography-container" >
270
- < p > { __ ( 'Body' , i18n ) } </ p >
271
- < div className = "ugb-style-guide__typography-label" > System Font / Normal / 16px</ div >
272
- </ div >
273
- < div className = "ugb-style-guide__typography-container" >
274
- < p > { __ ( 'Subtitle' , i18n ) } </ p >
275
- < div className = "ugb-style-guide__typography-label" > System Font / Normal / 16px</ div >
276
- </ div >
277
- < div className = "ugb-style-guide__typography-container" >
278
- < p > { __ ( 'Button' , i18n ) } </ p >
279
- < div className = "ugb-style-guide__typography-label" > System Font / Bold / 16px</ div >
280
- </ div >
249
+ { typography . desktop . length > 0 && typography . desktop . map ( ( [ element , description ] , i ) => {
250
+ const Tag = element . startsWith ( 'h' ) ? element : 'p'
251
+ const classname = i === 7 ? 'stk-subtitle' : i === 8 ? 'stk-button__inner-text' : ''
252
+
253
+ const label = i < 6 ? sprintf ( __ ( 'Heading %d' , i18n ) , i + 1 )
254
+ : i === 6 ? __ ( 'Body' , i18n )
255
+ : i === 7 ? __ ( 'Subtitle' , i18n )
256
+ : __ ( 'Button' , i18n )
257
+
258
+ return (
259
+ < div key = { i } className = "ugb-style-guide__typography-container" >
260
+ < Tag className = { `ugb-style-guide__typography-preview ${ classname } ` } data-device = "desktop" > { label } </ Tag >
261
+ < div className = "ugb-style-guide__typography-label" > { description } </ div >
262
+ </ div >
263
+ )
264
+ } ) }
281
265
</ div >
282
266
283
267
< div className = "ugb-style-guide__column" >
284
268
< h2 className = "ugb-style-guide__section-subheading ugb-style-guide__title" > { __ ( 'Tablet' , i18n ) } </ h2 >
285
- < div className = "ugb-style-guide__typography-container" >
286
- < h1 > { __ ( 'Heading 1' , i18n ) } </ h1 >
287
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
288
- </ div >
289
- < div className = "ugb-style-guide__typography-container" >
290
- < h2 > { __ ( 'Heading 2' , i18n ) } </ h2 >
291
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
292
- </ div >
293
- < div className = "ugb-style-guide__typography-container" >
294
- < h3 > { __ ( 'Heading 3' , i18n ) } </ h3 >
295
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
296
- </ div >
297
- < div className = "ugb-style-guide__typography-container" >
298
- < h4 > { __ ( 'Heading 4' , i18n ) } </ h4 >
299
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
300
- </ div >
301
- < div className = "ugb-style-guide__typography-container" >
302
- < h5 > { __ ( 'Heading 5' , i18n ) } </ h5 >
303
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
304
- </ div >
305
- < div className = "ugb-style-guide__typography-container" >
306
- < h6 > { __ ( 'Heading 6' , i18n ) } </ h6 >
307
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
308
- </ div >
309
- < div className = "ugb-style-guide__typography-container" >
310
- < p > { __ ( 'Body' , i18n ) } </ p >
311
- < div className = "ugb-style-guide__typography-label" > System Font / Normal / 16px</ div >
312
- </ div >
313
- < div className = "ugb-style-guide__typography-container" >
314
- < p > { __ ( 'Subtitle' , i18n ) } </ p >
315
- < div className = "ugb-style-guide__typography-label" > System Font / Normal / 16px</ div >
316
- </ div >
317
- < div className = "ugb-style-guide__typography-container" >
318
- < p > { __ ( 'Button' , i18n ) } </ p >
319
- < div className = "ugb-style-guide__typography-label" > System Font / Bold / 16px</ div >
320
- </ div >
269
+ { typography . tablet . length > 0 && typography . tablet . map ( ( [ element , description ] , i ) => {
270
+ const Tag = element . startsWith ( 'h' ) ? element : 'p'
271
+ const classname = i === 7 ? 'stk-subtitle' : i === 8 ? 'stk-button__inner-text' : ''
272
+ const label = i < 6 ? sprintf ( __ ( 'Heading %d' , i18n ) , i + 1 )
273
+ : i === 6 ? __ ( 'Body' , i18n )
274
+ : i === 7 ? __ ( 'Subtitle' , i18n )
275
+ : __ ( 'Button' , i18n )
276
+
277
+ return (
278
+ < div key = { i } className = "ugb-style-guide__typography-container" >
279
+ < Tag className = { `ugb-style-guide__typography-preview ${ classname } ` } data-device = "tablet" > { label } </ Tag >
280
+ < div className = "ugb-style-guide__typography-label" > { description } </ div >
281
+ </ div >
282
+ )
283
+ } ) }
321
284
</ div >
322
285
323
286
< div className = "ugb-style-guide__column" >
324
287
< h2 className = "ugb-style-guide__section-subheading ugb-style-guide__title" > { __ ( 'Mobile' , i18n ) } </ h2 >
325
- < div className = "ugb-style-guide__typography-container" >
326
- < h1 > { __ ( 'Heading 1' , i18n ) } </ h1 >
327
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
328
- </ div >
329
- < div className = "ugb-style-guide__typography-container" >
330
- < h2 > { __ ( 'Heading 2' , i18n ) } </ h2 >
331
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
332
- </ div >
333
- < div className = "ugb-style-guide__typography-container" >
334
- < h3 > { __ ( 'Heading 3' , i18n ) } </ h3 >
335
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
336
- </ div >
337
- < div className = "ugb-style-guide__typography-container" >
338
- < h4 > { __ ( 'Heading 4' , i18n ) } </ h4 >
339
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
340
- </ div >
341
- < div className = "ugb-style-guide__typography-container" >
342
- < h5 > { __ ( 'Heading 5' , i18n ) } </ h5 >
343
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
344
- </ div >
345
- < div className = "ugb-style-guide__typography-container" >
346
- < h6 > { __ ( 'Heading 6' , i18n ) } </ h6 >
347
- < div className = "ugb-style-guide__typography-label" > DM Sans / Bold / 36px</ div >
348
- </ div >
349
- < div className = "ugb-style-guide__typography-container" >
350
- < p > { __ ( 'Body' , i18n ) } </ p >
351
- < div className = "ugb-style-guide__typography-label" > System Font / Normal / 16px</ div >
352
- </ div >
353
- < div className = "ugb-style-guide__typography-container" >
354
- < p > { __ ( 'Subtitle' , i18n ) } </ p >
355
- < div className = "ugb-style-guide__typography-label" > System Font / Normal / 16px</ div >
356
- </ div >
357
- < div className = "ugb-style-guide__typography-container" >
358
- < p > { __ ( 'Button' , i18n ) } </ p >
359
- < div className = "ugb-style-guide__typography-label" > System Font / Bold / 16px</ div >
360
- </ div >
288
+ { typography . mobile . length > 0 && typography . mobile . map ( ( [ element , description ] , i ) => {
289
+ const Tag = element . startsWith ( 'h' ) ? element : 'p'
290
+ const classname = i === 7 ? 'stk-subtitle' : i === 8 ? 'stk-button__inner-text' : ''
291
+ const label = i < 6 ? sprintf ( __ ( 'Heading %d' , i18n ) , i + 1 )
292
+ : i === 6 ? __ ( 'Body' , i18n )
293
+ : i === 7 ? __ ( 'Subtitle' , i18n )
294
+ : __ ( 'Button' , i18n )
295
+
296
+ return (
297
+ < div key = { i } className = "ugb-style-guide__typography-container" >
298
+ < Tag className = { `ugb-style-guide__typography-preview ${ classname } ` } data-device = "mobile" > { label } </ Tag >
299
+ < div className = "ugb-style-guide__typography-label" > { description } </ div >
300
+ </ div >
301
+ )
302
+ } ) }
361
303
</ div >
362
304
</ div >
363
305
364
306
< div className = "ugb-style-guide__columns ugb-style-guide__typography-body" >
365
307
< div className = "ugb-style-guide__column" >
366
308
< h2 className = "ugb-style-guide__section-subheading ugb-style-guide__title" > { __ ( 'Desktop' , i18n ) } </ h2 >
367
- < h2 > { __ ( 'Built on the Moments Between' , i18n ) } </ h2 >
368
- < p > { LONG_TEXT [ 0 ] } { LONG_TEXT [ 1 ] } { LONG_TEXT [ 2 ] } </ p >
309
+ < h2 className = "ugb-style-guide__typography-preview" data-device = "desktop" > { __ ( 'Built on the Moments Between' , i18n ) } </ h2 >
310
+ < p className = "ugb-style-guide__typography-preview" data-device = "desktop" > { LONG_TEXT [ 0 ] } { LONG_TEXT [ 1 ] } { LONG_TEXT [ 2 ] } </ p >
369
311
</ div >
370
312
< div className = "ugb-style-guide__column" >
371
313
< h2 className = "ugb-style-guide__section-subheading ugb-style-guide__title" > { __ ( 'Tablet' , i18n ) } </ h2 >
372
- < h2 > { __ ( 'Built on the Moments Between' , i18n ) } </ h2 >
373
- < p > { LONG_TEXT [ 1 ] } { LONG_TEXT [ 2 ] } { LONG_TEXT [ 3 ] } </ p >
314
+ < h2 className = "ugb-style-guide__typography-preview" data-device = "tablet" > { __ ( 'Built on the Moments Between' , i18n ) } </ h2 >
315
+ < p className = "ugb-style-guide__typography-preview" data-device = "tablet" > { LONG_TEXT [ 1 ] } { LONG_TEXT [ 2 ] } { LONG_TEXT [ 3 ] } </ p >
374
316
</ div >
375
317
< div className = "ugb-style-guide__column" >
376
318
< h2 className = "ugb-style-guide__section-subheading ugb-style-guide__title" > { __ ( 'Mobile' , i18n ) } </ h2 >
377
- < h2 > { __ ( 'Built on the Moments Between' , i18n ) } </ h2 >
378
- < p > { LONG_TEXT [ 2 ] } { LONG_TEXT [ 1 ] } { LONG_TEXT [ 2 ] } </ p >
319
+ < h2 className = "ugb-style-guide__typography-preview" data-device = "mobile" > { __ ( 'Built on the Moments Between' , i18n ) } </ h2 >
320
+ < p className = "ugb-style-guide__typography-preview" data-device = "mobile" > { LONG_TEXT [ 2 ] } { LONG_TEXT [ 1 ] } { LONG_TEXT [ 2 ] } </ p >
379
321
</ div >
380
322
</ div >
381
323
0 commit comments