File size: 1,561 Bytes
f3d45a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from typing import Callable

import mesop as me


@me.content_component
def panel(is_open: bool, title: str, on_click_close: Callable | None = None, key: str = ""):
  """Slide-in panel from right side."""
  with me.box(
    style=me.Style(
      display="block" if is_open else "none",
      height="100%",
      overflow_x="auto",
      overflow_y="auto",
      pointer_events="none",
      position="fixed",
      width="100%",
      z_index=1000,
    )
  ):
    with me.box(
      style=me.Style(
        align_items="center",
        display="grid",
        height="calc(100vh - 10px)",
        justify_items="end",
      )
    ):
      with me.box(
        style=me.Style(
          background=me.theme_var("surface-container-low"),
          border_radius=5,
          box_sizing="border-box",
          border=me.Border.all(
            me.BorderSide(width=1, color=me.theme_var("outline-variant"), style="solid"),
          ),
          margin=me.Margin(top=10, right=5),
          padding=me.Padding.all(20),
          pointer_events="auto",
          height="100%",
          width="30%",
        )
      ):
        with me.box(
          style=me.Style(
            align_items="center",
            display="flex",
            justify_content="space-between",
            margin=me.Margin(bottom=15),
          ),
        ):
          me.text(title, style=me.Style(font_size=16, font_weight="bold"))
          with me.box(key=f"show_{key}", on_click=on_click_close, style=me.Style(cursor="pointer")):
            me.icon("close")

        me.slot()