File size: 1,492 Bytes
8e04495
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import mesop as me


def select_density(e: me.SelectSelectionChangeEvent):
  me.set_theme_density(int(e.value))  # type: ignore


def load(e: me.LoadEvent):
  me.set_theme_mode("system")


@me.page(
  on_load=load,
  security_policy=me.SecurityPolicy(
    allowed_iframe_parents=["https://google.github.io", "https://huggingface.co."]
  ),
  path="/density",
)
def main():
  with me.box(style=me.Style(margin=me.Margin.all(15))):
    me.select(
      label="Density",
      options=[
        me.SelectOption(label="0 (least dense)", value="0"),
        me.SelectOption(label="-1", value="-1"),
        me.SelectOption(label="-2", value="-2"),
        me.SelectOption(label="-3", value="-3"),
        me.SelectOption(label="-4 (most dense)", value="-4"),
      ],
      on_selection_change=select_density,
    )
    me.text("Button types:", style=me.Style(margin=me.Margin(bottom=12)))
    with me.box(style=me.Style(display="flex", flex_direction="row", gap=12)):
      me.button("default")
      me.button("raised", type="raised")
      me.button("flat", type="flat")
      me.button("stroked", type="stroked")

    me.text(
      "Button colors:", style=me.Style(margin=me.Margin(top=12, bottom=12))
    )
    with me.box(style=me.Style(display="flex", flex_direction="row", gap=12)):
      me.button("default", type="flat")
      me.button("primary", color="primary", type="flat")
      me.button("secondary", color="accent", type="flat")
      me.button("warn", color="warn", type="flat")