From b68887e1d5c1a6e848e3622146e8f1b9ab35c4d4 Mon Sep 17 00:00:00 2001 From: Nurit Shahar <43785095+nuritsha@users.noreply.github.com> Date: Wed, 25 Dec 2024 15:07:48 +0200 Subject: [PATCH] Fix: Zigzag Widget alternate color & icon [TMZ-273] (#147) --- .../assets/scss/hello-plus-zigzag.scss | 57 +++++++++++++------ .../classes/render/widget-zig-zag-render.php | 24 +++----- modules/content/widgets/zig-zag.php | 14 ++--- 3 files changed, 56 insertions(+), 39 deletions(-) diff --git a/modules/content/assets/scss/hello-plus-zigzag.scss b/modules/content/assets/scss/hello-plus-zigzag.scss index d3c9c6d..5063496 100644 --- a/modules/content/assets/scss/hello-plus-zigzag.scss +++ b/modules/content/assets/scss/hello-plus-zigzag.scss @@ -127,11 +127,49 @@ display: flex; } + &.has-alternate-icon-color { + .ehp-zigzag__item-wrapper:nth-child(odd) { + .ehp-zigzag__graphic-element-container { + color: var(--zigzag-icon-color-alternate); + } + } + } + + &.has-direction { + &-start { + .ehp-zigzag__item-wrapper:nth-child(odd) { + .ehp-zigzag__item-container { + flex-direction: row; + } + } + + .ehp-zigzag__item-wrapper:nth-child(even) { + .ehp-zigzag__item-container { + flex-direction: row-reverse; + } + } + } + + &-end { + .ehp-zigzag__item-wrapper:nth-child(odd) { + .ehp-zigzag__item-container { + flex-direction: row-reverse; + } + } + + .ehp-zigzag__item-wrapper:nth-child(even) { + .ehp-zigzag__item-container { + flex-direction: row; + } + } + } + } + &__text-container { display: flex; flex-direction: column; justify-content: var(--zigzag-content-position); - + &.is-graphic-image { width: calc(100% - var(--zigzag-image-width)); } @@ -162,7 +200,7 @@ object-fit: cover; object-position: var(--zigzag-image-position); width: 100%; - } + } } &.has-icon { @@ -191,21 +229,6 @@ padding-inline-end: var(--zigzag-box-padding-inline-end); max-width: var(--zigzag-content-width); width: 100%; - - &.row-even { - flex-direction: row; - - &.has-alternate-icon-color { - - .ehp-zigzag__graphic-element-container { - color: var(--zigzag-icon-color-alternate); - } - } - } - - &.row-odd { - flex-direction: row-reverse; - } @media screen and (max-width: $screen-tablet-max) { gap: var(--zigzag-elements-gap); diff --git a/modules/content/classes/render/widget-zig-zag-render.php b/modules/content/classes/render/widget-zig-zag-render.php index db5ff54..17eb8d6 100644 --- a/modules/content/classes/render/widget-zig-zag-render.php +++ b/modules/content/classes/render/widget-zig-zag-render.php @@ -27,11 +27,17 @@ public function __construct( Zig_Zag $widget ) { } public function render(): void { - $layout_classnames = self::LAYOUT_CLASSNAME; $first_zigzag_direction = $this->settings['first_zigzag_direction']; $has_alternate_icon_color = $this->settings['has_alternate_icon_color']; - $layout_classnames .= ' has-direction-' . $first_zigzag_direction; + $layout_classnames = [ + self::LAYOUT_CLASSNAME, + 'has-direction-' . $first_zigzag_direction, + ]; + + if ( 'yes' === $has_alternate_icon_color ) { + $layout_classnames[] = 'has-alternate-icon-color'; + } $this->widget->add_render_attribute( 'layout', [ 'class' => $layout_classnames, @@ -40,24 +46,12 @@ public function render(): void { ?>