Skip to content

Commit

Permalink
Merge branch 'feature/TMZ-276' of github.com:elementor/hello-plus int…
Browse files Browse the repository at this point in the history
…o feature/TMZ-276
  • Loading branch information
nicoladj77 committed Jan 12, 2025
2 parents e24dea2 + 6b7021c commit 76d96d9
Show file tree
Hide file tree
Showing 23 changed files with 594 additions and 164 deletions.
6 changes: 6 additions & 0 deletions assets/dev/scss/variables/values.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
$transition: all .3s;

$corners-shape-default: 8px;
$corners-shape-sharp: 0;
$corners-shape-rounded: 12px;
$corners-shape-round: 32px;
$corners-shape-oval: 50%;

$corners-image-shape-rounded: 52px;
$corners-image-shape-round: 300px;

$corners-box-shape-rounded: 52px;
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.25.11' );
define( 'HELLOPLUS_MIN_ELEMENTOR_VERSION', '3.26.4' );

// Init the Plugin class
require HELLOPLUS_PATH . '/plugin.php';
Expand Down
13 changes: 9 additions & 4 deletions includes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ public static function has_pro(): bool {
return defined( 'ELEMENTOR_PRO_VERSION' );
}

public static function are_we_on_elementor_domains() {
public static function are_we_on_elementor_domains(): bool {
$current_domain = filter_input( INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_URL );
$allowed_domains = [
'elementor.com' => true,
'elementor.red' => true,
'elementor.com',
'elementor.red',
];

return isset( $allowed_domains[ $current_domain ] );
foreach ( $allowed_domains as $domain ) {
if ( str_ends_with( $current_domain, $domain ) ) {
return true;
}
}
return false;
}

public static function has_hello_biz(): bool {
Expand Down
116 changes: 116 additions & 0 deletions modules/content/assets/js/frontend/handlers/hello-plus-zigzag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
export default class ZigZagHandler extends elementorModules.frontend.handlers.Base {
getDefaultSettings() {
return {
selectors: {
main: '.ehp-zigzag',
itemWrapper: '.ehp-zigzag__item-wrapper',
},
constants: {
entranceAnimation: 'zigzag_animation',
entranceAnimationAlternate: 'zigzag_animation_alternate',
hasEntranceAnimation: 'has-entrance-animation',
hasAlternateAnimation: 'has-alternate-animation',
none: 'none',
visible: 'visible',
hidden: 'hidden',
},
};
}

getDefaultElements() {
const selectors = this.getSettings( 'selectors' );

return {
main: this.$element[ 0 ].querySelector( selectors.main ),
itemWrappers: this.$element[ 0 ].querySelectorAll( selectors.itemWrapper ),
};
}

bindEvents() {
if ( this.elements.itemWrappers.length > 0 ) {
this.elements.itemWrappers.forEach( ( itemWrapper ) => {
itemWrapper.addEventListener( 'animationend', this.removeAnimationClasses.bind( this ) );
} );
}
}

getResponsiveSetting( controlName ) {
const currentDevice = elementorFrontend.getCurrentDeviceMode();
return elementorFrontend.utils.controls.getResponsiveControlValue( this.getElementSettings(), controlName, '', currentDevice );
}

initEntranceAnimation() {
const { entranceAnimation, entranceAnimationAlternate, none, visible, hidden } = this.getSettings( 'constants' );
const entranceAnimationClass = this.getResponsiveSetting( entranceAnimation );

if ( ! entranceAnimationClass || none === entranceAnimationClass ) {
return;
}
const alternateAnimationClass = this.getResponsiveSetting( entranceAnimationAlternate );

const observerCallback = ( entries ) => {
const sortedEntries = [ ...entries ].sort( ( a, b ) => {
const indexA = a.target.dataset.index;
const indexB = b.target.dataset.index;
return indexA - indexB;
} );

sortedEntries.forEach( ( entry, index ) => {
if ( entry.isIntersecting && ! entry.target.classList.contains( visible ) ) {
setTimeout( () => {
entry.target.classList.remove( hidden );
const entryIndex = parseInt( entry.target.dataset.index, 10 );
const animation = this.hasAlternateAnimation( entryIndex ) ? alternateAnimationClass : entranceAnimationClass;
entry.target.classList.add( animation );
}, index * 200 );
}
} );
};

const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.5,
};
const observer = new IntersectionObserver( observerCallback, observerOptions );

this.elements.itemWrappers.forEach( ( element, index ) => {
element.dataset.index = index;
observer.observe( element );
} );
}

removeAnimationClasses( event ) {
const { entranceAnimation, entranceAnimationAlternate, visible, hidden } = this.getSettings( 'constants' );
const element = event.target;
const entranceAnimationClass = this.getResponsiveSetting( entranceAnimation );
const alternateAnimationClass = this.getResponsiveSetting( entranceAnimationAlternate );
const entryIndex = parseInt( element.dataset.index, 10 );

const animation = this.hasAlternateAnimation( entryIndex ) ? alternateAnimationClass : entranceAnimationClass;
element.classList.remove( animation );

element.classList.remove( hidden );
element.classList.add( visible );
}

hasAlternateAnimation( index ) {
const { hasAlternateAnimation } = this.getSettings( 'constants' );
const isEven = 0 === ( index + 1 ) % 2;
return this.elements.main.classList.contains( hasAlternateAnimation ) && isEven;
}

getAlternateAnimationClass( entranceAnimationClass ) {
return entranceAnimationClass.replace( /Right|Left/g, ( match ) => ( 'Right' === match ? 'Left' : 'Right' ) );
}

onInit( ...args ) {
const { hasEntranceAnimation } = this.getSettings( 'constants' );

super.onInit( ...args );

if ( this.elements.main && this.elements.main.classList.contains( hasEntranceAnimation ) ) {
this.initEntranceAnimation();
}
}
}
13 changes: 13 additions & 0 deletions modules/content/assets/js/frontend/hello-plus-zigzag-fe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default class HelloPlusZigzagFe extends elementorModules.Module {
constructor() {
super();

elementorFrontend.elementsHandler.attachHandler( 'zigzag', [
() => import( /* webpackChunkName: 'js/content' */ './handlers/hello-plus-zigzag' ),
] );
}
}

window.addEventListener( 'elementor/frontend/init', () => {
new HelloPlusZigzagFe();
} );
18 changes: 8 additions & 10 deletions modules/content/assets/scss/hello-plus-cta.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
--cta-text-width-heading: 800px;
--cta-text-width-description: 440px;

--cta-button-primary-background-color: #0052FF;
--cta-button-primary-icon-spacing: 10px;
--cta-button-primary-icon-size: 16px;
--cta-button-primary-text-color: #FFFFFF;
Expand All @@ -32,7 +31,6 @@
--cta-button-primary-padding-inline-start: 16px;
--cta-button-primary-border-radius: 0;

--cta-button-secondary-background-color: transparent;
--cta-button-secondary-icon-spacing: 10px;
--cta-button-secondary-icon-size: 16px;
--cta-button-secondary-text-color: #555963;
Expand All @@ -48,7 +46,6 @@
--cta-button-text-color: var(--cta-button-primary-text-color);
--cta-button-text-color-hover: var(--cta-button-primary-text-color-hover);
--cta-button-border-color: var(--cta-button-primary-border-color);
--cta-button-background-color: var(--cta-button-primary-background-color);
--cta-button-padding-block-end: var(--cta-button-primary-padding-block-end);
--cta-button-padding-block-start: var(--cta-button-primary-padding-block-start);
--cta-button-padding-inline-end: var(--cta-button-primary-padding-inline-end);
Expand Down Expand Up @@ -182,12 +179,10 @@
width: var(--cta-button-icon-size);
}

