@@ -2,14 +2,14 @@ import { parseTypographyVariants } from "../../../bin/css_to_ts/typography";
22import type { TypographyVariant } from "../../../bin/css_to_ts/typography" ;
33import { assert } from "tsafe/assert" ;
44import { same } from "evt/tools/inDepth/same" ;
5- import * as fs from "fs" ;
65
76console . log ( `Running test ${ __filename } ` ) ;
87
98const rawCssCode = `
109
1110:root {
1211 --title-spacing: 0 0 1.5rem;
12+ --text-spacing: 0 0 1.5rem;
1313}
1414
1515h6 {
@@ -359,18 +359,14 @@ sup {
359359
360360const got = parseTypographyVariants ( rawCssCode ) ;
361361
362- fs . writeFileSync ( "./view.json" , Buffer . from ( got as any , "utf8" ) ) ;
363-
364- //console.log(got);
365-
366362const expected : TypographyVariant [ ] = [
367363 {
368364 "selector" : "h6" ,
369365 "style" : {
370366 "fontWeight" : 700 ,
371367 "fontSize" : "1.125rem" ,
372368 "lineHeight" : "1.5rem" ,
373- "margin" : "0 0 1.5rem " ,
369+ "margin" : "var(--title-spacing) " ,
374370 "@media (min-width: 48em)" : {
375371 "fontSize" : "1.25rem" ,
376372 "lineHeight" : "1.75rem"
@@ -383,14 +379,216 @@ const expected: TypographyVariant[] = [
383379 "fontWeight" : 700 ,
384380 "fontSize" : "1.25rem" ,
385381 "lineHeight" : "1.75rem" ,
386- "margin" : "0 0 1.5rem " ,
382+ "margin" : "var(--title-spacing) " ,
387383 "@media (min-width: 48em)" : {
388384 "fontSize" : "1.375rem" ,
389385 "lineHeight" : "1.75rem"
390386 }
391387 }
388+ } ,
389+ {
390+ "selector" : "h4" ,
391+ "style" : {
392+ "fontWeight" : 700 ,
393+ "fontSize" : "1.375rem" ,
394+ "lineHeight" : "1.75rem" ,
395+ "margin" : "var(--title-spacing)" ,
396+ "@media (min-width: 48em)" : {
397+ "fontSize" : "1.5rem" ,
398+ "lineHeight" : "2rem"
399+ }
400+ }
401+ } ,
402+ {
403+ "selector" : "h3" ,
404+ "style" : {
405+ "fontWeight" : 700 ,
406+ "fontSize" : "1.5rem" ,
407+ "lineHeight" : "2rem" ,
408+ "margin" : "var(--title-spacing)" ,
409+ "@media (min-width: 48em)" : {
410+ "fontSize" : "1.75rem" ,
411+ "lineHeight" : "2.25rem"
412+ }
413+ }
414+ } ,
415+ {
416+ "selector" : "h2" ,
417+ "style" : {
418+ "fontWeight" : 700 ,
419+ "fontSize" : "1.75rem" ,
420+ "lineHeight" : "2.25rem" ,
421+ "margin" : "var(--title-spacing)" ,
422+ "@media (min-width: 48em)" : {
423+ "fontSize" : "2rem" ,
424+ "lineHeight" : "2.5rem"
425+ }
426+ }
427+ } ,
428+ {
429+ "selector" : "h1" ,
430+ "style" : {
431+ "fontWeight" : 700 ,
432+ "fontSize" : "2rem" ,
433+ "lineHeight" : "2.5rem" ,
434+ "margin" : "var(--title-spacing)" ,
435+ "@media (min-width: 48em)" : {
436+ "fontSize" : "2.5rem" ,
437+ "lineHeight" : "3rem"
438+ }
439+ }
440+ } ,
441+ {
442+ "selector" : "p" ,
443+ "style" : {
444+ "fontSize" : "1rem" ,
445+ "lineHeight" : "1.5rem" ,
446+ "margin" : "var(--text-spacing)"
447+ }
448+ } ,
449+ {
450+ "selector" : ".fr-text--light" ,
451+ "style" : {
452+ "fontWeight" : "300 !important"
453+ }
454+ } ,
455+ {
456+ "selector" : ".fr-text--regular" ,
457+ "style" : {
458+ "fontWeight" : "400 !important"
459+ }
460+ } ,
461+ {
462+ "selector" : ".fr-text--bold" ,
463+ "style" : {
464+ "fontWeight" : "700 !important"
465+ }
466+ } ,
467+ {
468+ "selector" : ".fr-text--heavy" ,
469+ "style" : {
470+ "fontWeight" : "900 !important"
471+ }
472+ } ,
473+ {
474+ "selector" : ".fr-display--xs" ,
475+ "style" : {
476+ "fontWeight" : "700 !important" ,
477+ "fontSize" : "2.5rem !important" ,
478+ "lineHeight" : "3rem !important" ,
479+ "margin" : "var(--display-spacing)" ,
480+ "@media (min-width: 48em)" : {
481+ "fontSize" : "3rem !important" ,
482+ "lineHeight" : "3.5rem !important"
483+ }
484+ }
485+ } ,
486+ {
487+ "selector" : ".fr-display--sm" ,
488+ "style" : {
489+ "fontWeight" : "700 !important" ,
490+ "fontSize" : "3rem !important" ,
491+ "lineHeight" : "3.5rem !important" ,
492+ "margin" : "var(--display-spacing)" ,
493+ "@media (min-width: 48em)" : {
494+ "fontSize" : "3.5rem !important" ,
495+ "lineHeight" : "4rem !important"
496+ }
497+ }
498+ } ,
499+ {
500+ "selector" : ".fr-display--md" ,
501+ "style" : {
502+ "fontWeight" : "700 !important" ,
503+ "fontSize" : "3.5rem !important" ,
504+ "lineHeight" : "4rem !important" ,
505+ "margin" : "var(--display-spacing)" ,
506+ "@media (min-width: 48em)" : {
507+ "fontSize" : "4rem !important" ,
508+ "lineHeight" : "4.5rem !important"
509+ }
510+ }
511+ } ,
512+ {
513+ "selector" : ".fr-display--lg" ,
514+ "style" : {
515+ "fontWeight" : "700 !important" ,
516+ "fontSize" : "4rem !important" ,
517+ "lineHeight" : "4.5rem !important" ,
518+ "margin" : "var(--display-spacing)" ,
519+ "@media (min-width: 48em)" : {
520+ "fontSize" : "4.5rem !important" ,
521+ "lineHeight" : "5rem !important"
522+ }
523+ }
524+ } ,
525+ {
526+ "selector" : ".fr-display--xl" ,
527+ "style" : {
528+ "fontWeight" : "700 !important" ,
529+ "fontSize" : "4.5rem !important" ,
530+ "lineHeight" : "5rem !important" ,
531+ "margin" : "var(--display-spacing)" ,
532+ "@media (min-width: 48em)" : {
533+ "fontSize" : "5rem !important" ,
534+ "lineHeight" : "5.5rem !important"
535+ }
536+ }
537+ } ,
538+ {
539+ "selector" : ".fr-text--alt" ,
540+ "style" : {
541+ "fontFamily" : '"Spectral", georgia, serif !important'
542+ }
543+ } ,
544+ {
545+ "selector" : ".fr-text--xs" ,
546+ "style" : {
547+ "fontSize" : "0.75rem !important" ,
548+ "lineHeight" : "1.25rem !important" ,
549+ "margin" : "var(--text-spacing)"
550+ }
551+ } ,
552+ {
553+ "selector" : ".fr-text--sm" ,
554+ "style" : {
555+ "fontSize" : "0.875rem !important" ,
556+ "lineHeight" : "1.5rem !important" ,
557+ "margin" : "var(--text-spacing)"
558+ }
559+ } ,
560+ {
561+ "selector" : ".fr-text--md" ,
562+ "style" : {
563+ "fontSize" : "1rem !important" ,
564+ "lineHeight" : "1.5rem !important" ,
565+ "margin" : "var(--text-spacing)"
566+ }
567+ } ,
568+ {
569+ "selector" : ".fr-text--lg" ,
570+ "style" : {
571+ "fontSize" : "1.125rem !important" ,
572+ "lineHeight" : "1.75rem !important" ,
573+ "margin" : "var(--text-spacing)"
574+ }
575+ } ,
576+ {
577+ "selector" : ".fr-text--xl" ,
578+ "style" : {
579+ "fontSize" : "1.25rem !important" ,
580+ "lineHeight" : "2rem !important" ,
581+ "margin" : "var(--text-spacing)"
582+ }
583+ } ,
584+ {
585+ "selector" : ".fr-text--lead" ,
586+ "style" : {
587+ "fontSize" : "1.25rem !important" ,
588+ "lineHeight" : "2rem !important" ,
589+ "margin" : "var(--text-spacing)"
590+ }
392591 }
393- /* ... */
394592] ;
395593
396594assert ( same ( got , expected ) ) ;
0 commit comments