Skip to content

Commit

Permalink
Deprecate the SubHeadline component
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed Aug 14, 2024
1 parent a22f08d commit db7c357
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/circuit-ui/components/SubHeadline/SubHeadline.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import * as Stories from './SubHeadline.stories';

# SubHeadline

<Status variant="stable" />
<Status variant="deprecated">
Use the Headline component in size `s` instead.
</Status>

The SubHeadline component helps break up larger related chunks of content in the same section. It is typically used to separate subsections within a card.

Expand Down
11 changes: 9 additions & 2 deletions packages/circuit-ui/components/SubHeadline/SubHeadline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { forwardRef, type HTMLAttributes } from 'react';

import { clsx } from '../../styles/clsx.js';
import { CircuitError } from '../../util/errors.js';
import { deprecate } from '../../util/logger.js';

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

Expand All @@ -30,8 +31,7 @@ export interface SubHeadlineProps extends HTMLAttributes<HTMLHeadingElement> {
}

/**
* A flexible SubHeadline component capable of rendering using any HTML heading
* element, except h1.
* @deprecated Use the Headline component in size `s` instead.
*/
export const SubHeadline = forwardRef<HTMLHeadingElement, SubHeadlineProps>(
({ className, as, ...props }, ref) => {
Expand All @@ -44,6 +44,13 @@ export const SubHeadline = forwardRef<HTMLHeadingElement, SubHeadlineProps>(
throw new CircuitError('SubHeadline', 'The `as` prop is required.');
}

if (process.env.NODE_ENV !== 'production') {
deprecate(
'SubHeadline',
'The SubHeadline component has been deprecated. Use the Headline component in size `s` instead.',
);
}

const Element = as || 'h2';

return (
Expand Down

0 comments on commit db7c357

Please sign in to comment.