Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #53 from smartive-education/feature/label-refactoring
Browse files Browse the repository at this point in the history
feature/label-refactoring
  • Loading branch information
mthomann authored Jan 16, 2023
2 parents 721c84e + e8f4e1f commit 03ea500
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/components/typography/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export enum LabelSize {

export type LabelProps = {
/**
* Label text
* Label/span text
*/
children: ReactNode;
/**
* For attribute for the label
* For-attribute for the label. If prop is set, component creates a HTML-Label, else a HTML-Span.
*/
htmlFor?: string;
/**
* Label font size
* Label/span font size
*/
size: LabelSize;
};
Expand All @@ -31,8 +31,11 @@ const classMap: Record<LabelSize, string> = {
placeholder: 'font-poppins font-medium text-sm leading-none text-slate-300',
};

export const Label: FC<LabelProps> = ({ children, size = LabelSize.m, htmlFor }) => (
<label htmlFor={htmlFor} className={classMap[size]}>
{children}
</label>
);
export const Label: FC<LabelProps> = ({ children, size = LabelSize.m, htmlFor }) =>
htmlFor ? (
<label htmlFor={htmlFor} className={classMap[size]}>
{children}
</label>
) : (
<span className={classMap[size]}>{children}</span>
);

0 comments on commit 03ea500

Please sign in to comment.