mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
New Text Component, new pages
This commit is contained in:
7
components/ui/Text/Text.module.css
Normal file
7
components/ui/Text/Text.module.css
Normal file
@@ -0,0 +1,7 @@
|
||||
.body {
|
||||
@apply text-lg leading-7 font-medium max-w-6xl mx-auto;
|
||||
}
|
||||
|
||||
.heading {
|
||||
@apply text-5xl mb-12;
|
||||
}
|
54
components/ui/Text/Text.tsx
Normal file
54
components/ui/Text/Text.tsx
Normal 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
|
1
components/ui/Text/index.ts
Normal file
1
components/ui/Text/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './Text'
|
Reference in New Issue
Block a user