8802b0fd68
* feat: eslint update * feat: start over and layout * feat: nextjs13 boilerplate * feat: static homepage * feat: static pages * feat: static unirse * chore: remove old mui types * chore: moving from yarn to bun * chore: update dependencies * feat: static equipo unirse * feat: move appwrite to entgamers-database package * feat: improve ui components * feat: update dependencies * feat: static login & register pages * fix: remove unused logs * feat: state redux toolkit & feedback slice * fix: equipo div inside p * feat: session * feat: metadataBase * feat: basic apply form * feat: http verbs * feat: recover password flow * chore: updated dependencies * fix: fix image config * fix: api team-applications route * fix: remove not longer used fonts * feat: session with current user * fix: login form recuperar contraseña * feat: equipo pages now uses data from database package * feat: useManageErrors hook * feat: updated cuenta page * chore: updated old formik forms to use hooks * feat: updated dependencies &package name * fix: session related bugs * fix: missing helper texts * feat: static applications dashboard * chore: update dependencies * refactor: team applications * fix: session api update
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { cx } from '@/styled-system/css'
|
|
import { typography, type TypographyVariantProps } from '@/styled-system/recipes/typography'
|
|
import { type MergeOmitting } from '@/types/utilities'
|
|
import { type ElementType, type FC, type HTMLAttributes } from 'react'
|
|
|
|
type ComposedTypographyProps = MergeOmitting<HTMLAttributes<HTMLElement>, TypographyVariantProps>
|
|
|
|
export interface TypographyProps extends ComposedTypographyProps {
|
|
component?: ElementType
|
|
}
|
|
|
|
const variantToComponent = (variant: TypographyVariantProps['variant']): ElementType => {
|
|
switch (variant) {
|
|
case 'h1':
|
|
case 'h2':
|
|
case 'h3':
|
|
case 'h4':
|
|
case 'h5':
|
|
case 'h6':
|
|
return variant
|
|
case 'subtitle1':
|
|
case 'subtitle2':
|
|
return 'div'
|
|
case 'button':
|
|
case 'overline':
|
|
case 'srOnly':
|
|
case 'caption':
|
|
return 'span'
|
|
case 'body1':
|
|
case 'body2':
|
|
default:
|
|
return 'p'
|
|
}
|
|
}
|
|
|
|
const Typography: FC<TypographyProps> = ({ children, className, component, ...rest }) => {
|
|
const [typographyRecipeArgs, allOtherTypographyProps] = typography.splitVariantProps(rest)
|
|
const Component = component ?? variantToComponent(typographyRecipeArgs.variant)
|
|
typographyRecipeArgs.color = typographyRecipeArgs.color ?? (
|
|
typeof typographyRecipeArgs.variant === 'string' && typographyRecipeArgs.variant.startsWith('h')
|
|
? 'primary'
|
|
: 'inherit'
|
|
)
|
|
return (
|
|
<Component
|
|
className={cx(typography(typographyRecipeArgs), className)}
|
|
{...allOtherTypographyProps}
|
|
>
|
|
{children}
|
|
</Component>
|
|
)
|
|
}
|
|
|
|
export default Typography
|