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