false, 'selector' => $selector, 'declaration' => $declaration, ]; }; // Flex layout for non-video, non-top placement. if ('video' !== $main_figure) { if ('top' !== $figure_placement) { $push($order_class . ' .dtq-info-box', 'display: flex;'); $push($order_class . ' .dtq-info-box-content', 'flex: 1 1;'); } if ('right' === $figure_placement) { $push($order_class . ' .dtq-info-box', 'flex-direction: row-reverse;'); } } // Media image sizing. if ('image' === $main_figure) { $push($order_class . ' .dtq-info-box .dtq-info-box-figure', sprintf('width: %1$s !important;', $image_width)); $push($order_class . ' .dtq-info-box .dtq-info-box-figure', sprintf('flex: 0 0 %1$s !important;', $image_width)); if ('off' === $equalize_content) { if ('top' !== $figure_placement && 'auto' !== $image_height) { $push($order_class . ' .dtq-info-box .dtq-info-box-figure', sprintf('height: %1$s !important;', $image_height)); $push($order_class . ' .dtq-info-box .dtq-info-box-figure img', 'height: 100%; object-fit: cover;width:100%;'); $push($order_class . ' .dtq-info-box', sprintf('align-items: %1$s !important;', $align_items)); } } else { $push($order_class . ' .dtq-info-box .dtq-info-box-figure img', 'height: 100%; object-fit: cover;width:100%;'); } } // Button spacing. $push($order_class . ' .dtq-info-box-btn', sprintf('padding-top: %1$s;', $btn_spacing_top)); // Title spacing. $push($order_class . ' .dtq-info-box-title', sprintf('padding-bottom: %1$s !important;', $title_spacing)); // Content alignment. $push($order_class, sprintf('text-align: %1$s;', $content_alignment)); // Content padding. if ('' !== $content_padding_css) { $push($order_class . ' .dtq-info-box-content', $content_padding_css); } // Icon. if ('icon' === $main_figure) { if ('on' === $use_icon_box) { $push($order_class . ' .dtq-info-box-icon', sprintf('background: %1$s;', $icon_bg)); $push($order_class . ' .dtq-info-box-icon', sprintf('height: %1$s;', $icon_height)); $push($order_class . ' .dtq-info-box-icon', sprintf('width: %1$s;', $icon_width)); } // Icon padding. if ('' !== $icon_padding_css) { $push($order_class . ' .dtq-info-box-icon', $icon_padding_css); } } $push($order_class . ' .dtq-info-box-icon i', sprintf('color: %1$s;', $icon_color)); $push($order_class . ' .dtq-info-box-icon i', sprintf('font-size: %1$s;', $icon_size)); // Image hover overlay (designOverlay group). Mirrors the Image Card // module; keep in lockstep with the JS twin in styles.jsx. if (($advanced['useOverlay']['desktop']['value'] ?? 'off') === 'on') { $overlay_color = dtq_css_color(dtq_resolve_css_value($val('overlayColor', '#2EA3F2')), '#2EA3F2'); $overlay_icon_col = dtq_css_color(dtq_resolve_css_value($val('overlayIconColor', '#2EA3F2')), '#2EA3F2'); $overlay_icon_sz = dtq_css_length($val('overlayIconSize', '32px'), '32px'); $overlay_icon_op = dtq_css_length($val('overlayIconOpacity', '1'), '1'); $overlay_speed = dtq_css_length($val('overlayHoverSpeed', '500ms'), '500ms'); $push( $order_class . ' .dtq-overlay', sprintf('background-color: %1$s; transition: all %2$s;', $overlay_color, $overlay_speed) ); $push( $order_class . ' .dtq-overlay .dtq-overlay-icon', sprintf('color: %1$s; font-size: %2$s; opacity: %3$s;', $overlay_icon_col, $overlay_icon_sz, $overlay_icon_op) ); // "Show overlay only on hover" off => keep it permanently visible. if (($advanced['overlayOnHover']['desktop']['value'] ?? 'on') !== 'on') { $push($order_class . ' .dtq-info-box-figure .dtq-overlay', 'opacity: 1;'); } } // Video overlay. if (!empty($vo_icon_color)) { $push($order_class . ' .et_pb_video_overlay .et_pb_video_play', sprintf('color: %1$s;', $vo_icon_color)); } if (!empty($vo_icon_size)) { $push($order_class . ' .et_pb_video_overlay .et_pb_video_play', sprintf('font-size: %1$s;', $vo_icon_size)); } if (!empty($vo_bg)) { $push($order_class . ' .et_pb_video_overlay_hover:hover', sprintf('background: %1$s;', $vo_bg)); } // --- Additive responsive (tablet/phone) output. --------------------- // Mirrors the desktop declarations above for the responsive fields, // wrapped in @media at-rules. Each breakpoint entry is only emitted // when its saved value exists and differs from the next-larger // breakpoint, so the desktop output above is never altered. $media = [ 'tablet' => '@media only screen and (max-width: 980px)', 'phone' => '@media only screen and (max-width: 767px)', ]; // Return the value for a breakpoint only when it exists AND differs // from the next-larger breakpoint; otherwise null (skip the entry). $bp_value = function ($key, $breakpoint) use ($advanced) { $current = $advanced[$key][$breakpoint]['value'] ?? null; if (null === $current || '' === $current) { return null; } $larger = ('phone' === $breakpoint) ? ($advanced[$key]['tablet']['value'] ?? $advanced[$key]['desktop']['value'] ?? null) : ($advanced[$key]['desktop']['value'] ?? null); if ($current === $larger) { return null; } return $current; }; $push_media = function ($at_rule, $selector, $declaration) use (&$styles) { $styles[] = [ 'atRules' => $at_rule, 'selector' => $selector, 'declaration' => $declaration, ]; }; foreach ($media as $breakpoint => $at_rule) { // Image width / flex. if ('image' === $main_figure) { $r_image_width = $bp_value('imageWidth', $breakpoint); if (null !== $r_image_width) { $push_media($at_rule, $order_class . ' .dtq-info-box .dtq-info-box-figure', sprintf('width: %1$s !important;', $r_image_width)); $push_media($at_rule, $order_class . ' .dtq-info-box .dtq-info-box-figure', sprintf('flex: 0 0 %1$s !important;', $r_image_width)); } // Image height (only in the same branch desktop emits it). if ('off' === $equalize_content && 'top' !== $figure_placement) { $r_image_height = $bp_value('imageHeight', $breakpoint); if (null !== $r_image_height && 'auto' !== $r_image_height) { $push_media($at_rule, $order_class . ' .dtq-info-box .dtq-info-box-figure', sprintf('height: %1$s !important;', $r_image_height)); } } } // Button spacing. $r_btn_spacing_top = $bp_value('btnSpacingTop', $breakpoint); if (null !== $r_btn_spacing_top) { $push_media($at_rule, $order_class . ' .dtq-info-box-btn', sprintf('padding-top: %1$s;', $r_btn_spacing_top)); } // Title spacing. $r_title_spacing = $bp_value('titleBottomSpacing', $breakpoint); if (null !== $r_title_spacing) { $push_media($at_rule, $order_class . ' .dtq-info-box-title', sprintf('padding-bottom: %1$s !important;', $r_title_spacing)); } // Content alignment. $r_content_alignment = $bp_value('contentAlignment', $breakpoint); if (null !== $r_content_alignment) { $push_media($at_rule, $order_class, sprintf('text-align: %1$s;', $r_content_alignment)); } // Icon box height / width. if ('icon' === $main_figure && 'on' === $use_icon_box) { $r_icon_height = $bp_value('iconHeight', $breakpoint); if (null !== $r_icon_height) { $push_media($at_rule, $order_class . ' .dtq-info-box-icon', sprintf('height: %1$s;', $r_icon_height)); } $r_icon_width = $bp_value('iconWidth', $breakpoint); if (null !== $r_icon_width) { $push_media($at_rule, $order_class . ' .dtq-info-box-icon', sprintf('width: %1$s;', $r_icon_width)); } } // Icon size. $r_icon_size = $bp_value('iconSize', $breakpoint); if (null !== $r_icon_size) { $push_media($at_rule, $order_class . ' .dtq-info-box-icon i', sprintf('font-size: %1$s;', $r_icon_size)); } // Video overlay icon size. $r_vo_icon_size = $bp_value('voIconSize', $breakpoint); if (null !== $r_vo_icon_size) { $push_media($at_rule, $order_class . ' .et_pb_video_overlay .et_pb_video_play', sprintf('font-size: %1$s;', $r_vo_icon_size)); } } return $styles; } /** * Generate the module styles. * * @param array $args Style args. * @return void */ public static function module_styles($args) { $attrs = $args['attrs'] ?? []; $elements = $args['elements']; $settings = $args['settings'] ?? []; $order_class = $args['orderClass'] ?? ''; $advanced = $attrs['module']['advanced'] ?? []; $custom_styles = self::build_custom_styles($advanced, $order_class); $all_styles = [ // Module wrapper styles (background, spacing, border, etc.). $elements->style( [ 'attrName' => 'module', 'styleProps' => [ 'disabledOn' => [ 'disabledModuleVisibility' => $settings['disabledModuleVisibility'] ?? null, ], ], ] ), // Title font / heading styles. $elements->style(['attrName' => 'title']), // Body content font styles. $elements->style(['attrName' => 'content']), // Button decoration styles. $elements->style(['attrName' => 'button']), ]; if (!empty($custom_styles)) { $all_styles[] = $custom_styles; } // Custom CSS (Advanced tab). $all_styles[] = CssStyle::style( [ 'selector' => $order_class, 'attr' => $attrs['css'] ?? [], 'cssFields' => self::custom_css_fields(), ] ); Style::add( [ 'id' => $args['id'], 'name' => $args['name'], 'orderIndex' => $args['orderIndex'], 'storeInstance' => $args['storeInstance'], 'styles' => $all_styles, ] ); } }