27 changed files with 116 additions and 270 deletions
@ -13,8 +13,8 @@ lint: |
|||||
- [email protected] |
- [email protected] |
||||
- [email protected] |
- [email protected] |
||||
- git-diff-check |
- git-diff-check |
||||
- [email protected]2 |
- [email protected]3 |
||||
- [email protected].2 |
- [email protected].3 |
||||
runtimes: |
runtimes: |
||||
enabled: |
enabled: |
||||
- [email protected] |
- [email protected] |
||||
|
|||||
@ -1,73 +1,22 @@ |
|||||
import type React from "react"; |
import type React from "react"; |
||||
import type { HTMLProps } from "react"; |
import type { HTMLProps } from "react"; |
||||
|
|
||||
import { Button } from "@components/form/Button.js"; |
|
||||
import { |
|
||||
ArrowRightCircleIcon, |
|
||||
ArrowUturnLeftIcon, |
|
||||
CheckIcon, |
|
||||
ChevronRightIcon, |
|
||||
HomeIcon |
|
||||
} from "@heroicons/react/24/outline"; |
|
||||
|
|
||||
export interface FormProps extends HTMLProps<HTMLFormElement> { |
export interface FormProps extends HTMLProps<HTMLFormElement> { |
||||
title: string; |
|
||||
breadcrumbs: string[]; |
|
||||
reset: () => void; |
|
||||
onSubmit: (event: React.FormEvent<HTMLFormElement>) => Promise<void>; |
onSubmit: (event: React.FormEvent<HTMLFormElement>) => Promise<void>; |
||||
dirty: boolean; |
|
||||
} |
} |
||||
|
|
||||
export const Form = ({ |
export const Form = ({ |
||||
title, |
|
||||
breadcrumbs, |
|
||||
reset, |
|
||||
dirty, |
|
||||
children, |
children, |
||||
onSubmit, |
onSubmit, |
||||
...props |
...props |
||||
}: FormProps): JSX.Element => { |
}: FormProps): JSX.Element => { |
||||
return ( |
return ( |
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
<form |
||||
<form className="w-full px-2" onSubmit={onSubmit} {...props}> |
className="mr-2 w-full rounded-md bg-backgroundSecondary px-2" |
||||
<div className="select-none rounded-md bg-backgroundPrimary p-4"> |
onSubmit={onSubmit} |
||||
<ol className="flex gap-4 text-textSecondary"> |
{...props} |
||||
<li className="cursor-pointer hover:brightness-disabled"> |
> |
||||
<HomeIcon className="h-5 w-5 flex-shrink-0" /> |
<div className="flex flex-col gap-3 p-4">{children}</div> |
||||
</li> |
|
||||
{breadcrumbs.map((breadcrumb, index) => ( |
|
||||
<li key={index} className="flex gap-4"> |
|
||||
<ChevronRightIcon className="h-5 w-5 flex-shrink-0 brightness-disabled" /> |
|
||||
<span className="cursor-pointer text-sm font-medium hover:brightness-disabled"> |
|
||||
{breadcrumb} |
|
||||
</span> |
|
||||
</li> |
|
||||
))} |
|
||||
</ol> |
|
||||
<div className="mt-2 flex items-center"> |
|
||||
<h2 className="text-3xl font-bold tracking-tight text-textPrimary"> |
|
||||
{title} |
|
||||
</h2> |
|
||||
<div className="ml-auto flex gap-2"> |
|
||||
<Button |
|
||||
type="button" |
|
||||
onClick={() => { |
|
||||
reset(); |
|
||||
}} |
|
||||
iconBefore={<ArrowUturnLeftIcon className="w-4" />} |
|
||||
> |
|
||||
Reset |
|
||||
</Button> |
|
||||
<Button |
|
||||
disabled={!dirty} |
|
||||
iconBefore={<CheckIcon className="w-4" />} |
|
||||
> |
|
||||
Save |
|
||||
</Button> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
<div className="flex flex-col gap-3 p-2">{children}</div> |
|
||||
</form> |
</form> |
||||
); |
); |
||||
}; |
}; |
||||
|
|||||
Loading…
Reference in new issue