maru_design2 0.0.1 → 0.0.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.
Files changed (47) hide show
  1. package/dist/components/atoms/button/Button.d.ts +26 -5
  2. package/dist/components/atoms/button/index.d.ts +1 -1
  3. package/dist/components/atoms/checkbox/Checkbox.d.ts +22 -0
  4. package/dist/components/atoms/checkbox/index.d.ts +1 -0
  5. package/dist/components/atoms/chip/Chip.d.ts +25 -0
  6. package/dist/components/atoms/chip/index.d.ts +1 -0
  7. package/dist/components/atoms/icon/Icon.d.ts +18 -0
  8. package/dist/components/atoms/icon/iconmap.d.ts +188 -0
  9. package/dist/components/atoms/icon/index.d.ts +1 -0
  10. package/dist/components/atoms/input/Input.d.ts +32 -0
  11. package/dist/components/atoms/input/index.d.ts +1 -0
  12. package/dist/components/atoms/popover/Popover.d.ts +24 -0
  13. package/dist/components/atoms/popover/index.d.ts +1 -0
  14. package/dist/components/atoms/radio/Radio.d.ts +13 -0
  15. package/dist/components/atoms/radio/index.d.ts +1 -0
  16. package/dist/components/atoms/toggle/Toggle.d.ts +21 -0
  17. package/dist/components/atoms/toggle/index.d.ts +1 -0
  18. package/dist/components/atoms/tooltip/Tooltip.d.ts +23 -0
  19. package/dist/components/atoms/tooltip/index.d.ts +1 -0
  20. package/dist/components/molecules/dropdown/Dropdown.d.ts +89 -0
  21. package/dist/components/molecules/dropdown/Menu.d.ts +21 -0
  22. package/dist/components/molecules/dropdown/index.d.ts +1 -0
  23. package/dist/components/molecules/dropdown/toggles/Arrow.d.ts +7 -0
  24. package/dist/components/molecules/dropdown/toggles/Button.d.ts +24 -0
  25. package/dist/components/molecules/dropdown/toggles/Clear.d.ts +8 -0
  26. package/dist/components/molecules/dropdown/toggles/Input.d.ts +24 -0
  27. package/dist/components/molecules/modal/Modal.d.ts +51 -0
  28. package/dist/components/molecules/modal/index.d.ts +1 -0
  29. package/dist/components/molecules/pagination/Pagination.d.ts +27 -0
  30. package/dist/components/molecules/pagination/index.d.ts +1 -0
  31. package/dist/components/styleProvider/StyleProvider.d.ts +10 -0
  32. package/dist/components/styleProvider/index.d.ts +1 -0
  33. package/dist/enums/color.d.ts +13 -0
  34. package/dist/enums/direction.d.ts +2 -0
  35. package/dist/enums/gap.d.ts +2 -0
  36. package/dist/enums/size.d.ts +10 -0
  37. package/dist/enums/type.d.ts +4 -0
  38. package/dist/enums/variant.d.ts +4 -0
  39. package/dist/hooks/useButtonState.d.ts +18 -0
  40. package/dist/hooks/useColor.d.ts +4 -0
  41. package/dist/hooks/useCombineRef.d.ts +1 -1
  42. package/dist/hooks/useCreatePortal.d.ts +1 -1
  43. package/dist/hooks/useId.d.ts +7 -0
  44. package/dist/index.d.ts +13 -1
  45. package/dist/index.js +3281 -8
  46. package/package.json +21 -18
  47. package/scripts/svg-parser.js +224 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maru_design2",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "./dist/index.js",
5
5
  "author": "zena-42maru",
6
6
  "license": "MIT",
@@ -13,34 +13,37 @@
13
13
  "@babel/preset-env": "^7.24.4",
14
14
  "@babel/preset-react": "^7.24.1",
15
15
  "@babel/preset-typescript": "^7.24.1",
16
+ "@chromatic-com/storybook": "^1",
17
+ "@popperjs/core": "^2.11.6",
16
18
  "@rollup/plugin-babel": "^5.3.1",
