@bobbykim/manguito-theme 0.1.0 → 0.1.2

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/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022-present Bobby Kim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @bobbykim/manguito-theme
2
+
3
+ manguito-theme includes basic config for MCL, including theme.types and generateClass function that returns tailwindCSS style classes.
4
+
5
+ ## Demo
6
+
7
+ [MCL Histoire Page](https://manguito-component-library.vercel.app/story/src-stories-documentation-mcltheme-story-vue?variantId=src-stories-documentation-mcltheme-story-vue-0)
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm i -D tailwindcss postcss autoprefixer sass
13
+ npm i @bobbykim/manguito-theme
14
+ npx tailwindcss init -p
15
+ ```
16
+
17
+ ## Setup
18
+
19
+ tailwind.config.cjs
20
+
21
+ ```cjs
22
+ const {
23
+ mclTheme,
24
+ mclHeading,
25
+ } = require('@bobbykim/manguito-theme/themeVariables.cjs')
26
+
27
+ module.exports = {
28
+ content: [
29
+ './src/**/*.{vue,ts,js,cjs}',
30
+ './node_modules/@bobbykim/**/*.{vue,ts,js,cjs}',
31
+ ],
32
+ theme: mclTheme,
33
+ plugins: [mclHeading],
34
+ }
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ `import generateClass from '@bobbykim/manguito-theme'`
40
+
41
+ in Vue component file.
42
+
43
+ ```vue
44
+ <script setup lang="ts">
45
+ ...
46
+ import generateClass from '@bobbykim/manguito-theme'
47
+ import type { <Type you need> } from '@bobbykim/manguito-theme/theme/theme.types'
48
+ ...
49
+ </script>
50
+
51
+ <template>...</template>
52
+ ```
53
+
54
+ ## Authors
55
+
56
+ - **Bobby Kim** - _Initial work_
57
+
58
+ ## License
59
+
60
+ This project is licensed under the MIT License - see the [LICENSE.md](./LICENSE.md) file for details
package/index.ts CHANGED
@@ -1,10 +1,10 @@
1
- import GenerateMCLClass from './theme/generateClass'
2
- import type { ClassType, InputType } from './theme/generateClass'
3
-
4
- const generateClass = (type: ClassType, value: InputType): string => {
5
- const mclGenerate = new GenerateMCLClass(type, value)
6
-
7
- return mclGenerate.generateClassName()
8
- }
9
-
10
- export default generateClass
1
+ import GenerateMCLClass from './theme/generateClass'
2
+ import type { ClassType, InputType } from './theme/generateClass'
3
+
4
+ const generateClass = (type: ClassType, value: InputType): string => {
5
+ const mclGenerate = new GenerateMCLClass(type, value)
6
+
7
+ return mclGenerate.generateClassName()
8
+ }
9
+
10
+ export default generateClass
package/package.json CHANGED
@@ -1,19 +1,21 @@
1
- {
2
- "name": "@bobbykim/manguito-theme",
3
- "version": "0.1.0",
4
- "description": "main theme file for manguito components library. Other MCL components will need to import this file to run.",
5
- "type": "module",
6
- "main": "index.ts",
7
- "publishConfig": {
8
- "access": "public"
9
- },
10
- "author": {
11
- "name": "Bobby Kim",
12
- "url": "https://www.devbobbykim.com/"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "https://github.com/bobbykim89/manguito-component-library.git"
17
- },
18
- "license": "MIT"
19
- }
1
+ {
2
+ "name": "@bobbykim/manguito-theme",
3
+ "version": "0.1.2",
4
+ "description": "main theme file for manguito components library. Other MCL components will need to import this file to run.",
5
+ "type": "module",
6
+ "main": "index.ts",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "author": {
11
+ "name": "Bobby Kim",
12
+ "url": "https://www.devbobbykim.com/"
13
+ },
14
+ "homepage": "https://manguito-component-library.vercel.app/",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/bobbykim89/manguito-component-library.git"
18
+ },
19
+ "license": "MIT",
20
+ "gitHead": "043ea8b9d21660b299d1d70e37b135dded540170"
21
+ }
@@ -1,231 +1,231 @@
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
-
49
- export type InputType =
50
- | ColorPalette
51
- | HeadingSize
52
- | BodyText
53
- | FontWeight
54
- | Range<12>
55
- | OpacityRange
56
- | SpacingLevel
57
-
58
- class GenerateMCLClass extends MCLTheme {
59
- classType: ClassType
60
- classValue: InputType
61
-
62
- constructor(classType: ClassType, classValue: InputType) {
63
- super()
64
- this.classType = classType
65
- this.classValue = classValue
66
- }
67
- generateClassName(): string {
68
- switch (this.classType) {
69
- case 'BGCOLOR':
70
- case 'BEFOREBG':
71
- case 'AFTERBG':
72
- case 'TEXTCOLOR':
73
- case 'DISABLEDTEXTCOLOR':
74
- case 'SVGFILL':
75
- case 'RINGCOLOR':
76
- case 'FOCUSRING':
77
- case 'ACTIVERING':
78
- case 'ACTIVEBG':
79
- return this.getColorClass()
80
- case 'HVBGCOLOR':
81
- case 'HVTEXTCOLOR':
82
- return this.getHoverColorClass()
83
- case 'H1':
84
- case 'H2':
85
- case 'H3':
86
- case 'H4':
87
- return this.getHeadingTextSizeClass()
88
- case 'BODYTEXT':
89
- return this.getBodyTextSizeClass()
90
- case 'FONTWEIGHT':
91
- return this.getFontWeightClass()
92
- case 'BORDER':
93
- case 'BORDERX':
94
- case 'BORDERY':
95
- case 'BORDERT':
96
- case 'BORDERB':
97
- case 'BORDERL':
98
- return this.getBorderColorClass()
99
- case 'BORDERTW':
100
- case 'BORDERLW':
101
- return this.getBorderWidthClass()
102
- case 'BGOPACITY':
103
- return this.getBgOpacityClass()
104
- case 'OPACITY':
105
- return this.getOpacityClass()
106
- case 'MARGINB':
107
- return this.getSpacingClass()
108
- default:
109
- return
110
- }
111
- }
112
- getColorClass(): string {
113
- const {
114
- bgColor,
115
- beforeBgColor,
116
- afterBgColor,
117
- textColor,
118
- disabledTextColor,
119
- svgFillColor,
120
- ringColor,
121
- ringFocusColor,
122
- ringActiveColor,
123
- bgActiveColor,
124
- } = MCLTheme
125
- if (this.classType === 'BGCOLOR') {
126
- return bgColor[this.classValue]
127
- }
128
- if (this.classType === 'BEFOREBG') {
129
- return beforeBgColor[this.classValue]
130
- }
131
- if (this.classType === 'AFTERBG') {
132
- return afterBgColor[this.classValue]
133
- }
134
- if (this.classType === 'TEXTCOLOR') {
135
- return textColor[this.classValue]
136
- }
137
- if (this.classType === 'DISABLEDTEXTCOLOR') {
138
- return disabledTextColor[this.classValue]
139
- }
140
- if (this.classType === 'SVGFILL') {
141
- return svgFillColor[this.classValue]
142
- }
143
- if (this.classType === 'FOCUSRING') {
144
- return ringFocusColor[this.classValue]
145
- }
146
- if (this.classType === 'ACTIVERING') {
147
- return ringActiveColor[this.classValue]
148
- }
149
- if (this.classType === 'ACTIVEBG') {
150
- return bgActiveColor[this.classValue]
151
- }
152
- return ringColor[this.classValue]
153
- }
154
- getHoverColorClass(): string {
155
- const { hoverBgColor, hoverTextColor } = MCLTheme
156
- if (this.classType === 'HVBGCOLOR') {
157
- return hoverBgColor[this.classValue]
158
- }
159
- return hoverTextColor[this.classValue]
160
- }
161
- getHeadingTextSizeClass(): string {
162
- const { heading1, heading2, heading3, heading4 } = MCLTheme
163
- if (this.classType === 'H1') {
164
- return heading1[this.classValue]
165
- }
166
- if (this.classType === 'H2') {
167
- return heading2[this.classValue]
168
- }
169
- if (this.classType === 'H3') {
170
- return heading3[this.classValue]
171
- }
172
- return heading4[this.classValue]
173
- }
174
- getBodyTextSizeClass(): string {
175
- const { bodyText } = MCLTheme
176
- return bodyText[this.classValue]
177
- }
178
- getFontWeightClass(): string {
179
- const { fontweight } = MCLTheme
180
- return fontweight[this.classValue]
181
- }
182
- getBorderColorClass(): string {
183
- const {
184
- borderColor,
185
- borderXColor,
186
- borderYColor,
187
- borderTopColor,
188
- borderBottomColor,
189
- borderLeftColor,
190
- } = MCLTheme
191
- if (this.classType === 'BORDERX') {
192
- return borderXColor[this.classValue]
193
- }
194
- if (this.classType === 'BORDERY') {
195
- return borderYColor[this.classValue]
196
- }
197
- if (this.classType === 'BORDERT') {
198
- return borderTopColor[this.classValue]
199
- }
200
- if (this.classType === 'BORDERB') {
201
- return borderBottomColor[this.classValue]
202
- }
203
- if (this.classType === 'BORDERL') {
204
- return borderLeftColor[this.classValue]
205
- }
206
- return borderColor[this.classValue]
207
- }
208
- getBorderWidthClass(): string {
209
- const { borderTopWidth, borderLeftWidth } = MCLTheme
210
- if (this.classType === 'BORDERTW') {
211
- return borderTopWidth[this.classValue]
212
- }
213
- return borderLeftWidth[this.classValue]
214
- }
215
- getBgOpacityClass(): string {
216
- const { backgroundOpacity } = MCLTheme
217
- return backgroundOpacity[this.classValue]
218
- }
219
- getOpacityClass(): string {
220
- const { opacity } = MCLTheme
221
- return opacity[this.classValue]
222
- }
223
- getSpacingClass(): string {
224
- const { marginBottom } = MCLTheme
225
- if (this.classType === 'MARGINB') {
226
- return marginBottom[this.classValue]
227
- }
228
- }
229
- }
230
-
231
- export default GenerateMCLClass
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
+
49
+ export type InputType =
50
+ | ColorPalette
51
+ | HeadingSize
52
+ | BodyText
53
+ | FontWeight
54
+ | Range<12>
55
+ | OpacityRange
56
+ | SpacingLevel
57
+
58
+ class GenerateMCLClass extends MCLTheme {
59
+ classType: ClassType
60
+ classValue: InputType
61
+
62
+ constructor(classType: ClassType, classValue: InputType) {
63
+ super()
64
+ this.classType = classType
65
+ this.classValue = classValue
66
+ }
67
+ generateClassName(): string {
68
+ switch (this.classType) {
69
+ case 'BGCOLOR':
70
+ case 'BEFOREBG':
71
+ case 'AFTERBG':
72
+ case 'TEXTCOLOR':
73
+ case 'DISABLEDTEXTCOLOR':
74
+ case 'SVGFILL':
75
+ case 'RINGCOLOR':
76
+ case 'FOCUSRING':
77
+ case 'ACTIVERING':
78
+ case 'ACTIVEBG':
79
+ return this.getColorClass()
80
+ case 'HVBGCOLOR':
81
+ case 'HVTEXTCOLOR':
82
+ return this.getHoverColorClass()
83
+ case 'H1':
84
+ case 'H2':
85
+ case 'H3':
86
+ case 'H4':
87
+ return this.getHeadingTextSizeClass()
88
+ case 'BODYTEXT':
89
+ return this.getBodyTextSizeClass()
90
+ case 'FONTWEIGHT':
91
+ return this.getFontWeightClass()
92
+ case 'BORDER':
93
+ case 'BORDERX':
94
+ case 'BORDERY':
95
+ case 'BORDERT':
96
+ case 'BORDERB':
97
+ case 'BORDERL':
98
+ return this.getBorderColorClass()
99
+ case 'BORDERTW':
100
+ case 'BORDERLW':
101
+ return this.getBorderWidthClass()
102
+ case 'BGOPACITY':
103
+ return this.getBgOpacityClass()
104
+ case 'OPACITY':
105
+ return this.getOpacityClass()
106
+ case 'MARGINB':
107
+ return this.getSpacingClass()
108
+ default:
109
+ return
110
+ }
111
+ }
112
+ getColorClass(): string {
113
+ const {
114
+ bgColor,
115
+ beforeBgColor,
116
+ afterBgColor,
117
+ textColor,
118
+ disabledTextColor,
119
+ svgFillColor,
120
+ ringColor,
121
+ ringFocusColor,
122
+ ringActiveColor,
123
+ bgActiveColor,
124
+ } = MCLTheme
125
+ if (this.classType === 'BGCOLOR') {
126
+ return bgColor[this.classValue]
127
+ }
128
+ if (this.classType === 'BEFOREBG') {
129
+ return beforeBgColor[this.classValue]
130
+ }
131
+ if (this.classType === 'AFTERBG') {
132
+ return afterBgColor[this.classValue]
133
+ }
134
+ if (this.classType === 'TEXTCOLOR') {
135
+ return textColor[this.classValue]
136
+ }
137
+ if (this.classType === 'DISABLEDTEXTCOLOR') {
138
+ return disabledTextColor[this.classValue]
139
+ }
140
+ if (this.classType === 'SVGFILL') {
141
+ return svgFillColor[this.classValue]
142
+ }
143
+ if (this.classType === 'FOCUSRING') {
144
+ return ringFocusColor[this.classValue]
145
+ }
146
+ if (this.classType === 'ACTIVERING') {
147
+ return ringActiveColor[this.classValue]
148
+ }
149
+ if (this.classType === 'ACTIVEBG') {
150
+ return bgActiveColor[this.classValue]
151
+ }
152
+ return ringColor[this.classValue]
153
+ }
154
+ getHoverColorClass(): string {
155
+ const { hoverBgColor, hoverTextColor } = MCLTheme
156
+ if (this.classType === 'HVBGCOLOR') {
157
+ return hoverBgColor[this.classValue]
158
+ }
159
+ return hoverTextColor[this.classValue]
160
+ }
161
+ getHeadingTextSizeClass(): string {
162
+ const { heading1, heading2, heading3, heading4 } = MCLTheme
163
+ if (this.classType === 'H1') {
164
+ return heading1[this.classValue]
165
+ }
166
+ if (this.classType === 'H2') {
167
+ return heading2[this.classValue]
168
+ }
169
+ if (this.classType === 'H3') {
170
+ return heading3[this.classValue]
171
+ }
172
+ return heading4[this.classValue]
173
+ }
174
+ getBodyTextSizeClass(): string {
175
+ const { bodyText } = MCLTheme
176
+ return bodyText[this.classValue]
177
+ }
178
+ getFontWeightClass(): string {
179
+ const { fontweight } = MCLTheme
180
+ return fontweight[this.classValue]
181
+ }
182
+ getBorderColorClass(): string {
183
+ const {
184
+ borderColor,
185
+ borderXColor,
186
+ borderYColor,
187
+ borderTopColor,
188
+ borderBottomColor,
189
+ borderLeftColor,
190
+ } = MCLTheme
191
+ if (this.classType === 'BORDERX') {
192
+ return borderXColor[this.classValue]
193
+ }
194
+ if (this.classType === 'BORDERY') {
195
+ return borderYColor[this.classValue]
196
+ }
197
+ if (this.classType === 'BORDERT') {
198
+ return borderTopColor[this.classValue]
199
+ }
200
+ if (this.classType === 'BORDERB') {
201
+ return borderBottomColor[this.classValue]
202
+ }
203
+ if (this.classType === 'BORDERL') {
204
+ return borderLeftColor[this.classValue]
205
+ }
206
+ return borderColor[this.classValue]
207
+ }
208
+ getBorderWidthClass(): string {
209
+ const { borderTopWidth, borderLeftWidth } = MCLTheme
210
+ if (this.classType === 'BORDERTW') {
211
+ return borderTopWidth[this.classValue]
212
+ }
213
+ return borderLeftWidth[this.classValue]
214
+ }
215
+ getBgOpacityClass(): string {
216
+ const { backgroundOpacity } = MCLTheme
217
+ return backgroundOpacity[this.classValue]
218
+ }
219
+ getOpacityClass(): string {
220
+ const { opacity } = MCLTheme
221
+ return opacity[this.classValue]
222
+ }
223
+ getSpacingClass(): string {
224
+ const { marginBottom } = MCLTheme
225
+ if (this.classType === 'MARGINB') {
226
+ return marginBottom[this.classValue]
227
+ }
228
+ }
229
+ }
230
+
231
+ export default GenerateMCLClass