[offers][feat] tweak offer background submission form (#490)
* [offers][feat] tweak offer background submission form * [offers][feat] tweak breadcrumbspull/492/head
parent
6682d81d2e
commit
03b0e4d856
@ -1,45 +1,50 @@
|
||||
export type BreadcrumbStep = {
|
||||
import clsx from 'clsx';
|
||||
import { ChevronRightIcon } from '@heroicons/react/20/solid';
|
||||
|
||||
export type BreadcrumbStep = Readonly<{
|
||||
label: string;
|
||||
step?: number;
|
||||
};
|
||||
}>;
|
||||
|
||||
type BreadcrumbsProps = Readonly<{
|
||||
currentStep: number;
|
||||
setStep: (nextStep: number) => void;
|
||||
steps: Array<BreadcrumbStep>;
|
||||
steps: ReadonlyArray<BreadcrumbStep>;
|
||||
}>;
|
||||
|
||||
function getPrimaryText(text: string) {
|
||||
return <p className="text-primary-700 text-sm">{text}</p>;
|
||||
}
|
||||
|
||||
function getSlateText(text: string) {
|
||||
return <p className="text-sm text-slate-400">{text}</p>;
|
||||
}
|
||||
|
||||
function getTextWithLink(text: string, onClickHandler: () => void) {
|
||||
return (
|
||||
<p
|
||||
className="hover:text-primary-700 cursor-pointer text-sm text-slate-400 hover:underline hover:underline-offset-2"
|
||||
onClick={onClickHandler}>
|
||||
{text}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
export function Breadcrumbs({ steps, currentStep, setStep }: BreadcrumbsProps) {
|
||||
return (
|
||||
<div className="flex space-x-1">
|
||||
<nav aria-label="Submit offer stages" className="inline-flex">
|
||||
<ol className="mx-auto flex w-full space-x-2 sm:space-x-4" role="list">
|
||||
{steps.map(({ label, step }, index) => (
|
||||
<div key={label} className="flex space-x-1">
|
||||
{step === currentStep
|
||||
? getPrimaryText(label)
|
||||
: step !== undefined
|
||||
? getTextWithLink(label, () => setStep(step))
|
||||
: getSlateText(label)}
|
||||
{index !== steps.length - 1 && getSlateText('>')}
|
||||
</div>
|
||||
<li key={step} className="flex items-center">
|
||||
{index > 0 && (
|
||||
<ChevronRightIcon
|
||||
aria-hidden="true"
|
||||
className="h-5 w-5 flex-shrink-0 text-slate-400"
|
||||
/>
|
||||
)}
|
||||
<button
|
||||
aria-current={step === currentStep ? 'page' : undefined}
|
||||
className={clsx(
|
||||
'text-xs font-medium text-slate-600 sm:text-sm',
|
||||
index > 0 && 'ml-4',
|
||||
step != null ? 'hover:text-primary-500' : 'cursor-default',
|
||||
step === currentStep && 'text-primary-500',
|
||||
)}
|
||||
type="button"
|
||||
{...(step != null
|
||||
? {
|
||||
onClick: () => {
|
||||
setStep(step);
|
||||
},
|
||||
}
|
||||
: {})}>
|
||||
{label}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</div>
|
||||
</ol>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
import { HorizontalDivider } from '@tih/ui';
|
||||
|
||||
export default function FormSection({
|
||||
children,
|
||||
title,
|
||||
}: Readonly<{ children: React.ReactNode; title: string }>) {
|
||||
return (
|
||||
<div>
|
||||
<div className="mb-4">
|
||||
<h2 className="text-lg font-medium leading-6 text-slate-900">
|
||||
{title}
|
||||
</h2>
|
||||
<HorizontalDivider />
|
||||
</div>
|
||||
<div className="space-y-4 sm:space-y-6">{children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
Loading…
Reference in new issue