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

Internal: Header/Footer templates-api [TMZ-276] #151

Merged
merged 27 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6d3dbd1
For Hello+ Header and Footer, use the library modal
nicoladj77 Jan 5, 2025
c9a7d45
remove logging
nicoladj77 Jan 5, 2025
1fb0caa
implement redirect
nicoladj77 Jan 5, 2025
619524b
more specific events
nicoladj77 Jan 5, 2025
d04bfa1
linting
nicoladj77 Jan 6, 2025
c7e5ebd
linting
nicoladj77 Jan 6, 2025
1bdd1a3
Merge branch 'master' into feature/TMZ-276
nicoladj77 Jan 6, 2025
6839917
new url
nicoladj77 Jan 6, 2025
93d3e56
Merge branch 'feature/TMZ-276' of github.com:elementor/hello-plus int…
nicoladj77 Jan 6, 2025
47d1864
minor tweaks
nuritsha Jan 7, 2025
799344c
hello plus
nicoladj77 Jan 12, 2025
a34b82a
Merge branch 'feature/TMZ-276' of github.com:elementor/hello-plus int…
nicoladj77 Jan 12, 2025
3a2998b
linting
nicoladj77 Jan 12, 2025
6b7021c
Merge branch 'master' into feature/TMZ-276
nuritsha Jan 12, 2025
e24dea2
refactoring
nicoladj77 Jan 12, 2025
76d96d9
Merge branch 'feature/TMZ-276' of github.com:elementor/hello-plus int…
nicoladj77 Jan 12, 2025
aec42b3
remote-ehp
nuritsha Jan 13, 2025
8860186
fix
nicoladj77 Jan 16, 2025
871d172
refactor remote
nicoladj77 Jan 17, 2025
c736041
Merge branch 'master' into feature/TMZ-276
nuritsha Jan 18, 2025
9f03b90
refactor
nicoladj77 Jan 21, 2025
29bda2e
Merge branch 'feature/TMZ-276' of github.com:elementor/hello-plus int…
nicoladj77 Jan 21, 2025
0379450
Merge branch 'master' into feature/TMZ-276
nuritsha Jan 22, 2025
cca1afe
switch to add_filter
nicoladj77 Jan 22, 2025
ecf3119
g pMerge branch 'feature/TMZ-276' of github.com:elementor/hello-plus …
nicoladj77 Jan 22, 2025
de4a60c
refactor
nicoladj77 Jan 22, 2025
2f82346
Update Elementor core dependency to v 3.27.1
nuritsha Jan 23, 2025
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
11 changes: 11 additions & 0 deletions assets/dev/scss/variables/breakpoints.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ $screen-tablet-extra-next: -1;
$screen-laptop-min: -1;
$screen-laptop-max: -1;
$screen-widescreen-min: -1;

$editor-screen-xs-max: map_get($breakpoints, sm) - 1;
$editor-screen-sm-min: map_get($breakpoints, sm);
$editor-screen-sm-max: map_get($breakpoints, md) - 1;
$editor-screen-md-min: map_get($breakpoints, md);
$editor-screen-md-max: map_get($breakpoints, lg) - 1;
$editor-screen-lg-min: map_get($breakpoints, lg);
$editor-screen-lg-max: map_get($breakpoints, xl) - 1;
$editor-screen-xl-min: map_get($breakpoints, xl);
$editor-screen-xl-max: map_get($breakpoints, xxl) - 1;
$editor-screen-xxl-min: map_get($breakpoints, xxl);
1 change: 1 addition & 0 deletions assets/dev/scss/variables/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import "./breakpoints";
@import "./values";
@import "./global-colors";
@import "./mixins";
30 changes: 30 additions & 0 deletions assets/dev/scss/variables/mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@mixin ellipsis {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}

@mixin absolute-center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

@mixin start($value) {
body.rtl & {
right: $value;
}
body:not(.rtl) & {
left: $value;
}
}

