Skip to content

Commit

Permalink
Deprecate the RadioButton and Selector components
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed May 12, 2023
1 parent 014e3df commit 3df00f9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-onions-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sumup/circuit-ui': minor
---

Deprecated the RadioButton component. Use the RadioButtonGroup component instead.
5 changes: 5 additions & 0 deletions .changeset/mighty-apples-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sumup/circuit-ui': minor
---

Deprecated the Selector component. Use the SelectorGroup component instead.
10 changes: 9 additions & 1 deletion packages/circuit-ui/components/RadioButton/RadioButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { hideVisually, focusOutline } from '../../styles/style-mixins';
import { uniqueId } from '../../util/id';
import { useClickEvent, TrackingProps } from '../../hooks/useClickEvent';
import { AccessibilityError } from '../../util/errors';
import { deprecate } from '../../util/logger';

export interface RadioButtonProps
extends InputHTMLAttributes<HTMLInputElement> {
Expand Down Expand Up @@ -186,7 +187,7 @@ const RadioButtonInput = styled('input')<InputElProps>(
);

/**
* RadioButton component for forms.
* @deprecated Use the {@link RadioButtonGroup} component instead.
*/
export const RadioButton = forwardRef(
(
Expand All @@ -206,6 +207,13 @@ export const RadioButton = forwardRef(
}: RadioButtonProps,
ref: RadioButtonProps['ref'],
) => {
if (process.env.NODE_ENV !== 'production') {
deprecate(
'RadioButton',
'The RadioButton component has been deprecated. Use the RadioButtonGroup component instead.',
);
}

if (
process.env.NODE_ENV !== 'production' &&
process.env.NODE_ENV !== 'test' &&
Expand Down
10 changes: 8 additions & 2 deletions packages/circuit-ui/components/Selector/Selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ const inputStyles = ({ theme }: StyleProps) => css`
const SelectorInput = styled('input')(inputStyles);

/**
* A selector allows users to choose between several mutually-exclusive choices
* accompanied by descriptions, possibly with tabular data.
* @deprecated Use the {@link SelectorGroup} component instead.
*/
export const Selector = forwardRef<HTMLInputElement, SelectorProps>(
(
Expand Down Expand Up @@ -238,6 +237,13 @@ export const Selector = forwardRef<HTMLInputElement, SelectorProps>(
const type = multiple ? 'checkbox' : 'radio';
const handleChange = useClickEvent(onChange, tracking, 'selector');

if (process.env.NODE_ENV !== 'production') {
deprecate(
'Selector',
'The Selector component has been deprecated. Use the SelectorGroup component instead.',
);
}

if (process.env.NODE_ENV !== 'production' && children) {
deprecate(
'Selector',
Expand Down

0 comments on commit 3df00f9

Please sign in to comment.