summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src/demo.tsx
blob: 96579c999007aee73f383731914241593198f393 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
import type { Component } from "solid-js"
import { createSignal } from "solid-js"
import {
  Accordion,
  Button,
  Checkbox,
  Select,
  Tabs,
  Tooltip,
  Fonts,
  List,
  Dialog,
  Icon,
  IconButton,
  Input,
  SelectDialog,
  Collapsible,
} from "./components"
import "./index.css"

const Demo: Component = () => {
  const [dialogOpen, setDialogOpen] = createSignal(false)
  const [selectDialogOpen, setSelectDialogOpen] = createSignal(false)
  const [inputValue, setInputValue] = createSignal("")
  const [checked, setChecked] = createSignal(false)
  const [termsAccepted, setTermsAccepted] = createSignal(false)

  const Content = (props: { dark?: boolean }) => (
    <div class={`${props.dark ? "dark" : ""}`}>
      <h3>Buttons</h3>
      <section>
        <Button variant="primary" size="normal">
          Normal Primary
        </Button>
        <Button variant="secondary" size="normal">
          Normal Secondary
        </Button>
        <Button variant="ghost" size="normal">
          Normal Ghost
        </Button>
        <Button variant="secondary" size="normal" disabled>
          Normal Disabled
        </Button>
        <Button variant="primary" size="large">
          Large Primary
        </Button>
        <Button variant="secondary" size="large">
          Large Secondary
        </Button>
        <Button variant="ghost" size="large">
          Large Ghost
        </Button>
        <Button variant="secondary" size="large" disabled>
          Large Disabled
        </Button>
      </section>
      <h3>Select</h3>
      <section>
        <Select
          class={props.dark ? "dark" : ""}
          variant="primary"
          options={["Option 1", "Option 2", "Option 3"]}
          placeholder="Select Primary"
        />
        <Select
          variant="secondary"
          class={props.dark ? "dark" : ""}
          options={["Option 1", "Option 2", "Option 3"]}
          placeholder="Select Secondary"
        />
        <Select
          variant="ghost"
          class={props.dark ? "dark" : ""}
          options={["Option 1", "Option 2", "Option 3"]}
          placeholder="Select Ghost"
        />
      </section>
      <h3>Tabs</h3>
      <section>
        <Tabs defaultValue="tab1" style={{ width: "100%" }}>
          <Tabs.List>
            <Tabs.Trigger value="tab1">Tab 1</Tabs.Trigger>
            <Tabs.Trigger value="tab2">Tab 2</Tabs.Trigger>
            <Tabs.Trigger value="tab3">Tab 3</Tabs.Trigger>
            <Tabs.Trigger value="tab4" disabled>
              Disabled Tab
            </Tabs.Trigger>
          </Tabs.List>
          <Tabs.Content value="tab1">
            <div style={{ padding: "16px" }}>
              <h4>Tab 1 Content</h4>
              <p>This is the content for the first tab.</p>
            </div>
          </Tabs.Content>
          <Tabs.Content value="tab2">
            <div style={{ padding: "16px" }}>
              <h4>Tab 2 Content</h4>
              <p>This is the content for the second tab.</p>
            </div>
          </Tabs.Content>
          <Tabs.Content value="tab3">
            <div style={{ padding: "16px" }}>
              <h4>Tab 3 Content</h4>
              <p>This is the content for the third tab.</p>
            </div>
          </Tabs.Content>
          <Tabs.Content value="tab4">
            <div style={{ padding: "16px" }}>
              <h4>Tab 4 Content</h4>
              <p>This tab should be disabled.</p>
            </div>
          </Tabs.Content>
        </Tabs>
      </section>
      <h3>Tooltips</h3>
      <section>
        <Tooltip value="This is a top tooltip" placement="top">
          <Button variant="secondary">Top Tooltip</Button>
        </Tooltip>
        <Tooltip value="This is a bottom tooltip" placement="bottom">
          <Button variant="secondary">Bottom Tooltip</Button>
        </Tooltip>
        <Tooltip value="This is a left tooltip" placement="left">
          <Button variant="secondary">Left Tooltip</Button>
        </Tooltip>
        <Tooltip value="This is a right tooltip" placement="right">
          <Button variant="secondary">Right Tooltip</Button>
        </Tooltip>
        <Tooltip value={`Dynamic tooltip: ${new Date().toLocaleTimeString()}`} placement="top">
          <Button variant="primary">Dynamic Tooltip</Button>
        </Tooltip>
      </section>
      <h3>List</h3>
      <section style={{ height: "300px" }}>
        <List data={["Item 1", "Item 2", "Item 3"]} key={(x) => x}>
          {(x) => <div>{x}</div>}
        </List>
      </section>
      <h3>Input</h3>
      <section>
        <Input
          placeholder="Enter text..."
          value={inputValue()}
          onInput={(e: InputEvent & { currentTarget: HTMLInputElement }) => setInputValue(e.currentTarget.value)}
        />
        <Input placeholder="Disabled input" disabled />
        <Input type="password" placeholder="Password input" />
      </section>
      <h3>Checkbox</h3>
      <section style={{ "flex-direction": "column", "align-items": "flex-start", gap: "12px" }}>
        <Checkbox label="Simple checkbox" />
        <Checkbox label="Checked by default" defaultChecked />
        <Checkbox label="Disabled checkbox" disabled />
        <Checkbox label="Disabled & checked" disabled checked />
        <Checkbox
          label="Controlled checkbox"
          description="This checkbox is controlled by state"
          checked={checked()}
          onChange={setChecked}
        />
        <Checkbox label="With description" description="This is a helpful description for the checkbox" />
        <Checkbox label="Indeterminate state" description="Useful for nested checkbox lists" indeterminate />
        <Checkbox
          label="I agree to the Terms and Conditions"
          description="You must agree to continue"
          checked={termsAccepted()}
          onChange={setTermsAccepted}
          validationState={!termsAccepted() ? "invalid" : "valid"}
        />
      </section>
      <h3>Icons</h3>
      <section>
        <Icon name="close" />
        <Icon name="checkmark" />
        <Icon name="chevron-down" />
        <Icon name="chevron-up" />
        <Icon name="chevron-left" />
        <Icon name="chevron-right" />
        <Icon name="search" />
        <Icon name="loading" />
      </section>
      <h3>Icon Buttons</h3>
      <section>
        <IconButton icon="close" onClick={() => console.log("Close clicked")} />
        <IconButton icon="checkmark" onClick={() => console.log("Check clicked")} />
        <IconButton icon="search" onClick={() => console.log("Search clicked")} disabled />
      </section>
      <h3>Dialog</h3>
      <section>
        <Button onClick={() => setDialogOpen(true)}>Open Dialog</Button>
        <Dialog open={dialogOpen()} onOpenChange={setDialogOpen}>
          <Dialog.Title>Example Dialog</Dialog.Title>
          <Dialog.Description>This is an example dialog with a title and description.</Dialog.Description>
          <div
            style={{
              "margin-top": "16px",
              display: "flex",
              gap: "8px",
              "justify-content": "flex-end",
            }}
          >
            <Button variant="ghost" onClick={() => setDialogOpen(false)}>
              Cancel
            </Button>
            <Button variant="primary" onClick={() => setDialogOpen(false)}>
              Confirm
            </Button>
          </div>
        </Dialog>
      </section>
      <h3>Select Dialog</h3>
      <section>
        <Button onClick={() => setSelectDialogOpen(true)}>Open Select Dialog</Button>
        <SelectDialog
          title="Select an Option"
          defaultOpen={selectDialogOpen()}
          onOpenChange={setSelectDialogOpen}
          items={["Option 1", "Option 2", "Option 3", "Option 4", "Option 5"]}
          key={(x) => x}
          onSelect={(option) => {
            console.log("Selected:", option)
            setSelectDialogOpen(false)
          }}
          placeholder="Search options..."
        >
          {(item) => <div>{item}</div>}
        </SelectDialog>
      </section>
      <h3>Collapsible</h3>
      <section>
        <Collapsible>
          <Collapsible.Trigger>
            <Button variant="secondary">Toggle Content</Button>
          </Collapsible.Trigger>
          <Collapsible.Content>
            <div
              style={{
                padding: "16px",
                "background-color": "var(--surface-base)",
                "border-radius": "8px",
                "margin-top": "8px",
              }}
            >
              <p>This is collapsible content that can be toggled open and closed.</p>
              <p>It animates smoothly using CSS animations.</p>
            </div>
          </Collapsible.Content>
        </Collapsible>
      </section>
      <h3>Accordion</h3>
      <section>
        <Accordion collapsible>
          <Accordion.Item value="item-1">
            <Accordion.Header>
              <Accordion.Trigger>What is Kobalte?</Accordion.Trigger>
            </Accordion.Header>
            <Accordion.Content>
              <div style={{ padding: "16px" }}>
                <p>Kobalte is a UI toolkit for building accessible web apps and design systems with SolidJS.</p>
              </div>
            </Accordion.Content>
          </Accordion.Item>
          <Accordion.Item value="item-2">
            <Accordion.Header>
              <Accordion.Trigger>Is it accessible?</Accordion.Trigger>
            </Accordion.Header>
            <Accordion.Content>
              <div style={{ padding: "16px" }}>
                <p>Yes. It adheres to the WAI-ARIA design patterns.</p>
              </div>
            </Accordion.Content>
          </Accordion.Item>
          <Accordion.Item value="item-3">
            <Accordion.Header>
              <Accordion.Trigger>Can it be animated?</Accordion.Trigger>
            </Accordion.Header>
            <Accordion.Content>
              <div style={{ padding: "16px" }}>
                <p>Yes! You can animate the content height using CSS animations.</p>
              </div>
            </Accordion.Content>
          </Accordion.Item>
        </Accordion>
      </section>
    </div>
  )

  return (
    <>
      <Fonts />
      <main>
        <Content />
        <Content dark />
      </main>
    </>
  )
}

export default Demo