-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
523 additions
and
218 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
73 changes: 73 additions & 0 deletions
73
src/pages/Registration/Steps/ContactDetails/Form/ReferralMethodSelector.tsx
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,73 @@ | ||
import { | ||
Field, | ||
Label, | ||
Listbox, | ||
ListboxButton, | ||
ListboxOption, | ||
ListboxOptions, | ||
} from "@headlessui/react"; | ||
import Icon from "components/Icon"; | ||
import { forwardRef } from "react"; | ||
import { referralOptions } from "../constants"; | ||
import type { ReferralOption } from "./schema"; | ||
|
||
interface Props { | ||
disabled?: boolean; | ||
value: ReferralOption; | ||
onChange: (value: ReferralOption) => void; | ||
error?: string; | ||
classes?: string; | ||
} | ||
|
||
function Star() { | ||
return <span className="text-red">*</span>; | ||
} | ||
|
||
export const ReferralMethodSelector = forwardRef<HTMLButtonElement, Props>( | ||
function List({ classes = "", ...props }, ref) { | ||
return ( | ||
<Field className={`${classes} grid`}> | ||
<Label className="text-sm mb-1 block"> | ||
How did you find about us? <Star /> | ||
</Label> | ||
<Listbox | ||
disabled={props.disabled} | ||
value={props.value} | ||
by="value" | ||
onChange={props.onChange} | ||
as="div" | ||
className="group" | ||
> | ||
<ListboxButton | ||
ref={ref} | ||
className="group flex items-center focus:outline outline-2 outline-blue-d1 outline-offset-[3px] text-sm justify-between w-full px-4 py-3.5 text-navy-d4 border border-gray-l3 font-heading rounded disabled:bg-gray-l5 disabled:text-navy-l1" | ||
> | ||
<span>{props.value.label}</span> | ||
<Icon | ||
size={20} | ||
className="group-data-[open]:rotate-180 transition-transform ease-in-out" | ||
type="ChevronDown" | ||
/> | ||
</ListboxButton> | ||
<ListboxOptions | ||
anchor={{ to: "bottom", gap: 5, padding: 10 }} | ||
className="border border-gray-l3 w-[var(--button-width)] bg-white z-10 rounded h-40" | ||
> | ||
{referralOptions.map((o) => ( | ||
<ListboxOption | ||
key={o.value} | ||
value={o} | ||
className="py-1 px-4 hover:bg-blue-l4 text-sm font-heading data-[selected]:text-blue" | ||
> | ||
{o.label} | ||
</ListboxOption> | ||
))} | ||
</ListboxOptions> | ||
<p className="mt-1 text-right text-xs text-red empty:hidden"> | ||
{props.error} | ||
</p> | ||
</Listbox> | ||
</Field> | ||
); | ||
} | ||
); |
74 changes: 74 additions & 0 deletions
74
src/pages/Registration/Steps/ContactDetails/Form/RoleSelector.tsx
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,74 @@ | ||
import { | ||
Field, | ||
Label, | ||
Listbox, | ||
ListboxButton, | ||
ListboxOption, | ||
ListboxOptions, | ||
} from "@headlessui/react"; | ||
import Icon from "components/Icon"; | ||
import { forwardRef } from "react"; | ||
import { roleOptions } from "../constants"; | ||
import type { RoleOption } from "./schema"; | ||
|
||
interface Props { | ||
disabled?: boolean; | ||
value: RoleOption; | ||
onChange: (value: RoleOption) => void; | ||
error?: string; | ||
classes?: string; | ||
} | ||
|
||
function Star() { | ||
return <span className="text-red">*</span>; | ||
} | ||
|
||
export const RoleSelector = forwardRef<HTMLButtonElement, Props>(function List( | ||
{ classes = "", ...props }, | ||
ref | ||
) { | ||
return ( | ||
<Field className={`${classes} grid`}> | ||
<Label className="text-sm mb-1 block"> | ||
What's your role within the organization? <Star /> | ||
</Label> | ||
<Listbox | ||
disabled={props.disabled} | ||
value={props.value} | ||
by="value" | ||
onChange={props.onChange} | ||
as="div" | ||
className="" | ||
> | ||
<ListboxButton | ||
ref={ref} | ||
className="group focus:outline outline-2 outline-blue-d1 outline-offset-[3px] flex items-center text-sm justify-between w-full px-4 py-3.5 text-navy-d4 border border-gray-l3 font-heading rounded disabled:bg-gray-l5 disabled:text-navy-l1" | ||
> | ||
<span>{props.value.label}</span> | ||
<Icon | ||
size={20} | ||
className="group-data-[open]:rotate-180 transition-transform ease-in-out" | ||
type="ChevronDown" | ||
/> | ||
</ListboxButton> | ||
<ListboxOptions | ||
anchor={{ to: "bottom", gap: 5, padding: 10 }} | ||
className="border border-gray-l3 w-[var(--button-width)] bg-white z-10 rounded h-40" | ||
> | ||
{roleOptions.map((o) => ( | ||
<ListboxOption | ||
key={o.value} | ||
value={o} | ||
className="py-1 px-4 hover:bg-blue-l4 text-sm font-heading data-[selected]:text-blue" | ||
> | ||
{o.label} | ||
</ListboxOption> | ||
))} | ||
</ListboxOptions> | ||
<p className="mt-1 text-right text-xs text-red empty:hidden"> | ||
{props.error} | ||
</p> | ||
</Listbox> | ||
</Field> | ||
); | ||
}); |
Oops, something went wrong.