@mixin end($value) {
body.rtl & {
left: $value;
}
body:not(.rtl) & {
right: $value;
}
}
2 changes: 1 addition & 1 deletion hello-plus.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
define( 'HELLOPLUS_STYLE_URL', HELLOPLUS_ASSETS_URL . 'css/' );
define( 'HELLOPLUS_IMAGES_PATH', HELLOPLUS_ASSETS_PATH . 'images/' );
define( 'HELLOPLUS_IMAGES_URL', HELLOPLUS_ASSETS_URL . 'images/' );
define( 'HELLOPLUS_MIN_ELEMENTOR_VERSION', '3.26.4' );
define( 'HELLOPLUS_MIN_ELEMENTOR_VERSION', '3.27.1' );

// Init the Plugin class
require HELLOPLUS_PATH . '/plugin.php';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { __ } from '@wordpress/i18n';

export class EhpAddLibraryTab extends $e.modules.hookUI.Before {
getCommand() {
return 'library/open';
}

getId() {
return 'ehp-add-library-tab';
}

getConditions() {
return [ 'ehp-header', 'ehp-footer' ].includes( elementor?.config?.document?.type );
}

getTitle() {
switch ( elementor?.config?.document?.type ) {
case 'ehp-header':
return __( 'Hello+ Header', 'hello-plus' );
case 'ehp-footer':
return __( 'Hello+ Footer', 'hello-plus' );
default:
return __( 'Hello Plus', 'elementor' );
}
}

apply() {
$e.components.get( 'library' ).addTab( 'templates/ehp-elements', {
title: this.getTitle(),
filter: {
source: 'remote-ehp',
type: 'block',
subtype: elementor?.config?.document?.type,
},
}, 2 );

$e.components.get( 'library' ).removeTab( 'templates/blocks' );
$e.components.get( 'library' ).removeTab( 'templates/pages' );
}
}

export default EhpAddLibraryTab;
3 changes: 3 additions & 0 deletions modules/template-parts/assets/js/editor/hooks/ui/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
export { SelectEhpElementOnOpen } from './attach-preview';
export { SelectAfterContainer } from './select';
export { EhpAddLibraryTab } from './add-library-tab';
export { EhpRemoveLibraryTab } from './remove-library-tab';
export { EhpOpenLibraryAfterDelete } from './open-library-after-delete';
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export class EhpOpenLibraryAfterDelete extends $e.modules.hookUI.After {
getCommand() {
return 'document/elements/delete';
}

getId() {
return 'ehp-open-library-after-delete';
}

getConditions( args ) {
let type = args?.container?.document?.config?.type;
if ( ! type ) {
type = args?.containers[ 0 ]?.document?.config?.type;
}

return [ 'ehp-header', 'ehp-footer' ].includes( type );
}

apply() {
$e.run( 'library/open' );
}
}

export default EhpOpenLibraryAfterDelete;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export class EhpRemoveLibraryTab extends $e.modules.hookUI.After {
getCommand() {
return 'editor/documents/unload';
}

getId() {
return 'ehp-remove-library-tab';
}

getConditions( args ) {
const document = elementor.documents.get( args.id );
return [ 'ehp-header', 'ehp-footer' ].includes( document.config.type );
}

apply() {
$e.components.get( 'library' ).removeTab( 'templates/ehp-elements' );

$e.components.get( 'library' ).addTab( 'templates/pages' );
$e.components.get( 'library' ).addTab( 'templates/blocks' );
}
}

export default EhpRemoveLibraryTab;
17 changes: 17 additions & 0 deletions modules/template-parts/assets/js/editor/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,22 @@ export default class TemplatesModule extends elementorModules.editor.utils.Modul
elementor.hooks.addFilter( 'elements/widget/controls/common/default', this.resetCommonControls.bind( this ) );
elementor.hooks.addFilter( 'elements/widget/controls/common-optimized/default', this.resetCommonControls.bind( this ) );

const types = [
'core/modal/close/ehp-footer',
'core/modal/close/ehp-header',
];

