UI Revamped v5

Landing page section migration and ui improvements.
This commit is contained in:
2026-03-07 20:57:59 -04:00
parent 2eb0d79394
commit 8700b35f3f
7 changed files with 153 additions and 105 deletions

View File

@@ -157,10 +157,30 @@ module CommunityLanding
html << "<div class=\"cl-hero__actions\">\n"
html << "<a href=\"#{primary_url}\" class=\"cl-btn cl-btn--primary cl-btn--lg\">#{e(primary_label)}</a>\n"
html << "<a href=\"#{secondary_url}\" class=\"cl-btn cl-btn--ghost cl-btn--lg\">#{e(secondary_label)}</a>\n"
html << "</div>\n</div>\n"
html << "</div>\n"
# Hero creators (top 3)
contributors = @data[:contributors]
if (@s.contributors_enabled rescue false) && contributors&.any?
top3 = contributors.first(3)
html << "<div class=\"cl-hero__creators\">\n"
top3.each do |user|
avatar_url = user.avatar_template.gsub("{size}", "120")
activity_count = user.attributes["post_count"].to_i rescue 0
html << "<a href=\"#{login_url}\" class=\"cl-creator-pill\">\n"
html << "<img src=\"#{avatar_url}\" alt=\"#{e(user.username)}\" class=\"cl-creator-pill__avatar\" loading=\"lazy\">\n"
html << "<span class=\"cl-creator-pill__name\">@#{e(user.username)}</span>\n"
html << "<span class=\"cl-creator-pill__count\">#{activity_count}</span>\n"
html << "</a>\n"
end
html << "</div>\n"
end
html << "</div>\n"
hero_image_urls_raw = @s.hero_image_urls.presence
hero_video = @s.hero_video_url.presence rescue nil
blur_attr = (@s.hero_video_blur_on_hover rescue true) ? " data-blur-hover=\"true\"" : ""
has_images = false
if hero_image_urls_raw
@@ -171,7 +191,7 @@ module CommunityLanding
html << "<div class=\"cl-hero__image\" data-hero-images=\"#{e(urls.to_json)}\">\n"
html << "<img src=\"#{urls.first}\" alt=\"#{e(site_name)}\" class=\"cl-hero__image-img\" style=\"max-height: #{img_max_h}px;\">\n"
if hero_video
html << "<button class=\"cl-hero-play\" data-video-url=\"#{e(hero_video)}\" aria-label=\"Play video\">"
html << "<button class=\"cl-hero-play\" data-video-url=\"#{e(hero_video)}\"#{blur_attr} aria-label=\"Play video\">"
html << "<span class=\"cl-hero-play__icon\">#{Icons::PLAY_SVG}</span>"
html << "</button>\n"
end
@@ -181,7 +201,7 @@ module CommunityLanding
if hero_video && !has_images
html << "<div class=\"cl-hero__image cl-hero__image--video-only\">\n"
html << "<button class=\"cl-hero-play\" data-video-url=\"#{e(hero_video)}\" aria-label=\"Play video\">"
html << "<button class=\"cl-hero-play\" data-video-url=\"#{e(hero_video)}\"#{blur_attr} aria-label=\"Play video\">"
html << "<span class=\"cl-hero-play__icon\">#{Icons::PLAY_SVG}</span>"
html << "</button>\n"
html << "</div>\n"
@@ -199,16 +219,17 @@ module CommunityLanding
border = @s.stats_border_style rescue "none"
min_h = @s.stats_min_height rescue 0
icon_shape = @s.stat_icon_shape rescue "circle"
round_nums = @s.stat_round_numbers rescue false
html = +""
html << "<section class=\"cl-stats cl-anim\" id=\"cl-stats-row\"#{section_style(border, min_h)}><div class=\"cl-container\">\n"
html << "<h2 class=\"cl-section-title\">#{e(stats_title)}</h2>\n"
html << "<div class=\"cl-stats__grid\">\n"
html << stat_card(Icons::STAT_MEMBERS_SVG, stats[:members], @s.stat_members_label, icon_shape)
html << stat_card(Icons::STAT_TOPICS_SVG, stats[:topics], @s.stat_topics_label, icon_shape)
html << stat_card(Icons::STAT_POSTS_SVG, stats[:posts], @s.stat_posts_label, icon_shape)
html << stat_card(Icons::STAT_LIKES_SVG, stats[:likes], @s.stat_likes_label, icon_shape)
html << stat_card(Icons::STAT_CHATS_SVG, stats[:chats], @s.stat_chats_label, icon_shape)
html << stat_card(Icons::STAT_MEMBERS_SVG, stats[:members], @s.stat_members_label, icon_shape, round_nums)
html << stat_card(Icons::STAT_TOPICS_SVG, stats[:topics], @s.stat_topics_label, icon_shape, round_nums)
html << stat_card(Icons::STAT_POSTS_SVG, stats[:posts], @s.stat_posts_label, icon_shape, round_nums)
html << stat_card(Icons::STAT_LIKES_SVG, stats[:likes], @s.stat_likes_label, icon_shape, round_nums)
html << stat_card(Icons::STAT_CHATS_SVG, stats[:chats], @s.stat_chats_label, icon_shape, round_nums)
html << "</div>\n</div></section>\n"
html
end
@@ -339,8 +360,7 @@ module CommunityLanding
light = 45 + (group.name.bytes.last.to_i % 12)
icon_color = "hsl(#{hue}, #{sat}%, #{light}%)"
html << "<a href=\"#{login_url}\" class=\"cl-space-card\">\n"
html << "<div class=\"cl-space-card__header\" style=\"--space-color: #{icon_color}\">\n"
html << "<a href=\"#{login_url}\" class=\"cl-space-card\" style=\"--space-color: #{icon_color}\">\n"
html << "<div class=\"cl-space-card__icon\">"
if group.flair_url.present?
html << "<img src=\"#{group.flair_url}\" alt=\"\">"
@@ -348,7 +368,6 @@ module CommunityLanding
html << "<span class=\"cl-space-card__letter\">#{group.name[0].upcase}</span>"
end
html << "</div>\n"
html << "</div>\n"
html << "<div class=\"cl-space-card__body\">\n"
html << "<span class=\"cl-space-card__name\">#{e(display_name)}</span>\n"
html << "<span class=\"cl-space-card__sub\">#{group.user_count} members</span>\n"
@@ -447,12 +466,15 @@ module CommunityLanding
# ── Shared helpers ──
def stat_card(icon_svg, count, label, icon_shape = "circle")
def stat_card(icon_svg, count, label, icon_shape = "circle", round_numbers = false)
shape_class = icon_shape == "rounded" ? "cl-stat-icon--rounded" : "cl-stat-icon--circle"
round_attr = round_numbers ? ' data-round="true"' : ''
"<div class=\"cl-stat-card\">\n" \
"<div class=\"cl-stat-card__icon-wrap #{shape_class}\">#{icon_svg}</div>\n" \
"<div class=\"cl-stat-card__text\">\n" \
"<span class=\"cl-stat-card__value\" data-count=\"#{count}\"#{round_attr}>0</span>\n" \
"<span class=\"cl-stat-card__label\">#{e(label)}</span>\n" \
"<span class=\"cl-stat-card__value\" data-count=\"#{count}\">0</span>\n" \
"</div>\n" \
"</div>\n"
end

