- Replace all hand-written CSS with Tailwind utility classes - Upgrade CodeMirror 5 to CodeMirror 6 (scoped @codemirror/* packages) - Redesign layout with responsive sidebar navigation using JSX/Mithril - Flatten admin routes (e.g. /admin/presets -> /presets) - Add "remember me" login option with 2-week persistent cookie - Add delete confirmation dialogs across admin pages - Upgrade esbuild from 0.21 to 0.27 and update browser targets - Add Inter and Roboto Mono variable fonts with subset script
68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import { ClosureComponent, VnodeDOM } from "mithril";
|
|
import { m } from "../components.ts";
|
|
import { QueryResponse, evaluateExpression } from "../store.ts";
|
|
import { FlatDevice } from "../../lib/ui/db.ts";
|
|
import { Expression } from "../../lib/types.ts";
|
|
|
|
interface Attrs {
|
|
device: FlatDevice;
|
|
parameters: Record<
|
|
string,
|
|
{ type?: Expression; label: Expression; parameter: Expression }
|
|
>;
|
|
deviceQuery: QueryResponse;
|
|
}
|
|
|
|
const component: ClosureComponent<Attrs> = () => {
|
|
return {
|
|
view: (vnode) => {
|
|
const device = vnode.attrs.device;
|
|
|
|
const rows = Object.values(vnode.attrs.parameters).map((parameter) => {
|
|
const type = evaluateExpression(parameter.type, device);
|
|
const p = m.context(
|
|
{
|
|
device: device,
|
|
parameter: parameter.parameter,
|
|
},
|
|
(type as string) || "parameter",
|
|
parameter,
|
|
);
|
|
|
|
return m(
|
|
"div.py-3 grid grid-cols-3 gap-4 px-6",
|
|
{
|
|
oncreate: (vn) => {
|
|
(vn.dom as HTMLElement).style.display = (p as VnodeDOM).dom
|
|
? ""
|
|
: "none";
|
|
},
|
|
onupdate: (vn) => {
|
|
(vn.dom as HTMLElement).style.display = (p as VnodeDOM).dom
|
|
? ""
|
|
: "none";
|
|
},
|
|
},
|
|
m(
|
|
"dt.text-sm font-medium text-stone-500",
|
|
evaluateExpression(parameter["label"], device),
|
|
),
|
|
m("dd.text-sm text-stone-900 col-span-2", p),
|
|
);
|
|
});
|
|
|
|
return m(
|
|
"loading",
|
|
{ queries: [vnode.attrs.deviceQuery] },
|
|
m(
|
|
"dl.bg-white shadow-sm overflow-hidden rounded-lg w-max py-1",
|
|
{ class: "[&>*+*]:border-t [&>*+*]:border-stone-200" },
|
|
rows,
|
|
),
|
|
);
|
|
},
|
|
};
|
|
};
|
|
|
|
export default component;
|