@liner-fe/internal-icon 1.0.2 → 1.0.3

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/.ultra.cache.json CHANGED
@@ -1 +1 @@
1
- {"files":{"lib":"1764577696822.9573","node_modules":"1764577682688.9214","CHANGELOG.md":"f71cd485ee819ddbf933134b38e4563d7db50b5b","README.md":"e0a89d4fcf5bddf1f816bfb20a928ddb301b8d2c","figma.json":"1c65dae980f3b2b3f57d08bd57fe2c021ebd12ec","package.json":"febacb54057e1c4e8bd5411015e3285929a830c1","src/generate-svg-files.ts":"18687c8c5c7766b988257f5bef3d296b86fefaa8","src/generate-tsx-components.ts":"175a39c7f9b02a6f76422f06bf9b16ca25e9d028","src/index.ts":"9e03c9c45c92fc534262982bce233b91892c05f1","tsconfig.json":"298030567ca332304807fcdbb95d1218c9c0814f","tsup.config.ts":"4dc8bfd36076fff8fa1d84a48a072d40e6581810"},"deps":{}}
1
+ {"files":{"lib":"1764914149225.7688","node_modules":"1764914134010.825","CHANGELOG.md":"23f80c764240f05db00818583dbdcd7e9bef94e7","README.md":"e0a89d4fcf5bddf1f816bfb20a928ddb301b8d2c","figma.json":"1c65dae980f3b2b3f57d08bd57fe2c021ebd12ec","package.json":"44f4e701d20a8a3c1071adfa805f4d370f044f16","src/generate-svg-files.ts":"18687c8c5c7766b988257f5bef3d296b86fefaa8","src/generate-tsx-components.ts":"ba97e0330300610e94ead0c872c4725120eb830b","src/index.ts":"9e03c9c45c92fc534262982bce233b91892c05f1","tsconfig.json":"298030567ca332304807fcdbb95d1218c9c0814f","tsup.config.ts":"4dc8bfd36076fff8fa1d84a48a072d40e6581810"},"deps":{}}
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @internal/icon
2
2
 
3
+ ## 1.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 9ac52fb: color icon 예외 처리
8
+
3
9
  ## 1.0.2
4
10
 
5
11
  ### Patch Changes
