Home Download Direct linkSettings
Aa
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
Copy
{%- extends "base.html" -%}
{%- block title -%} Spinner {%- endblock -%}

{%- block head -%}
<style id="vars">
    :root {
        --dot: 40em;
        --size: 80em;
        --time: 2s;
        --amount: 6;
        --color: lightsalmon;
    }
</style>

<style>
    .centered,
    .spinner-block {
        flex-grow: 1;
    }

    .spinner-block {
        align-self: stretch;
        display: flex;
        justify-content: center;
        position: relative;
    }

    .fog {
        position: absolute;
        top: -1em;
        left: -1em;
        bottom: -1em;
        right: -1em;
        z-index: -1;
        box-shadow: inset 0 0 1em 1em var(--bg), 0 0 0 300px var(--bg);
        opacity: 0.97;
    }

    .spinner {
        font-size: 1px;
        align-self: center;
        animation: rotation var(--time) linear infinite;
        z-index: -2;
    }

    .spinner *,
    .spinner *::after {
        transition-duration: 0.3s;
        transition-timing-function: ease-in-out;
    }

    .spinner,
    .spinner>div {
        width: 0;
        height: 0;
    }

    .spinner>div {
        transform: rotate(calc(360deg / var(--amount) * var(--t)));
    }

    .spinner>div>div {
        position: relative;
        height: calc(var(--size) + var(--dot) / 2);
        transition-property: height;
    }

    .spinner>div>div::after {
        content: "";
        position: absolute;
        bottom: 0;
        transform: translate(-50%);

        width: var(--dot);
        height: var(--dot);
        color: var(--color);
        background: var(--color);
        border-radius: 50%;
        animation: color calc(var(--time) / 2) infinite;
        animation-delay: calc(var(--time) / var(--amount) * var(--t) * -0.5);

        transition-property: color, background, width, height;
    }

    @keyframes rotation {
        from { transform: rotate(0deg); }
        to { transform: rotate(360deg); }
    }

    @keyframes color {
        from { filter: hue-rotate(0deg); }
        to { filter: hue-rotate(360deg); }
    }

    .var_setting {
        min-width: 8rem;
        text-align: center;
    }
</style>
{%- endblock -%}



{%- macro var_setting(name, var_name, unit, min, max, step, value) -%}

<div class="stretched line-block">
    <div class="frame var_setting">
        {{ name }}: <label for="{{ var_name }}"> {{- value -}} </label>
    </div>

    <input
        id="{{ var_name }}" class="frame range" type="range"
        min="{{ min }}" max="{{ max }}" step="{{ step }}" value="{{ value }}"
    >
</div>

<script>
    document.getElementById("{{ var_name }}").addEventListener(
        "input",
        event => SetCssVar(event, "{{ var_name }}", "{{ unit }}"),
    );
</script>

{%- endmacro -%}


{%- block content -%}

<script>
    const VARS = document.getElementById("vars").sheet.cssRules[0].style;
    
    function SetCssVar(event, var_name, unit) {
        event.target.labels.forEach(i => i.innerHTML = event.target.value);
        VARS.setProperty("--" + var_name, event.target.value + unit);
    }
</script>

<div class="centered">
    <h1> CSS only spinner: </h1>

    <div class="spinner-block">
        <div class="fog"></div>
        <div class="spinner">
            {%- for i in range(10) -%}
                <div style="--t: {{ i }}"><div></div></div>
            {%- endfor -%}
        </div>
    </div>

    <hr>

    <h3> CSS --vars: </h3>
    {{ var_setting("Spinner size", "size", "em", 0, 200, 10, 80) }}
    {{ var_setting("Circle size", "dot", "em", 0, 100, 5, 40) }}
    {{ var_setting("Loop time", "time", "s", 0.5, 5, 0.5, 2) }}
    {{ var_setting("Circle amount", "amount", "", 1, 10, 1, 6) }}
</div>
{%- endblock -%}