Skip to content

Commit

Permalink
Merge pull request #55 from input-output-hk/LW-11556/add_test_ids
Browse files Browse the repository at this point in the history
add data-testid to toggle-switch component
  • Loading branch information
ljagiela authored Sep 24, 2024
2 parents 57d4126 + 6726320 commit 65d3a58
Show file tree
Hide file tree
Showing 2 changed files with 14 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
15 changes: 13 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,40 @@ 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 + 'toggle-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 + 'toggle-icon'}>
{icon}
</Box>
)}
<Switch.Root
{...props}
disabled={disabled}
className={cx.toogleSwitch}
id={id}
data-testid={testId + 'toggle-switch'}
>
<Switch.Thumb className={cx.thumb} />
</Switch.Root>
Expand Down

0 comments on commit 65d3a58

Please sign in to comment.