@linagora/twake-icons
v2.10.0
Published
Icon library for Twake applications — SVG icons and illustrations
Readme
@linagora/twake-icons
Icon library for Twake applications. Provides SVG icons and illustrations as React components.
Installation
npm install @linagora/twake-iconsUsage
Import individual icons (tree-shakeable)
import { Icon, Check, Folder } from '@linagora/twake-icons'
<Icon icon={Check} size={16} />
<Icon icon={Folder} size={24} color="var(--primary)" />Use sprite identifiers
import { Icon, Sprite } from '@linagora/twake-icons'
// Render the sprite once at the root of your app
<Sprite />
// Then use string identifiers anywhere
<Icon icon="check" size={16} />
<Icon icon="folder" color="blue" />Icon Props
| Prop | Type | Description |
|------|------|-------------|
| icon | string \| Component \| ReactElement | Icon identifier, SVGr component, or custom SVG element |
| size | number \| string | Width and height in pixels |
| color | string | Fill color |
| rotate | number | Rotation in degrees |
| spin | boolean | Apply spinning animation |
How to add an icon
Add the new icon in /assets folder, then optimize it and create the SVGr component and the Sprite:
Remove fill props If your SVG file is an icon (not an illustration), verify that the file doesn't have any
fillorfill-opacityproperties. Remove them if necessary, to be able to set the color.Optimize SVGs
npm run svgoOr for a single icon:
npx svgo assets/ui/new-icon.svgGenerate SVGr components
npm run makeSvgrOr for a single icon:
npm run makeSvgr -- assets/ui/new-icon.svgRegenerate the sprite
npm run spriteRebuild and fix lint
npm run build && npm run lint:fixCheck the barrel The barrel export (
src/Icons/index.ts) is automatically regenerated during build, so verify it's in sync with the generated components.npm run check:barrel
License
MIT
