woocommerce/plugins/woocommerce-blocks/assets/js/components/block-title/index.js

49 lines
972 B
JavaScript
Raw Normal View History

/**
* External dependencies
*/
import PropTypes from 'prop-types';
import { PlainText } from '@wordpress/block-editor';
import classnames from 'classnames';
/**
* Internal dependencies
*/
import './editor.scss';
const BlockTitle = ( { className, headingLevel, onChange, heading } ) => {
const TagName = `h${ headingLevel }`;
return (
<TagName>
<PlainText
className={ classnames(
Add Inner Block Rendering and Atomic Block Styles (https://github.com/woocommerce/woocommerce-blocks/pull/2607) * Register Atomic Blocks and save some block content * renderInnerBlocks utility * Frontend Rendering * Clean up atomic block classnames * Move shared styles * Create a hoc for attribute mapping * Rename some unpluralised class names * Remove prefixes from atomic component class names * Updated styles * Update styles from master * Revert product list styles * 2020 fixes * Separate renderFrontend from renderInnerBlocks * Lazy loading of components * Tweak loading classes * FIx all products loading state * Revert lazy implementation - creates too many unneccessary files due to webpack config * Cleanup * Remove wcBlocksBuildUrl * Move call to register_atomic_blocks * Remove duplicate key * reuse render frontend * Corectly handle frontend attribute mapping to keep editor working * Style updates * Update side effects * Remove width style from rating to fix alignment * Move ssr grid styles to main stylesheet * Put back prefixed classnames * 2020 styling fixes * Create frontend files instead of doing it all in block map * Update assets/js/atomic/utils/get-block-map.js Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update assets/js/atomic/utils/render-parent-block.js Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Fix last child alignment regardless of block type * More specificity fixes * 2020 button alignment * static fix to prevent offsets * fix placeholder image in firefox * Issues reported in feedback Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-06-05 12:18:16 +00:00
'wc-block-components-title',
className
) }
value={ heading }
onChange={ onChange }
/>
</TagName>
);
};
BlockTitle.propTypes = {
/**
* Classname to add to title in addition to the defaults.
*/
className: PropTypes.string,
/**
* The value of the heading.
*/
value: PropTypes.string,
/**
* Callback to update the attribute when text is changed.
*/
onChange: PropTypes.func,
/**
* Level of the heading tag (1, 2, 3... will render <h1>, <h2>, <h3>... elements).
*/
headingLevel: PropTypes.number,
};
export default BlockTitle;