-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement dummy Create card page (#6)
* Rename add card to create card * Implement PageTemplate. * Use Page template in add-cards * Add text inputs * Add some dropdowns. * Add some dropdowns. * Add some dropdown fixes. * Update main layout. * Add some icon buttons. * Adjust layout * Adjust navigation. * Finish create card page style. * Adjust submit button name. * Update plan
- Loading branch information
1 parent
e77c26e
commit 1075128
Showing
14 changed files
with
340 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { CardIcon, Colors, iconsMap, Routes } from '@/app/lib/shared'; | ||
import { DropdownField } from '@/app/ui/dropdown-field'; | ||
import PageTemplate from '@/app/ui/page-template'; | ||
import { SecondaryHeader } from '@/app/ui/secondary-header'; | ||
import { TextAreaField } from '@/app/ui/text-area-field'; | ||
import { TextField } from '@/app/ui/text-field'; | ||
import { IconCamera, IconPalette } from '@tabler/icons-react'; | ||
import Link from 'next/link'; | ||
|
||
export default function Page() { | ||
return ( | ||
<PageTemplate | ||
header={<SecondaryHeader title="Create a card" href={Routes.AddCards} />} | ||
> | ||
<form className="px-4 py-6 w-full h-full"> | ||
<div className="flex gap-4"> | ||
<TextField label="Card number" /> | ||
<Link | ||
className="btn btn-primary btn-square mt-9" | ||
href={Routes.ScanCard} | ||
> | ||
<IconCamera className="w-6 h-6" /> | ||
</Link> | ||
</div> | ||
<TextField label="Card name" /> | ||
<TextAreaField label="Note" /> | ||
<div className="flex gap-4"> | ||
<DropdownField | ||
label="Background color" | ||
dropdownClassName="dropdown-top" | ||
value={Colors.Khaki} | ||
options={Object.entries(Colors).map(([name, hex]) => ({ | ||
label: ( | ||
<div className="flex gap-2 items-center"> | ||
<div className="w-4 h-4" style={{ backgroundColor: hex }} /> | ||
<span>{name}</span> | ||
</div> | ||
), | ||
value: hex, | ||
}))} | ||
/> | ||
<button className="btn btn-primary btn-square mt-9"> | ||
<IconPalette className="w-6 h-6" /> | ||
</button> | ||
</div> | ||
<DropdownField | ||
label="Icon" | ||
dropdownClassName="dropdown-top" | ||
value={CardIcon.Airlines} | ||
options={Object.entries(iconsMap).map(([key, Icon]) => ({ | ||
label: ( | ||
<span> | ||
<Icon className="w-6 h-6" /> | ||
</span> | ||
), | ||
value: key, | ||
}))} | ||
/> | ||
<div className="h-32" /> | ||
<footer className="btm-nav btm-nav-md text-base-content px-4"> | ||
<button className="btn btn-primary w-full">Create card</button> | ||
</footer> | ||
</form> | ||
</PageTemplate> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import clsx from 'clsx'; | ||
|
||
export type Option<T> = { | ||
label: string | React.ReactNode; | ||
value: T; | ||
}; | ||
|
||
export function DropdownField<T = string>({ | ||
label, | ||
className, | ||
dropdownClassName, | ||
options, | ||
value, | ||
}: { | ||
label: string; | ||
className?: string; | ||
dropdownClassName?: string; | ||
options: Option<T>[]; | ||
value?: T; | ||
}) { | ||
const currentOption = options.find(option => option.value === value); | ||
|
||
return ( | ||
<label className={clsx('form-control w-full', className)}> | ||
<div className="label"> | ||
<span className="label-text">{label}</span> | ||
</div> | ||
<div className={clsx('dropdown dropdown-end', dropdownClassName)}> | ||
<div className="input input-bordered w-full flex items-center"> | ||
{currentOption ? ( | ||
<div tabIndex={0} role="button" className="w-full"> | ||
{currentOption.label} | ||
</div> | ||
) : ( | ||
<input tabIndex={0} type="text" role="button" className="w-full" /> | ||
)} | ||
</div> | ||
<ul | ||
tabIndex={0} | ||
className="dropdown-content menu bg-base-100 rounded-box z-[1] w-full p-2 shadow max-h-96 overflow-auto" | ||
> | ||
{options.map(option => ( | ||
<li key={String(option.value)}>{option.label}</li> | ||
))} | ||
</ul> | ||
</div> | ||
</label> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export default function PageTemplate({ | ||
header, | ||
children, | ||
footer, | ||
}: { | ||
header: React.ReactNode; | ||
footer?: React.ReactNode; | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<div className="h-full flex flex-col text-base-content"> | ||
{header} | ||
<main className="overflow-y-auto flex-1 bg-base-100">{children}</main> | ||
{footer} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.