Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/common/Toggle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type ToggleProps = {
id?: string;
disabled?: boolean;
label?: string;
className?: string;
} & InputWrapperProps;

const ToggleContainer = styled(Box)<ToggleProps>`
Expand Down Expand Up @@ -89,6 +90,7 @@ export const Toggle = forwardRef<CustomCheckboxProps, ToggleProps>(
id: givenId,
disabled,
label,
className,
...rest
},
ref,
Expand All @@ -112,6 +114,7 @@ export const Toggle = forwardRef<CustomCheckboxProps, ToggleProps>(
as="label"
htmlFor={id}
disabled={disabled}
className={className}
{...pick(rest)}
>
<CustomCheckbox
Expand Down
19 changes: 19 additions & 0 deletions src/components/common/Toggle/toggle.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';

import { Toggle } from '~components';

import { styled } from '~lib';

export default {
component: Toggle,
title: 'components/Toggle',
Expand All @@ -22,4 +24,21 @@ export default {
parameters: { controls: { hideNoControlsWarning: true } },
};

const ExtendedToggle = styled(Toggle, {
baseStyles: {
'> .slider': {
backgroundColor: 'grey300',
borderColor: 'grey300',
},
"[data-reach-custom-checkbox][data-state='checked']": {
'& + .slider': {
backgroundColor: 'grey800',
borderColor: 'grey800',
},
},
},
});

export const Basic = (args) => <Toggle {...args} />;

export const Extended = (args) => <ExtendedToggle />;