|
| 1 | +import { Meta } from '@storybook/addon-docs'; |
| 2 | +import { iconNames } from './icons/icons'; |
| 3 | +import { Typography } from '../Typography' |
| 4 | +import { StyledIcon, StyledItemList, StyledUnorderedList } from './IconStoriesStyles' |
| 5 | +import { Icon } from './Icon'; |
| 6 | +import * as Colors from '../../../Utils/@next/colors'; |
| 7 | + |
| 8 | +<Meta title="General/@next/Icon" /> |
| 9 | + |
| 10 | +# Icons |
| 11 | + |
| 12 | +<StyledUnorderedList> |
| 13 | + {iconNames.map((name) => |
| 14 | + <StyledItemList key={name}> |
| 15 | + <StyledIcon name={name} height={28}/> |
| 16 | + <Typography variant='subtitle2'>{name}</Typography> |
| 17 | + </StyledItemList> |
| 18 | + )} |
| 19 | +</StyledUnorderedList> |
| 20 | + |
| 21 | +## How to use |
| 22 | +- import NIcon component from glints-aries and pass name prop to use the specific icon |
| 23 | + |
| 24 | +<div style={{ display: 'flex' }}> |
| 25 | + <StyledIcon name="ri-account-circle-fill" height={48}/> |
| 26 | + <Typography variant='subtitle2'>ri-account-circle-fill</Typography> |
| 27 | +</div> |
| 28 | + |
| 29 | +```ts |
| 30 | +import { NIcon as Icon } from 'glints-aries'; |
| 31 | + |
| 32 | +export const MyComponent = () => ( |
| 33 | + <Icon name="ri-account-circle-fill" /> |
| 34 | +); |
| 35 | +``` |
| 36 | + |
| 37 | +### Color |
| 38 | +- you can change the color of the icon by passing the color to `fill` prop. |
| 39 | + |
| 40 | +<StyledIcon name="ri-account-circle-fill" height={48} fill={Colors.Blue.Brand} /> |
| 41 | + |
| 42 | +``` |
| 43 | +Import { Colors } from 'glints-aries' |
| 44 | +
|
| 45 | +<Icon name="ri-account-circle-fill" height={48} fill={Colors.Blue.Brand} /> |
| 46 | +``` |
| 47 | + |
| 48 | +### Size |
| 49 | +- you can change the size of the icon by either passing a height or width as **props** or using **styles**. |
| 50 | +- passing at least either the `height` or `width` automatically sets the other with the same value. |
| 51 | +#### Props |
| 52 | +- Passing height or width as props |
| 53 | +```ts |
| 54 | +<Icon name="ri-account-circle-fill" height={48} /> |
| 55 | +``` |
| 56 | + |
| 57 | +#### Style |
| 58 | +- Resizing by specifying height or width in styles |
| 59 | +```ts |
| 60 | +import { NIcon as Icon } from 'glints-aries'; |
| 61 | +import styled from 'styled-components'; |
| 62 | + |
| 63 | +const StyledIcon = styled(Icon)` |
| 64 | + height: '48px'; |
| 65 | +`; |
| 66 | + |
| 67 | +export const MyComponent = () => ( |
| 68 | + <StyledIcon name="ri-account-circle-fill" /> |
| 69 | +); |
| 70 | +``` |
| 71 | + |
| 72 | +## Adding new icons |
| 73 | +1. Add svg file to `src/General/@next/Icon/icons` |
| 74 | + - make sure only viewBox is defined. Remove height, width or fill. This is to make sure the generated React component generates correct props for styles to work. |
| 75 | +2. Generate SVG React Component. Run `yarn build`. Components can be found in `src/General/@next/Icon/components` |
| 76 | +3. Update `src/General/@next/Icon/icons/icons.ts` file. |
| 77 | + - insert the new icon's name to `iconNames` in alphabetical order. Refer to Iconography naming convention. |
| 78 | + - update `iconsMappingComponent` with it's corresponding component name. |
0 commit comments