summaryrefslogtreecommitdiff
path: root/.zs/components/wavy
blob: 20c4a70fa159632ddee32e026acb494816dd39a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/lua

package.path = ".zs/?.lua;" .. package.path
local html = require "components.html"

-- select what message to use
local name = arg[1]

local TEXT = {
    hey = "hey there!",
    ["404"] = "alas, there is nothing to be found here"
}

local acc = {}

local i = 0
for word in TEXT[name or "hey"]:gmatch("[^ ]+") do
    local word_acc = {}

    for char in word:gmatch(".") do
        table.insert(word_acc, {
            tag = "span",
            style = "animation-delay:" .. (-800 * i) .. "ms",
            char
        })
        i = i + 1
    end

    table.insert(word_acc, {
        tag = "span",
        style = "animation-delay:" .. (-800 * i) .. "ms",
        " "
    })

    i = i + 1

    table.insert(acc, {
        tag = "div",
        word_acc
    })
end

print(html {
    tag = "div",
    class = "wavy",
    acc
})