Improve collections carousel and items grid styles (#136)

This commit is contained in:
weryques 2018-10-31 13:32:43 -03:00
parent d10164cb1e
commit 2e66996980
2 changed files with 44 additions and 36 deletions

View File

@ -134,6 +134,7 @@ registerBlockType('tainacan/collections-carousel', {
content: contentTemp.length ? content: contentTemp.length ?
(<div> (<div>
<Carousel <Carousel
offset={20}
arrowLeft={arrowLeft} arrowLeft={arrowLeft}
arrowRight={arrowRight} arrowRight={arrowRight}
addArrowClickHandler addArrowClickHandler
@ -179,11 +180,12 @@ registerBlockType('tainacan/collections-carousel', {
<div key={collection.id}> <div key={collection.id}>
<div style={{ <div style={{
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column'}}>
marginLeft: '20px'}}>
{ isInEdit ? ( { isInEdit ? (
<IconButton <IconButton
isSmall
isPrimary
style={{position: 'absolute'}} style={{position: 'absolute'}}
label={ __('Remove', 'tainacan') } label={ __('Remove', 'tainacan') }
onClick={() => { onClick={() => {
@ -194,9 +196,8 @@ registerBlockType('tainacan/collections-carousel', {
) : null } ) : null }
<div className={`${className}__carousel-item`}> <div className={`${className}__carousel-item`}>
<div style={{width: '87px', marginRight: '3px'}} className={`${className}__carousel-item-first`}>
<div style={{width: '99px', marginRight: '3px'}} className={`${className}__carousel-item-first`}> {items[0] ? prepareItem(items[0], {display: 'flex', height: '87px'}, collection.name) : null}
{items[0] ? prepareItem(items[0], null, collection.name) : null}
</div> </div>
<div className={`${className}__carousel-item-others`}> <div className={`${className}__carousel-item-others`}>
@ -204,6 +205,7 @@ registerBlockType('tainacan/collections-carousel', {
{items[2] ? prepareItem(items[2], {width: '42px', height: '42px'}, collection.name) : null} {items[2] ? prepareItem(items[2], {width: '42px', height: '42px'}, collection.name) : null}
</div> </div>
</div> </div>
<small style={{ <small style={{
maxWidth: '130px', maxWidth: '130px',
marginLeft: '10px'}}> marginLeft: '10px'}}>
@ -357,6 +359,7 @@ registerBlockType('tainacan/collections-carousel', {
<div> <div>
{ contentTemp.length ? { contentTemp.length ?
<Carousel <Carousel
offset={20}
arrowLeft={arrowLeft} arrowLeft={arrowLeft}
arrowRight={arrowRight} arrowRight={arrowRight}
addArrowClickHandler addArrowClickHandler

View File

@ -15,10 +15,6 @@ registerBlockType('tainacan/items-grid', {
attributes: { attributes: {
items: { items: {
type: 'array', type: 'array',
source: 'query',
selector: 'picture',
query: {
img: {
source: 'query', source: 'query',
selector: 'img', selector: 'img',
query: { query: {
@ -30,8 +26,6 @@ registerBlockType('tainacan/items-grid', {
source: 'attribute', source: 'attribute',
attribute: 'alt' attribute: 'alt'
}, },
}
}
}, },
default: [] default: []
}, },
@ -45,6 +39,10 @@ registerBlockType('tainacan/items-grid', {
selector: 'div' selector: 'div'
}, },
}, },
supports: {
align: ['full', 'left', 'right', 'wide'],
html: false
},
edit({ attributes, setAttributes, className }){ edit({ attributes, setAttributes, className }){
console.log('edit', attributes); console.log('edit', attributes);
@ -55,16 +53,21 @@ registerBlockType('tainacan/items-grid', {
function prepareItem(item) { function prepareItem(item) {
return ( return (
<picture>
<img <img
style={{
width: '150px',
height: '150px',
padding: 0
}}
src={ src={
(item.thumbnail && item.thumbnail.thumb) ? (item.thumbnail && item.thumbnail.thumb) ?
item.thumbnail.thumb : item.thumbnail.thumb :
( (item.img && item.img[0].src) ? ((item && item.src) ?
item.img[0].src : `${tainacan_plugin.base_url}/admin/images/placeholder_square.png`) item.src : `${tainacan_plugin.base_url}/admin/images/placeholder_square.png`)
} }
alt={ item.title ? item.title : item.alt } />
</picture> alt={item.title ? item.title : item.alt}/>
); );
} }
@ -128,9 +131,10 @@ registerBlockType('tainacan/items-grid', {
setAttributes({ setAttributes({
content: ( content: (
<div style={{ <div style={{
columnCount: 4, display: 'flex',
columnGap: 0, flexDirection: 'row',
rowGap: 0, flexWrap: 'wrap',
alignContent: 'flex-start',
}}> }}>
{ items } { items }
</div> </div>
@ -189,9 +193,10 @@ registerBlockType('tainacan/items-grid', {
</Modal> : null } </Modal> : null }
<div style={{ <div style={{
columnCount: 4, display: 'flex',
columnGap: 0, flexDirection: 'row',
rowGap: 0, flexWrap: 'wrap',
alignContent: 'flex-start',
}}> }}>
{ items } { items }
</div> </div>