Skip to content

Commit a52652a

Browse files
committed
chore: add _library page
1 parent 3a3d9fc commit a52652a

File tree

15 files changed

+263
-27
lines changed

15 files changed

+263
-27
lines changed

src/app/_components/Alert.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ export const Alert = ({ class: className = "", children }) => {
55
</div>
66
)
77
}
8+
9+
export const AlertExample = () => <Alert>Hello World!</Alert>

src/app/_components/AutoGrowTextarea.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useState } from "preact/hooks"
2+
13
export const AutoGrowTextarea = ({ class: className = "", value, onChange, ...props }) => (
24
<div class="vstack relative">
35
<textarea class={`!absolute !inset-0 ${className}`} value={value} onInput={e => onChange(e.target!.value)} {...props} />
@@ -8,3 +10,13 @@ export const AutoGrowTextarea = ({ class: className = "", value, onChange, ...pr
810
/>
911
</div>
1012
)
13+
14+
export const AutoGrowTextareaExample = () => {
15+
const [text, setText] = useState("")
16+
17+
return (
18+
<div>
19+
<AutoGrowTextarea value={text} onChange={setText} placeholder="Line-growing textarea" />
20+
</div>
21+
)
22+
}

src/app/_components/Badge.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,11 @@ export const Badge = ({ class: className = "", value }) =>
22
value > 0 ? (
33
<span class={`ml-1 bg-neutral-6 text-neutral-11 px-2 py-1 text-xs font-bold rounded-full ${className}`}>{value}</span>
44
) : null
5+
6+
export const BadgeExample = () => (
7+
<div class="flex gap-4 items-center">
8+
<span>
9+
Notifications <Badge value={5} />
10+
</span>
11+
</div>
12+
)

src/app/_components/Checkbox.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useState } from "preact/hooks"
2+
13
export const Checkbox = ({ label, value, onChange }) => {
24
return (
35
<label class="flex items-center">
@@ -6,3 +8,13 @@ export const Checkbox = ({ label, value, onChange }) => {
68
</label>
79
)
810
}
11+
12+
export const CheckboxExample = () => {
13+
const [checked, setChecked] = useState(true)
14+
15+
return (
16+
<div>
17+
<Checkbox label="Check me" value={checked} onChange={setChecked} />
18+
</div>
19+
)
20+
}

src/app/_components/Dropdown.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/app/_components/List.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useState } from "preact/hooks"
12
import { useAriaList } from "../_hooks"
23

34
const List = ({ class: className = "", children, ...props }) => {
@@ -38,3 +39,20 @@ export { List }
3839
List.Item = ListItem
3940
ListItem.Title = ListItemTitle
4041
ListItem.Subtitle = ListItemSubtitle
42+
43+
export const ListExample = () => {
44+
const [selected, setSelected] = useState(1)
45+
46+
return (
47+
<div class="h-64">
48+
<List>
49+
{[1, 2, 3, 4, 5].map(i => (
50+
<List.Item key={i} selected={selected === i} onClick={() => setSelected(i)}>
51+
<ListItem.Title>Item {i}</ListItem.Title>
52+
<ListItem.Subtitle>Subtitle</ListItem.Subtitle>
53+
</List.Item>
54+
))}
55+
</List>
56+
</div>
57+
)
58+
}

src/app/_components/Markdown.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,35 @@ export const Markdown = ({ input, class: className = "", ...props }) => {
1515

1616
return <div ref={ref} class={`overflow-x-hidden markdown ${className}`} {...props} />
1717
}
18+
19+
const sampleMd = `
20+
# Heading 1
21+
## Heading 2
22+
### Heading 3
23+
24+
Some text with **bold** and *italic text*.
25+
26+
- Item 1
27+
- Item 2
28+
- Item 3
29+
30+
1. Numbered 1
31+
2. Numbered 2
32+
3. Numbered 3
33+
34+
> This is a blockquote
35+
36+
\`\`\`javascript
37+
const greeting = "Hello, World!";
38+
console.log(greeting);
39+
\`\`\`
40+
41+
[Link](https://github.com/cztomsik/ava)`
42+
43+
export const MarkdownExample = () => {
44+
return (
45+
<div class="border border-neutral-6 rounded p-4">
46+
<Markdown input={sampleMd} />
47+
</div>
48+
)
49+
}

src/app/_components/Page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const gridTemplate = `
77
"list footer details" auto / min-content 1fr min-content
88
`
99

10-
const Page = ({ children }) => (
11-
<div class="grid h-screen" style={{ gridTemplate }}>
10+
const Page = ({ children, class: className = "" }) => (
11+
<div class={`grid h-screen ${className}`} style={{ gridTemplate }}>
1212
{children}
1313
</div>
1414
)

src/app/_components/Select.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useState } from "preact/hooks"
2+
13
export const Select = ({ class: className = "", ...props }) => (
24
<div class={`relative ${className}`}>
35
<select class="block w-full overflow-hidden pr-6" {...props} />
@@ -8,3 +10,18 @@ export const Select = ({ class: className = "", ...props }) => (
810
</div>
911
</div>
1012
)
13+
14+
export const SelectExample = () => {
15+
const [value, setValue] = useState("option2")
16+
17+
return (
18+
<div class="space-y-4">
19+
<Select value={value} onChange={e => setValue(e.target.value)}>
20+
<option value="option1">Option 1</option>
21+
<option value="option2">Option 2</option>
22+
</Select>
23+
24+
<p class="text-sm text-neutral-11">Selected: {value}</p>
25+
</div>
26+
)
27+
}

src/app/_components/Slider.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useState } from "preact/hooks"
2+
13
// TODO: until this gets fixed the :focus does not really work for ranges in Safari (and macos webview)
24
// https://bugs.webkit.org/show_bug.cgi?id=234516
35

@@ -17,3 +19,13 @@ export const Slider = ({ label, onChange, ...props }) => {
1719
</div>
1820
)
1921
}
22+
23+
export const SliderExample = () => {
24+
const [volume, setVolume] = useState(0.5)
25+
26+
return (
27+
<div class="space-y-4 max-w-md">
28+
<Slider label="Volume" value={volume} onChange={setVolume} min={0} max={1} step={0.1} />
29+
</div>
30+
)
31+
}

0 commit comments

Comments
 (0)