Minor tweaks and bug fixes.

This commit is contained in:
2026-03-08 01:58:59 -04:00
parent c5d8630ca9
commit 66c505e313
8 changed files with 199 additions and 50 deletions

View File

@@ -131,9 +131,11 @@ module CommunityLanding
def render_hero
hero_card = @s.hero_card_enabled rescue true
hero_img_first = @s.hero_image_first rescue false
hero_bg_img = @s.hero_background_image_url.presence
hero_border = @s.hero_border_style rescue "none"
hero_min_h = @s.hero_min_height rescue 0
content_w = @s.hero_content_width rescue 50
site_name = @s.title
html = +""
@@ -142,14 +144,29 @@ module CommunityLanding
hero_style_parts << "background-image: url('#{hero_bg_img}');" if hero_bg_img
hero_style_parts << "border-bottom: 1px #{hero_border} var(--cl-border);" if hero_border.present? && hero_border != "none"
hero_style_parts << "min-height: #{hero_min_h}px;" if hero_min_h.to_i > 0
hero_style_parts << "--cl-hero-content-w: #{content_w.to_i}%;" if content_w.to_i != 50
hero_attr = hero_style_parts.any? ? " style=\"#{hero_style_parts.join(' ')}\"" : ""
html << "<section class=\"cl-hero#{hero_card ? ' cl-hero--card' : ''}\" id=\"cl-hero\"#{hero_attr}>\n"
hero_classes = "cl-hero"
hero_classes << " cl-hero--card" if hero_card
hero_classes << " cl-hero--image-first" if hero_img_first
html << "<section class=\"#{hero_classes}\" id=\"cl-hero\"#{hero_attr}>\n"
html << "<div class=\"cl-hero__inner\">\n<div class=\"cl-hero__content\">\n"
# Accent word: 0 = last word (default), N = Nth word (1-indexed)
title_words = @s.hero_title.to_s.split(" ")
accent_idx = (@s.hero_accent_word rescue 0).to_i
if title_words.length > 1
html << "<h1 class=\"cl-hero__title\">#{e(title_words[0..-2].join(' '))} <span class=\"cl-hero__title-accent\">#{e(title_words.last)}</span></h1>\n"
# Convert to 0-based index; 0 means last word
target = accent_idx > 0 ? [accent_idx - 1, title_words.length - 1].min : title_words.length - 1
before = title_words[0...target]
accent = title_words[target]
after = title_words[(target + 1)..]
parts = +""
parts << "#{e(before.join(' '))} " if before.any?
parts << "<span class=\"cl-hero__title-accent\">#{e(accent)}</span>"
parts << " #{e(after.join(' '))}" if after.any?
html << "<h1 class=\"cl-hero__title\">#{parts}</h1>\n"
else
html << "<h1 class=\"cl-hero__title\"><span class=\"cl-hero__title-accent\">#{e(@s.hero_title)}</span></h1>\n"
end

View File

@@ -15,9 +15,7 @@ module CommunityLanding
dark_bg = hex(@s.dark_bg_color) || "#06060f"
light_bg = hex(@s.light_bg_color) || "#faf6f0"
stat_icon = hex(@s.stat_icon_color) || accent
about_g1 = hex(@s.about_gradient_start) || "#fdf6ec"
about_g2 = hex(@s.about_gradient_mid) || "#fef9f0"
about_g3 = hex(@s.about_gradient_end) || "#fdf6ec"
about_card = hex(@s.about_card_color.presence) rescue nil
about_bg_img = @s.about_background_image_url.presence
app_g1 = hex(@s.app_cta_gradient_start) || accent
app_g2 = hex(@s.app_cta_gradient_mid) || accent_hover
@@ -45,7 +43,8 @@ module CommunityLanding
hero_card_dark_val = "rgba(#{hero_card_dark_rgb}, #{hero_card_opacity})"
hero_card_light_val = "rgba(#{hero_card_light_rgb}, #{hero_card_opacity})"
about_bg_extra = about_bg_img ? ", url('#{about_bg_img}') center/cover no-repeat" : ""
about_card_val = about_card || "var(--cl-card)"
about_card_css = about_bg_img ? "#{about_card_val}, url('#{about_bg_img}') center/cover no-repeat" : about_card_val
video_btn_line = video_btn_bg ? "\n --cl-video-btn-bg: #{video_btn_bg};" : ""
"<style>
@@ -65,7 +64,7 @@ module CommunityLanding
--cl-space-card-bg: #{space_card_bg_val};
--cl-topic-card-bg: #{topic_card_bg_val};#{video_btn_line}
--cl-hero-card-bg: #{hero_card_dark_val};
--cl-about-gradient: linear-gradient(135deg, #{about_g1}, #{about_g2}, #{about_g3})#{about_bg_extra};
--cl-about-card-bg: #{about_card_css};
--cl-app-gradient: linear-gradient(135deg, #{app_g1}, #{app_g2}, #{app_g3});
}
[data-theme=\"light\"] {
@@ -84,7 +83,7 @@ module CommunityLanding
--cl-space-card-bg: #{space_card_bg_val};
--cl-topic-card-bg: #{topic_card_bg_val};#{video_btn_line}
--cl-hero-card-bg: #{hero_card_light_val};
--cl-about-gradient: linear-gradient(135deg, #{about_g1}, #{about_g2}, #{about_g3})#{about_bg_extra};
--cl-about-card-bg: #{about_card_css};
--cl-app-gradient: linear-gradient(135deg, #{app_g1}, #{app_g2}, #{app_g3});
}
@media (prefers-color-scheme: light) {
@@ -99,7 +98,7 @@ module CommunityLanding
--cl-border-hover: rgba(#{accent_rgb}, 0.3);
--cl-orb-1: rgba(#{accent_rgb}, 0.08);
--cl-stat-icon-color: #{stat_icon};
--cl-about-gradient: linear-gradient(135deg, #{about_g1}, #{about_g2}, #{about_g3})#{about_bg_extra};
--cl-about-card-bg: #{about_card_css};
--cl-app-gradient: linear-gradient(135deg, #{app_g1}, #{app_g2}, #{app_g3});
}
}