1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00
metamask-extension/ui/components/component-library/label/label.tsx
Gabriel Méndez 9b0f8d457b
Migrate Label component to TS (#19146)
* Migrating Label component to TS

* label TS updates

---------

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
Co-authored-by: garrettbear <gwhisten@gmail.com>
2023-07-24 10:54:34 -07:00

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>
);
},
);