From f24831cf67b6946cb6b2944caf3f2ca73cce7695 Mon Sep 17 00:00:00 2001 From: Frederic Heem Date: Tue, 29 Oct 2024 16:12:39 -0300 Subject: [PATCH] increase count --- .../result-summary-component/src/resultSummary.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/result-summary-component/src/resultSummary.ts b/examples/result-summary-component/src/resultSummary.ts index ccb114e7..d3bdb282 100644 --- a/examples/result-summary-component/src/resultSummary.ts +++ b/examples/result-summary-component/src/resultSummary.ts @@ -1,6 +1,8 @@ import { type Context } from "@grucloud/bau-ui/context"; import data from "./data.json"; +const score = 76; + export default function (context: Context) { const { bau, css } = context; const { h1, h2, div, p, article, section, button, ul, li, span, img } = @@ -140,6 +142,17 @@ export default function (context: Context) { } `; + const scoreState = bau.state(score); + + var count = 0; + var interval = setInterval(() => { + count++; + scoreState.val = count; + if (count >= score) { + clearInterval(interval); + } + }, 5); + return function resultSummary() { return article( { class: className }, @@ -149,7 +162,7 @@ export default function (context: Context) { div( { class: "score-container" }, - div({ class: "score" }, "76"), + div({ class: "score" }, scoreState), div({ class: "score-total" }, "of 100") ), h2("Great"),