Skip to content

Commit

Permalink
Add deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed Sep 5, 2024
1 parent 76f7651 commit 95df536
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions packages/circuit-ui/components/Toggle/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import { FieldDescription, FieldWrapper } from '../Field/index.js';
import { clsx } from '../../styles/clsx.js';
import { utilClasses } from '../../styles/utility.js';
import { deprecate } from '../../util/logger.js';

import classes from './Toggle.module.css';

Expand Down Expand Up @@ -69,14 +70,31 @@ export const Toggle = forwardRef<HTMLButtonElement, ToggleProps>(
},
ref,
) => {
if (
process.env.NODE_ENV !== 'production' &&
process.env.NODE_ENV !== 'test' &&
!isSufficientlyLabelled(label)
) {
throw new AccessibilityError(
'Toggle',
'The `label` prop is missing or invalid.',
);
}

if (
process.env.NODE_ENV !== 'production' &&
process.env.NODE_ENV !== 'test'
) {
if (!isSufficientlyLabelled(label)) {
throw new AccessibilityError(
if (checkedLabel) {
deprecate(
'Toggle',
'The `checkedLabel` prop is deprecated and can be removed.',
);
}
if (uncheckedLabel) {
deprecate(
'Toggle',
'The `label` prop is missing or invalid.',
'The `uncheckedLabel` prop is deprecated and can be removed.',
);
}
}
Expand Down

0 comments on commit 95df536

Please sign in to comment.