BlockSettings.jsx
63 lines
| 1 | import { __ } from '@wordpress/i18n'; |
| 2 | import { RangeControl } from '@wordpress/components'; |
| 3 | |
| 4 | import { OpenPanel } from '@edge22/components'; |
| 5 | |
| 6 | import { |
| 7 | ApplyFilters, |
| 8 | TagNameControl, |
| 9 | } from '@components/index.js'; |
| 10 | |
| 11 | export function BlockSettings( { |
| 12 | getStyleValue, |
| 13 | onStyleChange, |
| 14 | name, |
| 15 | attributes, |
| 16 | setAttributes, |
| 17 | } ) { |
| 18 | const { |
| 19 | midSize, |
| 20 | tagName, |
| 21 | } = attributes; |
| 22 | |
| 23 | const panelProps = { |
| 24 | name, |
| 25 | attributes, |
| 26 | setAttributes, |
| 27 | }; |
| 28 | |
| 29 | return ( |
| 30 | <ApplyFilters |
| 31 | name="generateblocks.editor.blockControls" |
| 32 | blockName={ name } |
| 33 | getStyleValue={ getStyleValue } |
| 34 | onStyleChange={ onStyleChange } |
| 35 | attributes={ attributes } |
| 36 | setAttributes={ setAttributes } |
| 37 | > |
| 38 | <OpenPanel |
| 39 | { ...panelProps } |
| 40 | panelId="settings" |
| 41 | > |
| 42 | <RangeControl |
| 43 | type="number" |
| 44 | label={ __( 'Mid Size', 'generateblocks' ) } |
| 45 | value={ midSize } |
| 46 | onChange={ ( value ) => setAttributes( { midSize: value } ) } |
| 47 | step="1" |
| 48 | min="0" |
| 49 | max="10" |
| 50 | /> |
| 51 | |
| 52 | <TagNameControl |
| 53 | blockName="generateblocks/query-page-numbers" |
| 54 | value={ tagName } |
| 55 | onChange={ ( value ) => { |
| 56 | setAttributes( { tagName: value } ); |
| 57 | } } |
| 58 | /> |
| 59 | </OpenPanel> |
| 60 | </ApplyFilters> |
| 61 | ); |
| 62 | } |
| 63 |