Plugin Tabs noticias
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
import * as areoi from '../_components/Core.js';
|
||||
import meta from './block.json';
|
||||
|
||||
const ALLOWED_BLOCKS = [ 'areoi/button' ];
|
||||
const BLOCKS_TEMPLATE = [
|
||||
['areoi/button', {} ],
|
||||
['areoi/button', {} ]
|
||||
];
|
||||
|
||||
const blockIcon = <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24" x="0" y="0"/></g><g><g><path d="M19,13H5c-1.1,0-2,0.9-2,2v4c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2v-4C21,13.9,20.1,13,19,13z M19,19H5v-4h14V19z"/><path d="M19,3H5C3.9,3,3,3.9,3,5v4c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M19,9H5V5h14V9z"/></g></g></svg>;
|
||||
|
||||
areoi.blocks.registerBlockType( meta, {
|
||||
icon: blockIcon,
|
||||
edit: props => {
|
||||
const {
|
||||
attributes,
|
||||
setAttributes,
|
||||
clientId
|
||||
} = props;
|
||||
|
||||
const { block_id } = attributes;
|
||||
if ( !block_id ) {
|
||||
setAttributes( { block_id: clientId } );
|
||||
}
|
||||
|
||||
const classes = [
|
||||
attributes.size,
|
||||
attributes.style
|
||||
];
|
||||
|
||||
const blockProps = areoi.editor.useBlockProps( {
|
||||
className: areoi.helper.GetClassName( classes ),
|
||||
style: { cssText: areoi.helper.GetStyles( attributes ) }
|
||||
} );
|
||||
|
||||
function onChange( key, value ) {
|
||||
setAttributes( { [key]: value } );
|
||||
}
|
||||
|
||||
const tabDevice = ( tab ) => {
|
||||
return (
|
||||
<div>
|
||||
{ areoi.DisplayVisibility( areoi, attributes, onChange, tab ) }
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{ areoi.DisplayPreview( areoi, attributes, onChange, 'button-group' ) }
|
||||
|
||||
{ !attributes.preview &&
|
||||
<div { ...blockProps } data-anchor={ attributes.anchor ? ' : #' + attributes.anchor : '' }>
|
||||
<areoi.editor.InspectorControls key="setting">
|
||||
|
||||
<areoi.components.PanelBody title={ 'Settings' } initialOpen={ false }>
|
||||
<areoi.components.PanelRow className="areoi-panel-row">
|
||||
<areoi.components.SelectControl
|
||||
label="Style"
|
||||
labelPosition="top"
|
||||
help="Make a set of buttons appear vertically stacked rather than horizontally. Split button dropdowns are not supported here."
|
||||
value={ attributes.style }
|
||||
options={ [
|
||||
{ label: 'Default', value: 'btn-group' },
|
||||
{ label: 'Horizontal', value: 'btn-group' },
|
||||
{ label: 'Vertical', value: 'btn-group-vertical' },
|
||||
] }
|
||||
onChange={ ( value ) => onChange( 'style', value ) }
|
||||
/>
|
||||
</areoi.components.PanelRow>
|
||||
|
||||
<areoi.components.PanelRow>
|
||||
<areoi.components.SelectControl
|
||||
label="Size"
|
||||
help="Instead of applying button sizing classes to every button in a group, just add .btn-group-* to each .btn-group, including each one when nesting multiple groups."
|
||||
labelPosition="top"
|
||||
value={ attributes.size }
|
||||
options={ [
|
||||
{ label: 'Default', value: null },
|
||||
{ label: 'Small', value: 'btn-group-sm' },
|
||||
{ label: 'Medium', value: null },
|
||||
{ label: 'Large', value: 'btn-group-lg' },
|
||||
] }
|
||||
onChange={ ( value ) => onChange( 'size', value ) }
|
||||
/>
|
||||
</areoi.components.PanelRow>
|
||||
|
||||
</areoi.components.PanelBody>
|
||||
|
||||
{ areoi.ResponsiveTabPanel( tabDevice, meta, props ) }
|
||||
|
||||
</areoi.editor.InspectorControls>
|
||||
|
||||
<areoi.editor.InnerBlocks template={ BLOCKS_TEMPLATE } allowedBlocks={ ALLOWED_BLOCKS } />
|
||||
</div>
|
||||
}
|
||||
</>
|
||||
);
|
||||
},
|
||||
save: () => {
|
||||
return (
|
||||
<areoi.editor.InnerBlocks.Content/>
|
||||
);
|
||||
},
|
||||
} );
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"apiVersion": 2,
|
||||
"name": "areoi/button-group",
|
||||
"title": "Button Group",
|
||||
"parent": null,
|
||||
"category": "areoi-components",
|
||||
"description": "Group a series of buttons together on a single line or stack them in a vertical column.",
|
||||
"textdomain": "default",
|
||||
"keywords": [ "areoi", "bootstrap", "layout" ],
|
||||
"example": {
|
||||
"attributes": {
|
||||
"preview": true
|
||||
}
|
||||
},
|
||||
"attributes": {
|
||||
"preview": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"anchor": {
|
||||
"type": "string",
|
||||
"default": false
|
||||
},
|
||||
"block_id": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"style": {
|
||||
"type": "string",
|
||||
"default": "btn-group"
|
||||
},
|
||||
"size": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
|
||||
"hide_xs": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"hide_sm": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"hide_md": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"hide_lg": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"hide_xl": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"hide_xxl": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"anchor": true,
|
||||
"align": false,
|
||||
"html": false
|
||||
},
|
||||
"editorScript": "areoi-blocks",
|
||||
"editorStyle": "file:./index.css",
|
||||
"style": "file:../../build/style.css"
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
@@ -0,0 +1,48 @@
|
||||
.wp-block-areoi-button-group {
|
||||
border: 1px dashed #ccc;
|
||||
min-height: 28px;
|
||||
padding: 28px 0 !important;
|
||||
}
|
||||
.wp-block-areoi-button-group.btn-group-vertical {
|
||||
padding: 28px 0;
|
||||
}
|
||||
.wp-block-areoi-button-group.btn-group .wp-block-areoi-button {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* Horizontal */
|
||||
.btn-group > .block-editor-inner-blocks > .block-editor-block-list__layout > .btn,
|
||||
.btn-group > .block-editor-inner-blocks > .block-editor-block-list__layout > .btn-group {
|
||||
position: relative;
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.btn-group > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block:not(:last-of-type):not(.dropdown-toggle) .btn {
|
||||
border-top-right-radius: 0 !important;
|
||||
border-bottom-right-radius: 0 !important;
|
||||
}
|
||||
|
||||
.btn-group > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block:not(:first-of-type) .btn {
|
||||
border-top-left-radius: 0 !important;
|
||||
border-bottom-left-radius: 0 !important;
|
||||
margin-left: -1px;
|
||||
}
|
||||
|
||||
/* Vertical */
|
||||
.btn-group-vertical > .block-editor-inner-blocks > .block-editor-block-list__layout {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
}
|
||||
.btn-group-vertical > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block:not(:last-child):not(.dropdown-toggle) .btn {
|
||||
border-bottom-right-radius: 0 !important;
|
||||
border-bottom-left-radius: 0 !important;
|
||||
}
|
||||
.btn-group-vertical > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block:not(:first-child):not(.dropdown-toggle) .btn {
|
||||
border-top-right-radius: 0 !important;
|
||||
border-top-left-radius: 0 !important;
|
||||
}
|
||||
.btn-group-vertical > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block .btn {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
Reference in New Issue
Block a user