Skip to content

Commit 5c9fcc5

Browse files
committed
docs(ui): add example of what's to come
1 parent 39902a8 commit 5c9fcc5

File tree

1 file changed

+100
-7
lines changed

1 file changed

+100
-7
lines changed

apps/docs/pages/ui/overview.mdx

Lines changed: 100 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,106 @@
11
# Davstack UI
22

3-
Plans for this package:
3+
In the coming weeks I will be releasing a wide range of reusable UI component snippets that I have built while working on [Ream](https://reamapp.com).
44

5-
- Extension of shadcn/ui
6-
- Makes react-hook-form + shadcn/ui much more easier to use, WITHOUT sacrificing flexibility
7-
- Comprensive library of snippets for common form components
8-
- Dialog manager
9-
- Slot components
5+
This includes a comprehensive form library that is built on top of [shadcn/ui](https://ui.shadcn.com/) and [react-hook-form](https://react-hook-form.com/).
106

11-
Much of the code in this package has already been written while building [Ream](https://reamapp.com), but it is currently in a private repository.
7+
Example usage:
8+
9+
```tsx
10+
'use client';
11+
12+
import { useRouter } from 'next/navigation';
13+
import {
14+
Button,
15+
ButtonProps,
16+
dialog,
17+
Field,
18+
Form,
19+
PlusCircleIcon,
20+
toast,
21+
} from '@ui';
22+
import { z } from 'zod';
23+
24+
import { api } from '@ream/api/react';
25+
26+
export const createRitualFormSchema = z.object({
27+
title: z.string().min(1, 'Name is required'),
28+
description: z.string().optional(),
29+
frequency: FrequencySchema.optional(),
30+
timeOfDay: z.string().optional(),
31+
});
32+
33+
export interface CreateRitualFormProps {}
34+
35+
export function CreateRitualForm(props: CreateRitualFormProps) {
36+
const {} = props;
37+
38+
const createRitualMutation = api.ritual.createRitual.useMutation();
39+
40+
return (
41+
<>
42+
<Form.Root
43+
schema={createRitualFormSchema}
44+
onSubmit={async (d) => createRitualMutation?.mutateAsync(d)}
45+
mode="onSubmit"
46+
>
47+
<Form.Header>
48+
<Form.Title>Create ritual</Form.Title>
49+
</Form.Header>
50+
<Field.Text
51+
name="title"
52+
placeholder="morning ritual"
53+
inputProps={{
54+
autoFocus: true,
55+
}}
56+
/>
57+
<Field.Textarea
58+
name="description"
59+
optionalIndicator
60+
withVoiceRecognition
61+
/>
62+
63+
<Field.Time
64+
name="timeOfDay"
65+
orientation="horizontal"
66+
slotClasses={{
67+
root: 'mt-2',
68+
}}
69+
label="Notification Time"
70+
helpMessage="We will remind you at this time, and order your rituals based on this time."
71+
/>
72+
73+
<Field.Select
74+
name="frequency"
75+
options={[
76+
{ label: 'daily', value: 'DAILY' },
77+
{ label: 'weekly', value: 'WEEKLY' },
78+
{ label: 'monthly', value: 'MONTHLY' },
79+
{ label: 'yearly', value: 'YEARLY' },
80+
]}
81+
/>
82+
83+
<Form.SubmitButton className="ml-auto w-auto">create</Form.SubmitButton>
84+
</Form.Root>
85+
</>
86+
);
87+
}
88+
89+
export const openCreateRitualModal = () => {
90+
dialog.open(<CreateRitualForm />);
91+
};
92+
93+
export type CreateRitualButtonProps = ButtonProps & {};
94+
95+
export function CreateRitualButton(props: CreateRitualButtonProps) {
96+
const { ...buttonProps } = props;
97+
return (
98+
<Button variant="outline" onClick={openCreateRitualModal} {...buttonProps}>
99+
<PlusCircleIcon className="h-4 w-4 stroke-fg-muted" />
100+
create ritual
101+
</Button>
102+
);
103+
}
104+
```
12105

13106
I will be working on this package in the coming weeks. If you are interested in this package, please join the discord server and let me know!

0 commit comments

Comments
 (0)