-
Notifications
You must be signed in to change notification settings - Fork 87
chore: improve supported domain initial workflow #8054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 22 commits
6839602
529a1ae
41a4f91
fd15458
97c0eac
fafe17b
a50b2a1
259c544
08f6722
ba68dc9
ec7d549
3e69a2f
d169e4d
7ffd276
48cc104
5109bbd
dc1a5f5
d0850c4
167aa90
0083997
746515e
bd32dea
1a022ea
5a0c45b
a194313
6441704
c6c0910
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,72 @@ | ||
import { Popover, Transition, Combobox } from '@headlessui/react' | ||
import { Popover, Transition, Combobox, RadioGroup } from '@headlessui/react' | ||
import { CustomIcon } from '@src/components/CustomIcon' | ||
import { Fragment } from 'react' | ||
import { Fragment, useState } from 'react' | ||
import { isDesktop } from '@src/lib/isDesktop' | ||
import { ActionButton } from '@src/components/ActionButton' | ||
|
||
interface Domain { | ||
name: string | ||
} | ||
|
||
function SupportedDomainsRadioGroup({ | ||
selected, | ||
setSelected, | ||
domains, | ||
}: { | ||
selected: string | ||
setSelected: (environment: string) => void | ||
domains: Domain[] | ||
}) { | ||
return ( | ||
<div className="w-full py-4"> | ||
<div className="mx-auto w-full max-w-md"> | ||
<RadioGroup value={selected} onChange={setSelected}> | ||
<div className="space-y-2"> | ||
{domains.map((domain) => ( | ||
<RadioGroup.Option | ||
key={domain.name} | ||
value={domain.name} | ||
className={({ checked }) => | ||
`${checked ? 'bg-primary' : 'text-chalkboard-70'} | ||
relative flex cursor-pointer rounded py-1 focus:outline-none` | ||
} | ||
> | ||
{({ checked }) => ( | ||
<> | ||
<div className="flex w-full items-center justify-between"> | ||
<div className="flex items-center"> | ||
<div className="text-sm"> | ||
<RadioGroup.Label | ||
as="p" | ||
className={`text-xs px-1 ${ | ||
checked | ||
? 'text-chalkboard-30' | ||
: 'text-chalkboard-70 dark:text-chalkboard-30' | ||
}`} | ||
> | ||
{domain.name} | ||
</RadioGroup.Label> | ||
</div> | ||
</div> | ||
{checked && ( | ||
<div className="shrink-0 text-white"> | ||
<CustomIcon | ||
name="checkmark" | ||
className="w-4 h-4 text-chalkboard-10 dark:text-chalkboard-40" | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
</> | ||
)} | ||
</RadioGroup.Option> | ||
))} | ||
</div> | ||
</RadioGroup> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export const AdvancedSignInOptions = ({ | ||
pool, | ||
|
@@ -14,6 +79,19 @@ | |
selectedEnvironment: string | ||
setSelectedEnvironment: (environment: string) => void | ||
}) => { | ||
const domains: Domain[] = [ | ||
{ | ||
name: 'zoo.dev', | ||
}, | ||
{ | ||
name: 'zoogov.dev', | ||
}, | ||
{ | ||
name: 'dev.zoo.dev', | ||
}, | ||
] | ||
const [showCustomInput, setShowCustomInput] = useState(false) | ||
|
||
return isDesktop() ? ( | ||
<div className="flex flex-row items-center"> | ||
<span className="text-xs text-chalkboard-70 dark:text-chalkboard-30 w-64 h-8"> | ||
|
@@ -51,41 +129,70 @@ | |
as={Fragment} | ||
> | ||
<Popover.Panel | ||
className={`z-10 absolute top-full left-0 mt-1 p-2 w-52 bg-chalkboard-10 dark:bg-chalkboard-90 | ||
className={`z-10 flex flex-col absolute top-full left-0 mt-1 p-2 w-52 bg-chalkboard-10 dark:bg-chalkboard-90 | ||
border border-solid border-chalkboard-20 dark:border-chalkboard-90 rounded | ||
shadow-lg`} | ||
> | ||
{() => ( | ||
<> | ||
<div className="flex flex-col items-start py-0.5"> | ||
<span className="text-xs text-chalkboard-70 dark:text-chalkboard-30"> | ||
Domain | ||
</span> | ||
</div> | ||
<span className="text-xs text-chalkboard-70 dark:text-chalkboard-30"> | ||
Supported Domains | ||
</span> | ||
Check warning on line 140 in src/routes/AdvancedSignInOptions.tsx
|
||
<SupportedDomainsRadioGroup | ||
selected={selectedEnvironment} | ||
setSelected={setSelectedEnvironment} | ||
domains={domains} | ||
/> | ||
<ActionButton | ||
Element="button" | ||
className={ | ||
'text-xs text-chalkboard-70 dark:text-chalkboard-30 border-none pl-0 pb-2' | ||
} | ||
onClick={() => setShowCustomInput((show) => !show)} | ||
> | ||
Advanced options | ||
<CustomIcon | ||
name="caretDown" | ||
className={`w-4 h-4 ${!showCustomInput ? '' : 'ui-open:rotate-180'} `} | ||
/> | ||
</ActionButton> | ||
Check warning on line 158 in src/routes/AdvancedSignInOptions.tsx
|
||
{showCustomInput && ( | ||
<div className="flex flex-col items-start py-0.5"> | ||
<span className="text-xs text-chalkboard-70 dark:text-chalkboard-30"> | ||
Domain | ||
</span> | ||
Check warning on line 163 in src/routes/AdvancedSignInOptions.tsx
|
||
</div> | ||
)} | ||
|
||
<Combobox | ||
value={selectedEnvironment} | ||
onChange={setSelectedEnvironment} | ||
> | ||
<Combobox.Input | ||
className="gap-1 rounded h-9 mr-auto max-h-min min-w-max border py-1 flex items-center dark:hover:bg-chalkboard-90 text-xs text-chalkboard-70 dark:text-chalkboard-30" | ||
placeholder="auto" | ||
onChange={(event) => | ||
setSelectedEnvironment(event.target.value) | ||
} | ||
/> | ||
{showCustomInput && ( | ||
<Combobox.Input | ||
className="gap-1 rounded h-6 border px-2 flex items-center dark:hover:bg-chalkboard-80 text-xs text-chalkboard-70 dark:text-chalkboard-30 dark:bg-chalkboard-90" | ||
placeholder="auto" | ||
onChange={(event) => | ||
setSelectedEnvironment(event.target.value) | ||
} | ||
/> | ||
)} | ||
Comment on lines
+171
to
+179
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UI State Synchronization Issue There's a potential state synchronization issue between the radio group selection and the custom domain input. When a user:
The application maintains the Consider one of these approaches:
This would improve the user experience by maintaining a consistent relationship between the UI state and the underlying domain value. Spotted by Diamond |
||
</Combobox> | ||
<div className="flex flex-col items-start py-0.5"> | ||
<span className="text-xs text-chalkboard-70 dark:text-chalkboard-30"> | ||
Connection pool | ||
</span> | ||
</div> | ||
{showCustomInput && ( | ||
<div className="flex flex-col items-start py-1"> | ||
<span className="text-xs text-chalkboard-70 dark:text-chalkboard-30"> | ||
Connection pool | ||
</span> | ||
Check warning on line 185 in src/routes/AdvancedSignInOptions.tsx
|
||
</div> | ||
)} | ||
<Combobox value={pool} onChange={setPool}> | ||
<Combobox.Input | ||
className=" | ||
gap-1 rounded h-9 mr-auto max-h-min min-w-max border py-1 flex items-center dark:hover:bg-chalkboard-90 text-xs text-chalkboard-70 dark:text-chalkboard-30" | ||
placeholder="auto" | ||
onChange={(event) => setPool(event.target.value)} | ||
/> | ||
{showCustomInput && ( | ||
<Combobox.Input | ||
className="gap-1 rounded h-6 border px-2 flex items-center dark:hover:bg-chalkboard-80 text-xs text-chalkboard-70 dark:text-chalkboard-30 dark:bg-chalkboard-90" | ||
placeholder="auto" | ||
onChange={(event) => setPool(event.target.value)} | ||
/> | ||
)} | ||
</Combobox> | ||
</> | ||
)} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
ui-open:rotate-180
class is designed for Headless UI disclosure components where theui-open:
modifier is automatically applied. Since this is a standard button toggle using React state, the rotation should be directly tied to the state variable:This will ensure the caret rotates correctly when the advanced options are toggled.
Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.