Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add group variation for full block link #833

Merged
merged 1 commit into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions assets/src/editorIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,18 @@ replaceTaxonomyTermSelectors();
setupCustomSidebar();
setUpCssVariables();
blockEditorValidation();

const { registerBlockVariation } = wp.blocks;
const { __ } = wp.i18n;

registerBlockVariation('core/group', {
name: 'group-stretched-link',
title: __('Stretched Link', 'planet4-blocks-backend'),
description: __('Make the entire block contents clickable, using the first link inside.', 'planet4-blocks-backend'),
attributes: { className: 'group-stretched-link' },
scope: ['inserter', 'transform'],
isActive: (blockAttributes) => {
return blockAttributes.className === 'group-stretched-link';
},
icon: 'admin-links',
});
4 changes: 3 additions & 1 deletion assets/src/styles/blocks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

// Other
@import "blocks/WideBlocks";
@import "blocks/Editor";

.is-style-small-padding {
padding: 8px;
Expand Down Expand Up @@ -58,3 +57,6 @@
.is-style-roboto-font-family {
font-family: $roboto;
}

// Variations
@import "../variations/stretched-link";
4 changes: 0 additions & 4 deletions assets/src/styles/blocks/Editor.scss

This file was deleted.

6 changes: 6 additions & 0 deletions assets/src/styles/editorStyle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@import "blocks/TakeActionBoxout/edit";
@import "blocks/CookiesEditor";
@import "blocks/core-overrides/HeadingEditor";
@import "../variations/stretched-link/edit";

@import "components/LayoutSelector";
@import "components/EmptyMessage";
Expand All @@ -27,3 +28,8 @@
@import "components/FormField";
@import "components/HTMLSidebarHelp";
@import "editorFonts";

.block-edit-mode-warning {
padding: $sp-2;
margin: 0;
}
4 changes: 4 additions & 0 deletions assets/src/variations/stretched-link/edit.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.group-stretched-link {
outline: 1px dashed grey;
outline-offset: 2px;
}
19 changes: 19 additions & 0 deletions assets/src/variations/stretched-link/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.group-stretched-link {
position: relative;

// Ensure it's only applying to the first link.
a:first-of-type {
&:before {
content: "";
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}

&:after {
display: none;
}
}
}