&__button,
&__button:not([href]):not([tabindex]) {
& a.ehp-cta__button,
& a.ehp-cta__button:not([href]):not([tabindex]) {
align-items: center;
display: flex;
font-weight: 500;
font-size: 16px;
gap: var(--cta-button-icon-spacing);
justify-content: center;
text-decoration: none;
Expand All @@ -206,7 +201,6 @@
}

&.is-type-button {
background-color: var(--cta-button-background-color);
padding-block-end: var(--cta-button-padding-block-end);
padding-block-start: var(--cta-button-padding-block-start);
padding-inline-end: var(--cta-button-padding-inline-end);
Expand All @@ -216,9 +210,14 @@

&.is-type-link,
&.is-type-link:not([href]):not([tabindex]) {
background: none !important; // Always override primary and secondary background coming from the control
background: none;
align-self: center;
text-decoration: underline;

&:hover,
&:focus {
background: none;
}
}

&.is-type-button,
Expand Down Expand Up @@ -255,7 +254,6 @@
--cta-button-text-color: var(--cta-button-secondary-text-color);
--cta-button-text-color-hover: var(--cta-button-secondary-text-color-hover);
--cta-button-border-color: var(--cta-button-secondary-border-color);
--cta-button-background-color: var(--cta-button-secondary-background-color);
--cta-button-padding-block-end: var(--cta-button-secondary-padding-block-end);
--cta-button-padding-block-start: var(--cta-button-secondary-padding-block-start);
--cta-button-padding-inline-end: var(--cta-button-secondary-padding-inline-end);
Expand Down
Loading

0 comments on commit 76d96d9

Please sign in to comment.