tried again
This commit is contained in:
@@ -387,12 +387,11 @@ data:
|
|||||||
color_yellow: "#F0F046"
|
color_yellow: "#F0F046"
|
||||||
color_blue: "#46F0F0"
|
color_blue: "#46F0F0"
|
||||||
color_white: "#FFFFFF"
|
color_white: "#FFFFFF"
|
||||||
overlay_color: "rgba(0,0,0,0.35)"
|
|
||||||
template: |
|
template: |
|
||||||
{{/* Weather widget – fully customizable via options */}}
|
{{/* Weather widget – fully customizable via options */}}
|
||||||
{{ $temp_unit := .Options.StringOr "temp_unit" "celsius" }}
|
{{ $temp_unit := .Options.StringOr "temp_unit" "celsius" }}
|
||||||
{{ $weekend_color := .Options.StringOr "weekend_color" "var(--color-separator)" }}
|
{{ $weekend_color := .Options.StringOr "weekend_color" "var(--color-separator)" }}
|
||||||
{{ $overlay_color := .Options.StringOr "overlay_color" "hsl(var(--bghs), var(--bgl), 50%)" }}
|
{{ $overlay_color := .Options.StringOr "overlay_color" "rgba(0,0,0,0.35)" }}
|
||||||
{{ $color_clear := .Options.StringOr "color_clear" "var(--color-text-highlight)" }}
|
{{ $color_clear := .Options.StringOr "color_clear" "var(--color-text-highlight)" }}
|
||||||
{{ $color_partly := .Options.StringOr "color_partly" "var(--color-text-highlight)"}}
|
{{ $color_partly := .Options.StringOr "color_partly" "var(--color-text-highlight)"}}
|
||||||
{{ $color_cloud := .Options.StringOr "color_cloud" "var(--color-text-highlight)"}}
|
{{ $color_cloud := .Options.StringOr "color_cloud" "var(--color-text-highlight)"}}
|
||||||
@@ -534,33 +533,50 @@ data:
|
|||||||
{{ $thisHighPct := sub 1 (div (sub $max_max $thisHigh) $temp_range) }}
|
{{ $thisHighPct := sub 1 (div (sub $max_max $thisHigh) $temp_range) }}
|
||||||
{{ $thisLowPct := div (sub $thisLow $min_min) $temp_range }}
|
{{ $thisLowPct := div (sub $thisLow $min_min) $temp_range }}
|
||||||
{{ $thisTempRange := sub $thisHigh $thisLow }}
|
{{ $thisTempRange := sub $thisHigh $thisLow }}
|
||||||
|
|
||||||
|
{{/* Guard against division-by-zero if highs == lows */}}
|
||||||
|
{{ if eq $thisTempRange 0.0 }}
|
||||||
|
{{ $thisTempRange = 0.0001 }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{ $red_pos := mul 100 (div (sub $thisHigh $temp_red) $thisTempRange) | toInt }}
|
{{ $red_pos := mul 100 (div (sub $thisHigh $temp_red) $thisTempRange) | toInt }}
|
||||||
{{ $yel_pos := mul 100 (div (sub $thisHigh $temp_yellow) $thisTempRange) | toInt }}
|
{{ $yel_pos := mul 100 (div (sub $thisHigh $temp_yellow) $thisTempRange) | toInt }}
|
||||||
{{ $blu_pos := mul 100 (div (sub $thisHigh $temp_blue) $thisTempRange) | toInt }}
|
{{ $blu_pos := mul 100 (div (sub $thisHigh $temp_blue) $thisTempRange) | toInt }}
|
||||||
{{ $whi_pos := mul 100 (div (sub $thisHigh $temp_white) $thisTempRange) | toInt }}
|
{{ $whi_pos := mul 100 (div (sub $thisHigh $temp_white) $thisTempRange) | toInt }}
|
||||||
{{ $gradient_string := printf "%s %d%%, %s %d%%, %s %d%%, %s %d%%" $color_red $red_pos $color_yellow $yel_pos $color_blue $blu_pos $color_white $whi_pos }}
|
|
||||||
{{/* Clamp helper (no clamp() function in Glance templates) */}}
|
{{/* Clamp to 0..100 */}}
|
||||||
{{ $pRed := $red_pos }}{{ if lt $pRed 0 }}{{ $pRed = 0 }}{{ end }}{{ if gt $pRed 100 }}{{ $pRed = 100 }}{{ end }}
|
{{ $pRed := $red_pos }}{{ if lt $pRed 0 }}{{ $pRed = 0 }}{{ end }}{{ if gt $pRed 100 }}{{ $pRed = 100 }}{{ end }}
|
||||||
{{ $pYel := $yel_pos }}{{ if lt $pYel 0 }}{{ $pYel = 0 }}{{ end }}{{ if gt $pYel 100 }}{{ $pYel = 100 }}{{ end }}
|
{{ $pYel := $yel_pos }}{{ if lt $pYel 0 }}{{ $pYel = 0 }}{{ end }}{{ if gt $pYel 100 }}{{ $pYel = 100 }}{{ end }}
|
||||||
{{ $pBlu := $blu_pos }}{{ if lt $pBlu 0 }}{{ $pBlu = 0 }}{{ end }}{{ if gt $pBlu 100 }}{{ $pBlu = 100 }}{{ end }}
|
{{ $pBlu := $blu_pos }}{{ if lt $pBlu 0 }}{{ $pBlu = 0 }}{{ end }}{{ if gt $pBlu 100 }}{{ $pBlu = 100 }}{{ end }}
|
||||||
{{ $pWhi := $whi_pos }}{{ if lt $pWhi 0 }}{{ $pWhi = 0 }}{{ end }}{{ if gt $pWhi 100 }}{{ $pWhi = 100 }}{{ end }}
|
{{ $pWhi := $whi_pos }}{{ if lt $pWhi 0 }}{{ $pWhi = 0 }}{{ end }}{{ if gt $pWhi 100 }}{{ $pWhi = 100 }}{{ end }}
|
||||||
{{/* Make sure stops are non-decreasing (simple ordering guard) */}}
|
{{/* Ensure non-decreasing stops */}}
|
||||||
{{ if lt $pYel $pRed }}{{ $pYel = $pRed }}{{ end }}
|
{{ if lt $pYel $pRed }}{{ $pYel = $pRed }}{{ end }}
|
||||||
{{ if lt $pBlu $pYel }}{{ $pBlu = $pYel }}{{ end }}
|
{{ if lt $pBlu $pYel }}{{ $pBlu = $pYel }}{{ end }}
|
||||||
{{ if lt $pWhi $pBlu }}{{ $pWhi = $pBlu }}{{ end }}
|
{{ if lt $pWhi $pBlu }}{{ $pWhi = $pBlu }}{{ end }}
|
||||||
<div style="left: {{ mul $index 14 | add 3 }}%; bottom: {{ mul $thisLowPct 100 | toInt }}%;
|
<div style="left: {{ mul $index 14 | add 3 }}%; bottom: {{ mul $thisLowPct 100 | toInt }}%;
|
||||||
height: {{ mul (sub $thisHighPct $thisLowPct) 100 | toInt }}%; position: absolute;
|
height: {{ mul (sub $thisHighPct $thisLowPct) 100 | toInt }}%; position: absolute;
|
||||||
width: 10%; text-align: center; border-radius: 10px; overflow: hidden;">
|
width: 10%; text-align: center; border-radius: 10px; overflow: hidden;">
|
||||||
{{/* “Gradient” as 4 stacked color bands */}}
|
{{/* “Gradient” as stacked bands so Glance sanitizer won’t kill it */}}
|
||||||
<div style="position:absolute; inset:0;">
|
<div style="position:absolute; inset:0;">
|
||||||
<div style="position:absolute; top:0; left:0; right:0; height: {{ $pRed }}%; background-color: {{ $color_red }};"></div>
|
<div style="position:absolute; top:0; left:0; right:0; height: {{ $pRed }}%; background-color: {{ $color_red | safeCSS }};"></div>
|
||||||
<div style="position:absolute; top:{{ $pRed }}%; left:0; right:0; height: {{ sub $pYel $pRed }}%; background-color: {{ $color_yellow }};"></div>
|
<div style="position:absolute; top:{{ $pRed }}%; left:0; right:0; height: {{ sub $pYel $pRed }}%; background-color: {{ $color_yellow | safeCSS }};"></div>
|
||||||
<div style="position:absolute; top:{{ $pYel }}%; left:0; right:0; height: {{ sub $pBlu $pYel }}%; background-color: {{ $color_blue }};"></div>
|
<div style="position:absolute; top:{{ $pYel }}%; left:0; right:0; height: {{ sub $pBlu $pYel }}%; background-color: {{ $color_blue | safeCSS }};"></div>
|
||||||
<div style="position:absolute; top:{{ $pBlu }}%; left:0; right:0; height: {{ sub 100 $pBlu }}%; background-color: {{ $color_white }};"></div>
|
<div style="position:absolute; top:{{ $pBlu }}%; left:0; right:0; height: {{ sub 100 $pBlu }}%; background-color: {{ $color_white | safeCSS }};"></div>
|
||||||
</div>
|
</div>
|
||||||
{{/* Overlay for the numbers (keep it transparent-ish) */}}
|
{{ $top_pos := -2 }}
|
||||||
|
{{ $bot_pos := -2 }}
|
||||||
|
{{ $pos_thresh := 0.20 }}
|
||||||
|
{{ if lt (div $thisTempRange $temp_range) $pos_thresh }}
|
||||||
|
{{ $top_pos = -17 }}
|
||||||
|
{{ $bot_pos = -19 }}
|
||||||
|
{{ else if and (lt (div $thisTempRange $temp_range) (mul $pos_thresh 2)) (lt (sub 1 $thisHighPct) $thisLowPct) }}
|
||||||
|
{{ $bot_pos = -19 }}
|
||||||
|
{{ else if and (lt (div $thisTempRange $temp_range) (mul $pos_thresh 2)) (gt (sub 1 $thisHighPct) $thisLowPct) }}
|
||||||
|
{{ $top_pos = -17 }}
|
||||||
|
{{ end }}
|
||||||
|
{{/* Overlay layer for numbers */}}
|
||||||
<div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;
|
<div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;
|
||||||
background-color: {{ $overlay_color }}; z-index: 1; border-radius: 10px;">
|
background-color: {{ $overlay_color | safeCSS }}; z-index: 1; border-radius: 10px;">
|
||||||
<p style='color: #F0F0F0; position: absolute; top: {{ $top_pos }}px; left: 0px; right: 0px'>{{ $thisHigh | toInt }}</p>
|
<p style='color: #F0F0F0; position: absolute; top: {{ $top_pos }}px; left: 0px; right: 0px'>{{ $thisHigh | toInt }}</p>
|
||||||
<p style='color: #F0F0F0; position: absolute; bottom: {{ $bot_pos }}px; left: 0px; right:0px'>{{ $thisLow | toInt }}</p>
|
<p style='color: #F0F0F0; position: absolute; bottom: {{ $bot_pos }}px; left: 0px; right:0px'>{{ $thisLow | toInt }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user