Skip to content

Commit

Permalink
Merge pull request #98 from ensdomains/update-checkboxrow-disabled
Browse files Browse the repository at this point in the history
update disabled state for checkbox row
  • Loading branch information
storywithoutend authored Feb 15, 2023
2 parents 88ace59 + 9edd805 commit ef04ff5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions components/src/components/molecules/CheckboxRow/CheckboxRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useId } from '../../../hooks/useId'

export type Props = {
label: string
subLabel?: string
color?: Hue
} & React.InputHTMLAttributes<HTMLInputElement>

Expand Down Expand Up @@ -130,14 +131,18 @@ const Content = styled.div(
)

export const CheckboxRow = React.forwardRef<HTMLInputElement, Props>(
({ label: title, name, color = 'blue', ...props }, ref) => {
({ label, subLabel, name, color = 'blue', disabled, ...props }, ref) => {
const defaultRef = React.useRef<HTMLInputElement>(null)
const inputRef = ref || defaultRef

const id = useId()

const textColor = disabled ? 'grey' : 'text'

return (
<Container $color={color}>
<RootInput
disabled={disabled}
id={id}
name={name}
type="checkbox"
Expand All @@ -149,9 +154,14 @@ export const CheckboxRow = React.forwardRef<HTMLInputElement, Props>(
<CheckSVG />
</Circle>
<Content>
<Typography color="text" fontVariant="bodyBold">
{title}
<Typography color={textColor} fontVariant="bodyBold">
{label}
</Typography>
{subLabel && (
<Typography color={textColor} fontVariant="small">
{subLabel}
</Typography>
)}
</Content>
</Label>
</Container>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/reference/mdx/molecules/CheckboxRow.docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CheckboxRow } from '@ensdomains/thorin'
```

```tsx live=true expand=true
<CheckboxRow label="Label" />
<CheckboxRow label="Label" subLabel="Sublabel" />
```

## Props
Expand Down

0 comments on commit ef04ff5

Please sign in to comment.