Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: color should be svg property #498

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/icons-react/src/components/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ export interface CustomIconComponentProps {
fill?: string;
viewBox?: string;
className?: string;
color?: string;
style?: React.CSSProperties;
}

export interface IconComponentProps extends IconBaseProps {
viewBox?: string;
component?: React.ComponentType<CustomIconComponentProps | React.SVGProps<SVGSVGElement>> | React.ForwardRefExoticComponent<CustomIconComponentProps>;
Expand All @@ -34,6 +36,7 @@ Omit<IconComponentProps, 'ref'> & React.RefAttributes<HTMLSpanElement>

// affect inner <svg>...</svg>
component: Component,
color,
viewBox,
spin,
rotate,
Expand Down Expand Up @@ -80,6 +83,7 @@ Omit<IconComponentProps, 'ref'> & React.RefAttributes<HTMLSpanElement>

const innerSvgProps: CustomIconComponentProps = {
...svgBaseProps,
color,
className: svgClassString,
style: svgStyle,
viewBox,
Expand Down
1 change: 1 addition & 0 deletions packages/icons-react/src/components/IconBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface IconProps {
icon: IconDefinition;
className?: string;
onClick?: React.MouseEventHandler<SVGSVGElement>;
color?: string;
style?: React.CSSProperties;
primaryColor?: string; // only for two-tone
secondaryColor?: string; // only for two-tone
Expand Down
1 change: 1 addition & 0 deletions packages/icons-react/tests/Icon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('React AntdIcon Component', () => {
style: {
fontSize: '3rem',
},
color: 'red',
className: 'my-icon',
extraProps: { hello: 'world' },
} as any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
exports[`React AntdIcon Component should create SVG element. 1`] = `
<IconReact
className="my-icon"
color="red"
extraProps={
{
"hello": "world",
Expand Down
17 changes: 17 additions & 0 deletions packages/icons-react/tests/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,23 @@ exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
/>
</svg>
</span>
<span
class="anticon abc"
role="img"
>
<svg
aria-hidden="true"
class=""
color="blue"
focusable="false"
height="1em"
width="1em"
>
<use
href="#icon-twitter"
/>
</svg>
</span>
</div>
`;

Expand Down
1 change: 1 addition & 0 deletions packages/icons-react/tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ describe('Icon.createFromIconfontCN()', () => {
<IconFont type="icon-tuichu" />
<IconFont type="icon-facebook" />
<IconFont type="icon-twitter" />
<IconFont type="icon-twitter" color="blue" />
</div>,
);
expect(wrapper).toMatchSnapshot();
Expand Down