Skip to content

Commit

Permalink
chore: add data-testid to toggle-switch component
Browse files Browse the repository at this point in the history
  • Loading branch information
ljagiela committed Sep 24, 2024
1 parent 57d4126 commit a2647f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/design-system/box/box.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const Box = forwardRef<HTMLDivElement | null, Readonly<Props>>(
px,
py,
w,
testId = 'box',
testId,
...props
},
ref,
Expand Down
7 changes: 5 additions & 2 deletions src/design-system/toggle-switch/toggle-switch.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,32 @@ type Props = Omit<
defaultChecked?: boolean;
required?: boolean;
id?: string;
testId?: string;
};

export const ToggleSwitch = ({
label,
id,
icon,
disabled,
testId,
...props
}: Readonly<Props>): JSX.Element => {
return (
<Flex
alignItems="center"
className={disabled === true ? cx.disabled : undefined}
>
<label className={cx.label} htmlFor={id}>
<label className={cx.label} htmlFor={id} data-testid={testId + '-label'}>
<Text.Body.Normal color="secondary">{label}</Text.Body.Normal>
</label>
{icon !== undefined && <Box className={cx.iconContainer}>{icon}</Box>}
{icon !== undefined && <Box className={cx.iconContainer} testId={testId + '-icon'}>{icon}</Box>}
<Switch.Root
{...props}
disabled={disabled}
className={cx.toogleSwitch}
id={id}
data-testid={testId + '-switch'}
>
<Switch.Thumb className={cx.thumb} />
</Switch.Root>
Expand Down

0 comments on commit a2647f3

Please sign in to comment.