-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdl2_shared.py
More file actions
58 lines (48 loc) · 1.49 KB
/
Copy pathdl2_shared.py
File metadata and controls
58 lines (48 loc) · 1.49 KB
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
"""Shared layout helpers so every example page looks consistent."""
import dash_mantine_components as dmc
from dash import html
def map_div(demo_id, height="60vh", **kwargs):
"""The mount point the JS runtime (assets/leaflet2_maps.js) builds into.
`data-demo` selects which DEMOS[...] builder runs. We wrap it in a Paper so
it matches the dash-leaflet test app's framing.
"""
style = {"height": height}
style.update(kwargs.pop("style", {}))
return dmc.Paper(
html.Div(
className="leaflet2-map", style=style, **{"data-demo": demo_id}, **kwargs
),
shadow="sm",
radius="md",
withBorder=True,
style={"overflow": "hidden"},
)
def header(title, desc, badge=None):
bits = [dmc.Title(title, order=1)]
if badge:
bits = [
dmc.Group(
[
dmc.Title(title, order=1),
dmc.Badge(badge, color="green", variant="light"),
]
)
]
bits.append(dmc.Text(desc, c="dimmed"))
return dmc.Stack(bits, gap=4)
def code_panel(title, code):
return dmc.Paper(
[dmc.Title(title, order=4, mb="sm"), dmc.Code(code, block=True)],
shadow="sm",
radius="md",
p="md",
withBorder=True,
)
def info_panel(title, children):
return dmc.Paper(
[dmc.Title(title, order=4, mb="sm"), children],
shadow="sm",
radius="md",
p="md",
withBorder=True,
)