@bobbykim/manguito-theme 0.1.3 → 0.2.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.
@@ -1,234 +0,0 @@
1
- import MCLTheme from './theme'
2
- import type {
3
- ColorPalette,
4
- HeadingSize,
5
- BodyText,
6
- FontWeight,
7
- Range,
8
- OpacityRange,
9
- SpacingLevel,
10
- } from './theme.types'
11
-
12
- /**
13
- * @TailwindCSS - Good practice is to let all of used classes to be in full instead of generated dynamically using methods such as string literal.
14
- * @Interface - ClassType to define the case, and Input type to generate tailwind clssname.
15
- * @Export GenerateRDSClass - extends RDSTheme class
16
- */
17
-
18
- export type ClassType =
19
- | 'BGCOLOR'
20
- | 'BEFOREBG'
21
- | 'AFTERBG'
22
- | 'TEXTCOLOR'
23
- | 'DISABLEDTEXTCOLOR'
24
- | 'SVGFILL'
25
- | 'RINGCOLOR'
26
- | 'FOCUSRING'
27
- | 'ACTIVERING'
28
- | 'ACTIVEBG'
29
- | 'H1'
30
- | 'H2'
31
- | 'H3'
32
- | 'H4'
33
- | 'BODYTEXT'
34
- | 'FONTWEIGHT'
35
- | 'BORDER'
36
- | 'BORDERX'
37
- | 'BORDERY'
38
- | 'BORDERT'
39
- | 'BORDERL'
40
- | 'BORDERB'
41
- | 'BORDERTW'
42
- | 'BORDERLW'
43
- | 'HVBGCOLOR'
44
- | 'HVTEXTCOLOR'
45
- | 'BGOPACITY'
46
- | 'OPACITY'
47
- | 'MARGINB'
48
- | 'GAP'
49
-
50
- export type InputType =
51
- | ColorPalette
52
- | HeadingSize
53
- | BodyText
54
- | FontWeight
55
- | Range<12>
56
- | OpacityRange
57
- | SpacingLevel
58
-
59
- class GenerateMCLClass extends MCLTheme {
60
- classType: ClassType
61
- classValue: InputType
62
-
63
- constructor(classType: ClassType, classValue: InputType) {
64
- super()
65
- this.classType = classType
66
- this.classValue = classValue
67
- }
68
- generateClassName(): string {
69
- switch (this.classType) {
70
- case 'BGCOLOR':
71
- case 'BEFOREBG':
72
- case 'AFTERBG':
73
- case 'TEXTCOLOR':
74
- case 'DISABLEDTEXTCOLOR':
75
- case 'SVGFILL':
76
- case 'RINGCOLOR':
77
- case 'FOCUSRING':
78
- case 'ACTIVERING':
79
- case 'ACTIVEBG':
80
- return this.getColorClass()
81
- case 'HVBGCOLOR':
82
- case 'HVTEXTCOLOR':
83
- return this.getHoverColorClass()
84
- case 'H1':
85
- case 'H2':
86
- case 'H3':
87
- case 'H4':
88
- return this.getHeadingTextSizeClass()
89
- case 'BODYTEXT':
90
- return this.getBodyTextSizeClass()
91
- case 'FONTWEIGHT':
92
- return this.getFontWeightClass()
93
- case 'BORDER':
94
- case 'BORDERX':
95
- case 'BORDERY':
96
- case 'BORDERT':
97
- case 'BORDERB':
98
- case 'BORDERL':
99
- return this.getBorderColorClass()
100
- case 'BORDERTW':
101
- case 'BORDERLW':
102
- return this.getBorderWidthClass()
103
- case 'BGOPACITY':
104
- return this.getBgOpacityClass()
105
- case 'OPACITY':
106
- return this.getOpacityClass()
107
- case 'MARGINB':
108
- case 'GAP':
109
- return this.getSpacingClass()
110
- default:
111
- return
112
- }
113
- }
114
- getColorClass(): string {
115
- const {
116
- bgColor,
117
- beforeBgColor,
118
- afterBgColor,
119
- textColor,
120
- disabledTextColor,
121
- svgFillColor,
122
- ringColor,
123
- ringFocusColor,
124
- ringActiveColor,
125
- bgActiveColor,
126
- } = MCLTheme
127
- if (this.classType === 'BGCOLOR') {
128
- return bgColor[this.classValue]
129
- }
130
- if (this.classType === 'BEFOREBG') {
131
- return beforeBgColor[this.classValue]
132
- }
133
- if (this.classType === 'AFTERBG') {
134
- return afterBgColor[this.classValue]
135
- }
136
- if (this.classType === 'TEXTCOLOR') {
137
- return textColor[this.classValue]
138
- }
139
- if (this.classType === 'DISABLEDTEXTCOLOR') {
140
- return disabledTextColor[this.classValue]
141
- }
142
- if (this.classType === 'SVGFILL') {
143
- return svgFillColor[this.classValue]
144
- }
145
- if (this.classType === 'FOCUSRING') {
146
- return ringFocusColor[this.classValue]
147
- }
148
- if (this.classType === 'ACTIVERING') {
149
- return ringActiveColor[this.classValue]
150
- }
151
- if (this.classType === 'ACTIVEBG') {
152
- return bgActiveColor[this.classValue]
153
- }
154
- return ringColor[this.classValue]
155
- }
156
- getHoverColorClass(): string {
157
- const { hoverBgColor, hoverTextColor } = MCLTheme
158
- if (this.classType === 'HVBGCOLOR') {
159
- return hoverBgColor[this.classValue]
160
- }
161
- return hoverTextColor[this.classValue]
162
- }
163
- getHeadingTextSizeClass(): string {
164
- const { heading1, heading2, heading3, heading4 } = MCLTheme
165
- if (this.classType === 'H1') {
166
- return heading1[this.classValue]
167
- }
168
- if (this.classType === 'H2') {
169
- return heading2[this.classValue]
170
- }
171
- if (this.classType === 'H3') {
172
- return heading3[this.classValue]
173
- }
174
- return heading4[this.classValue]
175
- }
176
- getBodyTextSizeClass(): string {
177
- const { bodyText } = MCLTheme
178
- return bodyText[this.classValue]
179
- }
180
- getFontWeightClass(): string {
181
- const { fontweight } = MCLTheme
182
- return fontweight[this.classValue]
183
- }
184
- getBorderColorClass(): string {
185
- const {
186
- borderColor,
187
- borderXColor,
188
- borderYColor,
189
- borderTopColor,
190
- borderBottomColor,
191
- borderLeftColor,
192
- } = MCLTheme
193
- if (this.classType === 'BORDERX') {
194
- return borderXColor[this.classValue]
195
- }
196
- if (this.classType === 'BORDERY') {
197
- return borderYColor[this.classValue]
198
- }
199
- if (this.classType === 'BORDERT') {
200
- return borderTopColor[this.classValue]
201
- }
202
- if (this.classType === 'BORDERB') {
203
- return borderBottomColor[this.classValue]
204
- }
205
- if (this.classType === 'BORDERL') {
206
- return borderLeftColor[this.classValue]
207
- }
208
- return borderColor[this.classValue]
209
- }
210
- getBorderWidthClass(): string {
211
- const { borderTopWidth, borderLeftWidth } = MCLTheme
212
- if (this.classType === 'BORDERTW') {
213
- return borderTopWidth[this.classValue]
214
- }
215
- return borderLeftWidth[this.classValue]
216
- }
217
- getBgOpacityClass(): string {
218
- const { backgroundOpacity } = MCLTheme
219
- return backgroundOpacity[this.classValue]
220
- }
221
- getOpacityClass(): string {
222
- const { opacity } = MCLTheme
223
- return opacity[this.classValue]
224
- }
225
- getSpacingClass(): string {
226
- const { marginBottom, gap } = MCLTheme
227
- if (this.classType === 'MARGINB') {
228
- return marginBottom[this.classValue]
229
- }
230
- return gap[this.classValue]
231
- }
232
- }
233
-
234
- export default GenerateMCLClass