oficina / estilo Public

Clone
git clone https://amadan.net/oficina/estilo

Plain git — no account needed to clone.

Download

Download this file

1package savestatus
2
3import _ "embed"
4
5//go:embed status.html
6var markup string
7
8//go:embed status.css
9var css []byte
10
11//go:embed status.mjs
12var javascript []byte
13
14type Data struct {
15 State, Placement string
16 Saved, Saving, Retrying, Failed, Label string
17}
18
19func (d Data) CurrentState() string {
20 switch d.State {
21 case "saved", "saving", "retrying", "failed":
22 return d.State
23 default:
24 return "idle"
25 }
26}
27
28func (d Data) CurrentText() string {
29 switch d.CurrentState() {
30 case "saved":
31 return d.Saved
32 case "saving":
33 return d.Saving
34 case "retrying":
35 return d.Retrying
36 case "failed":
37 return d.Failed
38 default:
39 return ""
40 }
41}
42
43func (d Data) Mode() string {
44 if d.Placement == "floating" {
45 return "floating"
46 }
47 return "inline"
48}
49
50func Template() string { return markup }
51func CSS() []byte { return append([]byte(nil), css...) }
52func JS() []byte { return append([]byte(nil), javascript...) }
53