mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-25 11:28:51 +01:00
9b0f8d457b
* Migrating Label component to TS * label TS updates --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: garrettbear <gwhisten@gmail.com>
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import React from 'react';
|
|
import classnames from 'classnames';
|
|
import { Text } from '../text';
|
|
import type { TextProps } from '../text';
|
|
import {
|
|
FontWeight,
|
|
TextVariant,
|
|
Display,
|
|
AlignItems,
|
|
} from '../../../helpers/constants/design-system';
|
|
import type { PolymorphicRef } from '../box';
|
|
import { LabelProps, LabelComponent } from './label.types';
|
|
|
|
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>
|
|
);
|
|
},
|
|
);
|