Skip to content

Commit 2ea5e35

Browse files
committed
fix icon docs and things
1 parent 7652b99 commit 2ea5e35

File tree

6 files changed

+19
-22
lines changed

6 files changed

+19
-22
lines changed

docs/icons.md

+11-13
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
The Epic Stack uses SVG sprites for
44
[optimal icon performance](https://benadam.me/thoughts/react-svg-sprites/).
55
You'll find raw SVGs in the `./other/svg-icons` directory. These are then
6-
compiled into a sprite using the `npm run build:icons` script which generates
7-
the `icon.svg` file and an `icons.json` manifest file that allows Typescript to
8-
pick up the names of the icons.
6+
compiled into a sprite using the
7+
[`vite-plugin-icons-spritesheet`](https://github.com/jacobparis-insiders/vite-plugin-icons-spritesheet)
8+
plugin which generates the `app/components/ui/icons/sprite.svg` file and the
9+
accompanying `types.ts` file that allows Typescript to pick up the names of the
10+
icons.
911

1012
You can use [Sly](https://github.com/jacobparis-insiders/sly/tree/main/cli) to
1113
add new icons from the command line.
@@ -21,20 +23,16 @@ icons available in the `@radix-ui/icons` collection and let you select the ones
2123
you want to add.
2224

2325
Sly has been configured in the Epic Stack to automatically add the icons to the
24-
`./other/svg-icons` directory and to run the `npm run build:icons` script
25-
automatically, so there are no extra steps to take. You can see the
26-
configuration in the `./other/sly/sly.json` file.
26+
`./other/svg-icons` directory, so there are no extra steps to take. You can see
27+
the configuration in the `./other/sly/sly.json` file.
2728

2829
The SVGs used by default in the Epic Stack come from
2930
[icons.radix-ui.com](https://icons.radix-ui.com/). You can download additional
3031
SVG icons from there, or provide your own. Once you've added new files in the
31-
directory, run `npm run build:icons` and you can then use the `Icon` component
32-
to render it. The `icon` prop is the name of the file without the `.svg`
33-
extension. We recommend using `kebab-case` filenames rather than `PascalCase` to
34-
avoid casing issues with different operating systems.
35-
36-
Note that the `./other/build-icons.ts` file automatically removes `width` and
37-
`height` props from your SVGs to ensure they scale properly.
32+
directory, run `npm run build` and you can then use the `Icon` component to
33+
render it. The `icon` prop is the name of the file without the `.svg` extension.
34+
We recommend using `kebab-case` filenames rather than `PascalCase` to avoid
35+
casing issues with different operating systems.
3836

3937
By default, all the icons will have a height and width of `1em` so they should
4038
match the font-size of the text they're next to. You can also customize the size

docs/troubleshooting.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ error like this during local development:
4040

4141
> X [ERROR] Could not resolve "#app/components/ui/icon.tsx"
4242
43-
You need to be manually regenerate the icon with `npm run build:icons`.
43+
You need to be manually regenerate the icon with `npm run build`.
4444

4545
See
4646
[the icons decision document](https://github.com/epicweb-dev/epic-stack/blob/main/docs/decisions/020-icons.md)

other/sly/sly.json

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
{
55
"name": "@radix-ui/icons",
66
"directory": "./other/svg-icons",
7-
"postinstall": ["npm", "run", "build:icons"],
87
"transformers": ["transform-icon.ts"]
98
}
109
]

other/svg-icons/README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ These icons were downloaded from https://icons.radix-ui.com/ which is licensed
44
under MIT: https://github.com/radix-ui/icons/blob/master/LICENSE
55

66
It's important that you only add icons to this directory that the application
7-
actually needs as there's no "tree-shaking" for sprites. If you wish to manually
8-
split up your SVG sprite into multiple files, you'll need to update the
9-
`build-icons.ts` script to do that.
10-
11-
Run `npm run build:icons` to update the sprite.
7+
actually needs as the `vite-plugin-icons-spritesheet` plugin is configured to
8+
generate a spritesheet with icons from this directory. The plugin re-runs on
9+
every edit/delete/add to this directory.

package-lock.json

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsconfig.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"paths": {
99
"#app/*": ["./app/*"],
1010
"#tests/*": ["./tests/*"],
11-
"@/icon-name": ["./app/components/ui/icons/types.ts", "./types/types.ts"]
11+
"@/icon-name": [
12+
"./app/components/ui/icons/types.ts",
13+
"./types/icon-name.d.ts"
14+
]
1215
}
1316
}
1417
}

0 commit comments

Comments
 (0)