Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
fix: type naming conventions and allow label to accept any ReactNode
Browse files Browse the repository at this point in the history
  • Loading branch information
lukerohanbailey committed Jan 13, 2022
1 parent 8d2a0f1 commit 5c060e9
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/components/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { CheckboxProps, ToggleProps } from '@react-types/checkbox';
import type {
CheckboxProps as RTCheckboxProps,
ToggleProps,
} from '@react-types/checkbox';
import { gsap } from 'gsap';
import type { ComponentPropsWithRef } from 'react';
import type { ComponentPropsWithRef, ReactNode } from 'react';
import { useEffect, useRef } from 'react';
import { useCheckbox } from 'react-aria';
import { useToggleState } from 'react-stately';
Expand Down Expand Up @@ -67,19 +70,18 @@ const IconContainer = styled('div', {
transform: 'translate(-50%, -50%)',
});

type CustomCheckboxProps = {
text?: string;
type CheckboxProps = RTCheckboxProps & {
label?: ReactNode;
};

export const Checkbox = ({
validationState,
text,
label,
defaultSelected,
isIndeterminate,
...restProps
}: CheckboxProps &
ComponentPropsWithRef<'input'> &
CustomCheckboxProps &
RTCheckboxProps &
ToggleProps) => {
const ref = useRef<HTMLInputElement>(null);
const { isSelected, toggle, setSelected } = useToggleState({
Expand Down Expand Up @@ -117,7 +119,7 @@ export const Checkbox = ({
<IconContainer>
<CheckIcon strokeDashoffset={isSelected ? '' : '21'} />
</IconContainer>
{text}
{label}
</Label>
);
};

0 comments on commit 5c060e9

Please sign in to comment.