2019-11-21 17:21:14 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { PlainText } from '@wordpress/block-editor';
|
2021-08-17 15:21:07 +00:00
|
|
|
import { withInstanceId } from '@wordpress/compose';
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2019-11-21 17:21:14 +00:00
|
|
|
|
2019-11-26 10:56:14 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './editor.scss';
|
2023-06-13 11:00:57 +00:00
|
|
|
interface BlockTitleProps {
|
|
|
|
className: string;
|
|
|
|
headingLevel: number;
|
|
|
|
onChange: ( value: string ) => void;
|
|
|
|
heading: string;
|
|
|
|
instanceId: number;
|
|
|
|
}
|
2021-08-17 15:21:07 +00:00
|
|
|
const BlockTitle = ( {
|
|
|
|
className,
|
|
|
|
headingLevel,
|
|
|
|
onChange,
|
|
|
|
heading,
|
|
|
|
instanceId,
|
2023-06-13 11:00:57 +00:00
|
|
|
}: BlockTitleProps ) => {
|
|
|
|
const TagName = `h${ headingLevel }` as keyof JSX.IntrinsicElements;
|
2019-11-21 17:21:14 +00:00
|
|
|
return (
|
2021-09-15 11:35:06 +00:00
|
|
|
<TagName className={ className }>
|
2021-08-17 16:09:04 +00:00
|
|
|
<label
|
|
|
|
className="screen-reader-text"
|
|
|
|
htmlFor={ `block-title-${ instanceId }` }
|
|
|
|
>
|
2023-12-12 22:12:36 +00:00
|
|
|
{ __( 'Block title', 'woocommerce' ) }
|
2021-08-17 15:21:07 +00:00
|
|
|
</label>
|
2019-11-21 17:21:14 +00:00
|
|
|
<PlainText
|
2021-08-17 15:21:07 +00:00
|
|
|
id={ `block-title-${ instanceId }` }
|
2021-09-15 11:35:06 +00:00
|
|
|
className="wc-block-editor-components-title"
|
2019-11-21 17:21:14 +00:00
|
|
|
value={ heading }
|
|
|
|
onChange={ onChange }
|
2023-02-07 15:47:13 +00:00
|
|
|
style={ { backgroundColor: 'transparent' } }
|
2019-11-21 17:21:14 +00:00
|
|
|
/>
|
|
|
|
</TagName>
|
|
|
|
);
|
|
|
|
};
|
2019-11-26 11:16:28 +00:00
|
|
|
|
2021-08-17 15:21:07 +00:00
|
|
|
export default withInstanceId( BlockTitle );
|