diff --git a/components/atoms/ToggleOption/toggle-option.tsx b/components/atoms/ToggleOption/toggle-option.tsx index 7d5c9d153a..d920cc0698 100644 --- a/components/atoms/ToggleOption/toggle-option.tsx +++ b/components/atoms/ToggleOption/toggle-option.tsx @@ -12,7 +12,7 @@ const ToggleOption = ({ optionText, withIcon, checked, handleToggle }: ToogleOpt onClick={handleToggle} className="inline-flex cursor-pointer items-center gap-2 rounded-md px-2 py-0.5 border border-light-slate-6 bg-light-slate-1" > - + {optionText} {withIcon && ( void; size?: "sm" | "lg" | "base"; classNames?: string; -} +} & ({ ariaLabel: string; ariaLabelledBy?: never } | { ariaLabelledBy: string; ariaLabel?: never }); + +const ToggleSwitch = (props: ToggleSwitchProps): JSX.Element => { + const { name, checked = false, handleToggle, size = "base", classNames } = props; + let ariaProps: { "aria-label": string } | { "aria-labelledby": string } | undefined; + + if (props.ariaLabelledBy) { + ariaProps = { "aria-labelledby": props.ariaLabelledBy }; + } + + if (props.ariaLabel) { + ariaProps = { "aria-label": props.ariaLabel }; + } -const ToggleSwitch = ({ - name, - checked = false, - handleToggle, - size = "base", - classNames, -}: ToggleSwitchProps): JSX.Element => { return ( handleToggle()} id={name} + {...ariaProps} className={clsx( classNames ?? classNames, checked && "!bg-light-orange-10 justify-end", diff --git a/components/molecules/HubContributorsHeader/hub-contributors-header.tsx b/components/molecules/HubContributorsHeader/hub-contributors-header.tsx index cd36b013c7..0248e77338 100644 --- a/components/molecules/HubContributorsHeader/hub-contributors-header.tsx +++ b/components/molecules/HubContributorsHeader/hub-contributors-header.tsx @@ -70,10 +70,16 @@ const HubContributorsHeader = ({
- + Make Public - +
- We will import usernames of developers you are following on GitHub to create your new list. + + We will import usernames of developers you are following on GitHub to create your new list. +
diff --git a/components/organisms/InsightPage/InsightPage.tsx b/components/organisms/InsightPage/InsightPage.tsx index c36e800c0a..7be31ff24e 100644 --- a/components/organisms/InsightPage/InsightPage.tsx +++ b/components/organisms/InsightPage/InsightPage.tsx @@ -688,12 +688,15 @@ const InsightPage = ({ edit, insight, pageRepos }: InsightPageProps) => {
- Make this page publicly visible + + Make this page publicly visible +
Make Public setIsPublic((isPublic) => !isPublic)} diff --git a/pages/hub/lists/new.tsx b/pages/hub/lists/new.tsx index 14fd08fa1d..12bd0e382e 100644 --- a/pages/hub/lists/new.tsx +++ b/pages/hub/lists/new.tsx @@ -226,12 +226,15 @@ const CreateListPage = () => {
- Make this list publicly visible + + Make this list publicly visible +
Make Public setIsPublic((isPublic) => !isPublic)} diff --git a/stories/atoms/toggle-switch.stories.tsx b/stories/atoms/toggle-switch.stories.tsx index dd26905878..b105330a3e 100644 --- a/stories/atoms/toggle-switch.stories.tsx +++ b/stories/atoms/toggle-switch.stories.tsx @@ -16,19 +16,23 @@ Default.args = { name: "test", checked: false, size: "base", + ariaLabel: "This is a toggle switch", }; Small.args = { name: "test", checked: false, size: "sm", + ariaLabel: "This is a toggle switch", }; Large.args = { name: "test", checked: false, size: "lg", + ariaLabel: "This is a toggle switch", }; Custom.args = { name: "test", checked: false, classNames: "w-8 h-4", + ariaLabel: "This is a toggle switch", };