Skip to content

Commit

Permalink
increase count
Browse files Browse the repository at this point in the history
  • Loading branch information
FredericHeem committed Oct 29, 2024
1 parent 990b8c5 commit f24831c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion examples/result-summary-component/src/resultSummary.ts
Original file line number Diff line number Diff line change
@@ -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 } =
Expand Down Expand Up @@ -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 },
Expand All @@ -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"),
Expand Down

0 comments on commit f24831c

Please sign in to comment.