Skip to content

Commit

Permalink
fix: color should be svg property
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Aug 30, 2021
1 parent ada40f0 commit 7e6f7d4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 0 deletions.
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 @@ -5,6 +5,7 @@ import Context from './Context';
import { svgBaseProps, warning, useInsertStyles } from '../utils';

export interface IconBaseProps extends React.HTMLProps<HTMLSpanElement> {
color?: string;
spin?: boolean;
rotate?: number;
}
Expand All @@ -16,6 +17,7 @@ export interface CustomIconComponentProps {
viewBox?: string;
className?: string;
style?: React.CSSProperties;
color?: string
}
export interface IconComponentProps extends IconBaseProps {
viewBox?: string;
Expand All @@ -30,6 +32,7 @@ const Icon = React.forwardRef<HTMLSpanElement, IconComponentProps>((props, ref)

// affect inner <svg>...</svg>
component: Component,
color,
viewBox,
spin,
rotate,
Expand Down Expand Up @@ -69,6 +72,7 @@ const Icon = React.forwardRef<HTMLSpanElement, IconComponentProps>((props, ref)

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 @@ -12,6 +12,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={
Object {
"hello": "world",
Expand Down
18 changes: 18 additions & 0 deletions packages/icons-react/tests/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,24 @@ exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
/>
</svg>
</span>
<span
class="anticon abc"
role="img"
>
<svg
aria-hidden="true"
class=""
color="blue"
fill="currentColor"
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 @@ -300,6 +300,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

0 comments on commit 7e6f7d4

Please sign in to comment.