File size: 1,154 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
import { CSSProperties, forwardRef, ReactNode } from 'react'
import { Link } from 'phosphor-react'
import { heading, linkIcon } from './Heading.css'
import clsx from 'clsx'
import * as FontSizes from '../../styles/fontStyles.css'
export interface HeadingProps {
tag?: keyof Pick<
React.JSX.IntrinsicElements,
'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'figcaption'
>
fontStyle?: keyof FontSizes.FontSizes
className?: string
children?: ReactNode
isLink?: boolean
weight?: keyof FontSizes.FontWeights
style?: CSSProperties
}
export const Heading = forwardRef<HTMLHeadingElement, HeadingProps>(
(
{
tag = 'h1',
fontStyle = 'S',
weight = 'default',
className,
children,
isLink = false,
...restProps
},
ref
) => {
const Element = tag
return (
<Element
className={clsx(
FontSizes[fontStyle],
FontSizes.WEIGHTS[weight],
heading,
className
)}
ref={ref}
{...restProps}
>
{children}
{isLink ? <Link className={linkIcon} size={16} /> : null}
</Element>
)
}
)
|