@bobbykim/manguito-theme 0.2.0 → 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/README.md CHANGED
@@ -92,7 +92,7 @@ import type { <Type you need> } from '@bobbykim/manguito-theme/theme/theme.types
92
92
  <template>...</template>
93
93
  ```
94
94
 
95
- ## Authors
95
+ ## Maintainers
96
96
 
97
97
  - **Bobby Kim** - _Initial work_
98
98
 
package/index.ts CHANGED
@@ -1,10 +1,28 @@
1
- import GenerateMCLClass from './theme'
2
- import type { ClassType, InputType } from './theme'
1
+ import GenerateMCLClass, {
2
+ colorType,
3
+ textType,
4
+ borderWidthType,
5
+ scaleType,
6
+ } from './theme'
7
+ import type { ClassType, InputType } from './theme/index.js'
3
8
 
4
9
  const generateClass = (type: ClassType, value: InputType): string => {
10
+ console.log('running generate class')
5
11
  const mclGenerate = new GenerateMCLClass(type, value)
6
-
7
- return mclGenerate.generateClassName()
12
+ if ((<string[]>(<unknown>colorType)).includes(type)) {
13
+ return mclGenerate.generateColorClass()
14
+ }
15
+ if ((<string[]>(<unknown>textType)).includes(type)) {
16
+ return mclGenerate.generateTextClass()
17
+ }
18
+ if ((<string[]>(<unknown>borderWidthType)).includes(type)) {
19
+ return mclGenerate.generateBorderWidthClass()
20
+ }
21
+ if ((<string[]>(<unknown>scaleType)).includes(type)) {
22
+ return mclGenerate.generateScaleClass()
23
+ }
24
+ // return spacing type if all of above is false
25
+ return mclGenerate.generateSpacingClass()
8
26
  }
9
27
 
10
28
  export default generateClass
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobbykim/manguito-theme",
3
- "version": "0.2.0",
3
+ "version": "0.3.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": "aaee823ffe3d684532eb08f0553b96a4a5475a88"
20
+ "gitHead": "2c169fa8137650bf3fbc02ef2158c4c4e147a9ce"
21
21
  }
package/theme/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import MCLTheme from './theme'
1
+ import MCLTheme from './theme.js'
2
2
  import type {
3
3
  ColorPalette,
4
4
  HeadingSize,
@@ -16,68 +16,82 @@ import type {
16
16
  * @Export GenerateMCLClass - extends MCLTheme class
17
17
  */
18
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'
19
+ export const colorType = [
20
+ 'BGCOLOR',
21
+ 'BEFOREBG',
22
+ 'AFTERBG',
23
+ 'HVBGCOLOR',
24
+ 'ACTIVEBG',
25
+ 'TEXTCOLOR',
26
+ 'HVTEXTCOLOR',
27
+ 'DISABLEDTEXTCOLOR',
28
+ 'SVGFILL',
29
+ 'RINGCOLOR',
30
+ 'FOCUSRING',
31
+ 'ACTIVERING',
32
+ 'OFFSETRING',
33
+ 'DUMMYCOLOR',
34
+ 'BTNCOLOR',
35
+ 'LISTCOLOR',
36
+ 'BORDER',
37
+ 'BORDERX',
38
+ 'BORDERY',
39
+ 'BORDERT',
40
+ 'BORDERB',
41
+ 'BORDERL',
42
+ 'BORDERR',
43
+ ] as const
44
+
45
+ export const textType = [
46
+ 'H1',
47
+ 'H2',
48
+ 'H3',
49
+ 'H4',
50
+ 'BODYTEXT',
51
+ 'FONTWEIGHT',
52
+ 'TEXTALIGN',
53
+ ] as const
54
+ export const borderWidthType = [
55
+ 'BORDERW',
56
+ 'BORDERXW',
57
+ 'BORDERYW',
58
+ 'BORDERTW',
59
+ 'BORDERBW',
60
+ 'BORDERLW',
61
+ 'BORDERRW',
62
+ ] as const
63
+ export const scaleType = ['BGOPACITY', 'OPACITY'] as const
64
+ export const spacingType = [
65
+ 'MARGIN',
66
+ 'MARGINX',
67
+ 'MARGINY',
68
+ 'MARGINT',
69
+ 'MARGINB',
70
+ 'MARGINL',
71
+ 'MARGINR',
72
+ 'PADDING',
73
+ 'PADDINGX',
74
+ 'PADDINGY',
75
+ 'PADDINGT',
76
+ 'PADDINGB',
77
+ 'PADDINGL',
78
+ 'PADDINGR',
79
+ 'GAP',
80
+ ] as const
81
+ const allType = [
82
+ ...colorType,
83
+ ...textType,
84
+ ...borderWidthType,
85
+ ...scaleType,
86
+ ...spacingType,
87
+ ] as const
88
+
89
+ export type ClassType = (typeof allType)[number]
90
+ export type ColorClassType = (typeof colorType)[number]
91
+ export type TextClassType = (typeof textType)[number]
92
+ export type BorderWidthClassType = (typeof borderWidthType)[number]
93
+ export type ScaleClassType = (typeof scaleType)[number]
94
+ export type SpacingClassType = (typeof spacingType)[number]
81
95
 
82
96
  export type InputType =
83
97
  | ColorPalette
@@ -98,9 +112,9 @@ class GenerateMCLClass extends MCLTheme {
98
112
  this.classType = classType
99
113
  this.classValue = classValue
100
114
  }
101
- generateClassName(): string {
115
+ // handle color classes types
116
+ generateColorClass(): string {
102
117
  switch (this.classType) {
103
- // case: color class
104
118
  case 'BGCOLOR':
105
119
  return this.getBgColorClass()
106
120
  case 'HVBGCOLOR':
@@ -125,11 +139,12 @@ class GenerateMCLClass extends MCLTheme {
125
139
  return this.getFocusRingColorClass()
126
140
  case 'ACTIVERING':
127
141
  return this.getActiveRingColorClass()
142
+ case 'OFFSETRING':
143
+ return this.getRingOffsetColorClass()
128
144
  case 'BTNCOLOR':
129
145
  return this.getBtnColorClass()
130
146
  case 'LISTCOLOR':
131
147
  return this.getRingColorClass()
132
- // case: border color class
133
148
  case 'BORDER':
134
149
  return this.getBorderColorClass()
135
150
  case 'BORDERX':
@@ -144,6 +159,13 @@ class GenerateMCLClass extends MCLTheme {
144
159
  return this.getBorderLeftColorClass()
145
160
  case 'BORDERR':
146
161
  return this.getBorderRightColorClass()
162
+ default:
163
+ return ' '
164
+ }
165
+ }
166
+ // handle text class types
167
+ generateTextClass(): string {
168
+ switch (this.classType) {
147
169
  // case: heading text class
148
170
  case 'H1':
149
171
  return this.getH1Class()
@@ -162,6 +184,13 @@ class GenerateMCLClass extends MCLTheme {
162
184
  // case: text alignment class
163
185
  case 'TEXTALIGN':
164
186
  return this.getTextAlignClass()
187
+ default:
188
+ return ' '
189
+ }
190
+ }
191
+ // handle border width class types
192
+ generateBorderWidthClass(): string {
193
+ switch (this.classType) {
165
194
  // case: border width class
166
195
  case 'BORDERW':
167
196
  return this.getBorderWidthClass()
@@ -177,13 +206,24 @@ class GenerateMCLClass extends MCLTheme {
177
206
  return this.getBorderLeftWidthClass()
178
207
  case 'BORDERRW':
179
208
  return this.getBorderWidthClass()
209
+ default:
210
+ return ' '
211
+ }
212
+ }
213
+ generateScaleClass(): string {
214
+ switch (this.classType) {
180
215
  // case: opacity class
181
216
  case 'OPACITY':
182
217
  return this.getOpacityClass()
183
218
  case 'BGOPACITY':
184
219
  return this.getBgOpacityClass()
185
- // case: spacing class
186
- // margins
220
+ default:
221
+ return ' '
222
+ }
223
+ }
224
+ generateSpacingClass(): string {
225
+ switch (this.classType) {
226
+ // case: margins
187
227
  case 'MARGIN':
188
228
  return this.getMarginClass()
189
229
  case 'MARGINX':
@@ -198,7 +238,7 @@ class GenerateMCLClass extends MCLTheme {
198
238
  return this.getMarginLeftClass()
199
239
  case 'MARGINR':
200
240
  return this.getMarginRightClass()
201
- // paddings
241
+ // case: paddings
202
242
  case 'PADDING':
203
243
  return this.getPaddingClass()
204
244
  case 'PADDINGX':
@@ -213,7 +253,7 @@ class GenerateMCLClass extends MCLTheme {
213
253
  return this.getPaddingLeftClass()
214
254
  case 'PADDINGR':
215
255
  return this.getPaddingRightClass()
216
- // gap
256
+ // case: gap
217
257
  case 'GAP':
218
258
  return this.getGapClass()
219
259
  default:
@@ -297,6 +337,12 @@ class GenerateMCLClass extends MCLTheme {
297
337
  }
298
338
  return MCLTheme.ringActiveColor[this.classValue as ColorPalette]
299
339
  }
340
+ getRingOffsetColorClass(): string {
341
+ if (!this.validateColorType) {
342
+ return ' '
343
+ }
344
+ return MCLTheme.ringOffsetColor[this.classValue as ColorPalette]
345
+ }
300
346
  // btn & list
301
347
  getBtnColorClass(): string {
302
348
  if (!this.validateColorType) {
@@ -604,6 +650,9 @@ class GenerateMCLClass extends MCLTheme {
604
650
  }
605
651
  return validatorRe.test(this.classValue)
606
652
  }
653
+ dummyMethod(): any {
654
+ return this.getRingOffsetColorClass()
655
+ }
607
656
  }
608
657
 
609
658
  export default GenerateMCLClass
package/theme/theme.ts CHANGED
@@ -3,93 +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
87
37
  }
88
-
89
- export interface Alignment {
90
- left: string
91
- center: string
92
- right: string
38
+ export type Alignment = {
39
+ [key in Position]: string
93
40
  }
94
41
 
95
42
  abstract class MCLTheme {
@@ -333,6 +280,45 @@ abstract class MCLTheme {
333
280
  white: 'active:ring-white',
334
281
  transparent: 'active:ring-transparent',
335
282
  }
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
+ }
336
322
  // btn color class
337
323
  protected static btnColor: ColorClass = {
338
324
  primary: 'btn-primary',
@@ -57,6 +57,7 @@ export type Range<T extends number, R extends number> = IntRange<
57
57
  _RangeArray<T>,
58
58
  R
59
59
  >
60
+
60
61
  export type ButtonSize = 'small' | 'medium' | 'large'
61
62
  export type OpacityRange = 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100
62
63
  export type Directions = 'left' | 'right'
@@ -4,7 +4,6 @@ const mclTheme = plugin.withOptions(
4
4
  () => {
5
5
  return ({ addBase, theme, addComponents, addUtilities, e }) => {
6
6
  const colors = theme('colors')
7
- // console.log(colors)
8
7
  const listColors = Object.keys(colors).reduce((accumulator, key) => {
9
8
  if (typeof colors[key] === 'string') {
10
9
  return {
@@ -29,6 +28,34 @@ const mclTheme = plugin.withOptions(
29
28
  ),
30
29
  }
31
30
  }, {})
31
+ const linkColors = Object.keys(colors).reduce((accumulator, key) => {
32
+ const invalidKeys = ['current', 'transparent', 'inherit']
33
+ if (invalidKeys.includes(key)) {
34
+ return
35
+ }
36
+ if (typeof colors[key] === 'string') {
37
+ return {
38
+ ...accumulator,
39
+ [`.mcl-link.text-${e(key)}`]: {
40
+ '&:hover': {
41
+ [`@apply text-${key}/60`]: {},
42
+ },
43
+ },
44
+ }
45
+ }
46
+ const colorShades = Object.keys(colors[key])
47
+ return {
48
+ ...accumulator,
49
+ ...colorShades.reduce((acc, level) => ({
50
+ ...acc,
51
+ [`.mcl-link.text-${e(key)}-${level}`]: {
52
+ '&:hover': {
53
+ [`@apply text-${key}-${level}/60`]: {},
54
+ },
55
+ },
56
+ })),
57
+ }
58
+ })
32
59
  const btnColors = Object.keys(colors).reduce((accumulator, key) => {
33
60
  if (typeof colors[key] === 'string') {
34
61
  return {
@@ -56,6 +83,13 @@ const mclTheme = plugin.withOptions(
56
83
  '@apply ring-0': {},
57
84
  },
58
85
  },
86
+ [`.btn.btn-progress.btn-${e(key)}`]: {
87
+ [`@apply before:bg-${key} border-${key} text-${key} bg-transparent`]:
88
+ {},
89
+ '&:hover, &:focus': {
90
+ '@apply text-white': {},
91
+ },
92
+ },
59
93
  }
60
94
  }
61
95
 
@@ -90,6 +124,13 @@ const mclTheme = plugin.withOptions(
90
124
  '@apply ring-0': {},
91
125
  },
92
126
  },
127
+ [`.btn.btn-progress.btn-${e(key)}-${level}`]: {
128
+ [`@apply before:bg-${key}-${level} border-${key}-${level} text-${key}-${level} bg-transparent`]:
129
+ {},
130
+ '&:hover, &:focus': {
131
+ '@apply text-white': {},
132
+ },
133
+ },
93
134
  }),
94
135
  {}
95
136
  ),
@@ -252,6 +293,10 @@ const mclTheme = plugin.withOptions(
252
293
  '.mcl-link': {
253
294
  color: theme('colors.primary'),
254
295
  textDecoration: 'underline',
296
+ '@apply transition-colors duration-200 ease-in': {},
297
+ '&:hover': {
298
+ '@apply text-primary/60': {},
299
+ },
255
300
  },
256
301
  '.mcl-list': {
257
302
  'list-style-position': 'inside',
@@ -325,10 +370,47 @@ const mclTheme = plugin.withOptions(
325
370
  '@apply bg-primary text-white bg-opacity-100': {},
326
371
  },
327
372
  },
373
+ '.btn.btn-progress': {
374
+ position: 'relative',
375
+ '&::before': {
376
+ content: '""',
377
+ position: 'absolute',
378
+ height: '100%',
379
+ width: '0',
380
+ bottom: '0',
381
+ left: '0',
382
+ transition: 'width 300ms linear',
383
+ },
384
+ '@apply before:bg-primary border-2 border-primary text-primary bg-transparent':
385
+ {},
386
+ },
387
+ '.btn.btn-progress > *': {
388
+ position: 'relative',
389
+ },
390
+ '.btn.btn-progress.btn-progress-r': {
391
+ '&::before': {
392
+ left: '100%',
393
+ transition: 'all 300ms linear',
394
+ },
395
+ },
396
+ '.btn.btn-progress:hover, .btn.btn-progress:focus': {
397
+ '@apply text-white': {},
398
+ '&::before': {
399
+ width: '100%',
400
+ },
401
+ },
402
+ '.btn.btn-progress.btn-progress-r:hover, .btn.btn-progress.btn-progress-r:focus':
403
+ {
404
+ '&::before': {
405
+ width: '100%',
406
+ left: '0',
407
+ },
408
+ },
328
409
  })
329
410
 
330
411
  addUtilities(listColors)
331
412
  addUtilities(btnColors)
413
+ addUtilities(linkColors)
332
414
  }
333
415
  },
334
416
  (options = {}) => {