@bobbykim/manguito-theme 0.1.4 → 0.3.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/theme/theme.ts CHANGED
@@ -3,87 +3,40 @@
3
3
  * @Interface - Classes for color, header text, body text, border color, border width(top, left).
4
4
  * @Export RDSTheme - an abstract class
5
5
  */
6
+ import type {
7
+ ColorPalette,
8
+ HeadingSize,
9
+ BodyText,
10
+ FontWeight,
11
+ Range,
12
+ OpacityRange,
13
+ SpacingLevel,
14
+ Position,
15
+ } from './theme.types'
6
16
 
7
- export interface ColorClass {
8
- primary: string
9
- secondary: string
10
- success: string
11
- info: string
12
- warning: string
13
- danger: string
14
- 'light-1': string
15
- 'light-2': string
16
- 'light-3': string
17
- 'light-4': string
18
- 'dark-1': string
19
- 'dark-2': string
20
- 'dark-3': string
21
- 'dark-4': string
22
- black: string
23
- white: string
24
- transparent: string
17
+ export type ColorClass = {
18
+ [key in ColorPalette]: string
25
19
  }
26
-
27
- export interface HeaderSizeClass {
28
- sm: string
29
- md: string
30
- lg: string
31
- xl: string
20
+ export type HeaderSizeClass = {
21
+ [key in HeadingSize]: string
32
22
  }
33
-
34
- export interface BodyTextClass {
35
- xs: string
36
- sm: string
37
- md: string
38
- lg: string
39
- xl: string
23
+ export type BodyTextClass = {
24
+ [key in BodyText]: string
40
25
  }
41
-
42
- export interface FontWeightClass {
43
- light: string
44
- normal: string
45
- bold: string
26
+ export type FontWeightClass = {
27
+ [key in FontWeight]: string
46
28
  }
47
-
48
- export interface BorderWidth {
49
- 1: string
50
- 2: string
51
- 3: string
52
- 4: string
53
- 5: string
54
- 6: string
55
- 7: string
56
- 8: string
57
- 9: string
58
- 10: string
59
- 11: string
60
- 12: string
29
+ export type BorderWidth = {
30
+ [key in Range<1, 12>]: string
61
31
  }
62
-
63
- export interface Opacity {
64
- 10: string
65
- 20: string
66
- 30: string
67
- 40: string
68
- 50: string
69
- 60: string
70
- 70: string
71
- 80: string
72
- 90: string
73
- 100: string
32
+ export type Opacity = {
33
+ [key in OpacityRange]: string
74
34
  }
75
-
76
- export interface Spacing {
77
- '0': string
78
- '3xs': string
79
- '2xs': string
80
- xs: string
81
- sm: string
82
- md: string
83
- lg: string
84
- xl: string
85
- '2xl': string
86
- '3xl': string
35
+ export type Spacing = {
36
+ [key in SpacingLevel]: string
37
+ }
38
+ export type Alignment = {
39
+ [key in Position]: string
87
40
  }
88
41
 
89
42
  abstract class MCLTheme {
@@ -167,6 +120,26 @@ abstract class MCLTheme {
167
120
  white: 'after:bg-white',
168
121
  transparent: 'after:bg-transparent',
169
122
  }
123
+ // active:bg color class
124
+ protected static bgActiveColor: ColorClass = {
125
+ primary: 'active:bg-primary',
126
+ secondary: 'active:bg-secondary',
127
+ success: 'active:bg-success',
128
+ danger: 'active:bg-danger',
129
+ info: 'active:bg-info',
130
+ warning: 'active:bg-warning',
131
+ 'light-1': 'active:bg-light-1',
132
+ 'light-2': 'active:bg-light-2',
133
+ 'light-3': 'active:bg-light-3',
134
+ 'light-4': 'active:bg-light-4',
135
+ 'dark-1': 'active:bg-dark-1',
136
+ 'dark-2': 'active:bg-dark-2',
137
+ 'dark-3': 'active:bg-dark-3',
138
+ 'dark-4': 'active:bg-dark-4',
139
+ black: 'active:bg-black',
140
+ white: 'active:bg-white',
141
+ transparent: 'active:bg-transparent',
142
+ }
170
143
  // text color class
171
144
  protected static textColor: ColorClass = {
172
145
  primary: 'text-primary',
@@ -307,25 +280,84 @@ abstract class MCLTheme {
307
280
  white: 'active:ring-white',
308
281
  transparent: 'active:ring-transparent',
309
282
  }
310
- // active:bg color class
311
- protected static bgActiveColor: ColorClass = {
312
- primary: 'active:bg-primary',
313
- secondary: 'active:bg-secondary',
314
- success: 'active:bg-success',
315
- danger: 'active:bg-danger',
316
- info: 'active:bg-info',
317
- warning: 'active:bg-warning',
318
- 'light-1': 'active:bg-light-1',
319
- 'light-2': 'active:bg-light-2',
320
- 'light-3': 'active:bg-light-3',
321
- 'light-4': 'active:bg-light-4',
322
- 'dark-1': 'active:bg-dark-1',
323
- 'dark-2': 'active:bg-dark-2',
324
- 'dark-3': 'active:bg-dark-3',
325
- 'dark-4': 'active:bg-dark-4',
326
- black: 'active:bg-black',
327
- white: 'active:bg-white',
328
- transparent: 'active:bg-transparent',
283
+ // ring-offset color class
284
+ protected static ringOffsetColor: ColorClass = {
285
+ primary: 'ring-offset-primary',
286
+ secondary: 'ring-offset-secondary',
287
+ success: 'ring-offset-success',
288
+ danger: 'ring-offset-danger',
289
+ info: 'ring-offset-info',
290
+ warning: 'ring-offset-warning',
291
+ 'light-1': 'ring-offset-light-1',
292
+ 'light-2': 'ring-offset-light-2',
293
+ 'light-3': 'ring-offset-light-3',
294
+ 'light-4': 'ring-offset-light-4',
295
+ 'dark-1': 'ring-offset-dark-1',
296
+ 'dark-2': 'ring-offset-dark-2',
297
+ 'dark-3': 'ring-offset-dark-3',
298
+ 'dark-4': 'ring-offset-dark-4',
299
+ black: 'ring-offset-black',
300
+ white: 'ring-offset-white',
301
+ transparent: 'ring-offset-transparent',
302
+ }
303
+ protected static dummyColor: ColorClass = {
304
+ primary: 'ring-offset-primary',
305
+ secondary: 'ring-offset-secondary',
306
+ success: 'ring-offset-success',
307
+ danger: 'ring-offset-danger',
308
+ info: 'ring-offset-info',
309
+ warning: 'ring-offset-warning',
310
+ 'light-1': 'ring-offset-light-1',
311
+ 'light-2': 'ring-offset-light-2',
312
+ 'light-3': 'ring-offset-light-3',
313
+ 'light-4': 'ring-offset-light-4',
314
+ 'dark-1': 'ring-offset-dark-1',
315
+ 'dark-2': 'ring-offset-dark-2',
316
+ 'dark-3': 'ring-offset-dark-3',
317
+ 'dark-4': 'ring-offset-dark-4',
318
+ black: 'ring-offset-black',
319
+ white: 'ring-offset-white',
320
+ transparent: 'ring-offset-transparent',
321
+ }
322
+ // btn color class
323
+ protected static btnColor: ColorClass = {
324
+ primary: 'btn-primary',
325
+ secondary: 'btn-secondary',
326
+ success: 'btn-success',
327
+ danger: 'btn-danger',
328
+ info: 'btn-info',
329
+ warning: 'btn-warning',
330
+ 'light-1': 'btn-light-1',
331
+ 'light-2': 'btn-light-2',
332
+ 'light-3': 'btn-light-3',
333
+ 'light-4': 'btn-light-4',
334
+ 'dark-1': 'btn-dark-1',
335
+ 'dark-2': 'btn-dark-2',
336
+ 'dark-3': 'btn-dark-3',
337
+ 'dark-4': 'btn-dark-4',
338
+ black: 'btn-black',
339
+ white: 'btn-white',
340
+ transparent: 'btn-transparent',
341
+ }
342
+ // list color class
343
+ protected static listColor: ColorClass = {
344
+ primary: 'mcl-list-primary',
345
+ secondary: 'mcl-list-secondary',
346
+ success: 'mcl-list-success',
347
+ danger: 'mcl-list-danger',
348
+ info: 'mcl-list-info',
349
+ warning: 'mcl-list-warning',
350
+ 'light-1': 'mcl-list-light-1',
351
+ 'light-2': 'mcl-list-light-2',
352
+ 'light-3': 'mcl-list-light-3',
353
+ 'light-4': 'mcl-list-light-4',
354
+ 'dark-1': 'mcl-list-dark-1',
355
+ 'dark-2': 'mcl-list-dark-2',
356
+ 'dark-3': 'mcl-list-dark-3',
357
+ 'dark-4': 'mcl-list-dark-4',
358
+ black: 'mcl-list-black',
359
+ white: 'mcl-list-white',
360
+ transparent: 'mcl-list-transparent',
329
361
  }
330
362
  // h1 class
331
363
  protected static heading1: HeaderSizeClass = {
@@ -446,6 +478,25 @@ abstract class MCLTheme {
446
478
  white: 'border-t-white',
447
479
  transparent: 'border-t-transparent',
448
480
  }
481
+ protected static borderBottomColor: ColorClass = {
482
+ primary: 'border-b-primary',
483
+ secondary: 'border-b-secondary',
484
+ success: 'border-b-success',
485
+ danger: 'border-b-danger',
486
+ info: 'border-b-info',
487
+ warning: 'border-b-warning',
488
+ 'light-1': 'border-b-light-1',
489
+ 'light-2': 'border-b-light-2',
490
+ 'light-3': 'border-b-light-3',
491
+ 'light-4': 'border-b-light-4',
492
+ 'dark-1': 'border-b-dark-1',
493
+ 'dark-2': 'border-b-dark-2',
494
+ 'dark-3': 'border-b-dark-3',
495
+ 'dark-4': 'border-b-dark-4',
496
+ black: 'border-b-black',
497
+ white: 'border-b-white',
498
+ transparent: 'border-b-transparent',
499
+ }
449
500
  protected static borderLeftColor: ColorClass = {
450
501
  primary: 'border-l-primary',
451
502
  secondary: 'border-l-secondary',
@@ -465,26 +516,68 @@ abstract class MCLTheme {
465
516
  white: 'border-l-white',
466
517
  transparent: 'border-l-transparent',
467
518
  }
468
- protected static borderBottomColor: ColorClass = {
469
- primary: 'border-b-primary',
470
- secondary: 'border-b-secondary',
471
- success: 'border-b-success',
472
- danger: 'border-b-danger',
473
- info: 'border-b-info',
474
- warning: 'border-b-warning',
475
- 'light-1': 'border-b-light-1',
476
- 'light-2': 'border-b-light-2',
477
- 'light-3': 'border-b-light-3',
478
- 'light-4': 'border-b-light-4',
479
- 'dark-1': 'border-b-dark-1',
480
- 'dark-2': 'border-b-dark-2',
481
- 'dark-3': 'border-b-dark-3',
482
- 'dark-4': 'border-b-dark-4',
483
- black: 'border-b-black',
484
- white: 'border-b-white',
485
- transparent: 'border-b-transparent',
519
+ protected static borderRightColor: ColorClass = {
520
+ primary: 'border-r-primary',
521
+ secondary: 'border-r-secondary',
522
+ success: 'border-r-success',
523
+ danger: 'border-r-danger',
524
+ info: 'border-r-info',
525
+ warning: 'border-r-warning',
526
+ 'light-1': 'border-r-light-1',
527
+ 'light-2': 'border-r-light-2',
528
+ 'light-3': 'border-r-light-3',
529
+ 'light-4': 'border-r-light-4',
530
+ 'dark-1': 'border-r-dark-1',
531
+ 'dark-2': 'border-r-dark-2',
532
+ 'dark-3': 'border-r-dark-3',
533
+ 'dark-4': 'border-r-dark-4',
534
+ black: 'border-r-black',
535
+ white: 'border-r-white',
536
+ transparent: 'border-r-transparent',
537
+ }
538
+ // Border width class
539
+ protected static borderWidth: BorderWidth = {
540
+ 1: 'border-[1px]',
541
+ 2: 'border-[2px]',
542
+ 3: 'border-[3px]',
543
+ 4: 'border-[4px]',
544
+ 5: 'border-[5px]',
545
+ 6: 'border-[6px]',
546
+ 7: 'border-[7px]',
547
+ 8: 'border-[8px]',
548
+ 9: 'border-[9px]',
549
+ 10: 'border-[10px]',
550
+ 11: 'border-[11px]',
551
+ 12: 'border-[12px]',
552
+ }
553
+ protected static borderXWidth: BorderWidth = {
554
+ 1: 'border-x-[1px]',
555
+ 2: 'border-x-[2px]',
556
+ 3: 'border-x-[3px]',
557
+ 4: 'border-x-[4px]',
558
+ 5: 'border-x-[5px]',
559
+ 6: 'border-x-[6px]',
560
+ 7: 'border-x-[7px]',
561
+ 8: 'border-x-[8px]',
562
+ 9: 'border-x-[9px]',
563
+ 10: 'border-x-[10px]',
564
+ 11: 'border-x-[11px]',
565
+ 12: 'border-x-[12px]',
566
+ }
567
+ protected static borderYWidth: BorderWidth = {
568
+ 1: 'border-y-[1px]',
569
+ 2: 'border-y-[2px]',
570
+ 3: 'border-y-[3px]',
571
+ 4: 'border-y-[4px]',
572
+ 5: 'border-y-[5px]',
573
+ 6: 'border-y-[6px]',
574
+ 7: 'border-y-[7px]',
575
+ 8: 'border-y-[8px]',
576
+ 9: 'border-y-[9px]',
577
+ 10: 'border-y-[10px]',
578
+ 11: 'border-y-[11px]',
579
+ 12: 'border-y-[12px]',
486
580
  }
487
- // Border width class for top/left
488
581
  protected static borderTopWidth: BorderWidth = {
489
582
  1: 'border-t-[1px]',
490
583
  2: 'border-t-[2px]',
@@ -499,6 +592,20 @@ abstract class MCLTheme {
499
592
  11: 'border-t-[11px]',
500
593
  12: 'border-t-[12px]',
501
594
  }
595
+ protected static borderBottomWidth: BorderWidth = {
596
+ 1: 'border-b-[1px]',
597
+ 2: 'border-b-[2px]',
598
+ 3: 'border-b-[3px]',
599
+ 4: 'border-b-[4px]',
600
+ 5: 'border-b-[5px]',
601
+ 6: 'border-b-[6px]',
602
+ 7: 'border-b-[7px]',
603
+ 8: 'border-b-[8px]',
604
+ 9: 'border-b-[9px]',
605
+ 10: 'border-b-[10px]',
606
+ 11: 'border-b-[11px]',
607
+ 12: 'border-b-[12px]',
608
+ }
502
609
  protected static borderLeftWidth: BorderWidth = {
503
610
  1: 'border-l-[1px]',
504
611
  2: 'border-l-[2px]',
@@ -513,6 +620,21 @@ abstract class MCLTheme {
513
620
  11: 'border-l-[11px]',
514
621
  12: 'border-l-[12px]',
515
622
  }
623
+ protected static borderRightWidth: BorderWidth = {
624
+ 1: 'border-r-[1px]',
625
+ 2: 'border-r-[2px]',
626
+ 3: 'border-r-[3px]',
627
+ 4: 'border-r-[4px]',
628
+ 5: 'border-r-[5px]',
629
+ 6: 'border-r-[6px]',
630
+ 7: 'border-r-[7px]',
631
+ 8: 'border-r-[8px]',
632
+ 9: 'border-r-[9px]',
633
+ 10: 'border-r-[10px]',
634
+ 11: 'border-r-[11px]',
635
+ 12: 'border-r-[12px]',
636
+ }
637
+ // opacity
516
638
  protected static backgroundOpacity: Opacity = {
517
639
  10: 'bg-opacity-10',
518
640
  20: 'bg-opacity-20',
@@ -537,6 +659,55 @@ abstract class MCLTheme {
537
659
  90: 'opacity-90',
538
660
  100: 'opacity-100',
539
661
  }
662
+ // spacing: margin
663
+ protected static margin: Spacing = {
664
+ '0': 'm-0',
665
+ '3xs': 'm-3xs',
666
+ '2xs': 'm-2xs',
667
+ xs: 'm-xs',
668
+ sm: 'm-sm',
669
+ md: 'm-md',
670
+ lg: 'm-lg',
671
+ xl: 'm-xl',
672
+ '2xl': 'm-2xl',
673
+ '3xl': 'm-3xl',
674
+ }
675
+ protected static marginX: Spacing = {
676
+ '0': 'mx-0',
677
+ '3xs': 'mx-3xs',
678
+ '2xs': 'mx-2xs',
679
+ xs: 'mx-xs',
680
+ sm: 'mx-sm',
681
+ md: 'mx-md',
682
+ lg: 'mx-lg',
683
+ xl: 'mx-xl',
684
+ '2xl': 'mx-2xl',
685
+ '3xl': 'mx-3xl',
686
+ }
687
+ protected static marginY: Spacing = {
688
+ '0': 'my-0',
689
+ '3xs': 'my-3xs',
690
+ '2xs': 'my-2xs',
691
+ xs: 'my-xs',
692
+ sm: 'my-sm',
693
+ md: 'my-md',
694
+ lg: 'my-lg',
695
+ xl: 'my-xl',
696
+ '2xl': 'my-2xl',
697
+ '3xl': 'my-3xl',
698
+ }
699
+ protected static marginTop: Spacing = {
700
+ '0': 'mt-0',
701
+ '3xs': 'mt-3xs',
702
+ '2xs': 'mt-2xs',
703
+ xs: 'mt-xs',
704
+ sm: 'mt-sm',
705
+ md: 'mt-md',
706
+ lg: 'mt-lg',
707
+ xl: 'mt-xl',
708
+ '2xl': 'mt-2xl',
709
+ '3xl': 'mt-3xl',
710
+ }
540
711
  protected static marginBottom: Spacing = {
541
712
  '0': 'mb-0',
542
713
  '3xs': 'mb-3xs',
@@ -549,6 +720,115 @@ abstract class MCLTheme {
549
720
  '2xl': 'mb-2xl',
550
721
  '3xl': 'mb-3xl',
551
722
  }
723
+ protected static marginLeft: Spacing = {
724
+ '0': 'ml-0',
725
+ '3xs': 'ml-3xs',
726
+ '2xs': 'ml-2xs',
727
+ xs: 'ml-xs',
728
+ sm: 'ml-sm',
729
+ md: 'ml-md',
730
+ lg: 'ml-lg',
731
+ xl: 'ml-xl',
732
+ '2xl': 'ml-2xl',
733
+ '3xl': 'ml-3xl',
734
+ }
735
+ protected static marginRight: Spacing = {
736
+ '0': 'mr-0',
737
+ '3xs': 'mr-3xs',
738
+ '2xs': 'mr-2xs',
739
+ xs: 'mr-xs',
740
+ sm: 'mr-sm',
741
+ md: 'mr-md',
742
+ lg: 'mr-lg',
743
+ xl: 'mr-xl',
744
+ '2xl': 'mr-2xl',
745
+ '3xl': 'mr-3xl',
746
+ }
747
+ // spacing: padding
748
+ protected static padding: Spacing = {
749
+ '0': 'p-0',
750
+ '3xs': 'p-3xs',
751
+ '2xs': 'p-2xs',
752
+ xs: 'p-xs',
753
+ sm: 'p-sm',
754
+ md: 'p-md',
755
+ lg: 'p-lg',
756
+ xl: 'p-xl',
757
+ '2xl': 'p-2xl',
758
+ '3xl': 'p-3xl',
759
+ }
760
+ protected static paddingX: Spacing = {
761
+ '0': 'px-0',
762
+ '3xs': 'px-3xs',
763
+ '2xs': 'px-2xs',
764
+ xs: 'px-xs',
765
+ sm: 'px-sm',
766
+ md: 'px-md',
767
+ lg: 'px-lg',
768
+ xl: 'px-xl',
769
+ '2xl': 'px-2xl',
770
+ '3xl': 'px-3xl',
771
+ }
772
+ protected static paddingY: Spacing = {
773
+ '0': 'py-0',
774
+ '3xs': 'py-3xs',
775
+ '2xs': 'py-2xs',
776
+ xs: 'py-xs',
777
+ sm: 'py-sm',
778
+ md: 'py-md',
779
+ lg: 'py-lg',
780
+ xl: 'py-xl',
781
+ '2xl': 'py-2xl',
782
+ '3xl': 'py-3xl',
783
+ }
784
+ protected static paddingTop: Spacing = {
785
+ '0': 'pt-0',
786
+ '3xs': 'pt-3xs',
787
+ '2xs': 'pt-2xs',
788
+ xs: 'pt-xs',
789
+ sm: 'pt-sm',
790
+ md: 'pt-md',
791
+ lg: 'pt-lg',
792
+ xl: 'pt-xl',
793
+ '2xl': 'pt-2xl',
794
+ '3xl': 'pt-3xl',
795
+ }
796
+ protected static paddingBottom: Spacing = {
797
+ '0': 'pb-0',
798
+ '3xs': 'pb-3xs',
799
+ '2xs': 'pb-2xs',
800
+ xs: 'pb-xs',
801
+ sm: 'pb-sm',
802
+ md: 'pb-md',
803
+ lg: 'pb-lg',
804
+ xl: 'pb-xl',
805
+ '2xl': 'pb-2xl',
806
+ '3xl': 'pb-3xl',
807
+ }
808
+ protected static paddingLeft: Spacing = {
809
+ '0': 'pl-0',
810
+ '3xs': 'pl-3xs',
811
+ '2xs': 'pl-2xs',
812
+ xs: 'pl-xs',
813
+ sm: 'pl-sm',
814
+ md: 'pl-md',
815
+ lg: 'pl-lg',
816
+ xl: 'pl-xl',
817
+ '2xl': 'pl-2xl',
818
+ '3xl': 'pl-3xl',
819
+ }
820
+ protected static paddingRight: Spacing = {
821
+ '0': 'pr-0',
822
+ '3xs': 'pr-3xs',
823
+ '2xs': 'pr-2xs',
824
+ xs: 'pr-xs',
825
+ sm: 'pr-sm',
826
+ md: 'pr-md',
827
+ lg: 'pr-lg',
828
+ xl: 'pr-xl',
829
+ '2xl': 'pr-2xl',
830
+ '3xl': 'pr-3xl',
831
+ }
552
832
  // spacing gap class for flex/grid
553
833
  protected static gap: Spacing = {
554
834
  '0': 'gap-0',
@@ -562,6 +842,12 @@ abstract class MCLTheme {
562
842
  '2xl': 'gap-2xl',
563
843
  '3xl': 'gap-3xl',
564
844
  }
845
+ // text alignment
846
+ protected static textAlign: Alignment = {
847
+ left: 'text-left',
848
+ center: 'text-center',
849
+ right: 'text-right',
850
+ }
565
851
  }
566
852
 
567
853
  export default MCLTheme
@@ -38,17 +38,26 @@ export type BodyText = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
38
38
  // Font weight
39
39
  export type FontWeight = 'light' | 'normal' | 'bold'
40
40
  // border positions
41
- export type Position = 'left' | 'right'
41
+ export type Position = 'left' | 'center' | 'right'
42
42
  // link targets
43
43
  export type CtaTarget = '_self' | '_blank'
44
44
  // Highlight positions
45
- export type Location = 'left' | 'top'
45
+ export type Location = 'left' | 'right' | 'top' | 'bottom'
46
46
  // available ranges
47
- export type Range<T extends number> = number extends T ? number : _Range<T, []>
48
- export type _Range<
47
+ type _RangeArray<
49
48
  T extends number,
50
- R extends unknown[]
51
- > = R['length'] extends T ? R['length'] : R['length'] | _Range<T, [T, ...R]>
49
+ R extends unknown[] = []
50
+ > = R['length'] extends T ? R : _RangeArray<T, [...R, 1]>
51
+ type IntRange<
52
+ T extends number[],
53
+ E extends number,
54
+ R extends number = never
55
+ > = T['length'] extends E ? R | E : IntRange<[...T, 1], E, R | T['length']>
56
+ export type Range<T extends number, R extends number> = IntRange<
57
+ _RangeArray<T>,
58
+ R
59
+ >
60
+
52
61
  export type ButtonSize = 'small' | 'medium' | 'large'
53
62
  export type OpacityRange = 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100
54
63
  export type Directions = 'left' | 'right'