New Text Component, new pages

This commit is contained in:
Belen Curcio
2020-10-24 16:53:25 -03:00
parent 81f4771c4d
commit 5e8cb6e6df
11 changed files with 144 additions and 35 deletions

View File

@@ -0,0 +1,7 @@
.body {
@apply text-lg leading-7 font-medium max-w-6xl mx-auto;
}
.heading {
@apply text-5xl mb-12;
}

View File

@@ -0,0 +1,54 @@
import React, {
FunctionComponent,
JSXElementConstructor,
CSSProperties,
} from 'react'
import cn from 'classnames'
import s from './Text.module.css'
interface Props {
variant?: Variant
className?: string
style?: CSSProperties
children: React.ReactNode | any
}
type Variant = 'heading' | 'body'
const Text: FunctionComponent<Props> = ({
style,
className = '',
variant = 'body',
children,
}) => {
const componentsMap: {
[P in Variant]: React.ComponentType<any> | string
} = {
body: 'p',
heading: 'h2',
}
const Component:
| JSXElementConstructor<any>
| React.ReactElement<any>
| React.ComponentType<any>
| string = componentsMap![variant!]
return (
<Component
className={cn(
s.root,
{
[s.body]: variant === 'body',
[s.heading]: variant === 'heading',
},
className
)}
style={style}
>
{children}
</Component>
)
}
export default Text

View File

@@ -0,0 +1 @@
export { default } from './Text'

View File

@@ -8,3 +8,4 @@ export { default as Container } from './Container'
export { default as LoadingDots } from './LoadingDots'
export { default as Skeleton } from './Skeleton'
export { default as Modal } from './Modal'
export { default as Text } from './Text'

View File

@@ -1 +0,0 @@
export type Colors = 'violet' | 'black' | 'pink' | 'white'