17
19
  "@rollup/plugin-commonjs": "^22.0.2",
18
20
  "@rollup/plugin-image": "^2.1.1",
19
21
  "@rollup/plugin-node-resolve": "^13.3.0",
20
22
  "@rollup/plugin-typescript": "^8.3.4",
21
- "@storybook/addon-actions": "^8.0.6",
22
- "@storybook/addon-essentials": "^8.0.6",
23
- "@storybook/addon-interactions": "^8.0.6",
24
- "@storybook/addon-links": "^8.0.6",
23
+ "@storybook/addon-actions": "^8.0.9",
24
+ "@storybook/addon-essentials": "^8.0.9",
25
+ "@storybook/addon-interactions": "^8.0.9",
26
+ "@storybook/addon-links": "^8.0.9",
25
27
  "@storybook/addon-webpack5-compiler-swc": "^1.0.2",
26
28
  "@storybook/preset-scss": "^1.0.3",
27
- "@storybook/react": "^8.0.6",
28
- "@storybook/react-webpack5": "^8.0.6",
29
- "@storybook/test": "^8.0.6",
29
+ "@storybook/react": "^8.0.9",
30
+ "@storybook/react-webpack5": "^8.0.9",
31
+ "@storybook/test": "^8.0.9",
30
32
  "@types/react": "^17.0.11",
31
33
  "@types/react-dom": "^17.0.8",
32
- "@typescript-eslint/eslint-plugin": "^7.6.0",
33
- "@typescript-eslint/parser": "^7.6.0",
34
+ "@typescript-eslint/eslint-plugin": "^5.31.0",
35
+ "@typescript-eslint/parser": "^5.31.0",
34
36
  "chromatic": "^11.3.0",
37
+ "classnames": "^2.5.1",
35
38
  "css-loader": "^6.7.1",
36
- "eslint": "^9.0.0",
39
+ "eslint": "^8.20.0",
37
40
  "eslint-config-airbnb": "^19.0.4",
38
- "eslint-config-prettier": "^9.1.0",
39
- "eslint-plugin-import": "^2.29.1",
40
- "eslint-plugin-jsx-a11y": "^6.8.0",
41
- "eslint-plugin-prettier": "^5.1.3",
42
- "eslint-plugin-react": "^7.34.1",
43
- "eslint-plugin-simple-import-sort": "^12.0.0",
41
+ "eslint-config-prettier": "^8.5.0",
42
+ "eslint-plugin-import": "^2.26.0",
43
+ "eslint-plugin-jsx-a11y": "^6.6.1",
44
+ "eslint-plugin-prettier": "^4.2.1",
45
+ "eslint-plugin-react": "^7.30.1",
46
+ "eslint-plugin-simple-import-sort": "^7.0.0",
44
47
  "postcss": "^8.4.16",
45
48
  "postcss-url": "^10.1.3",
46
49
  "prettier": "^3.2.5",
@@ -49,7 +52,7 @@
49
52
  "rollup-plugin-postcss": "^4.0.2",
50
53
  "sass": "^1.54.4",
51
54
  "sass-loader": "^13.0.2",
52
- "storybook": "^8.0.6",
55
+ "storybook": "^8.0.9",
53
56
  "style-loader": "^3.3.1",
54
57
  "typescript": "^4.7.4"
55
58
  },
