@bobbykim/manguito-theme 0.1.4 → 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.
- package/README.md +45 -4
- package/index.ts +2 -2
- package/package.json +2 -2
- package/theme/index.ts +609 -0
- package/theme/theme.ts +338 -38
- package/theme/theme.types.ts +14 -6
- package/themeVariables.cjs +374 -181
- package/theme/generateClass.ts +0 -234
package/README.md
CHANGED
|
@@ -21,16 +21,57 @@ tailwind.config.cjs
|
|
|
21
21
|
```cjs
|
|
22
22
|
const {
|
|
23
23
|
mclTheme,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
} = require('./src/components/manguito-theme/themeVariables.cjs')
|
|
25
|
+
module.exports = {
|
|
26
|
+
content: [
|
|
27
|
+
'./src/**/*.{vue,ts,js,cjs}',
|
|
28
|
+
'./node_modules/@bobbykim/**/*.{vue,ts,js,cjs}',
|
|
29
|
+
],
|
|
30
|
+
plugins: [mclTheme()],
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Theme color configuration
|
|
35
|
+
|
|
36
|
+
You can change theme colors by adding colors/spacing in `tailwind.config.cjs`
|
|
26
37
|
|
|
38
|
+
```cjs
|
|
27
39
|
module.exports = {
|
|
28
40
|
content: [
|
|
29
41
|
'./src/**/*.{vue,ts,js,cjs}',
|
|
30
42
|
'./node_modules/@bobbykim/**/*.{vue,ts,js,cjs}',
|
|
31
43
|
],
|
|
32
|
-
|
|
33
|
-
|
|
44
|
+
plugins: [
|
|
45
|
+
mclTheme({
|
|
46
|
+
colors: {
|
|
47
|
+
primary: '#ec489a',
|
|
48
|
+
secondary: '#00feda',
|
|
49
|
+
success: '#78be20',
|
|
50
|
+
info: '#00a3e0',
|
|
51
|
+
warning: '#f1ac18',
|
|
52
|
+
danger: '#cc2f2f',
|
|
53
|
+
'light-1': '#fafafa',
|
|
54
|
+
'light-2': '#f1f1f1',
|
|
55
|
+
'light-3': '#e8e8e8',
|
|
56
|
+
'light-4': '#d0d0d0',
|
|
57
|
+
'dark-1': '#747474',
|
|
58
|
+
'dark-2': '#484848',
|
|
59
|
+
'dark-3': '#1f2937',
|
|
60
|
+
'dark-4': '#191919',
|
|
61
|
+
},
|
|
62
|
+
spacing: {
|
|
63
|
+
'3xs': '4px',
|
|
64
|
+
'2xs': '8px',
|
|
65
|
+
xs: '16px',
|
|
66
|
+
sm: '24px',
|
|
67
|
+
md: '32px',
|
|
68
|
+
lg: '48px',
|
|
69
|
+
xl: '64px',
|
|
70
|
+
'2xl': '96px',
|
|
71
|
+
'3xl': '128px',
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
],
|
|
34
75
|
}
|
|
35
76
|
```
|
|
36
77
|
|
package/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import GenerateMCLClass from './theme
|
|
2
|
-
import type { ClassType, InputType } from './theme
|
|
1
|
+
import GenerateMCLClass from './theme'
|
|
2
|
+
import type { ClassType, InputType } from './theme'
|
|
3
3
|
|
|
4
4
|
const generateClass = (type: ClassType, value: InputType): string => {
|
|
5
5
|
const mclGenerate = new GenerateMCLClass(type, value)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobbykim/manguito-theme",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "main theme file for manguito components library. Other MCL components will need to import this file to run.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
"url": "https://github.com/bobbykim89/manguito-component-library.git"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "aaee823ffe3d684532eb08f0553b96a4a5475a88"
|
|
21
21
|
}
|
package/theme/index.ts
ADDED
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
import MCLTheme from './theme'
|
|
2
|
+
import type {
|
|
3
|
+
ColorPalette,
|
|
4
|
+
HeadingSize,
|
|
5
|
+
BodyText,
|
|
6
|
+
FontWeight,
|
|
7
|
+
Range,
|
|
8
|
+
OpacityRange,
|
|
9
|
+
SpacingLevel,
|
|
10
|
+
Position,
|
|
11
|
+
} from './theme.types'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @TailwindCSS - Good practice is to let all of used classes to be in full instead of generated dynamically using methods such as string literal.
|
|
15
|
+
* @Interface - ClassType to define the case, and Input type to generate tailwind clssname.
|
|
16
|
+
* @Export GenerateMCLClass - extends MCLTheme class
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export type ClassType =
|
|
20
|
+
// color class
|
|
21
|
+
| 'BGCOLOR'
|
|
22
|
+
| 'BEFOREBG'
|
|
23
|
+
| 'AFTERBG'
|
|
24
|
+
| 'HVBGCOLOR'
|
|
25
|
+
| 'ACTIVEBG'
|
|
26
|
+
| 'TEXTCOLOR'
|
|
27
|
+
| 'HVTEXTCOLOR'
|
|
28
|
+
| 'DISABLEDTEXTCOLOR'
|
|
29
|
+
| 'SVGFILL'
|
|
30
|
+
| 'RINGCOLOR'
|
|
31
|
+
| 'FOCUSRING'
|
|
32
|
+
| 'ACTIVERING'
|
|
33
|
+
| 'BTNCOLOR'
|
|
34
|
+
| 'LISTCOLOR'
|
|
35
|
+
// header text class
|
|
36
|
+
| 'H1'
|
|
37
|
+
| 'H2'
|
|
38
|
+
| 'H3'
|
|
39
|
+
| 'H4'
|
|
40
|
+
// body text class
|
|
41
|
+
| 'BODYTEXT'
|
|
42
|
+
// font weight class
|
|
43
|
+
| 'FONTWEIGHT'
|
|
44
|
+
// border color class
|
|
45
|
+
| 'BORDER'
|
|
46
|
+
| 'BORDERX'
|
|
47
|
+
| 'BORDERY'
|
|
48
|
+
| 'BORDERT'
|
|
49
|
+
| 'BORDERB'
|
|
50
|
+
| 'BORDERL'
|
|
51
|
+
| 'BORDERR'
|
|
52
|
+
// border width class
|
|
53
|
+
| 'BORDERW'
|
|
54
|
+
| 'BORDERXW'
|
|
55
|
+
| 'BORDERYW'
|
|
56
|
+
| 'BORDERTW'
|
|
57
|
+
| 'BORDERBW'
|
|
58
|
+
| 'BORDERLW'
|
|
59
|
+
| 'BORDERRW'
|
|
60
|
+
// opacity class
|
|
61
|
+
| 'BGOPACITY'
|
|
62
|
+
| 'OPACITY'
|
|
63
|
+
// spacing class
|
|
64
|
+
| 'MARGIN'
|
|
65
|
+
| 'MARGINX'
|
|
66
|
+
| 'MARGINY'
|
|
67
|
+
| 'MARGINT'
|
|
68
|
+
| 'MARGINB'
|
|
69
|
+
| 'MARGINL'
|
|
70
|
+
| 'MARGINR'
|
|
71
|
+
| 'PADDING'
|
|
72
|
+
| 'PADDINGX'
|
|
73
|
+
| 'PADDINGY'
|
|
74
|
+
| 'PADDINGT'
|
|
75
|
+
| 'PADDINGB'
|
|
76
|
+
| 'PADDINGL'
|
|
77
|
+
| 'PADDINGR'
|
|
78
|
+
| 'GAP'
|
|
79
|
+
// text align class
|
|
80
|
+
| 'TEXTALIGN'
|
|
81
|
+
|
|
82
|
+
export type InputType =
|
|
83
|
+
| ColorPalette
|
|
84
|
+
| HeadingSize
|
|
85
|
+
| BodyText
|
|
86
|
+
| FontWeight
|
|
87
|
+
| Range<1, 12>
|
|
88
|
+
| OpacityRange
|
|
89
|
+
| SpacingLevel
|
|
90
|
+
| Position
|
|
91
|
+
|
|
92
|
+
class GenerateMCLClass extends MCLTheme {
|
|
93
|
+
classType: ClassType
|
|
94
|
+
classValue: InputType
|
|
95
|
+
|
|
96
|
+
constructor(classType: ClassType, classValue: InputType) {
|
|
97
|
+
super()
|
|
98
|
+
this.classType = classType
|
|
99
|
+
this.classValue = classValue
|
|
100
|
+
}
|
|
101
|
+
generateClassName(): string {
|
|
102
|
+
switch (this.classType) {
|
|
103
|
+
// case: color class
|
|
104
|
+
case 'BGCOLOR':
|
|
105
|
+
return this.getBgColorClass()
|
|
106
|
+
case 'HVBGCOLOR':
|
|
107
|
+
return this.getHoverBgColorClass()
|
|
108
|
+
case 'BEFOREBG':
|
|
109
|
+
return this.getBeforeBgColorClass()
|
|
110
|
+
case 'AFTERBG':
|
|
111
|
+
return this.getAfterBgColorClass()
|
|
112
|
+
case 'ACTIVEBG':
|
|
113
|
+
return this.getActiveBgColorClass()
|
|
114
|
+
case 'TEXTCOLOR':
|
|
115
|
+
return this.getTextColorClass()
|
|
116
|
+
case 'HVTEXTCOLOR':
|
|
117
|
+
return this.getHoverTextColorClass()
|
|
118
|
+
case 'DISABLEDTEXTCOLOR':
|
|
119
|
+
return this.getDisabledTextColorClass()
|
|
120
|
+
case 'SVGFILL':
|
|
121
|
+
return this.getSvgFillColorClass()
|
|
122
|
+
case 'RINGCOLOR':
|
|
123
|
+
return this.getRingColorClass()
|
|
124
|
+
case 'FOCUSRING':
|
|
125
|
+
return this.getFocusRingColorClass()
|
|
126
|
+
case 'ACTIVERING':
|
|
127
|
+
return this.getActiveRingColorClass()
|
|
128
|
+
case 'BTNCOLOR':
|
|
129
|
+
return this.getBtnColorClass()
|
|
130
|
+
case 'LISTCOLOR':
|
|
131
|
+
return this.getRingColorClass()
|
|
132
|
+
// case: border color class
|
|
133
|
+
case 'BORDER':
|
|
134
|
+
return this.getBorderColorClass()
|
|
135
|
+
case 'BORDERX':
|
|
136
|
+
return this.getBorderXColorClass()
|
|
137
|
+
case 'BORDERY':
|
|
138
|
+
return this.getBorderYColorClass()
|
|
139
|
+
case 'BORDERT':
|
|
140
|
+
return this.getBorderTopColorClass()
|
|
141
|
+
case 'BORDERB':
|
|
142
|
+
return this.getBorderBottomColorClass()
|
|
143
|
+
case 'BORDERL':
|
|
144
|
+
return this.getBorderLeftColorClass()
|
|
145
|
+
case 'BORDERR':
|
|
146
|
+
return this.getBorderRightColorClass()
|
|
147
|
+
// case: heading text class
|
|
148
|
+
case 'H1':
|
|
149
|
+
return this.getH1Class()
|
|
150
|
+
case 'H2':
|
|
151
|
+
return this.getH2Class()
|
|
152
|
+
case 'H3':
|
|
153
|
+
return this.getH3Class()
|
|
154
|
+
case 'H4':
|
|
155
|
+
return this.getH4Class()
|
|
156
|
+
// case: body text class
|
|
157
|
+
case 'BODYTEXT':
|
|
158
|
+
return this.getBodyTextSizeClass()
|
|
159
|
+
// case: font weight class
|
|
160
|
+
case 'FONTWEIGHT':
|
|
161
|
+
return this.getFontWeightClass()
|
|
162
|
+
// case: text alignment class
|
|
163
|
+
case 'TEXTALIGN':
|
|
164
|
+
return this.getTextAlignClass()
|
|
165
|
+
// case: border width class
|
|
166
|
+
case 'BORDERW':
|
|
167
|
+
return this.getBorderWidthClass()
|
|
168
|
+
case 'BORDERXW':
|
|
169
|
+
return this.getBorderXWidthClass()
|
|
170
|
+
case 'BORDERYW':
|
|
171
|
+
return this.getBorderYWidthClass()
|
|
172
|
+
case 'BORDERTW':
|
|
173
|
+
return this.getBorderTopWidthClass()
|
|
174
|
+
case 'BORDERBW':
|
|
175
|
+
return this.getBorderBottomWidthClass()
|
|
176
|
+
case 'BORDERLW':
|
|
177
|
+
return this.getBorderLeftWidthClass()
|
|
178
|
+
case 'BORDERRW':
|
|
179
|
+
return this.getBorderWidthClass()
|
|
180
|
+
// case: opacity class
|
|
181
|
+
case 'OPACITY':
|
|
182
|
+
return this.getOpacityClass()
|
|
183
|
+
case 'BGOPACITY':
|
|
184
|
+
return this.getBgOpacityClass()
|
|
185
|
+
// case: spacing class
|
|
186
|
+
// margins
|
|
187
|
+
case 'MARGIN':
|
|
188
|
+
return this.getMarginClass()
|
|
189
|
+
case 'MARGINX':
|
|
190
|
+
return this.getMarginXClass()
|
|
191
|
+
case 'MARGINY':
|
|
192
|
+
return this.getMarginYClass()
|
|
193
|
+
case 'MARGINT':
|
|
194
|
+
return this.getMarginTopClass()
|
|
195
|
+
case 'MARGINB':
|
|
196
|
+
return this.getMarginBottomClass()
|
|
197
|
+
case 'MARGINL':
|
|
198
|
+
return this.getMarginLeftClass()
|
|
199
|
+
case 'MARGINR':
|
|
200
|
+
return this.getMarginRightClass()
|
|
201
|
+
// paddings
|
|
202
|
+
case 'PADDING':
|
|
203
|
+
return this.getPaddingClass()
|
|
204
|
+
case 'PADDINGX':
|
|
205
|
+
return this.getPaddingXClass()
|
|
206
|
+
case 'PADDINGY':
|
|
207
|
+
return this.getPaddingYClass()
|
|
208
|
+
case 'PADDINGT':
|
|
209
|
+
return this.getPaddingTopClass()
|
|
210
|
+
case 'PADDINGB':
|
|
211
|
+
return this.getPaddingBottomClass()
|
|
212
|
+
case 'PADDINGL':
|
|
213
|
+
return this.getPaddingLeftClass()
|
|
214
|
+
case 'PADDINGR':
|
|
215
|
+
return this.getPaddingRightClass()
|
|
216
|
+
// gap
|
|
217
|
+
case 'GAP':
|
|
218
|
+
return this.getGapClass()
|
|
219
|
+
default:
|
|
220
|
+
return ' '
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// handle color class
|
|
224
|
+
// bg color
|
|
225
|
+
getBgColorClass(): string {
|
|
226
|
+
if (!this.validateColorType) {
|
|
227
|
+
return ' '
|
|
228
|
+
}
|
|
229
|
+
return MCLTheme.bgColor[this.classValue as ColorPalette]
|
|
230
|
+
}
|
|
231
|
+
getHoverBgColorClass(): string {
|
|
232
|
+
if (!this.validateColorType) {
|
|
233
|
+
return ' '
|
|
234
|
+
}
|
|
235
|
+
return MCLTheme.hoverBgColor[this.classValue as ColorPalette]
|
|
236
|
+
}
|
|
237
|
+
getBeforeBgColorClass(): string {
|
|
238
|
+
if (!this.validateColorType) {
|
|
239
|
+
return ' '
|
|
240
|
+
}
|
|
241
|
+
return MCLTheme.beforeBgColor[this.classValue as ColorPalette]
|
|
242
|
+
}
|
|
243
|
+
getAfterBgColorClass(): string {
|
|
244
|
+
if (!this.validateColorType) {
|
|
245
|
+
return ' '
|
|
246
|
+
}
|
|
247
|
+
return MCLTheme.afterBgColor[this.classValue as ColorPalette]
|
|
248
|
+
}
|
|
249
|
+
getActiveBgColorClass(): string {
|
|
250
|
+
if (!this.validateColorType) {
|
|
251
|
+
return ' '
|
|
252
|
+
}
|
|
253
|
+
return MCLTheme.bgActiveColor[this.classValue as ColorPalette]
|
|
254
|
+
}
|
|
255
|
+
// text color
|
|
256
|
+
getTextColorClass(): string {
|
|
257
|
+
if (!this.validateColorType) {
|
|
258
|
+
return ' '
|
|
259
|
+
}
|
|
260
|
+
return MCLTheme.textColor[this.classValue as ColorPalette]
|
|
261
|
+
}
|
|
262
|
+
getHoverTextColorClass(): string {
|
|
263
|
+
if (!this.validateColorType) {
|
|
264
|
+
return ' '
|
|
265
|
+
}
|
|
266
|
+
return MCLTheme.hoverTextColor[this.classValue as ColorPalette]
|
|
267
|
+
}
|
|
268
|
+
getDisabledTextColorClass(): string {
|
|
269
|
+
if (!this.validateColorType) {
|
|
270
|
+
return ' '
|
|
271
|
+
}
|
|
272
|
+
return MCLTheme.disabledTextColor[this.classValue as ColorPalette]
|
|
273
|
+
}
|
|
274
|
+
// svg color
|
|
275
|
+
getSvgFillColorClass(): string {
|
|
276
|
+
if (!this.validateColorType) {
|
|
277
|
+
return ' '
|
|
278
|
+
}
|
|
279
|
+
return MCLTheme.svgFillColor[this.classValue as ColorPalette]
|
|
280
|
+
}
|
|
281
|
+
// ring color
|
|
282
|
+
getRingColorClass(): string {
|
|
283
|
+
if (!this.validateColorType) {
|
|
284
|
+
return ' '
|
|
285
|
+
}
|
|
286
|
+
return MCLTheme.ringColor[this.classValue as ColorPalette]
|
|
287
|
+
}
|
|
288
|
+
getFocusRingColorClass(): string {
|
|
289
|
+
if (!this.validateColorType) {
|
|
290
|
+
return ' '
|
|
291
|
+
}
|
|
292
|
+
return MCLTheme.ringFocusColor[this.classValue as ColorPalette]
|
|
293
|
+
}
|
|
294
|
+
getActiveRingColorClass(): string {
|
|
295
|
+
if (!this.validateColorType) {
|
|
296
|
+
return ' '
|
|
297
|
+
}
|
|
298
|
+
return MCLTheme.ringActiveColor[this.classValue as ColorPalette]
|
|
299
|
+
}
|
|
300
|
+
// btn & list
|
|
301
|
+
getBtnColorClass(): string {
|
|
302
|
+
if (!this.validateColorType) {
|
|
303
|
+
return ' '
|
|
304
|
+
}
|
|
305
|
+
return MCLTheme.btnColor[this.classValue as ColorPalette]
|
|
306
|
+
}
|
|
307
|
+
getListColorClass(): string {
|
|
308
|
+
if (!this.validateColorType) {
|
|
309
|
+
return ' '
|
|
310
|
+
}
|
|
311
|
+
return MCLTheme.listColor[this.classValue as ColorPalette]
|
|
312
|
+
}
|
|
313
|
+
// border color
|
|
314
|
+
getBorderColorClass(): string {
|
|
315
|
+
if (!this.validateColorType) {
|
|
316
|
+
return ' '
|
|
317
|
+
}
|
|
318
|
+
return MCLTheme.borderColor[this.classValue as ColorPalette]
|
|
319
|
+
}
|
|
320
|
+
getBorderXColorClass(): string {
|
|
321
|
+
if (!this.validateColorType) {
|
|
322
|
+
return ' '
|
|
323
|
+
}
|
|
324
|
+
return MCLTheme.borderXColor[this.classValue as ColorPalette]
|
|
325
|
+
}
|
|
326
|
+
getBorderYColorClass(): string {
|
|
327
|
+
if (!this.validateColorType) {
|
|
328
|
+
return ' '
|
|
329
|
+
}
|
|
330
|
+
return MCLTheme.borderYColor[this.classValue as ColorPalette]
|
|
331
|
+
}
|
|
332
|
+
getBorderTopColorClass(): string {
|
|
333
|
+
if (!this.validateColorType) {
|
|
334
|
+
return ' '
|
|
335
|
+
}
|
|
336
|
+
return MCLTheme.borderTopColor[this.classValue as ColorPalette]
|
|
337
|
+
}
|
|
338
|
+
getBorderBottomColorClass(): string {
|
|
339
|
+
if (!this.validateColorType) {
|
|
340
|
+
return ' '
|
|
341
|
+
}
|
|
342
|
+
return MCLTheme.borderBottomColor[this.classValue as ColorPalette]
|
|
343
|
+
}
|
|
344
|
+
getBorderLeftColorClass(): string {
|
|
345
|
+
if (!this.validateColorType) {
|
|
346
|
+
return ' '
|
|
347
|
+
}
|
|
348
|
+
return MCLTheme.borderLeftColor[this.classValue as ColorPalette]
|
|
349
|
+
}
|
|
350
|
+
getBorderRightColorClass(): string {
|
|
351
|
+
if (!this.validateColorType) {
|
|
352
|
+
return ' '
|
|
353
|
+
}
|
|
354
|
+
return MCLTheme.borderRightColor[this.classValue as ColorPalette]
|
|
355
|
+
}
|
|
356
|
+
// handle heading classes
|
|
357
|
+
getH1Class(): string {
|
|
358
|
+
if (!this.validateHeadingTextSizeType) {
|
|
359
|
+
return ' '
|
|
360
|
+
}
|
|
361
|
+
return MCLTheme.heading1[this.classValue as HeadingSize]
|
|
362
|
+
}
|
|
363
|
+
getH2Class(): string {
|
|
364
|
+
if (!this.validateHeadingTextSizeType) {
|
|
365
|
+
return ' '
|
|
366
|
+
}
|
|
367
|
+
return MCLTheme.heading2[this.classValue as HeadingSize]
|
|
368
|
+
}
|
|
369
|
+
getH3Class(): string {
|
|
370
|
+
if (!this.validateHeadingTextSizeType) {
|
|
371
|
+
return ' '
|
|
372
|
+
}
|
|
373
|
+
return MCLTheme.heading3[this.classValue as HeadingSize]
|
|
374
|
+
}
|
|
375
|
+
getH4Class(): string {
|
|
376
|
+
if (!this.validateHeadingTextSizeType) {
|
|
377
|
+
return ' '
|
|
378
|
+
}
|
|
379
|
+
return MCLTheme.heading4[this.classValue as HeadingSize]
|
|
380
|
+
}
|
|
381
|
+
// handle body text size classes
|
|
382
|
+
getBodyTextSizeClass(): string {
|
|
383
|
+
if (!this.validateBodyTextSizeType) {
|
|
384
|
+
return ' '
|
|
385
|
+
}
|
|
386
|
+
return MCLTheme.bodyText[this.classValue as BodyText]
|
|
387
|
+
}
|
|
388
|
+
// handle font weight classes
|
|
389
|
+
getFontWeightClass(): string {
|
|
390
|
+
if (!this.validateFontWeightType) {
|
|
391
|
+
return ' '
|
|
392
|
+
}
|
|
393
|
+
return MCLTheme.fontweight[this.classValue as FontWeight]
|
|
394
|
+
}
|
|
395
|
+
// handle text align classes
|
|
396
|
+
getTextAlignClass(): string {
|
|
397
|
+
return MCLTheme.textAlign[this.classValue as Position]
|
|
398
|
+
}
|
|
399
|
+
// handle border width classes
|
|
400
|
+
getBorderWidthClass(): string {
|
|
401
|
+
if (!this.validateRangeType) {
|
|
402
|
+
return ' '
|
|
403
|
+
}
|
|
404
|
+
return MCLTheme.borderWidth[this.classValue as Range<1, 12>]
|
|
405
|
+
}
|
|
406
|
+
getBorderXWidthClass(): string {
|
|
407
|
+
if (!this.validateRangeType) {
|
|
408
|
+
return ' '
|
|
409
|
+
}
|
|
410
|
+
return MCLTheme.borderXWidth[this.classValue as Range<1, 12>]
|
|
411
|
+
}
|
|
412
|
+
getBorderYWidthClass(): string {
|
|
413
|
+
if (!this.validateRangeType) {
|
|
414
|
+
return ' '
|
|
415
|
+
}
|
|
416
|
+
return MCLTheme.borderYWidth[this.classValue as Range<1, 12>]
|
|
417
|
+
}
|
|
418
|
+
getBorderTopWidthClass(): string {
|
|
419
|
+
if (!this.validateRangeType) {
|
|
420
|
+
return ' '
|
|
421
|
+
}
|
|
422
|
+
return MCLTheme.borderTopWidth[this.classValue as Range<1, 12>]
|
|
423
|
+
}
|
|
424
|
+
getBorderBottomWidthClass(): string {
|
|
425
|
+
if (!this.validateRangeType) {
|
|
426
|
+
return ' '
|
|
427
|
+
}
|
|
428
|
+
return MCLTheme.borderBottomWidth[this.classValue as Range<1, 12>]
|
|
429
|
+
}
|
|
430
|
+
getBorderLeftWidthClass(): string {
|
|
431
|
+
if (!this.validateRangeType) {
|
|
432
|
+
return ' '
|
|
433
|
+
}
|
|
434
|
+
return MCLTheme.borderLeftWidth[this.classValue as Range<1, 12>]
|
|
435
|
+
}
|
|
436
|
+
getBorderRightWidthClass(): string {
|
|
437
|
+
if (!this.validateRangeType) {
|
|
438
|
+
return ' '
|
|
439
|
+
}
|
|
440
|
+
return MCLTheme.borderRightWidth[this.classValue as Range<1, 12>]
|
|
441
|
+
}
|
|
442
|
+
// handle opacity classes
|
|
443
|
+
getOpacityClass(): string {
|
|
444
|
+
if (!this.validateOpacityType) {
|
|
445
|
+
return ' '
|
|
446
|
+
}
|
|
447
|
+
return MCLTheme.opacity[this.classValue as OpacityRange]
|
|
448
|
+
}
|
|
449
|
+
getBgOpacityClass(): string {
|
|
450
|
+
if (!this.validateOpacityType) {
|
|
451
|
+
return ' '
|
|
452
|
+
}
|
|
453
|
+
return MCLTheme.backgroundOpacity[this.classValue as OpacityRange]
|
|
454
|
+
}
|
|
455
|
+
// handle spacing classes
|
|
456
|
+
// margins
|
|
457
|
+
getMarginClass(): string {
|
|
458
|
+
if (!this.validateSpaceType) {
|
|
459
|
+
return ' '
|
|
460
|
+
}
|
|
461
|
+
return MCLTheme.margin[this.classValue as SpacingLevel]
|
|
462
|
+
}
|
|
463
|
+
getMarginXClass(): string {
|
|
464
|
+
if (!this.validateSpaceType) {
|
|
465
|
+
return ' '
|
|
466
|
+
}
|
|
467
|
+
return MCLTheme.marginX[this.classValue as SpacingLevel]
|
|
468
|
+
}
|
|
469
|
+
getMarginYClass(): string {
|
|
470
|
+
if (!this.validateSpaceType) {
|
|
471
|
+
return ' '
|
|
472
|
+
}
|
|
473
|
+
return MCLTheme.marginY[this.classValue as SpacingLevel]
|
|
474
|
+
}
|
|
475
|
+
getMarginTopClass(): string {
|
|
476
|
+
if (!this.validateSpaceType) {
|
|
477
|
+
return ' '
|
|
478
|
+
}
|
|
479
|
+
return MCLTheme.marginTop[this.classValue as SpacingLevel]
|
|
480
|
+
}
|
|
481
|
+
getMarginBottomClass(): string {
|
|
482
|
+
if (!this.validateSpaceType) {
|
|
483
|
+
return ' '
|
|
484
|
+
}
|
|
485
|
+
return MCLTheme.marginBottom[this.classValue as SpacingLevel]
|
|
486
|
+
}
|
|
487
|
+
getMarginLeftClass(): string {
|
|
488
|
+
if (!this.validateSpaceType) {
|
|
489
|
+
return ' '
|
|
490
|
+
}
|
|
491
|
+
return MCLTheme.marginLeft[this.classValue as SpacingLevel]
|
|
492
|
+
}
|
|
493
|
+
getMarginRightClass(): string {
|
|
494
|
+
if (!this.validateSpaceType) {
|
|
495
|
+
return ' '
|
|
496
|
+
}
|
|
497
|
+
return MCLTheme.marginRight[this.classValue as SpacingLevel]
|
|
498
|
+
}
|
|
499
|
+
// padding
|
|
500
|
+
getPaddingClass(): string {
|
|
501
|
+
if (!this.validateSpaceType) {
|
|
502
|
+
return ' '
|
|
503
|
+
}
|
|
504
|
+
return MCLTheme.padding[this.classValue as SpacingLevel]
|
|
505
|
+
}
|
|
506
|
+
getPaddingXClass(): string {
|
|
507
|
+
if (!this.validateSpaceType) {
|
|
508
|
+
return ' '
|
|
509
|
+
}
|
|
510
|
+
return MCLTheme.paddingX[this.classValue as SpacingLevel]
|
|
511
|
+
}
|
|
512
|
+
getPaddingYClass(): string {
|
|
513
|
+
if (!this.validateSpaceType) {
|
|
514
|
+
return ' '
|
|
515
|
+
}
|
|
516
|
+
return MCLTheme.paddingY[this.classValue as SpacingLevel]
|
|
517
|
+
}
|
|
518
|
+
getPaddingTopClass(): string {
|
|
519
|
+
if (!this.validateSpaceType) {
|
|
520
|
+
return ' '
|
|
521
|
+
}
|
|
522
|
+
return MCLTheme.paddingTop[this.classValue as SpacingLevel]
|
|
523
|
+
}
|
|
524
|
+
getPaddingBottomClass(): string {
|
|
525
|
+
if (!this.validateSpaceType) {
|
|
526
|
+
return ' '
|
|
527
|
+
}
|
|
528
|
+
return MCLTheme.paddingBottom[this.classValue as SpacingLevel]
|
|
529
|
+
}
|
|
530
|
+
getPaddingLeftClass(): string {
|
|
531
|
+
if (!this.validateSpaceType) {
|
|
532
|
+
return ' '
|
|
533
|
+
}
|
|
534
|
+
return MCLTheme.paddingLeft[this.classValue as SpacingLevel]
|
|
535
|
+
}
|
|
536
|
+
getPaddingRightClass(): string {
|
|
537
|
+
if (!this.validateSpaceType) {
|
|
538
|
+
return ' '
|
|
539
|
+
}
|
|
540
|
+
return MCLTheme.paddingRight[this.classValue as SpacingLevel]
|
|
541
|
+
}
|
|
542
|
+
// gap
|
|
543
|
+
getGapClass(): string {
|
|
544
|
+
if (!this.validateSpaceType) {
|
|
545
|
+
return ' '
|
|
546
|
+
}
|
|
547
|
+
return MCLTheme.gap[this.classValue as SpacingLevel]
|
|
548
|
+
}
|
|
549
|
+
// input validation
|
|
550
|
+
validateColorType(): boolean {
|
|
551
|
+
const validatorRe =
|
|
552
|
+
/(primary|secondary|success|info|warning|danger|light-1|light-2|light-3|light-4|dark-1|dark-2|dark-3|dark-4|black|white|transparent)/
|
|
553
|
+
if (typeof this.classValue !== 'string') {
|
|
554
|
+
return false
|
|
555
|
+
}
|
|
556
|
+
return validatorRe.test(this.classValue)
|
|
557
|
+
}
|
|
558
|
+
validateSpaceType(): boolean {
|
|
559
|
+
const validatorRe = /(0|3xs|2xs|xs|sm|md|lg|xl|2xl|3xl)/
|
|
560
|
+
if (typeof this.classValue !== 'string') {
|
|
561
|
+
return false
|
|
562
|
+
}
|
|
563
|
+
return validatorRe.test(this.classValue)
|
|
564
|
+
}
|
|
565
|
+
validateHeadingTextSizeType(): boolean {
|
|
566
|
+
const validatorRe = /(sm|md|lg|xl)/
|
|
567
|
+
if (typeof this.classValue !== 'string') {
|
|
568
|
+
return false
|
|
569
|
+
}
|
|
570
|
+
return validatorRe.test(this.classValue)
|
|
571
|
+
}
|
|
572
|
+
validateBodyTextSizeType(): boolean {
|
|
573
|
+
const validatorRe = /(xs|sm|md|lg|xl)/
|
|
574
|
+
if (typeof this.classValue !== 'string') {
|
|
575
|
+
return false
|
|
576
|
+
}
|
|
577
|
+
return validatorRe.test(this.classValue)
|
|
578
|
+
}
|
|
579
|
+
validateFontWeightType(): boolean {
|
|
580
|
+
const validatorRe = /(light|normal|bold)/
|
|
581
|
+
if (typeof this.classValue !== 'string') {
|
|
582
|
+
return false
|
|
583
|
+
}
|
|
584
|
+
return validatorRe.test(this.classValue)
|
|
585
|
+
}
|
|
586
|
+
validateOpacityType(): boolean {
|
|
587
|
+
const validatorRe = /\b(0|[1-9]0|100)\b/
|
|
588
|
+
if (typeof this.classValue !== 'number') {
|
|
589
|
+
return false
|
|
590
|
+
}
|
|
591
|
+
return validatorRe.test(this.classValue.toString())
|
|
592
|
+
}
|
|
593
|
+
validateRangeType(): boolean {
|
|
594
|
+
const validatorRe = /\b([1-9]|1[0-2])\b/
|
|
595
|
+
if (typeof this.classValue !== 'number') {
|
|
596
|
+
return false
|
|
597
|
+
}
|
|
598
|
+
return validatorRe.test(this.classValue.toString())
|
|
599
|
+
}
|
|
600
|
+
validateAlignment(): boolean {
|
|
601
|
+
const validatorRe = /(left|center|right)/
|
|
602
|
+
if (typeof this.classValue !== 'string') {
|
|
603
|
+
return false
|
|
604
|
+
}
|
|
605
|
+
return validatorRe.test(this.classValue)
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
export default GenerateMCLClass
|