GridColumnSelector.jsx
32 lines
| 1 | import classnames from 'classnames'; |
| 2 | import { Button } from '@wordpress/components'; |
| 3 | import { layouts } from './layouts'; |
| 4 | import './editor.scss'; |
| 5 | |
| 6 | export function GridColumnSelector( { onClick, value } ) { |
| 7 | return ( |
| 8 | <div className="gb-grid-control__grid-template-columns-rows--presets"> |
| 9 | { layouts.map( ( { label, id, layout, divs } ) => { |
| 10 | return ( |
| 11 | <Button |
| 12 | label={ label } |
| 13 | showTooltip={ true } |
| 14 | key={ `layout-${ id }` } |
| 15 | className="gb-grid-control__grid-template-columns-rows--presets-button" |
| 16 | onClick={ () => onClick( layout ) } |
| 17 | isPressed={ layout === value } |
| 18 | style={ { '--grid-template-columns': layout } } |
| 19 | > |
| 20 | { Array.from( { length: divs }, ( _, index ) => ( |
| 21 | <div |
| 22 | key={ `layout-${ index }` } |
| 23 | className={ classnames( 'gb-preview-column' ) } |
| 24 | /> |
| 25 | ) ) } |
| 26 | </Button> |
| 27 | ); |
| 28 | } ) } |
| 29 | </div> |
| 30 | ); |
| 31 | } |
| 32 |