2020-05-25 16:45:38 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2024-05-31 03:49:36 +00:00
|
|
|
import clsx from 'clsx';
|
2023-03-02 14:26:00 +00:00
|
|
|
import type { ReactNode } from 'react';
|
2020-05-25 16:45:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './style.scss';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Component that renders a block title.
|
|
|
|
*/
|
2022-03-29 10:16:17 +00:00
|
|
|
const Title = ( {
|
|
|
|
children,
|
2023-11-07 13:45:38 +00:00
|
|
|
className = '',
|
2022-03-29 10:16:17 +00:00
|
|
|
headingLevel,
|
|
|
|
...props
|
|
|
|
}: TitleProps ): JSX.Element => {
|
2024-05-31 03:49:36 +00:00
|
|
|
const buttonClassName = clsx( 'wc-block-components-title', className );
|
2022-03-29 10:16:17 +00:00
|
|
|
const TagName = `h${ headingLevel }` as keyof JSX.IntrinsicElements;
|
2020-05-25 16:45:38 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<TagName className={ buttonClassName } { ...props }>
|
|
|
|
{ children }
|
|
|
|
</TagName>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-11-07 13:45:38 +00:00
|
|
|
export interface TitleProps {
|
2022-03-29 10:16:17 +00:00
|
|
|
headingLevel: '1' | '2' | '3' | '4' | '5' | '6';
|
2023-11-07 13:45:38 +00:00
|
|
|
className?: string | undefined;
|
2022-03-29 10:16:17 +00:00
|
|
|
children: ReactNode;
|
|
|
|
}
|
2020-05-25 16:45:38 +00:00
|
|
|
|
|
|
|
export default Title;
|