Plugin Tabs noticias
This commit is contained in:
@@ -0,0 +1,174 @@
|
||||
import * as areoi from '../_components/Core.js';
|
||||
import * as grid from './template-parts-js/grid.js';
|
||||
import * as stacked from './template-parts-js/stacked.js';
|
||||
import * as carousel from './template-parts-js/carousel.js';
|
||||
import meta from './block.json';
|
||||
|
||||
const ALLOWED_BLOCKS = [ 'core/heading', 'core/paragraph', 'areoi/button', 'core/image', 'core/video', 'areoi/icon' ];
|
||||
const BLOCKS_TEMPLATE = null;
|
||||
const NEW_TAB_REL = 'noreferrer noopener';
|
||||
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"><rect fill="none" height="24" width="24"/><path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M19,5v3H5V5H19z M19,10v4H5v-4H19z M5,19v-3h14v3H5z"/></svg>;
|
||||
|
||||
areoi.blocks.registerBlockType( meta, {
|
||||
icon: blockIcon,
|
||||
edit: props => {
|
||||
const {
|
||||
attributes,
|
||||
setAttributes,
|
||||
className,
|
||||
isSelected,
|
||||
onReplace,
|
||||
mergeBlocks,
|
||||
clientId
|
||||
} = props;
|
||||
|
||||
const { block_id } = attributes;
|
||||
if ( !block_id ) {
|
||||
setAttributes( { block_id: clientId } );
|
||||
}
|
||||
|
||||
const parentBlocks = wp.data.select( 'core/block-editor' ).getBlockParents(props.clientId);
|
||||
const parentAttributes = wp.data.select('core/block-editor').getBlocksByClientId(parentBlocks);
|
||||
|
||||
var parent_id = false;
|
||||
parentAttributes.forEach(element => {
|
||||
if ( element.name == 'areoi/banner' ) {
|
||||
parent_id = element.attributes.block_id;
|
||||
}
|
||||
});
|
||||
if ( parent_id ) {
|
||||
setAttributes( { parent_id: parent_id } );
|
||||
}
|
||||
|
||||
let parent = wp.data.select( 'core/block-editor' ).getBlock( parent_id ).attributes,
|
||||
layout = parent['layout'] ? parent['layout'] : 'stacked',
|
||||
container = layout == 'grid' ? 'container-fluid' : 'container';
|
||||
|
||||
const classes = [
|
||||
'banner-item'
|
||||
];
|
||||
|
||||
const {
|
||||
linkTarget,
|
||||
rel,
|
||||
text,
|
||||
url,
|
||||
url_title
|
||||
} = attributes;
|
||||
const onSetLinkRel = areoi.element.useCallback(
|
||||
( value ) => {
|
||||
setAttributes( { rel: value } );
|
||||
},
|
||||
[ setAttributes ]
|
||||
);
|
||||
|
||||
const onToggleOpenInNewTab = areoi.element.useCallback(
|
||||
( value ) => {
|
||||
const newLinkTarget = value ? '_blank' : undefined;
|
||||
|
||||
let updatedRel = rel;
|
||||
if ( newLinkTarget && ! rel ) {
|
||||
updatedRel = NEW_TAB_REL;
|
||||
} else if ( ! newLinkTarget && rel === NEW_TAB_REL ) {
|
||||
updatedRel = undefined;
|
||||
}
|
||||
|
||||
setAttributes( {
|
||||
linkTarget: newLinkTarget,
|
||||
rel: updatedRel,
|
||||
} );
|
||||
},
|
||||
[ rel, setAttributes ]
|
||||
);
|
||||
|
||||
const ref = areoi.element.useRef();
|
||||
const richTextRef = areoi.element.useRef();
|
||||
const blockProps = areoi.editor.useBlockProps( {
|
||||
ref,
|
||||
className: areoi.helper.GetClassName( classes ),
|
||||
style: { cssText: areoi.helper.GetStyles( attributes ) }
|
||||
} );
|
||||
|
||||
function onChange( key, value ) {
|
||||
setAttributes( { [key]: value } );
|
||||
}
|
||||
|
||||
const tabDevice = ( tab ) => {
|
||||
var append = ( tab.name == 'xs' ? '' : '-' + tab.name );
|
||||
|
||||
return (
|
||||
<div>
|
||||
{ areoi.DeviceLayout( areoi, attributes, onChange, tab ) }
|
||||
|
||||
{ areoi.DeviceBackground( areoi, attributes, onChange, tab ) }
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{ areoi.DisplayPreview( areoi, attributes, onChange, 'banner-item' ) }
|
||||
|
||||
{ !attributes.preview &&
|
||||
<div { ...blockProps } data-anchor={ attributes.anchor ? ' : #' + attributes.anchor : '' }>
|
||||
<areoi.editor.InspectorControls key="setting">
|
||||
|
||||
{ areoi.Background( areoi, attributes, onChange ) }
|
||||
|
||||
{ layout != 'grid' &&
|
||||
<areoi.components.PanelBody title={ 'Media' } initialOpen={ false }>
|
||||
|
||||
{ areoi.MediaUpload( areoi, attributes, onChange, 'Image', 'image', 'image' ) }
|
||||
|
||||
{ areoi.MediaUpload( areoi, attributes, onChange, 'Video', 'video', 'video' ) }
|
||||
|
||||
</areoi.components.PanelBody>
|
||||
}
|
||||
|
||||
|
||||
{ areoi.ResponsiveTabPanel( tabDevice, meta, props ) }
|
||||
|
||||
</areoi.editor.InspectorControls>
|
||||
|
||||
|
||||
|
||||
{ layout == 'stacked' &&
|
||||
<>
|
||||
{ stacked.render( areoi, attributes, container, BLOCKS_TEMPLATE, ALLOWED_BLOCKS ) }
|
||||
</>
|
||||
}
|
||||
|
||||
{ layout == 'grid' &&
|
||||
<>
|
||||
{ grid.render( areoi, attributes, container, BLOCKS_TEMPLATE, ALLOWED_BLOCKS ) }
|
||||
</>
|
||||
}
|
||||
|
||||
{ layout == 'carousel' &&
|
||||
<>
|
||||
{ carousel.render( areoi, attributes, container, BLOCKS_TEMPLATE, ALLOWED_BLOCKS ) }
|
||||
</>
|
||||
}
|
||||
|
||||
<areoi.URLPicker
|
||||
areoi={ areoi }
|
||||
url={ url }
|
||||
urlTitle={ url_title }
|
||||
setAttributes={ setAttributes }
|
||||
isSelected={ isSelected }
|
||||
opensInNewTab={ linkTarget === '_blank' }
|
||||
onToggleOpenInNewTab={ onToggleOpenInNewTab }
|
||||
anchorRef={ ref }
|
||||
richTextRef={ richTextRef }
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
</>
|
||||
);
|
||||
},
|
||||
save: () => {
|
||||
return (
|
||||
<areoi.editor.InnerBlocks.Content/>
|
||||
);
|
||||
},
|
||||
} );
|
||||
@@ -0,0 +1,472 @@
|
||||
{
|
||||
"apiVersion": 2,
|
||||
"name": "areoi/banner-item",
|
||||
"title": "Banner Item",
|
||||
"parent": [ "areoi/banner" ],
|
||||
"category": "areoi-strips",
|
||||
"description": "Add individual banner items within a banner.",
|
||||
"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
|
||||
},
|
||||
"parent_id": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
|
||||
"exclude_divider": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"exclude_pattern": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"change_pattern_color": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"pattern_color": {
|
||||
"type": "object",
|
||||
"default": {
|
||||
"hex": "#fff"
|
||||
}
|
||||
},
|
||||
"exclude_transition": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"exclude_parallax": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
|
||||
"image": {
|
||||
"type": "object",
|
||||
"default": null
|
||||
},
|
||||
"video": {
|
||||
"type": "object",
|
||||
"default": null
|
||||
},
|
||||
"utilities_bg": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"utilities_text": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"utilities_border": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"background_display": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"background_color": {
|
||||
"type": "object",
|
||||
"default": {
|
||||
"rgb": {
|
||||
"r": 0,
|
||||
"g": 0,
|
||||
"b": 0,
|
||||
"a": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"background_image": {
|
||||
"type": "object",
|
||||
"default": null
|
||||
},
|
||||
"background_video": {
|
||||
"type": "object",
|
||||
"default": null
|
||||
},
|
||||
"background_display_overlay": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"background_overlay": {
|
||||
"type": "object",
|
||||
"default": {
|
||||
"rgb": {
|
||||
"r": 0,
|
||||
"g": 0,
|
||||
"b": 0,
|
||||
"a": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"background_horizontal_align": {
|
||||
"type": "string",
|
||||
"default": "justify-content-start"
|
||||
},
|
||||
|
||||
"background_hide_xs": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"background_col_xs": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
|
||||
"background_hide_sm": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"background_col_sm": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
|
||||
"background_hide_md": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"background_col_md": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
|
||||
"background_hide_lg": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"background_col_lg": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
|
||||
"background_hide_xl": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"background_col_xl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
|
||||
"background_hide_xxl": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"background_col_xxl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
|
||||
"url": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"title": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"linkTarget": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"rel": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
|
||||
"height_dimension_xs": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"height_unit_xs": {
|
||||
"type": "string",
|
||||
"default": "px"
|
||||
},
|
||||
"padding_top_xs": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_right_xs": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_bottom_xs": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_left_xs": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_top_xs": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_right_xs": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_bottom_xs": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_left_xs": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"hide_xs": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
|
||||
"height_dimension_sm": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"height_unit_sm": {
|
||||
"type": "string",
|
||||
"default": "px"
|
||||
},
|
||||
"padding_top_sm": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_right_sm": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_bottom_sm": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_left_sm": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_top_sm": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_right_sm": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_bottom_sm": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_left_sm": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"hide_sm": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
|
||||
"height_dimension_md": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"height_unit_md": {
|
||||
"type": "string",
|
||||
"default": "px"
|
||||
},
|
||||
"padding_top_md": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_right_md": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_bottom_md": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_left_md": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_top_md": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_right_md": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_bottom_md": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_left_md": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"hide_md": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
|
||||
"height_dimension_lg": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"height_unit_lg": {
|
||||
"type": "string",
|
||||
"default": "px"
|
||||
},
|
||||
"padding_top_lg": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_right_lg": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_bottom_lg": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_left_lg": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_top_lg": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_right_lg": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_bottom_lg": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_left_lg": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"hide_lg": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
|
||||
"height_dimension_xl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"height_unit_xl": {
|
||||
"type": "string",
|
||||
"default": "px"
|
||||
},
|
||||
"padding_top_xl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_right_xl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_bottom_xl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_left_xl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_top_xl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_right_xl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_bottom_xl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_left_xl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"hide_xl": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
|
||||
"height_dimension_xxl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"height_unit_xxl": {
|
||||
"type": "string",
|
||||
"default": "px"
|
||||
},
|
||||
"padding_top_xxl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_right_xxl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_bottom_xxl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"padding_left_xxl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_top_xxl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_right_xxl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_bottom_xxl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"margin_left_xxl": {
|
||||
"type": "string",
|
||||
"default": null
|
||||
},
|
||||
"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: 146 KiB |
@@ -0,0 +1,41 @@
|
||||
function render( areoi, attributes, container, BLOCKS_TEMPLATE, ALLOWED_BLOCKS )
|
||||
{
|
||||
var has_media = (attributes['image'] && attributes['image'] != null) || (attributes['video'] && attributes['video'] != null);
|
||||
return (
|
||||
|
||||
<>
|
||||
{ areoi.DisplayBackground( areoi, attributes ) }
|
||||
|
||||
<div className={ areoi.helper.GetClassNameStr( [ 'container' ] ) }>
|
||||
<div className={ areoi.helper.GetClassNameStr( [ 'row', 'h-100', 'align-items-center', 'justify-content-' + ( has_media ? 'between' : 'center text-center' ) ] ) }>
|
||||
|
||||
<div class="col-11 col-md-8 col-lg-6 col-xl-5 position-relative">
|
||||
<div className={ areoi.helper.GetClassNameStr( [ 'areoi-banner-content', 'flex-grow-1' ] ) }>
|
||||
<areoi.editor.InnerBlocks template={ BLOCKS_TEMPLATE } allowedBlocks={ ALLOWED_BLOCKS } />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{
|
||||
has_media &&
|
||||
<div class="col-11 col-md-8 col-lg-6 col-xl-5 position-relative">
|
||||
{ attributes['image'] && attributes['image']['url'] &&
|
||||
<img src={ attributes['image']['url'] } class="img-fluid" />
|
||||
}
|
||||
|
||||
{ attributes['video'] && attributes['video']['url'] &&
|
||||
<video>
|
||||
<source src={ attributes['video']['url'] } />
|
||||
</video>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export {
|
||||
render
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
function render( areoi, attributes, container, BLOCKS_TEMPLATE, ALLOWED_BLOCKS )
|
||||
{
|
||||
return (
|
||||
|
||||
<div class="col position-relative">
|
||||
{ areoi.DisplayBackground( areoi, attributes ) }
|
||||
|
||||
<div className={ areoi.helper.GetClassNameStr( [ 'areoi-banner-content', 'flex-grow-1' ] ) }>
|
||||
<areoi.editor.InnerBlocks template={ BLOCKS_TEMPLATE } allowedBlocks={ ALLOWED_BLOCKS } />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export {
|
||||
render
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
function render( areoi, attributes, container, BLOCKS_TEMPLATE, ALLOWED_BLOCKS )
|
||||
{
|
||||
var has_media = attributes['image'] || attributes['video'];
|
||||
return (
|
||||
|
||||
<>
|
||||
{ areoi.DisplayBackground( areoi, attributes ) }
|
||||
|
||||
<div className={ areoi.helper.GetClassNameStr( [ 'container' ] ) }>
|
||||
<div className={ areoi.helper.GetClassNameStr( [ 'row', 'h-100', 'align-items-center', 'justify-content-' + ( has_media ? 'between' : 'center text-center' ) ] ) }>
|
||||
|
||||
<div class="col-11 col-md-8 col-lg-6 col-xl-5 position-relative">
|
||||
<div className={ areoi.helper.GetClassNameStr( [ 'areoi-banner-content', 'flex-grow-1' ] ) }>
|
||||
<areoi.editor.InnerBlocks template={ BLOCKS_TEMPLATE } allowedBlocks={ ALLOWED_BLOCKS } />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{
|
||||
has_media &&
|
||||
<div class="col-11 col-md-8 col-lg-6 col-xl-5 position-relative">
|
||||
{ attributes['image'] && attributes['image']['url'] &&
|
||||
<img src={ attributes['image']['url'] } class="img-fluid" />
|
||||
}
|
||||
|
||||
{ attributes['video'] && attributes['video']['url'] &&
|
||||
<video>
|
||||
<source src={ attributes['video']['url'] } />
|
||||
</video>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export {
|
||||
render
|
||||
}
|
||||
Reference in New Issue
Block a user