mirror of
https://github.com/dpnmw/community-landing.git
synced 2026-03-18 09:27:16 +00:00
UI Revamped v5
Landing page section migration and ui improvements.
This commit is contained in:
@@ -118,11 +118,19 @@
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// 6. STAT COUNTER
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
function formatRounded(n) {
|
||||
if (n < 1000) return n.toLocaleString();
|
||||
if (n < 10000) return (n / 1000).toFixed(1).replace(/\.0$/, "") + "K";
|
||||
if (n < 1000000) return Math.round(n / 1000) + "K";
|
||||
return (n / 1000000).toFixed(1).replace(/\.0$/, "") + "M";
|
||||
}
|
||||
|
||||
function animateCount(el) {
|
||||
if (el.classList.contains("counted")) return;
|
||||
el.classList.add("counted");
|
||||
var target = parseInt(el.getAttribute("data-count"), 10);
|
||||
if (isNaN(target) || target === 0) return;
|
||||
var round = el.getAttribute("data-round") === "true";
|
||||
|
||||
var duration = 2000;
|
||||
var start = null;
|
||||
@@ -131,9 +139,10 @@
|
||||
function step(ts) {
|
||||
if (!start) start = ts;
|
||||
var p = Math.min((ts - start) / duration, 1);
|
||||
el.textContent = Math.floor(target * ease(p)).toLocaleString();
|
||||
var current = Math.floor(target * ease(p));
|
||||
el.textContent = round ? formatRounded(current) : current.toLocaleString();
|
||||
if (p < 1) requestAnimationFrame(step);
|
||||
else el.textContent = target.toLocaleString();
|
||||
else el.textContent = round ? formatRounded(target) : target.toLocaleString();
|
||||
}
|
||||
requestAnimationFrame(step);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ const TABS = [
|
||||
"hero_image_urls", "hero_image_max_height",
|
||||
"hero_primary_button_label", "hero_primary_button_url",
|
||||
"hero_secondary_button_label", "hero_secondary_button_url",
|
||||
"hero_video_url",
|
||||
"hero_video_url", "hero_video_button_color", "hero_video_blur_on_hover",
|
||||
"hero_bg_dark", "hero_bg_light", "hero_min_height", "hero_border_style"
|
||||
])
|
||||
},
|
||||
@@ -37,7 +37,7 @@ const TABS = [
|
||||
settings: new Set([
|
||||
"stats_title", "stat_icon_color", "stat_icon_bg_color", "stat_icon_shape", "stat_counter_color",
|
||||
"stat_members_label", "stat_topics_label", "stat_posts_label",
|
||||
"stat_likes_label", "stat_chats_label",
|
||||
"stat_likes_label", "stat_chats_label", "stat_round_numbers",
|
||||
"stats_bg_dark", "stats_bg_light", "stats_min_height", "stats_border_style"
|
||||
])
|
||||
},
|
||||
@@ -184,7 +184,8 @@ function buildTabsUI() {
|
||||
if (!container) return false;
|
||||
|
||||
// Already injected — just re-apply filter
|
||||
if (container.querySelector(".cl-admin-tab")) {
|
||||
// Search broadly: native tabs may be a sibling of container, not a child
|
||||
if (document.querySelector(".cl-admin-tab")) {
|
||||
applyTabFilter();
|
||||
return true;
|
||||
}
|
||||
@@ -199,7 +200,10 @@ function buildTabsUI() {
|
||||
if (!hasOurs) return false;
|
||||
|
||||
// ── Strategy 1: Inject into native Discourse tab bar ──
|
||||
const nativeTabsEl = container.querySelector(".admin-plugin-config-area__tabs");
|
||||
// Native tabs may be a sibling of our container, so search at page level
|
||||
const page = container.closest(".admin-plugin-config-page") || container.parentElement;
|
||||
const nativeTabsEl = (page && page.querySelector(".admin-plugin-config-area__tabs")) ||
|
||||
document.querySelector(".admin-plugin-config-area__tabs");
|
||||
if (nativeTabsEl) {
|
||||
// Find the native "Settings" link and hook into it
|
||||
const nativeLink = nativeTabsEl.querySelector("a");
|
||||
@@ -326,7 +330,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
const c = getContainer();
|
||||
if (c && !c.querySelector(".cl-admin-tab")) {
|
||||
if (c && !document.querySelector(".cl-admin-tab")) {
|
||||
buildTabsUI();
|
||||
}
|
||||
}, 500);
|
||||
|
||||
Reference in New Issue
Block a user