Skip to content

Commit 2dc3b03

Browse files
committed
docs: update svg-icon
1 parent 806fed9 commit 2dc3b03

File tree

4 files changed

+69
-59
lines changed

4 files changed

+69
-59
lines changed

packages/react-docs/pages/components/svg-icon.page.mdx

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { SVGIcon } from '@tonic-ui/react';
2+
import React from 'react';
3+
4+
const App = () => (
5+
<SVGIcon color="gray:50" size={24} viewBox="0 0 16 16">
6+
<path d="M8 0c-4.418 0-8 3.582-8 8s3.582 8 8 8c4.418 0 8-3.582 8-8v0c0-4.418-3.582-8-8-8v0zM11 12l-3-3-3 3-1.060-1.060 3.060-2.94-3-3 1.060-1.070 2.94 2.95 2.94-2.94 1.060 1.060-2.89 3 3 3z" />
7+
</SVGIcon>
8+
);
9+
10+
export default App;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Stack, SVGIcon } from '@tonic-ui/react';
2+
import React from 'react';
3+
4+
const CustomIcon = ({ size, ...rest }) => {
5+
const viewBox = '0 0 16 16';
6+
return (
7+
<SVGIcon size={size} viewBox={viewBox} {...rest}>
8+
<path d="M15 8c0 3.866-3.134 7-7 7s-7-3.134-7-7c0-3.866 3.134-7 7-7v0c3.866 0 7 3.134 7 7v0z" />
9+
</SVGIcon>
10+
);
11+
};
12+
13+
const App = () => (
14+
<Stack direction="row" spacing="3x" alignItems="center">
15+
<CustomIcon size="1x" color="blue:10" />
16+
<CustomIcon size="2x" color="blue:20" />
17+
<CustomIcon size="3x" color="blue:30" />
18+
<CustomIcon size="4x" color="blue:40" />
19+
<CustomIcon size="5x" color="blue:50" />
20+
<CustomIcon size="6x" color="blue:60" />
21+
<CustomIcon size="7x" color="blue:70" />
22+
<CustomIcon size="8x" color="blue:80" />
23+
<CustomIcon size="9x" color="blue:90" />
24+
<CustomIcon size="10x" color="blue:100" />
25+
</Stack>
26+
);
27+
28+
export default App;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# SVGIcon
2+
3+
If you need a custom SVG icon, you can use the `<SVGIcon>` component to extend the native `<svg>` element:
4+
5+
* It comes with built-in accessibility.
6+
* SVG elements should be scaled for a 24x24px viewport.
7+
8+
## Import
9+
10+
```js
11+
import { SVGIcon } from '@tonic-ui/react';
12+
```
13+
14+
## Usage
15+
16+
{render('./basic')}
17+
18+
### Custom icon
19+
20+
{render('./custom-icon')}
21+
22+
## Props
23+
24+
### SVGIcon
25+
26+
| Name | Type | Default | Description |
27+
| :--- | :--- | :------ | :---------- |
28+
| size | string | | The size of the icon. |
29+
| color | string | 'currentColor' | The color of the icon. |
30+
| focusable | boolean | false | Denotes that the icon is not an interactive element, and only used for presentation. |
31+
| role | string | 'presentation' | One of: 'presentation', 'img' |

0 commit comments

Comments
 (0)