BlockSettings.jsx
76 lines
| 1 | import { __ } from '@wordpress/i18n'; |
| 2 | |
| 3 | import { OpenPanel } from '@edge22/components'; |
| 4 | |
| 5 | import { |
| 6 | ApplyFilters, |
| 7 | GridColumnSelector, |
| 8 | TagNameControl, |
| 9 | } from '@components/index.js'; |
| 10 | import { moreDesignOptions } from '@utils'; |
| 11 | import { useBlockStyles } from '@hooks/useBlockStyles'; |
| 12 | |
| 13 | export function BlockSettings( { |
| 14 | getStyleValue, |
| 15 | onStyleChange, |
| 16 | name, |
| 17 | attributes, |
| 18 | setAttributes, |
| 19 | } ) { |
| 20 | const { |
| 21 | currentAtRule, |
| 22 | } = useBlockStyles(); |
| 23 | |
| 24 | const panelProps = { |
| 25 | name, |
| 26 | attributes, |
| 27 | setAttributes, |
| 28 | }; |
| 29 | |
| 30 | const { |
| 31 | tagName, |
| 32 | } = attributes; |
| 33 | |
| 34 | return ( |
| 35 | <ApplyFilters |
| 36 | name="generateblocks.editor.blockControls" |
| 37 | blockName={ name } |
| 38 | getStyleValue={ getStyleValue } |
| 39 | onStyleChange={ onStyleChange } |
| 40 | currentAtRule={ currentAtRule } |
| 41 | attributes={ attributes } |
| 42 | setAttributes={ setAttributes } |
| 43 | > |
| 44 | <OpenPanel |
| 45 | { ...panelProps } |
| 46 | dropdownOptions={ [ |
| 47 | moreDesignOptions, |
| 48 | ] } |
| 49 | panelId="design" |
| 50 | > |
| 51 | <GridColumnSelector |
| 52 | label={ __( 'Layout', 'generateblocks' ) } |
| 53 | value={ getStyleValue( 'gridTemplateColumns', currentAtRule ) } |
| 54 | onClick={ ( value ) => { |
| 55 | onStyleChange( 'display', 'grid', currentAtRule ); |
| 56 | onStyleChange( 'gridTemplateColumns', value, currentAtRule ); |
| 57 | } } |
| 58 | /> |
| 59 | </OpenPanel> |
| 60 | |
| 61 | <OpenPanel |
| 62 | { ...panelProps } |
| 63 | panelId="settings" |
| 64 | > |
| 65 | <TagNameControl |
| 66 | blockName="generateblocks/looper" |
| 67 | value={ tagName } |
| 68 | onChange={ ( value ) => { |
| 69 | setAttributes( { tagName: value } ); |
| 70 | } } |
| 71 | /> |
| 72 | </OpenPanel> |
| 73 | </ApplyFilters> |
| 74 | ); |
| 75 | } |
| 76 |