| @@ -32,8 +32,21 @@ | ||
| 32 | 32 | $this->get_main_wrapper_css( $attributes, 'Mobile' ) |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | 35 | $css_generator->add_class_styles( |
| 36 | + '{{WRAPPER}}.ablocks-block--container-has-link-overlay', | |
| 37 | + $this->get_link_overlay_wrapper_css( $attributes ) | |
| 38 | + ); | |
| 39 | + $css_generator->add_class_styles( | |
| 40 | + '{{WRAPPER}}.ablocks-block--container-has-link-overlay > .ablocks-block-container__link-overlay', | |
| 41 | + $this->get_link_overlay_css( $attributes ) | |
| 42 | + ); | |
| 43 | + $css_generator->add_class_styles( | |
| 44 | + '{{WRAPPER}}.ablocks-block--container-has-link-overlay > *:not(.ablocks-block-container__link-overlay):not(.ablocks-background--video):not(.ablocks-background-video-wrapper)', | |
| 45 | + $this->get_link_overlay_content_css( $attributes ) | |
| 46 | + ); | |
| 47 | + | |
| 48 | + $css_generator->add_class_styles( | |
| 36 | 49 | '{{WRAPPER}} > .ablocks-block-container', |
| 37 | 50 | $this->get_block_container_css( $attributes ), |
| 38 | 51 | $this->get_block_container_css( $attributes, 'Tablet' ), |
| 39 | 52 | $this->get_block_container_css( $attributes, 'Mobile' ) |
| @@ -109,8 +122,21 @@ | ||
| 109 | 122 | $this->get_main_wrapper_css( $attributes, 'Tablet' ), |
| 110 | 123 | $this->get_main_wrapper_css( $attributes, 'Mobile' ) |
| 111 | 124 | ); |
| 112 | 125 | |
| 126 | + $css_generator->add_class_styles( | |
| 127 | + '{{WRAPPER}}.ablocks-block--container-has-link-overlay', | |
| 128 | + $this->get_link_overlay_wrapper_css( $attributes ) | |
| 129 | + ); | |
| 130 | + $css_generator->add_class_styles( | |
| 131 | + '{{WRAPPER}}.ablocks-block--container-has-link-overlay > .ablocks-block-container__link-overlay', | |
| 132 | + $this->get_link_overlay_css( $attributes ) | |
| 133 | + ); | |
| 134 | + $css_generator->add_class_styles( | |
| 135 | + '{{WRAPPER}}.ablocks-block--container-has-link-overlay > *:not(.ablocks-block-container__link-overlay):not(.ablocks-background--video):not(.ablocks-background-video-wrapper)', | |
| 136 | + $this->get_link_overlay_content_css( $attributes ) | |
| 137 | + ); | |
| 138 | + | |
| 113 | 139 | // Block Container only available root block |
| 114 | 140 | $css_generator->add_class_styles( |
| 115 | 141 | $attributes['isRootContainer'] ? '{{WRAPPER}} > .ablocks-block-container' : '{{WRAPPER}}', |
| 116 | 142 | $this->get_block_container_css( $attributes ), |
| @@ -393,8 +419,47 @@ | ||
| 393 | 419 | Dimensions::get_css( $attributes['_padding'], 'padding', $device ), |
| 394 | 420 | $css |
| 395 | 421 | ); |
| 396 | 422 | } |
| 423 | + | |
| 424 | + // The container's link (HTML Tag = a) is rendered as an overlay <a>, not as | |
| 425 | + // the wrapping tag, so nested blocks can never end up with an <a> nested | |
| 426 | + // inside another <a>. These three methods position that overlay and lift | |
| 427 | + // the container's real content above it so nested interactive elements | |
| 428 | + // (e.g. an InfoBox button) stay independently clickable. | |
| 429 | + public function get_link_overlay_wrapper_css( $attributes, $device = '' ) { | |
| 430 | + if ( empty( $attributes['htmlTag'] ) || 'a' !== $attributes['htmlTag'] ) { | |
| 431 | + return []; | |
| 432 | + } | |
| 433 | + return [ 'position' => 'relative' ]; | |
| 434 | + } | |
| 435 | + | |
| 436 | + public function get_link_overlay_css( $attributes, $device = '' ) { | |
| 437 | + if ( empty( $attributes['htmlTag'] ) || 'a' !== $attributes['htmlTag'] ) { | |
| 438 | + return []; | |
| 439 | + } | |
| 440 | + return [ | |
| 441 | + 'position' => 'absolute', | |
| 442 | + 'top' => '0', | |
| 443 | + 'left' => '0', | |
| 444 | + 'right' => '0', | |
| 445 | + 'bottom' => '0', | |
| 446 | + 'width' => '100%', | |
| 447 | + 'height' => '100%', | |
| 448 | + 'z-index' => '0', | |
| 449 | + ]; | |
| 450 | + } | |
| 451 | + | |
| 452 | + public function get_link_overlay_content_css( $attributes, $device = '' ) { | |
| 453 | + if ( empty( $attributes['htmlTag'] ) || 'a' !== $attributes['htmlTag'] ) { | |
| 454 | + return []; | |
| 455 | + } | |
| 456 | + return [ | |
| 457 | + 'position' => 'relative', | |
| 458 | + 'z-index' => '1', | |
| 459 | + ]; | |
| 460 | + } | |
| 461 | + | |
| 397 | 462 | public static function get_container_before_css( $attributes, $device = '' ) { |
| 398 | 463 | if ( ! isset( $attributes['_backgroundOverlay']['backgroundOverlayType'] ) || $attributes['_backgroundOverlay']['backgroundOverlayType'] === 'none' ) { |
| 399 | 464 | return []; |
| 400 | 465 | } |