diff --git a/glance-system/glance-helper.yaml b/glance-system/glance-helper.yaml index ac56147..998c28d 100644 --- a/glance-system/glance-helper.yaml +++ b/glance-system/glance-helper.yaml @@ -55,37 +55,39 @@ data: span = g_max - g_min if span <= 0: span = 1.0 - # 2. Calculate percentages for key colors relative to this week's range - # -10 (White), 0 (Blue), 15 (Purple), 25 (Pink), 35 (Red) + # 2. Helper to get percentage def get_pct(t): return (t - g_min) / span * 100.0 + # 3. Calculate stops (floats) s_wht = get_pct(-10) s_blu = get_pct(0) s_pur = get_pct(15) s_pnk = get_pct(25) s_red = get_pct(35) - # 3. Generate CSS Variables for each row + # 4. Inject individual floats into the dictionary for d in daily_items: tmin, tmax = d["tmin_c"], d["tmax_c"] if tmin is None or tmax is None: continue - # Bar Geometry w_pct = (tmax - tmin) / span * 100.0 if w_pct < 2: w_pct = 2 l_pct = (tmin - g_min) / span * 100.0 - # Gradient Compensation (Zoom & Shift) inner_w = (100.0 / w_pct) * 100.0 inner_ml = -(l_pct / w_pct) * 100.0 - # We pass ONLY variables to avoid HTML sanitization issues - d["css_vars"] = ( - f"--l: {l_pct:.1f}%; --w: {w_pct:.1f}%; " - f"--gw: {inner_w:.1f}%; --ml: {inner_ml:.1f}%; " - f"--s-wht: {s_wht:.1f}%; --s-blu: {s_blu:.1f}%; " - f"--s-pur: {s_pur:.1f}%; --s-pnk: {s_pnk:.1f}%; --s-red: {s_red:.1f}%;" - ) + # STORE AS FLOATS (No "%" symbol here) + d["c_l"] = l_pct + d["c_w"] = w_pct + d["c_gw"] = inner_w + d["c_ml"] = inner_ml + + d["c_s1"] = s_wht # White + d["c_s2"] = s_blu # Blue + d["c_s3"] = s_pur # Purple + d["c_s4"] = s_pnk # Pink + d["c_s5"] = s_red # Red return daily_items diff --git a/glance-system/glance-kisfenyo.yaml b/glance-system/glance-kisfenyo.yaml index 0b95f49..11bc3f3 100644 --- a/glance-system/glance-kisfenyo.yaml +++ b/glance-system/glance-kisfenyo.yaml @@ -737,8 +737,19 @@ data: