UNPKG

@sb1/ffe-core-react

Version:

React components for ffe-core components

17 lines (16 loc) 1.38 kB
import React from 'react'; import classNames from 'classnames'; const Heading = React.forwardRef(({ children, className, error, inline, noMargin, withBorder, lookLike, textCenter, level, ...rest }, ref) => { const headingClass = `ffe-h${lookLike ? lookLike : level}`; return React.createElement(`h${level}`, { ...rest, ref, className: classNames(headingClass, { [`${headingClass}--error`]: error }, { [`${headingClass}--inline`]: inline }, { [`${headingClass}--no-margin`]: noMargin }, { [`${headingClass}--with-border`]: withBorder }, { [`${headingClass}--text-center`]: textCenter }, className), }, children); }); export const Heading1 = React.forwardRef((props, ref) => React.createElement(Heading, { ...props, ref: ref, level: 1 })); export const Heading2 = React.forwardRef((props, ref) => React.createElement(Heading, { ...props, ref: ref, level: 2 })); export const Heading3 = React.forwardRef((props, ref) => React.createElement(Heading, { ...props, ref: ref, level: 3 })); export const Heading4 = React.forwardRef((props, ref) => React.createElement(Heading, { ...props, ref: ref, level: 4 })); export const Heading5 = React.forwardRef((props, ref) => React.createElement(Heading, { ...props, ref: ref, level: 5 })); export const Heading6 = React.forwardRef((props, ref) => React.createElement(Heading, { ...props, ref: ref, level: 6 }));