@@ -0,0 +1,224 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ const inputDir = './src/assets/icons';
6
+ const outputDir = './src/components/atoms/icon';
7
+ const svgs = fs.readdirSync(inputDir);
8
+
9
+ // 아이콘의 정보들을 모을 객체
10
+ const icons = {};
11
+ // 아이콘의 이름을 모을 객체
12
+ const names = {};
13
+
14
+ const toCamelCase = (pascalStr) =>
15
+ pascalStr
16
+ .split('-')
17
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
18
+ .join('');
19
+
20
+ const readFile = (filePath, fileName, fileExtension) =>
21
+ new Promise((resolve, reject) => {
22
+ fs.readFile(filePath, 'utf8', (err, data) => {
23
+ if (err) {
24
+ reject(err);
25
+ return;
26
+ }
27
+
28
+ console.log('---------- parsing start ----------');
29
+
30
+ console.log('((data))', data);
31
+
32
+ // svg args 추출
33
+ const svgStartRegex = /<svg/g;
34
+ const svgEndRegex = />/;
35
+ const svgArgs = data.split(svgStartRegex)[1].split(svgEndRegex)[0];
36
+
37
+ console.log('**svgArgs', svgArgs);
38
+
39
+ // width 추출
40
+ const widthRegex = /width=".{1,9}"/g;
41
+ const width = svgArgs.match(widthRegex)?.[0]?.split('"')?.[1];
42
+ console.log('*width', width);
43
+
44
+ // height 추출
45
+ const heightRegex = /height=".{1,9}"/g;
46
+ const height = svgArgs.match(heightRegex)?.[0]?.split('"')?.[1];
47
+ console.log('*height', height);
48
+
49
+ // viewBox 추출
50
+ const viewBoxRegex = /viewBox="[0-9\s-.]*"/;
51
+ const viewBox = svgArgs.match(viewBoxRegex)?.[0]?.split('"')?.[1];
52
+ console.log('*viewBox', viewBox);
53
+
54
+ // svgFill 추출
55
+ const fillRegex = /fill=".{1,9}"/g;
56
+ const svgFill = svgArgs.match(fillRegex)?.[0]?.split('"')?.[1];
57
+ console.log('*svgFill', svgFill);
58
+
59
+ // path args 추출
60
+ const pathStartRegex = /<path/g;
61
+ const paths = data
62
+ .split(pathStartRegex)
63
+ .filter((_, idx) => idx > 0)
64
+ .map((pathArgs) => {
65
+ // d 추출
66
+ const dRegex = /d=".*"/g;
67
+ const d = pathArgs.match(dRegex)?.[0]?.split('"')?.[1];
68
+ console.log('*d', d);
69
+
70
+ // pathFill 추출
71
+ const pathFill = pathArgs.match(fillRegex)?.[0]?.split('"')?.[1];
72
+ console.log('*pathFill', pathFill);
73
+
74
+ // fillRule 추출
75
+ const fillRuleRegex = /fill-rule=".{1,9}"/g;
76
+ const fillRule = pathArgs.match(fillRuleRegex)?.[0]?.split('"')?.[1];
77
+ console.log('*fillRule', fillRule);
78
+
79
+ // clipRule 추출
80
+ const clipRuleRegex = /clip-rule=".{1,9}"/g;
81
+ const clipRule = pathArgs.match(clipRuleRegex)?.[0]?.split('"')?.[1];
82
+ console.log('*clipRule', clipRule);
83
+
84
+ // stroke 추출
85
+ const strokeRegex = /stroke=".{1,9}"/g;
86
+ const stroke = pathArgs.match(strokeRegex)?.[0]?.split('"')?.[1];
87
+ console.log('*stroke', stroke);
88
+
89
+ // strokeWidth 추출
90
+ const strokeWidthRegex = /stroke-width=".{1,9}"/g;
91
+ const strokeWidth = pathArgs
92
+ .match(strokeWidthRegex)?.[0]
93
+ ?.split('"')?.[1];
94
+ console.log('*strokeWidth', strokeWidth);
95
+
96
+ // strokeLinecap 추출
97
+ const strokeLinecapRegex = /stroke-linecap=".{1,9}"/g;
98
+ const strokeLinecap = pathArgs
99
+ .match(strokeLinecapRegex)?.[0]
100
+ ?.split('"')?.[1];
101
+ console.log('*strokeLinecap', strokeLinecap);
102
+
103
+ // strokeLinejoin 추출
104
+ const strokeLinejoinRegex = /stroke-linejoin=".{1,9}"/g;
105
+ const strokeLinejoin = pathArgs
106
+ .match(strokeLinejoinRegex)?.[0]
107
+ ?.split('"')?.[1];
108
+ console.log('*strokeLinejoin', strokeLinejoin);
109
+
110
+ return {
111
+ d,
112
+ fill: pathFill,
113
+ fillRule,
114
+ clipRule,
115
+ stroke,
116
+ strokeWidth,
117
+ strokeLinecap,
118
+ strokeLinejoin,
119
+ };
120
+ });
121
+
122
+ // circle args 추출
123
+ const circleStartRegex = /<circle/g;
124
+ const circles = data
125
+ .split(circleStartRegex)
126
+ .filter((_, idx) => idx > 0)
127
+ .map((circleArgs) => {
128
+ // cx 추출
129
+ const cxRegex = /cx=".{1,9}"/g;
130
+ const cx = circleArgs.match(cxRegex)?.[0]?.split('"')?.[1];
131
+ console.log('*cx', cx);
132
+
133
+ // cy 추출
134
+ const cyRegex = /cy=".{1,9}"/g;
135
+ const cy = circleArgs.match(cyRegex)?.[0]?.split('"')?.[1];
136
+ console.log('*cy', cy);
137
+
138
+ // r 추출
139
+ const rRegex = /r=".{1,9}"/g;
140
+ const r = circleArgs.match(rRegex)?.[0]?.split('"')?.[1];
141
+ console.log('*r', r);
142
+
143
+ // circleFill 추출
144
+ const circleFill = circleArgs.match(fillRegex)?.[0]?.split('"')?.[1];
145
+ console.log('*circleFill', circleFill);
146
+
147
+ return { cx, cy, r, fill: circleFill };
148
+ });
149
+
150
+ const fileNameWithoutExtension = toCamelCase(
151
+ fileName.split(fileExtension)[0],
152
+ );
153
+ console.log('fileNameWithoutExtension', fileNameWithoutExtension);
154
+
155
+ icons[fileNameWithoutExtension] = {
156
+ width,
157
+ height,
158
+ viewBox,
159
+ fill: svgFill,
160
+ paths,
161
+ circles,
162
+ };
163
+ names[fileNameWithoutExtension] = fileNameWithoutExtension;
164
+
165
+ resolve();
166
+ });
167
+ });
168
+
169
+ async function main() {
170
+ for (const svg of svgs) {
171
+ const extension = path.extname(svg);
172
+ if (extension === '.svg' && !svg.includes('NoConvert')) {
173
+ await readFile(`${inputDir}/${svg}`, svg, extension);
174
+ }
175
+ }
176
+
177
+ console.log('### icons', icons);
178
+ console.log('### names', names);
179
+
180
+ fs.writeFileSync(
181
+ `${outputDir}/iconmap.ts`,
182
+ `/* eslint-disable no-multiple-empty-lines */
183
+ /* eslint-disable no-trailing-spaces */
184
+ /* eslint-disable eol-last */
185
+ /* eslint-disable object-curly-spacing */
186
+ /* eslint-disable comma-spacing */
187
+ /* eslint-disable key-spacing */
188
+ /* eslint-disable quotes */
189
+ /* eslint-disable quote-props */
190
+ export const iconmap: {
191
+ [key: string]: {
192
+ width: string;
193
+ height: string;
194
+ viewBox: string;
195
+ fill: string;
196
+ paths: {
197
+ d: string;
198
+ fill?: string;
199
+ fillRule?: string;
200
+ clipRule?: string;
201
+ stroke?: string;
202
+ strokeWidth?: string;
203
+ strokeLinecap?: string;
204
+ strokeLinejoin?: string;
205
+ }[];
206
+ circles: {
207
+ cx: string;
208
+ cy: string;
209
+ r: string;
210
+ fill: string;
211
+ }[];
212
+ };
213
+ } = ${JSON.stringify(icons)};
214
+ export const ICONS = ${JSON.stringify(names)} as const;
215
+ export type TIcons = (typeof ICONS)[keyof typeof ICONS];
216
+ `,
217
+ 'utf8',
218
+ (error) => {
219
+ if (error) throw error;
220
+ },
221
+ );
222
+ }
223
+
224
+ main();