diff --git a/index.html b/index.html index b6b2a62..bee1cae 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ Waight - + diff --git a/src/App.tsx b/src/App.tsx index d27005e..d6cff48 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,3 +1,89 @@ +import { createSignal, For } from "solid-js"; + +type Entry = { + weight: number; + timestamp: Date; +}; + export default function App() { - return

Waight

; + const [entries, setEntries] = createSignal( + [ + { + timestamp: new Date(), + weight: 100, + }, + ], + { + equals: false, + } + ); + + function handleSubmit( + event: SubmitEvent & { currentTarget: HTMLFormElement } + ) { + event.preventDefault(); + + const input = event.currentTarget.elements.namedItem("weight"); + if (!(input instanceof HTMLInputElement)) + throw new Error("Expected input element"); + + const weight = input.valueAsNumber; + setEntries((entries) => { + entries.push({ weight, timestamp: new Date() }); + return entries; + }); + } + + return ( +
+

Waight

+
    + + {(entry) => ( +
  1. +

    {entry.weight}

    + +
  2. + )} +
    +
+
+ + + +
+
+ ); }