diff --git a/experiments/oldwidgets.nim b/experiments/oldwidgets.nim index 46d87c2..fce9908 100644 --- a/experiments/oldwidgets.nim +++ b/experiments/oldwidgets.nim @@ -111,3 +111,22 @@ when false: if plugins.len > 0: plugins[0][1]() +var + images: seq[cstring] = @[cstring"a", "b", "c", "d"] + +proc carousel*(): VNode = + var currentIndex = 0 + + proc next(ev: Event; n: VNode) = + currentIndex = (currentIndex + 1) mod images.len + + proc prev(ev: Event; n: VNode) = + currentIndex = (currentIndex - 1) mod images.len + + result = buildHtml(tdiv): + text images[currentIndex] + button(onclick = next): + text "Next" + button(onclick = prev): + text "Previous" +