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: <Icon component={HomeOutlined} /> align issue #33709

Merged
merged 2 commits into from Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
562 changes: 562 additions & 0 deletions components/icon/__tests__/__snapshots__/demo-extend.test.ts.snap

Large diffs are not rendered by default.

562 changes: 562 additions & 0 deletions components/icon/__tests__/__snapshots__/demo.test.ts.snap

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions components/icon/__tests__/demo-extend.test.ts
@@ -0,0 +1,3 @@
import { extendTest } from '../../../tests/shared/demoTest';

extendTest('icon');
3 changes: 3 additions & 0 deletions components/icon/__tests__/demo.test.ts
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('icon');
16 changes: 3 additions & 13 deletions components/icon/demo/basic.md
Expand Up @@ -14,6 +14,7 @@ title:
Import icons from `@ant-design/icons`, component name of icons with different theme is the icon name suffixed by the theme name. Specify the `spin` property to show spinning animation.

```jsx
import { Space } from 'antd';
import {
HomeOutlined,
SettingFilled,
Expand All @@ -23,25 +24,14 @@ import {
} from '@ant-design/icons';

ReactDOM.render(
<div className="icons-list">
<Space>
<HomeOutlined />
<SettingFilled />
<SmileOutlined />
<SyncOutlined spin />
<SmileOutlined rotate={180} />
<LoadingOutlined />
</div>,
</Space>,
mountNode,
);
```

<style>
.icons-list > .anticon {
margin-right: 6px;
font-size: 24px;
}
.ant-row-rtl .icons-list > .anticon {
margin-right: 0;
margin-left: 6px;
}
</style>
19 changes: 6 additions & 13 deletions components/icon/demo/custom.md
Expand Up @@ -14,7 +14,8 @@ title:
Create a reusable React component by using `<Icon component={...} />`. The property `component` takes a React component that renders to `svg` element.

```jsx
import Icon from '@ant-design/icons';
import { Space } from 'antd';
import Icon, { HomeOutlined } from '@ant-design/icons';

const HeartSvg = () => (
<svg width="1em" height="1em" fill="currentColor" viewBox="0 0 1024 1024">
Expand Down Expand Up @@ -72,20 +73,12 @@ const HeartIcon = props => <Icon component={HeartSvg} {...props} />;
const PandaIcon = props => <Icon component={PandaSvg} {...props} />;

ReactDOM.render(
<div className="custom-icons-list">
<Space>
<HeartIcon style={{ color: 'hotpink' }} />
<PandaIcon style={{ fontSize: '32px' }} />
</div>,
<Icon component={HomeOutlined} />
<HomeOutlined />
</Space>,
mountNode,
);
```

```css
.custom-icons-list > .anticon {
margin-right: 6px;
}
.ant-row-rtl .custom-icons-list > .anticon {
margin-right: 0;
margin-left: 6px;
}
```
5 changes: 3 additions & 2 deletions components/icon/demo/iconfont.md
Expand Up @@ -14,18 +14,19 @@ title:
If you are using [iconfont.cn](http://iconfont.cn/), you can use the icons in your project gracefully.

```jsx
import { Space } from 'antd';
import { createFromIconfontCN } from '@ant-design/icons';

const IconFont = createFromIconfontCN({
scriptUrl: '//at.alicdn.com/t/font_8d5l8fzk5b87iudi.js',
});

ReactDOM.render(
<div className="icons-list">
<Space>
<IconFont type="icon-tuichu" />
<IconFont type="icon-facebook" />
<IconFont type="icon-twitter" />
</div>,
</Space>,
mountNode,
);
```
5 changes: 3 additions & 2 deletions components/icon/demo/scriptUrl.md
Expand Up @@ -14,6 +14,7 @@ title:
You can use `scriptUrl` as an array after `@ant-design/icons@4.1.0`, manage icons in one `<Icon />` from multiple [iconfont.cn](http://iconfont.cn/) resources. If icon with a duplicate name in resources, it will overrided in array order.

```jsx
import { Space } from 'antd';
import { createFromIconfontCN } from '@ant-design/icons';

const IconFont = createFromIconfontCN({
Expand All @@ -24,12 +25,12 @@ const IconFont = createFromIconfontCN({
});

ReactDOM.render(
<div className="icons-list">
<Space>
<IconFont type="icon-javascript" />
<IconFont type="icon-java" />
<IconFont type="icon-shoppingcart" />
<IconFont type="icon-python" />
</div>,
</Space>,
mountNode,
);
```
5 changes: 3 additions & 2 deletions components/icon/demo/two-tone.md
Expand Up @@ -14,14 +14,15 @@ title:
You can set `twoToneColor` prop to specific primary color for two-tone icons.

```jsx
import { Space } from 'antd';
import { SmileTwoTone, HeartTwoTone, CheckCircleTwoTone } from '@ant-design/icons';

ReactDOM.render(
<div className="icons-list">
<Space>
<SmileTwoTone />
<HeartTwoTone twoToneColor="#eb2f96" />
<CheckCircleTwoTone twoToneColor="#52c41a" />
</div>,
</Space>,
mountNode,
);
```
5 changes: 5 additions & 0 deletions components/style/core/iconfont.less
Expand Up @@ -4,6 +4,11 @@
.@{iconfont-css-prefix} {
.iconfont-mixin();

// https://github.com/ant-design/ant-design/issues/33703
& > & {
vertical-align: 0;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关键改动只有这一句。


&[tabindex] {
cursor: pointer;
}
Expand Down