Skip to content

Commit

Permalink
added possibility to clear the gallery control
Browse files Browse the repository at this point in the history
  • Loading branch information
nk-o committed Oct 8, 2024
1 parent ec28773 commit e1a68e9
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 10 deletions.
31 changes: 25 additions & 6 deletions assets/editor/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -370,24 +370,48 @@
display: flex;
align-items: center;
justify-content: center;
background-color: rgba(255, 255, 255, 0.5);
backdrop-filter: blur(2px);
width: 100%;
height: 100%;
opacity: 0;
transition: 0.15s opacity;

> .components-button {
background-color: #fff;
color: #000;
}
}

&:hover .lzb-gutenberg-gallery-button,
&:hover .lzb-gutenberg-image-button {
opacity: 1;
}

.lzb-gutenberg-gallery-button-edit:hover,
.lzb-gutenberg-gallery-button-edit:focus {
color: #2279ea;
}

.lzb-gutenberg-gallery-button-remove {
&:hover,
&:focus {
color: #ea2c22;
}

svg {
width: 1em;
height: 1em;
fill: none;
}
}

.lzb-gutenberg-image-item,
.lzb-gutenberg-gallery-item {
position: relative;
display: block;
background-color: #e6e6e6;
border-radius: 3px;
transition: 0.15s opacity;

&::after {
display: block;
Expand Down Expand Up @@ -432,11 +456,6 @@
width: 30%;
margin: 0 auto;
}

&:hover .lzb-gutenberg-gallery-item,
&:hover .lzb-gutenberg-image-item {
opacity: 0.6;
}
}

// File control
Expand Down
64 changes: 60 additions & 4 deletions controls/gallery/gallery-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
* WordPress dependencies.
*/
import { __ } from '@wordpress/i18n';
import { Button, DropZone, withNotices } from '@wordpress/components';
import {
Button,
ButtonGroup,
Tooltip,
DropZone,
withNotices,
} from '@wordpress/components';
import { MediaPlaceholder, MediaUpload } from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';

Expand Down Expand Up @@ -121,11 +127,61 @@ function GalleryControl(props) {
});
}}
/>
<div className="lzb-gutenberg-gallery-button">
<Button variant="secondary" size="small">
<ButtonGroup className="lzb-gutenberg-gallery-button">
<Button
variant="secondary"
size="compact"
className="lzb-gutenberg-gallery-button-edit"
>
{__('Edit Gallery', 'lazy-blocks')}
</Button>
</div>
<Tooltip
text={__(
'Clear the gallery',
'lazy-blocks'
)}
>
<Button
variant="secondary"
size="compact"
className="lzb-gutenberg-gallery-button-remove"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();

onChange([]);
}}
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="M3 6h18" />
<path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" />
<path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" />
<line
x1="10"
x2="10"
y1="11"
y2="17"
/>
<line
x1="14"
x2="14"
y1="11"
y2="17"
/>
</svg>
</Button>
</Tooltip>
</ButtonGroup>
{value.map((img) => (
<div
className="lzb-gutenberg-gallery-item"
Expand Down

0 comments on commit e1a68e9

Please sign in to comment.