Skip to content

Commit 724a607

Browse files
authored
Merge pull request #297 from mrzachnugent/@zach/docs-init
feat(docs): document the init command from the CLI + content improvements
2 parents 159a38b + d92cdb8 commit 724a607

File tree

5 files changed

+438
-522
lines changed

5 files changed

+438
-522
lines changed

apps/docs/astro.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export default defineConfig({
3939
link: '/getting-started/initial-setup/',
4040
},
4141
{
42-
label: 'Adding Icons',
43-
link: '/getting-started/adding-icons/',
42+
label: 'Icons',
43+
link: '/getting-started/icons/',
4444
},
4545
{
4646
label: 'Common patterns',

apps/docs/src/components/ui/button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const buttonVariants = cva(
99
{
1010
variants: {
1111
variant: {
12-
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
12+
default: 'bg-primary text-white hover:bg-primary/90',
1313
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
1414
outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
1515
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',

apps/docs/src/content/docs/getting-started/adding-icons.mdx

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: Adding Icons
3+
description: Wrap your icon components with `iconWithClassName` to add a class name to the icon.
4+
---
5+
6+
{/* prettier-ignore-start */}
7+
{/* prettier-ignore-end */}
8+
9+
import { Aside, Code, Steps } from '@astrojs/starlight/components';
10+
11+
## Set Up
12+
13+
<Steps>
14+
1. Install the following packages:
15+
</Steps>
16+
17+
```bash
18+
npx expo install react-native-svg lucide-react-native
19+
```
20+
<Steps>
21+
2. Resolve the className strings into icon styles
22+
</Steps>
23+
24+
Add the `iconWithClassName` function in the `~/lib/icons/iconWithClassName.ts` file.
25+
26+
```tsx
27+
import type { LucideIcon } from 'lucide-react-native';
28+
import { cssInterop } from 'nativewind';
29+
30+
export function iconWithClassName(icon: LucideIcon) {
31+
cssInterop(icon, {
32+
className: {
33+
target: 'style',
34+
nativeStyleToProp: {
35+
color: true,
36+
opacity: true,
37+
},
38+
},
39+
});
40+
}
41+
```
42+
43+
<Steps>
44+
3. Create a file for each Icon component
45+
</Steps>
46+
47+
48+
49+
## Create Icon Components
50+
51+
Wrap your icon components with `iconWithClassName` to add a class name to the icon.
52+
53+
<Aside type='caution'>
54+
Neglecting to wrap icons with `iconWithClassName` will prevent you from being able to update the
55+
`color` or `opacity` props via the `className` prop.
56+
</Aside>
57+
58+
### Create a file for each icon in `~/lib/icons/`
59+
60+
Wrap your icon components with `iconWithClassName` to add a class name to the icon.
61+
62+
**First**, create a new file in the `~/lib/icons/` directory with the name of the [LucideIcon](https://lucide.dev/icons/).
63+
64+
65+
**Then**, in each file:
66+
67+
<Steps>
68+
1. Import the Icon from LucideIcon
69+
</Steps>
70+
<Steps>
71+
2. Import the `iconWithClassName` function
72+
</Steps>
73+
<Steps>
74+
3. Call the `iconWithClassName` function and pass the icon as its argument
75+
</Steps>
76+
<Steps>
77+
4. Export the Icon as a named export
78+
</Steps>
79+
80+
### Examples
81+
82+
**Sun**
83+
84+
<Code title="~/lib/icons/Sun" lang="tsx" code={`
85+
import { Sun } from 'lucide-react-native';
86+
import { iconWithClassName } from './iconWithClassName';
87+
iconWithClassName(Sun);
88+
export { Sun };`} />
89+
90+
**MoonStar**
91+
92+
<Code title="~/lib/icons/MoonStar" lang="tsx" code={`
93+
import { MoonStar } from 'lucide-react-native';
94+
import { iconWithClassName } from './iconWithClassName';
95+
iconWithClassName(MoonStar);
96+
export { MoonStar };`} />
97+

0 commit comments

Comments
 (0)