Skip to content

Commit beb68e1

Browse files
author
MRBadri
committed
docs: update README files for @iconsync/core; enhance installation instructions, usage examples, and configuration details for Figma integration
1 parent a575c6c commit beb68e1

File tree

2 files changed

+129
-46
lines changed

2 files changed

+129
-46
lines changed

README.md

Lines changed: 123 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,151 @@
1-
# Turborepo Design System starter with Changesets
1+
# @iconsync/core
22

3-
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.
3+
A powerful tool for synchronizing Figma icons with your codebase. Fetch icons from Figma and generate React components automatically.
44

5-
## Using this example
5+
[![Documentation](https://img.shields.io/badge/docs-visit-blue.svg)](https://iconsync-docs.vercel.app/)
66

7-
Run the following command:
7+
## Documentation
88

9-
```sh
10-
npx create-turbo@latest -e with-changesets
9+
For full documentation, visit [https://iconsync-docs.vercel.app/](https://iconsync-docs.vercel.app/)
10+
11+
## Installation
12+
13+
```bash
14+
# npm
15+
npm install @iconsync/core
16+
17+
# yarn
18+
yarn add @iconsync/core
19+
20+
# pnpm
21+
pnpm add @iconsync/core
1122
```
1223

13-
## What's inside?
24+
## Usage
25+
26+
### 1. Create a configuration file
27+
28+
Create an `icon.config.ts` file in your project root:
29+
30+
```typescript
31+
import { iconConfig } from "@iconsync/core";
32+
33+
export default iconConfig({
34+
figma: {
35+
token: process.env.FIGMA_TOKEN!, // Your Figma API token
36+
url: "https://www.figma.com/design/YOUR_FILE_ID/YOUR_FILE_NAME?node-id=YOUR_NODE_ID",
37+
// Alternatively, you can specify fileId and nodeId directly:
38+
// fileId: "YOUR_FILE_ID",
39+
// nodeId: "YOUR_NODE_ID",
40+
},
41+
fetch: {
42+
concurrentDownloads: 5, // Number of concurrent downloads
43+
// Optional configurations:
44+
// nodeTypes: ["COMPONENT", "COMPONENT_SET"], // Types of nodes to fetch
45+
// generateFileName: (node, parentNode) => node.name + "--" + parentNode.name, // Custom filename generator
46+
// sanitizeName: true, // Sanitize filenames
47+
// limit: 10, // Limit the number of icons to fetch
48+
},
49+
generator: {
50+
icon: true, // Generate icon components
51+
typescript: true, // Generate TypeScript files
52+
titleProp: true, // Add title prop to components
53+
dimensions: false, // Include width/height dimensions
54+
expandProps: "end", // Position of expanded props
55+
replaceAttrValues: {
56+
"#000000": "currentColor", // Replace specific colors
57+
"#fff": "currentColor",
58+
},
59+
outDir: "src/components/icons", // Output directory
60+
ext: "tsx", // File extension
61+
prettier: true, // Format with Prettier
62+
memo: false, // Use React.memo
63+
ref: false, // Forward refs
64+
filenameCase: "camel", // Filename case style: "pascal", "camel", "kebab", "snake"
65+
},
66+
});
67+
```
1468

15-
This Turborepo includes the following:
69+
### 2. Add scripts to your package.json
70+
71+
```json
72+
{
73+
"scripts": {
74+
"icon:fetch": "figmicon fetch",
75+
"icon:cache:stats": "figmicon cache:stats",
76+
"icon:cache:clear": "figmicon cache:clear",
77+
"icon:generate": "figmicon generator"
78+
}
79+
}
80+
```
1681

17-
### Apps and Packages
82+
### 3. Set up your Figma token
1883

19-
- `@iconsync/docs`: Documentation site powered by [Nextra](https://nextra.site/) and [Next.js](https://nextjs.org/)
20-
- `@iconsync/docs`: A placeholder documentation site powered by [Next.js](https://nextjs.org/)
21-
- `@iconsync/core`: core React components
22-
- `@iconsync/utils`: shared React utilities
23-
- `@iconsync/tsconfig`: shared `tsconfig.json`s used throughout the monorepo
24-
- `@iconsync/eslint-config`: ESLint preset
84+
Create a `.env` file and add your Figma token:
2585

26-
Each package and app is 100% [TypeScript](https://www.typescriptlang.org/).
86+
```
87+
FIGMA_TOKEN=your_figma_api_token
88+
```
2789

28-
### Utilities
90+
### 4. Run the commands
2991

30-
This Turborepo has some additional tools already setup for you:
92+
```bash
93+
# Fetch icons from Figma
94+
npm run icon:fetch
3195

32-
- [TypeScript](https://www.typescriptlang.org/) for static type checking
33-
- [ESLint](https://eslint.org/) for code linting
34-
- [Prettier](https://prettier.io) for code formatting
96+
# Generate React components
97+
npm run icon:generate
3598

36-
### Useful commands
99+
# View cache statistics
100+
npm run icon:cache:stats
37101

38-
- `yarn build` - Build all packages and the docs site
39-
- `yarn dev` - Develop all packages and the docs site
40-
- `yarn lint` - Lint all packages
41-
- `yarn changeset` - Generate a changeset
42-
- `yarn clean` - Clean up all `node_modules` and `dist` folders (runs each package's clean script)
102+
# Clear the cache
103+
npm run icon:cache:clear
104+
```
43105

44-
### Changing the npm organization scope
106+
## API Reference
45107

46-
The npm organization scope for this design system starter is `@iconsync`. To change this, it's a bit manual at the moment, but you'll need to do the following:
108+
### iconConfig(options)
47109

48-
- Rename folders in `packages/*` to replace `acme` with your desired scope
49-
- Search and replace `acme` with your desired scope
50-
- Re-run `yarn install`
110+
The main configuration function that accepts the following options:
51111

52-
## Versioning and Publishing packages
112+
#### figma
53113

54-
Package publishing has been configured using [Changesets](https://github.com/changesets/changesets). Please review their [documentation](https://github.com/changesets/changesets#documentation) to familiarize yourself with the workflow.
114+
- `token`: Your Figma API token
115+
- `url`: Figma file URL with node ID
116+
- `fileId`: Figma file ID (alternative to URL)
117+
- `nodeId`: Figma node ID (alternative to URL)
55118

56-
This example comes with automated npm releases setup in a [GitHub Action](https://github.com/changesets/action). To get this working, you will need to create an `NPM_TOKEN` and `GITHUB_TOKEN` in your repository settings. You should also install the [Changesets bot](https://github.com/apps/changeset-bot) on your GitHub repository as well.
119+
#### fetch
57120

58-
For more information about this automation, refer to the official [changesets documentation](https://github.com/changesets/changesets/blob/main/docs/automating-changesets.md)
121+
- `concurrentDownloads`: Number of concurrent downloads
122+
- `nodeTypes`: Types of nodes to fetch (default: `["COMPONENT", "COMPONENT_SET"]`)
123+
- `generateFileName`: Custom filename generator function
124+
- `sanitizeName`: Whether to sanitize filenames (default: `true`)
125+
- `limit`: Limit the number of icons to fetch
59126

60-
### npm
127+
#### generator
61128

62-
If you want to publish package to the public npm registry and make them publicly available, this is already setup.
129+
- `icon`: Generate icon components (default: `true`)
130+
- `typescript`: Generate TypeScript files (default: `true`)
131+
- `titleProp`: Add title prop to components (default: `true`)
132+
- `dimensions`: Include width/height dimensions (default: `false`)
133+
- `expandProps`: Position of expanded props (default: `"end"`)
134+
- `replaceAttrValues`: Object mapping colors to replace
135+
- `outDir`: Output directory for generated components
136+
- `ext`: File extension for generated components (default: `"tsx"`)
137+
- `prettier`: Format with Prettier (default: `true`)
138+
- `memo`: Use React.memo (default: `false`)
139+
- `ref`: Forward refs (default: `false`)
140+
- `filenameCase`: Filename case style (default: `"camel"`)
63141

64-
To publish packages to a private npm organization scope, **remove** the following from each of the `package.json`'s
142+
## CLI Commands
65143

66-
```diff
67-
- "publishConfig": {
68-
- "access": "public"
69-
- },
70-
```
144+
- `figmicon fetch`: Fetch icons from Figma
145+
- `figmicon generator`: Generate React components from fetched icons
146+
- `figmicon cache:stats`: View cache statistics
147+
- `figmicon cache:clear`: Clear the cache
71148

72-
### GitHub Package Registry
149+
## License
73150

74-
See [Working with the npm registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#publishing-a-package-using-publishconfig-in-the-packagejson-file)
151+
MIT

packages/core/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
A powerful tool for synchronizing Figma icons with your codebase. Fetch icons from Figma and generate React components automatically.
44

5+
[![Documentation](https://img.shields.io/badge/docs-visit-blue.svg)](https://iconsync-docs.vercel.app/)
6+
7+
## Documentation
8+
9+
For full documentation, visit [https://iconsync-docs.vercel.app/](https://iconsync-docs.vercel.app/)
10+
511
## Installation
612

713
```bash

0 commit comments

Comments
 (0)