-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform.tsx
More file actions
64 lines (57 loc) · 1.38 KB
/
form.tsx
File metadata and controls
64 lines (57 loc) · 1.38 KB
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
import type {
FormContentProps,
FormDescriptionProps,
FormFooterProps,
FormHeaderProps,
FormProps,
FormTitleProps
} from '../types'
import { Container } from './container'
import { Heading } from './heading'
import { Text } from './text'
const FormTitle: React.FC<FormTitleProps> = ({ children }) => {
return <Heading level="2">{children}</Heading>
}
const FormDescription: React.FC<FormDescriptionProps> = ({ children }) => {
return (
<Text variant="secondary" size="sm">
{children}
</Text>
)
}
const FormHeader: React.FC<FormHeaderProps> = ({ children }) => {
return <Container arrangement="column">{children}</Container>
}
const FormContent: React.FC<FormContentProps> = ({ children }) => {
return <Container gap="md">{children}</Container>
}
const FormFooter: React.FC<FormFooterProps> = ({ children }) => {
return (
<Container arrangement="row" justify="end" gap="sm">
{children}
</Container>
)
}
const Form: React.FC<FormProps> = ({ children, onSubmit, action, method, onKeyDown }) => {
return (
<form
onSubmit={
onSubmit
? e => {
e.preventDefault()
onSubmit(e)
}
: undefined
}
onKeyDown={onKeyDown}
action={action}
method={method}
className="w-full"
>
<Container gap="md" width="full">
{children}
</Container>
</form>
)
}
export { Form, FormContent, FormDescription, FormFooter, FormHeader, FormTitle }