Skip to content

Commit 8eb8224

Browse files
authored
feat(frontend): draw the energiavirta nodes as neon signs (#1023)
Each node in the energy flow diagram is now a glowbox neon sign: ring and glyph as one drawing, lit by the data. An inactive node keeps its unlit glass instead of fading out, and the battery ring is a gauge — lit as far as the charge runs, dim tube for the rest, replacing the dasharray arc. Glow is scaled against a per-node reference power rather than an arbitrary curve: the sun is glowed against the array's 7.2 kWp nameplate, so only a clear noon lights it all the way, and the battery against its 5 kW charge/discharge ceiling. The glyph geometry (sun, activity, plug, house, six battery states) is transcribed from lucide 1.30 into path data, since art takes paths or polylines rather than lucide's circle/rect primitives. Ring and glyph keep their registration through the art frame, which also makes every glyph land the same size regardless of how much of its 24 units it fills. Two things that had to be built around: - A partial ring shrinks the bounds the sign is scaled to fit, so a lone 62% arc rendered smaller and off-centre and the node resized itself on every poll. Drawing the unlit remainder as a second, dim circuit keeps the bounds a full ring at any charge level. - A canvas in a foreignObject is laid out in SVG user units but measures itself in scaled CSS pixels, so the signs landed offset and oversized by the viewBox scale. They are now an overlay positioned by percentages of the diagram box. Opening the energy view strikes the board in order — the reveal program walks the tubes of each sign, and a per-node delay walks outward from the inverter. A browser tab returning to the front never remounts, so that case re-strikes through the sign handle. Below 30% the battery flickers, harder the lower it gets. The clock faces' glowbox theme bridge moves to hooks/useGlowboxTheme so both callers share it.
1 parent 4af2518 commit 8eb8224

4 files changed

Lines changed: 497 additions & 283 deletions

File tree

‎frontend/src/components/CurrentTime.tsx‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { fi } from "date-fns/locale/fi";
55
import React, { memo } from "react";
66

77
import useCurrentTime from "../hooks/useCurrentTime";
8+
import useGlowboxTheme from "../hooks/useGlowboxTheme";
89
import useLocal from "../hooks/useLocal";
910

1011
type CurrentTimeProps = {} & React.HTMLAttributes<HTMLDivElement>;
@@ -124,11 +125,6 @@ type NixieClockProps = {
124125
ss: string;
125126
};
126127

127-
// Every glowbox core takes its own colour bundle, 'dark' | 'light' | 'auto'. 'auto'
128-
// would follow prefers-color-scheme on its own, but so does our theme (Root.tsx), so
129-
// pass ours: one source of truth, and it still works if a manual toggle lands later.
130-
const useGlowboxTheme = (): "dark" | "light" => (useTheme().mode === "light" ? "light" : "dark");
131-
132128
const NixieClock: React.FC<NixieClockProps> = ({ hh, mm, ss }) => {
133129
const glowboxTheme = useGlowboxTheme();
134130

0 commit comments

Comments
 (0)