View File

@@ -26,6 +26,7 @@ module CommunityLanding
stat_counter = hex(@s.stat_counter_color.presence) rescue nil
space_card_bg = hex(@s.groups_card_bg_color.presence) rescue nil
topic_card_bg = hex(@s.topics_card_bg_color.presence) rescue nil
video_btn_bg = hex(@s.hero_video_button_color.presence) rescue nil
accent_rgb = hex_to_rgb(accent)
stat_icon_rgb = hex_to_rgb(stat_icon)
@@ -35,6 +36,7 @@ module CommunityLanding
topic_card_bg_val = topic_card_bg || "var(--cl-card)"
about_bg_extra = about_bg_img ? ", url('#{about_bg_img}') center/cover no-repeat" : ""
video_btn_line = video_btn_bg ? "\n --cl-video-btn-bg: #{video_btn_bg};" : ""
"<style>
:root, [data-theme=\"dark\"] {
@@ -51,7 +53,7 @@ module CommunityLanding
--cl-stat-icon-bg: #{stat_icon_bg_val};
--cl-stat-counter-color: #{stat_counter_val};
--cl-space-card-bg: #{space_card_bg_val};
--cl-topic-card-bg: #{topic_card_bg_val};
--cl-topic-card-bg: #{topic_card_bg_val};#{video_btn_line}
--cl-about-gradient: linear-gradient(135deg, #{about_g1}, #{about_g2}, #{about_g3})#{about_bg_extra};
--cl-app-gradient: linear-gradient(135deg, #{app_g1}, #{app_g2}, #{app_g3});
}
@@ -69,7 +71,7 @@ module CommunityLanding
--cl-stat-icon-bg: #{stat_icon_bg_val};
--cl-stat-counter-color: #{stat_counter_val};
--cl-space-card-bg: #{space_card_bg_val};
--cl-topic-card-bg: #{topic_card_bg_val};
--cl-topic-card-bg: #{topic_card_bg_val};#{video_btn_line}
--cl-about-gradient: linear-gradient(135deg, #{about_g1}, #{about_g2}, #{about_g3})#{about_bg_extra};
--cl-app-gradient: linear-gradient(135deg, #{app_g1}, #{app_g2}, #{app_g3});
}