{{/* 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 }}
{{/* Modern Typography Hierarchy - Responsive text colors */}} {{ with $title }}

{{ . }}

{{ end }} {{/* Enhanced Text with Better Spacing - Responsive colors */}} {{ with $text }}
{{ . }}
{{ end }} {{ $button_raw := index $content "button" }} {{ if and $button_raw (reflect.IsMap $button_raw) }} {{ $button_text := "" }} {{ $button_url := "" }} {{ $button_icon := "" }} {{ $button_new_tab := partial "functions/coerce_bool" (dict "value" (index $button_raw "new_tab") "default" false) }} {{ with index $button_raw "text" }}{{ $button_text = printf "%v" . }}{{ end }} {{ with index $button_raw "url" }}{{ $button_url = printf "%v" . }}{{ end }} {{ with index $button_raw "icon" }} {{ if eq (printf "%T" .) "string" }} {{ $button_icon = . }} {{ end }} {{ end }} {{ $button_text = strings.TrimSpace $button_text }} {{ $button_url = strings.TrimSpace $button_url }} {{ if and $button_text $button_url }} {{/* Modern 2025 Button Container */}}
{{ $button_link := $button_url }} {{ $button_scheme := (urls.Parse $button_link).Scheme }} {{ $button_target := "" }} {{ if not $button_scheme }} {{/* Check if it's a hash fragment (page anchor) */}} {{ if not (hasPrefix $button_link "#") }} {{/* Apply relLangURL for relative paths */}} {{ $button_link = $button_link | relLangURL }} {{ end }} {{ if eq (path.Ext $button_link) ".pdf" }} {{ $button_new_tab = true }} {{ end }} {{ else if in (slice "http" "https") $button_scheme }} {{ $button_new_tab = true }} {{ end }} {{/* Apply new tab if requested or external link */}} {{ if $button_new_tab }} {{ $button_target = "target=\"_blank\" rel=\"noopener\"" }} {{ end }} {{/* 2025 Glassmorphism Button */}} {{/* Button Background with Glassmorphism */}}
{{/* Button Content */}} {{ $button_text }} {{ if $button_icon }} {{ partial "functions/get_icon" (dict "name" $button_icon "attributes" "style=\"height: 1.25em\" class='inline-block'") }} {{ end }} {{/* Subtle glow effect */}}
{{ end }} {{ end }}