-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathexample.star
77 lines (71 loc) · 1.87 KB
/
example.star
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
load("render.star", "render")
load("schema.star", "schema")
def main(config):
pet = config.get("pet", "turtle")
children = [
render.Marquee(
width = 64,
child = render.Text("pet: %s" % pet),
),
]
if pet == "dog":
has_leash = config.bool("leash", False)
children.append(
render.Marquee(
width = 64,
child = render.Text("has leash: %s" % has_leash),
),
)
if pet == "cat":
has_litter_box = config.bool("litter-box", False)
children.append(
render.Marquee(
width = 64,
child = render.Text("has litter box: %s" % has_litter_box),
),
)
return render.Root(
child = render.Column(
children = children,
),
)
def more_options(pet):
if pet == "dog":
return [
schema.Toggle(
id = "leash",
name = "Leash",
desc = "A toggle to enable a dog leash.",
icon = "gear",
default = False,
),
]
elif pet == "cat":
return [
schema.Toggle(
id = "litter-box",
name = "Litter Box",
desc = "A toggle to enable a litter box.",
icon = "gear",
default = False,
),
]
else:
return []
def get_schema():
return schema.Schema(
version = "1",
fields = [
schema.Text(
id = "pet",
name = "Pet Type",
desc = "What type of pet do you have?",
icon = "gear",
),
schema.Generated(
id = "generated",
source = "pet",
handler = more_options,
),
],
)