Full cleanup pass
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { memo, useCallback, useId, forwardRef } from "react";
|
||||
import { useTranslation } from "../../../contexts/MessagesContext";
|
||||
import { SwitchView } from "./Switch.view";
|
||||
import type { SwitchProps } from "./Switch.types";
|
||||
|
||||
@@ -10,6 +11,7 @@ import type { SwitchProps } from "./Switch.types";
|
||||
*/
|
||||
const SwitchContainer = memo(
|
||||
forwardRef<HTMLButtonElement, SwitchProps>((props, ref) => {
|
||||
const t = useTranslation("controlsChrome");
|
||||
const {
|
||||
propSwitch = false,
|
||||
onChange,
|
||||
@@ -154,6 +156,7 @@ const SwitchContainer = memo(
|
||||
trackClasses={trackClasses}
|
||||
thumbClasses={thumbClasses}
|
||||
labelClasses={labelClasses}
|
||||
switchAriaLabel={text ?? t("toggleSwitch")}
|
||||
onClick={handleClick}
|
||||
onKeyDown={handleKeyDown}
|
||||
onFocus={handleFocus}
|
||||
|
||||
@@ -37,6 +37,7 @@ export interface SwitchViewProps {
|
||||
trackClasses: string;
|
||||
thumbClasses: string;
|
||||
labelClasses: string;
|
||||
switchAriaLabel: string;
|
||||
onClick: (_e: React.MouseEvent<HTMLButtonElement>) => void;
|
||||
onKeyDown: (_e: React.KeyboardEvent<HTMLButtonElement>) => void;
|
||||
onFocus: (_e: React.FocusEvent<HTMLButtonElement>) => void;
|
||||
|
||||
@@ -11,6 +11,7 @@ export const SwitchView = forwardRef<HTMLButtonElement, SwitchViewProps>(
|
||||
trackClasses,
|
||||
thumbClasses,
|
||||
labelClasses,
|
||||
switchAriaLabel,
|
||||
onClick,
|
||||
onKeyDown,
|
||||
onFocus,
|
||||
@@ -27,7 +28,7 @@ export const SwitchView = forwardRef<HTMLButtonElement, SwitchViewProps>(
|
||||
type="button"
|
||||
role="switch"
|
||||
aria-checked={propSwitch}
|
||||
aria-label={text || "Toggle switch"}
|
||||
aria-label={switchAriaLabel}
|
||||
onClick={onClick}
|
||||
onKeyDown={onKeyDown}
|
||||
onFocus={onFocus}
|
||||
|
||||
Reference in New Issue
Block a user