diff --git a/src/components/common/Heading.stories.jsx b/src/components/common/Heading.stories.jsx new file mode 100644 index 0000000..827ff46 --- /dev/null +++ b/src/components/common/Heading.stories.jsx @@ -0,0 +1,50 @@ +import * as React from "react" +import * as ReactDOM from "react-dom" +import * as Decorators from "../../utils/Decorators" +import { Heading as HeadingComponent } from "./Heading" + + +export default { + component: HeadingComponent, + title: "Common/Heading", + decorators: [Decorators.Bluelib], +} + + +const HeadingTemplate = props => ( + + The United Cantons capitulate! + +) + + +export const HeadingLevel1 = HeadingTemplate.bind({}) +HeadingLevel1.args = { + level: 1, +} + +export const HeadingLevel2 = HeadingTemplate.bind({}) +HeadingLevel2.args = { + level: 2, +} + +export const HeadingLevel3 = HeadingTemplate.bind({}) +HeadingLevel3.args = { + level: 3, +} + +export const HeadingLevel4 = HeadingTemplate.bind({}) +HeadingLevel4.args = { + level: 4, +} + +export const HeadingLevel5 = HeadingTemplate.bind({}) +HeadingLevel5.args = { + level: 5, +} + +export const HeadingLevel6 = HeadingTemplate.bind({}) +HeadingLevel6.args = { + level: 6, +} + diff --git a/src/components/common/Heading.tsx b/src/components/common/Heading.tsx new file mode 100644 index 0000000..9f9b697 --- /dev/null +++ b/src/components/common/Heading.tsx @@ -0,0 +1,29 @@ +import * as React from "react" +import * as ReactDOM from "react-dom" +import * as Types from "../../types" +import {BaseElement} from "../BaseElement" +import mergeClassNames from "classnames" + + +export interface HeadingProps extends Types.BluelibHTMLProps { + level: 1 | 2 | 3 | 4 | 5 | 6, +} + + +const HEADING_KINDS_BY_LEVEL = { + 1: "h1", + 2: "h2", + 3: "h3", + 4: "h4", + 5: "h5", + 6: "h6", +} + + +export function Heading({level, ...props}: HeadingProps): JSX.Element { + props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, "heading") + + return ( + + ) +}