Skip to content

Commit

Permalink
Adds disabled state to option field (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
pushchris authored Oct 13, 2023
1 parent 5c21c26 commit a87e510
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions apps/ui/src/ui/form/OptionField.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
}

.options-group .option {
/* border: 1px solid var(--color-grey); */
flex-grow: 1;
border-radius: var(--border-radius-inner);
padding: 8px 10px;
Expand All @@ -28,7 +27,7 @@
display: block;
}

.options-group .option:hover {
.options-group .option:hover:not(.disabled) {
background: var(--color-grey-soft);
border-color: var(--color-grey-hard);
}
Expand All @@ -37,4 +36,8 @@
background: var(--color-primary);
color: var(--color-on-primary);
border-color: var(--color-primary);
}

.options-group .option.disabled {
cursor: not-allowed;
}
8 changes: 4 additions & 4 deletions apps/ui/src/ui/form/OptionField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RadioGroup } from '@headlessui/react'
import { FieldProps, FieldOption } from './Field'
import './OptionField.css'
import { snakeToTitle } from '../../utils'
import clsx from 'clsx'

interface OptionFieldProps<X extends FieldValues, P extends FieldPath<X>> extends FieldProps<X, P> {
options: FieldOption[]
Expand Down Expand Up @@ -51,10 +52,9 @@ export default function OptionField<X extends FieldValues, P extends FieldPath<X
<RadioGroup.Option
key={key}
value={key}
className={({ active, checked }) =>
`option ${active ? 'active' : ''}
${checked ? 'selected' : ''}`
}>{label}</RadioGroup.Option>
className={({ active, checked, disabled }) => clsx(
'option', { selected: checked, active, disabled },
)}>{label}</RadioGroup.Option>
))}
</div>
</RadioGroup>
Expand Down

0 comments on commit a87e510

Please sign in to comment.