-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14c63ae
commit a96c726
Showing
6 changed files
with
43 additions
and
86 deletions.
There are no files selected for viewing
11 changes: 0 additions & 11 deletions
11
ui/components/component-library/label/__snapshots__/label.test.js.snap
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { Label } from './label'; | ||
export type { LabelProps } from './label.types'; | ||
export type { LabelComponent, LabelProps } from './label.types'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,39 @@ | ||
import React, { Ref, forwardRef } from 'react'; | ||
import React from 'react'; | ||
import classnames from 'classnames'; | ||
import { Text, ValidTag } from '../text'; | ||
import { Text } from '../text'; | ||
import type { TextProps } from '../text'; | ||
import { | ||
FontWeight, | ||
TextVariant, | ||
Display, | ||
AlignItems, | ||
} from '../../../helpers/constants/design-system'; | ||
import { LabelProps } from './label.types'; | ||
import type { PolymorphicRef } from '../box'; | ||
import { LabelProps, LabelComponent } from './label.types'; | ||
|
||
export const Label = forwardRef(function Label( | ||
{ htmlFor, className, children, ...props }: LabelProps, | ||
ref: Ref<HTMLElement>, | ||
) { | ||
return ( | ||
<Text | ||
className={classnames( | ||
'mm-label', | ||
{ 'mm-label--html-for': Boolean(htmlFor) }, | ||
className ?? '', | ||
)} | ||
as={ValidTag.Label} | ||
htmlFor={htmlFor} | ||
variant={TextVariant.bodyMd} | ||
fontWeight={FontWeight.Bold} | ||
display={Display.InlineFlex} | ||
alignItems={AlignItems.center} | ||
ref={ref} | ||
{...props} | ||
> | ||
{children} | ||
</Text> | ||
); | ||
}); | ||
export const Label: LabelComponent = React.forwardRef( | ||
<C extends React.ElementType = 'label'>( | ||
{ htmlFor, className, children, ...props }: LabelProps<C>, | ||
ref?: PolymorphicRef<C>, | ||
) => { | ||
return ( | ||
<Text | ||
className={classnames( | ||
'mm-label', | ||
{ 'mm-label--html-for': Boolean(htmlFor) }, | ||
className ?? '', | ||
)} | ||
as="label" | ||
htmlFor={htmlFor} | ||
variant={TextVariant.bodyMd} | ||
fontWeight={FontWeight.Medium} | ||
display={Display.InlineFlex} | ||
alignItems={AlignItems.center} | ||
ref={ref} | ||
{...(props as TextProps<C>)} | ||
> | ||
{children} | ||
</Text> | ||
); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters