Skip to content

Commit

Permalink
feat(Label): Remove deprecated as prop (#1904)
Browse files Browse the repository at this point in the history
  • Loading branch information
Barsnes authored Apr 30, 2024
1 parent 6ba395e commit a1469e4
Showing 1 changed file with 28 additions and 32 deletions.
60 changes: 28 additions & 32 deletions packages/react/src/components/Typography/Label/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { forwardRef } from 'react';
import cl from 'clsx';
import { Slot } from '@radix-ui/react-slot';

import type { OverridableComponent } from '../../../types/OverridableComponent';

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

type FontWeights = 'regular' | 'medium' | 'semibold';
Expand All @@ -30,36 +28,34 @@ const fontWeightsClasses: Record<FontWeights, string> = {
};

/** Use `Label` for labels. */
export const Label: OverridableComponent<LabelProps, HTMLLabelElement> =
forwardRef(
(
{
className,
size = 'medium',
spacing,
as = 'label',
weight = 'medium',
asChild,
...rest
},
ref,
) => {
const Component = asChild ? Slot : as;

return (
<Component
ref={ref}
className={cl(
classes.label,
classes[size],
spacing && classes.spacing,
weight && [fontWeightsClasses[weight]],
className,
)}
{...rest}
/>
);
export const Label = forwardRef<HTMLLabelElement, LabelProps>(
(
{
className,
size = 'medium',
spacing,
weight = 'medium',
asChild,
...rest
},
);
ref,
) => {
const Component = asChild ? Slot : 'label';

return (
<Component
ref={ref}
className={cl(
classes.label,
classes[size],
spacing && classes.spacing,
weight && [fontWeightsClasses[weight]],
className,
)}
{...rest}
/>
);
},
);

Label.displayName = 'Label';

0 comments on commit a1469e4

Please sign in to comment.