types.forEach( ( type ) => {
window.addEventListener( type, this.redirectToHelloPlus );
} );

window.templatesModule = this;
}

redirectToHelloPlus() {
window.location.href = elementor.config.close_modal_redirect_hello_plus;
}

async openSiteIdentity() {
await $e.run( 'panel/global/open' );
$e.route( 'panel/global/settings-site-identity' );
Expand All @@ -22,4 +35,8 @@ export default class TemplatesModule extends elementorModules.editor.utils.Modul

return commonControls;
}

isEhpDocument() {
return [ 'ehp-footer', 'ehp-header' ].includes( elementor.config.document.type );
}
}
3 changes: 3 additions & 0 deletions modules/template-parts/assets/scss/editor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import "../../../../assets/dev/scss/variables";
@import 'editor/_template-modal';
@import 'editor/_hello-plus-template-parts-preview';
159 changes: 159 additions & 0 deletions modules/template-parts/assets/scss/editor/_template-modal.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
$remote-templates-items-space: 30px;

.elementor-template-library-template-remote-ehp {
margin: calc( #{$remote-templates-items-space} / 2 );
padding: 8px;
border: var(--e-a-border);
border-radius: 3px;

&:hover {
background-color: var(--e-a-bg-hover);

.elementor-template-library-template-name {
display: none;
}
}

&:not(:hover) {

.elementor-template-library-template-preview {
opacity: 0;
}

.elementor-template-library-favorite,
.elementor-template-library-template-action {
display: none;
}
}

&.elementor-template-library-pro-template {

.elementor-template-library-template-body:before {
content: var( --elementor-template-library-subscription-plan-label );
background-color: var(--e-a-color-accent);
color: var(--e-a-color-white);
position: absolute;
text-transform: uppercase;
line-height: 1;
top: 5px;
@include end(5px);
padding: 3px 5px;
font-size: 8px;
border-radius: 2px;
}
}

// For blocks
&:not(.elementor-template-library-template-page):not(.elementor-template-library-template-lp) {
position: relative;
width: calc(33.333% - #{$remote-templates-items-space});
overflow: hidden;

img {
display: block;
width: 100%;
}

.elementor-template-library-template-footer {
position: absolute;
width: 100%;
bottom: 0;
@include start(0);
padding: 10px;
background-color: var(--e-a-bg-default);
transition: transform .5s;
}

.elementor-template-library-template-name {
display: none;
}

&:not(:hover) {

.elementor-template-library-template-footer {
transform: translateY(100%)
}
}
}

.elementor-template-library-template-body {
position: relative;
}

@media (max-width: $editor-screen-lg-min) {

.elementor-template-library-template-body {
height: 300px;
}
}

.elementor-template-library-template-screenshot {
height: 100%;
background-size: cover;
background-position-x: 50%;
box-shadow: inset 0px -2px 15px -6px rgba(0, 0, 0, 0.07);
}

.elementor-template-library-template-preview {
position: absolute;
inset: 0;
background-color: rgba(0,0,0,.5);
transition: opacity .5s;
cursor: pointer;

i {
font-size: 20px;
@include absolute-center;
}
}

.elementor-template-library-template-footer {
display: flex;
justify-content: space-between;
font-size: 11px;
line-height: 1;
height: 40px;
align-items: center;
}

.elementor-template-library-template-name {
text-align: start;
flex-grow: 1;
@include ellipsis;
padding-inline-end: 5px;
}

.elementor-template-library-favorite {
margin-inline-start: auto;
}

.elementor-template-library-template-favorite-input {
display: none;

&:checked {

+ .elementor-template-library-template-favorite-label {

i {

&:before {
content: '\e93f';
color: var(--e-a-color-primary-bold);
}
}
}
}
}

.elementor-template-library-template-favorite-label {
font-size: 15px;
cursor: pointer;

&:hover {

i {
color: var(--e-a-color-primary-bold);
}
}
}
}
Loading
Loading