|
1 | 1 | # Icons |
2 | 2 |
|
3 | | -Figmicon includes an icon system that allows you to easily use icons from Figma in your application. |
| 3 | +IconSync allows you to easily fetch icons from Figma and use them in your application as React components. |
4 | 4 |
|
5 | | -## Usage |
| 5 | +## Configuration |
6 | 6 |
|
7 | | -```jsx |
8 | | -import { Icon } from '@iconsync/core'; |
| 7 | +Create an `icon.config.ts` file in your project root: |
9 | 8 |
|
10 | | -export default function IconExample() { |
11 | | - return ( |
12 | | - <Icon name="arrow-right" size="md" /> |
13 | | - ); |
14 | | -} |
| 9 | +```typescript |
| 10 | +import { iconConfig } from "@iconsync/core"; |
| 11 | + |
| 12 | +export default iconConfig({ |
| 13 | + figma: { |
| 14 | + token: process.env.FIGMA_TOKEN!, // Your Figma API token |
| 15 | + url: "https://www.figma.com/design/YOUR_FILE_ID/YOUR_FILE_NAME?node-id=YOUR_NODE_ID", |
| 16 | + }, |
| 17 | + fetch: { |
| 18 | + concurrentDownloads: 5, // Number of concurrent downloads |
| 19 | + }, |
| 20 | + generator: { |
| 21 | + icon: true, // Generate icon components |
| 22 | + typescript: true, // Generate TypeScript files |
| 23 | + titleProp: true, // Add title prop to components |
| 24 | + dimensions: false, // Include width/height dimensions |
| 25 | + expandProps: "end", // Position of expanded props |
| 26 | + replaceAttrValues: { |
| 27 | + "#000000": "currentColor", // Replace specific colors |
| 28 | + "#fff": "currentColor", |
| 29 | + }, |
| 30 | + outDir: "src/components/icons", // Output directory |
| 31 | + ext: "tsx", // File extension |
| 32 | + prettier: true, // Format with Prettier |
| 33 | + filenameCase: "camel", // Filename case style |
| 34 | + }, |
| 35 | +}); |
15 | 36 | ``` |
16 | 37 |
|
17 | | -## Available Icons |
| 38 | +## Fetching Icons |
| 39 | + |
| 40 | +After setting up your configuration file, you can fetch icons from Figma: |
18 | 41 |
|
19 | | -Figmicon includes a wide range of icons that you can use in your application. Here are some examples: |
| 42 | +```bash |
| 43 | +# Using the CLI directly |
| 44 | +npx figmicon fetch |
20 | 45 |
|
21 | | -- `arrow-right` |
22 | | -- `arrow-left` |
23 | | -- `check` |
24 | | -- `close` |
25 | | -- `menu` |
26 | | -- `settings` |
27 | | -- `user` |
| 46 | +# Or using a package.json script |
| 47 | +npm run icon:fetch |
| 48 | +``` |
28 | 49 |
|
29 | | -## Customizing Icons |
| 50 | +## Generating Components |
30 | 51 |
|
31 | | -You can customize the appearance of icons by passing props: |
| 52 | +After fetching icons, you can generate React components: |
| 53 | + |
| 54 | +```bash |
| 55 | +# Using the CLI directly |
| 56 | +npx figmicon generator |
| 57 | + |
| 58 | +# Or using a package.json script |
| 59 | +npm run icon:generate |
| 60 | +``` |
| 61 | + |
| 62 | +## Using Generated Icons |
| 63 | + |
| 64 | +Once your icon components are generated, you can import and use them in your React application: |
32 | 65 |
|
33 | 66 | ```jsx |
34 | | -<Icon |
35 | | - name="arrow-right" |
36 | | - size="lg" |
37 | | - color="primary" |
38 | | - strokeWidth={2} |
39 | | -/> |
| 67 | +import { ArrowRight } from './components/icons'; |
| 68 | + |
| 69 | +export default function IconExample() { |
| 70 | + return ( |
| 71 | + <ArrowRight |
| 72 | + width={24} |
| 73 | + height={24} |
| 74 | + color="currentColor" |
| 75 | + title="Arrow Right Icon" |
| 76 | + /> |
| 77 | + ); |
| 78 | +} |
40 | 79 | ``` |
| 80 | + |
| 81 | +The exact props available will depend on your generator configuration. |
0 commit comments