Skip to content

Commit

Permalink
fixup! ✨(frontend) create Text component
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoLC committed Oct 3, 2023
1 parent 9b78b3c commit c0d1563
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Maybe } from 'lib-common';
import { ReactHTML } from 'react';

import {
ObtainHTMLProps,
Typo,
TypoPropsOnly,
} from '@lib-components/common/Typo';
import { Typo, TypoProps } from '@lib-components/common/Typo';

export const TextWeights = {
black: 'fw-black',
Expand All @@ -25,15 +22,16 @@ export const TextSizes = {
tiny: 'fs-t',
} as const;

export interface TextPropsOnly<T> extends TypoPropsOnly<T> {
export interface TextPropsOnly {
size?: keyof typeof TextSizes;
weight?: keyof typeof TextWeights;
}

type TextTypes = Pick<ReactHTML, 'p' | 'span' | 'div'>;

export type TextProps<T extends keyof TextTypes> = TextPropsOnly<TextTypes> &
ObtainHTMLProps<TextTypes[T]>;
export type TextProps<T extends Maybe<keyof TextTypes>> = TypoProps<
T,
TextPropsOnly
>;

/**
* @param TextPropsOnly -
Expand All @@ -43,7 +41,7 @@ export type TextProps<T extends keyof TextTypes> = TextPropsOnly<TextTypes> &
* @See {@link Typo }
* @returns Text component
*/
export const Text = <T extends keyof TextTypes>({
export const Text = <T extends Maybe<keyof TextTypes>>({
className,
size = 'medium-large',
type = 'span',
Expand Down

0 comments on commit c0d1563

Please sign in to comment.