Skip to content

Commit

Permalink
feat: add name prop to IconBase for dynamic class and testID generation
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkpatchaa committed Jan 23, 2025
1 parent ae16180 commit 06cf7c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion generator/generate-svg.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ import IconBase from "../lib/icon-base";
import weights from '../defs/${component}'
function ${componentName}({...props }: IconProps) {
return (<IconBase {...props} weights={weights} />)
return (<IconBase {...props} weights={weights} name="${icon}" />)
}
export default ${componentName}`;
Expand Down
6 changes: 4 additions & 2 deletions src/lib/icon-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface IconBaseProps extends IconProps {
IconWeight,
ReactElement | FC<{ duotoneColor?: string; duotoneOpacity?: number }>
>;
name: string;
}

function IconBase({
Expand All @@ -19,6 +20,7 @@ function IconBase({
duotoneOpacity,
title,
titleId,
name,
weights,
...props
}: IconBaseProps) {
Expand All @@ -43,8 +45,8 @@ function IconBase({
}),
},
]}
className={`acorn-${weight}__svg-icon-phosphor`}
testID={props.testID ?? 'phosphor-react-native-acorn-bold'}
className={`${name}-${weight}__svg-icon-phosphor`}
testID={props.testID ?? `phosphor-react-native-${name}-${weight}`}
fill="currentColor"
viewBox="0 0 256 256"
width={size ?? contextSize}
Expand Down

0 comments on commit 06cf7c3

Please sign in to comment.