package/lib/index.js CHANGED
@@ -100,6 +100,17 @@ var generateTsxComponents = /* @__PURE__ */ __name(() => {
100
100
  return variantSvgs;
101
101
  }
102
102
  __name(processSvgVariants, "processSvgVariants");
103
+ function generateColorTsxComponent(componentName, defaultSvg) {
104
+ return `import React, { forwardRef } from 'react';
105
+ import { iconSizeMap } from '@liner-fe/design-token-primitive';
106
+ import { ColorIconProps } from '../../index';
107
+
108
+ export const Icon${componentName} = forwardRef<SVGSVGElement, ColorIconProps>(
109
+ ({ size = 'm', className, ...props }, ref) => ${defaultSvg}
110
+ );
111
+ `;
112
+ }
113
+ __name(generateColorTsxComponent, "generateColorTsxComponent");
103
114
  function generateTsxComponent(componentName, variantSvgs, defaultSvg) {
104
115
  return `import React, { forwardRef } from 'react';
105
116
  import { iconSizeMap } from '@liner-fe/design-token-primitive';
@@ -127,13 +138,23 @@ export const Icon${componentName} = forwardRef<SVGSVGElement, IconProps>(
127
138
  Object.entries(figmaData).forEach(([iconName, variants]) => {
128
139
  const iconDir = path3.join(OUTPUT_DIR, iconName);
129
140
  ensureDirectoryExists(iconDir);
130
- const variantSvgs = processSvgVariants(variants);
131
- if (Object.keys(variantSvgs).length > 0) {
132
- const componentName = generateIconName(iconName);
133
- const defaultSvg = variantSvgs.default || variantSvgs.thick || Object.values(variantSvgs)[0];
134
- const tsxCode = generateTsxComponent(componentName, variantSvgs, defaultSvg);
141
+ const componentName = generateIconName(iconName);
142
+ if (componentName.startsWith("Color")) {
143
+ const tsxCode = generateColorTsxComponent(
144
+ componentName,
145
+ // @ts-ignore
146
+ normalizeSvgAttributes(variants.default)
147
+ );
135
148
  const filePath = path3.join(iconDir, "index.tsx");
136
149
  fs2.writeFileSync(filePath, tsxCode);
150
+ } else {
151
+ const variantSvgs = processSvgVariants(variants);
152
+ if (Object.keys(variantSvgs).length > 0) {
153
+ const defaultSvg = variantSvgs.default || variantSvgs.thick || Object.values(variantSvgs)[0];
154
+ const tsxCode = generateTsxComponent(componentName, variantSvgs, defaultSvg);
155
+ const filePath = path3.join(iconDir, "index.tsx");
156
+ fs2.writeFileSync(filePath, tsxCode);
157
+ }
137
158
  }
138
159
  });
139
160
  }
@@ -157,6 +178,8 @@ export type IconSizeKey = keyof typeof iconSizeMap;
157
178
 
158
179
  export interface IconProps extends Omit<SVGProps<SVGSVGElement>, 'fill' | 'name'> ${IconProps("size?: keyof typeof iconSizeMap;")}
159
180
 
181
+ export type ColorIconProps = Omit<IconProps, 'type' | 'fillType' | 'fill' | 'thick'>;
182
+
160
183
  export type IconComponentType = React.ForwardRefExoticComponent<
161
184
  Omit<IconProps, 'ref'> & React.RefAttributes<SVGSVGElement>
162
185
  >;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liner-fe/internal-icon",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -87,6 +87,17 @@ export const generateTsxComponents = () => {
87
87
  return variantSvgs;
88
88
  }
89
89
 
90
+ function generateColorTsxComponent(componentName: string, defaultSvg: string): string {
91
+ return `import React, { forwardRef } from 'react';
92
+ import { iconSizeMap } from '@liner-fe/design-token-primitive';
93
+ import { ColorIconProps } from '../../index';
94
+
95
+ export const Icon${componentName} = forwardRef<SVGSVGElement, ColorIconProps>(
96
+ ({ size = 'm', className, ...props }, ref) => ${defaultSvg}
97
+ );
98
+ `;
99
+ }
100
+
90
101
  // TSX 컴포넌트 코드 생성 함수
91
102
  function generateTsxComponent(
92
103
  componentName: string,
@@ -124,18 +135,32 @@ export const Icon${componentName} = forwardRef<SVGSVGElement, IconProps>(
124
135
  const iconDir = path.join(OUTPUT_DIR, iconName);
125
136
  ensureDirectoryExists(iconDir);
126
137
 
127
- // @ts-ignore
128
- const variantSvgs = processSvgVariants(variants);
138
+ const componentName = generateIconName(iconName);
129
139
 
130
- if (Object.keys(variantSvgs).length > 0) {
131
- const componentName = generateIconName(iconName);
132
- const defaultSvg =
133
- variantSvgs.default || variantSvgs.thick || Object.values(variantSvgs)[0];
140
+ if (componentName.startsWith('Color')) {
141
+ const tsxCode = generateColorTsxComponent(
142
+ componentName,
143
+ // @ts-ignore
144
+ normalizeSvgAttributes(variants.default),
145
+ );
134
146
 
135
- const tsxCode = generateTsxComponent(componentName, variantSvgs, defaultSvg);
136
147
  const filePath = path.join(iconDir, 'index.tsx');
137
148
 
138
149
  fs.writeFileSync(filePath, tsxCode);
150
+ } else {
151
+ // @ts-ignore
152
+ const variantSvgs = processSvgVariants(variants);
153
+
154
+ if (Object.keys(variantSvgs).length > 0) {
155
+ const defaultSvg =
156
+ variantSvgs.default || variantSvgs.thick || Object.values(variantSvgs)[0];
157
+
158
+ const tsxCode = generateTsxComponent(componentName, variantSvgs, defaultSvg);
159
+
160
+ const filePath = path.join(iconDir, 'index.tsx');
161
+
162
+ fs.writeFileSync(filePath, tsxCode);
163
+ }
139
164
  }
140
165
  });
141
166
  }
@@ -165,6 +190,8 @@ export type IconSizeKey = keyof typeof iconSizeMap;
165
190
 
166
191
  export interface IconProps extends Omit<SVGProps<SVGSVGElement>, 'fill' | 'name'> ${IconProps('size?: keyof typeof iconSizeMap;')}
167
192
 
193
+ export type ColorIconProps = Omit<IconProps, 'type' | 'fillType' | 'fill' | 'thick'>;
194
+
168
195
  export type IconComponentType = React.ForwardRefExoticComponent<
169
196
  Omit<IconProps, 'ref'> & React.RefAttributes<SVGSVGElement>
170
197
  >;