/** @jsx jsx */ import * as React from "react" import { jsx, Theme, ThemeUICSSObject } from "theme-ui" import useSpecimensConfig from "../hooks/useSpecimensConfig" import Badge from "./badge" import getValue from "../utils/get-value" import themeConfig from "../theme" type HeadingProps = { styles?: Theme["styles"] config: Theme previewText?: string } const infoStyles: ThemeUICSSObject = { display: `flex`, flexDirection: `column`, alignItems: `flex-start`, } const Heading = ({ styles = undefined, config, previewText = `Heading` }: HeadingProps) => { const specimensConfig = useSpecimensConfig() if (!styles) { return
No styles defined
} return ( {Object.entries(styles).length !== 0 ? ( Object.entries(styles).map(([key, value]) => { const type = { level: key, // @ts-ignore fontFamily: value.fontFamily, // @ts-ignore size: value.fontSize, // @ts-ignore weight: value.fontWeight, // @ts-ignore lineHeight: value.lineHeight, } return (
{previewText}
div": { mr: themeConfig.space[4], mb: themeConfig.space[2], }, span: { mb: themeConfig.space[2], }, }} >
Type {type.level}
Token {type.size}
Size {config?.fontSizes?.[type.size]}
Line Height {config?.lineHeights?.[type.lineHeight]}
Weight {config?.fontWeights?.[type.weight]}
{specimensConfig.codeExample && (
                    
                      {`{`}
                       fontSize:
                      {` `}
                      {type.size}
                      , fontWeight
                      :
                      {` `}
                      "{type.weight}"
                      , lineHeight
                      :
                      {` `}
                      "{type.lineHeight}"
                      , fontFamily
                      :
                      {` `}
                      "{type.fontFamily}"
                      {` `}
                      {`}`}
                    
                  
)}
) }) ) : (
No heading styles defined
)}
) } export default Heading