{{/* Hugo Blox: CTA Card */}} {{/* Documentation: https://hugoblox.com/blocks/ */}} {{/* License: https://github.com/HugoBlox/kit/blob/main/LICENSE.md */}} {{/* Initialise */}} {{ $page := .wcPage }} {{ $block := .wcBlock }} {{ $content := $block.content }} {{ if not (reflect.IsMap $content) }}{{ $content = dict }}{{ end }} {{ $design := $block.design }} {{ if not (reflect.IsMap $design) }}{{ $design = dict }}{{ end }} {{ $card := index $design "card" }} {{ if not (reflect.IsMap $card) }}{{ $card = dict }}{{ end }} {{ $title := "" }} {{ with index $content "title" }}{{ $title = printf "%v" . | emojify | $page.RenderString }}{{ end }} {{ $text := "" }} {{ with index $content "text" }}{{ $text = printf "%v" . | emojify | $page.RenderString | safeHTML }}{{ end }} {{ $card_class := "" }} {{ $card_class_raw := index $card "css_class" }} {{ if eq (printf "%T" $card_class_raw) "string" }} {{ $card_class = $card_class_raw }} {{ end }} {{ $card_style := "" }} {{ $card_style_raw := index $card "css_style" }} {{ if eq (printf "%T" $card_style_raw) "string" }} {{ $card_style = $card_style_raw }} {{ end }} {{/* Contrast and accessibility controls */}} {{ $text_color_mode := "auto" }} {{ $text_color_raw := index $card "text_color" }} {{ if eq (printf "%T" $text_color_raw) "string" }} {{ $text_color_candidate := lower (strings.TrimSpace $text_color_raw) }} {{ if in (slice "auto" "light" "dark") $text_color_candidate }} {{ $text_color_mode = $text_color_candidate }} {{ end }} {{ end }} {{ $overlay_opacity := 0.15 }} {{ $overlay_raw := index $card "overlay_opacity" }} {{ if ne $overlay_raw nil }} {{ $overlay_type := printf "%T" $overlay_raw }} {{ if or (eq $overlay_type "int") (eq $overlay_type "int8") (eq $overlay_type "int16") (eq $overlay_type "int32") (eq $overlay_type "int64") (eq $overlay_type "uint") (eq $overlay_type "uint8") (eq $overlay_type "uint16") (eq $overlay_type "uint32") (eq $overlay_type "uint64") (eq $overlay_type "float32") (eq $overlay_type "float64") }} {{ $overlay_opacity = float $overlay_raw }} {{ else if eq $overlay_type "string" }} {{ $overlay_trimmed := strings.TrimSpace $overlay_raw }} {{ if gt (len (findRE "^-?[0-9]*\\.?[0-9]+$" $overlay_trimmed)) 0 }} {{ $overlay_opacity = float $overlay_trimmed }} {{ end }} {{ end }} {{ end }} {{ if lt $overlay_opacity 0 }}{{ $overlay_opacity = 0 }}{{ end }} {{ if gt $overlay_opacity 1 }}{{ $overlay_opacity = 1 }}{{ end }} {{/* Auto-detect text color based on background */}} {{ $text_classes := "" }} {{ $button_classes := "" }} {{ if eq $text_color_mode "light" }} {{ $text_classes = "text-white" }} {{ $button_classes = "text-gray-900 dark:text-white" }} {{ else if eq $text_color_mode "dark" }} {{ $text_classes = "text-gray-900 dark:text-white" }} {{ $button_classes = "text-gray-900 dark:text-white" }} {{ else }} {{/* Auto mode - detect based on gradient colors */}} {{ $is_dark_bg := false }} {{ $gradient_start := "" }} {{ $bg := index $design "background" }} {{ if and $bg (reflect.IsMap $bg) }} {{ $gradient := index $bg "gradient" }} {{ if and $gradient (reflect.IsMap $gradient) }} {{ $start_raw := index $gradient "start" }} {{ if eq (printf "%T" $start_raw) "string" }} {{ $gradient_start = $start_raw }} {{ end }} {{ end }} {{ end }} {{ if $gradient_start }} {{ if or (hasPrefix $gradient_start "primary-7") (hasPrefix $gradient_start "primary-8") (hasPrefix $gradient_start "primary-9") (hasPrefix $gradient_start "secondary-7") (hasPrefix $gradient_start "secondary-8") (hasPrefix $gradient_start "secondary-9") }} {{ $is_dark_bg = true }} {{ end }} {{ end }} {{ if $is_dark_bg }} {{ $text_classes = "text-white" }} {{ $button_classes = "text-gray-900" }} {{ else }} {{ $text_classes = "text-gray-900 dark:text-white" }} {{ $button_classes = "text-gray-900 dark:text-gray-100" }} {{ end }} {{ end }} {{/* Modern 2025 CTA Card - Background controlled via design.background in front matter */}} {{ $custom_style := printf "--glassmorphism-opacity: %s;" (string $overlay_opacity) }} {{ if $card_style }} {{ $custom_style = printf "%s%s" $custom_style $card_style }} {{ end }}