-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
85 lines (71 loc) · 1.9 KB
/
app.py
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
78
79
80
81
82
83
84
85
from dash import (
Dash,
html,
dcc,
page_container,
Output,
Input,
State,
clientside_callback,
ALL,
)
from utils import navigacny_panel
import dash_mantine_components as dmc
app = Dash(__name__, use_pages=True)
server = app.server
links = {
"o-mne": {"label": "O mne"},
"skusenosti": {"label": "Skúsenosti"},
"projekty": {"label": "Projekty"},
"kontakty": {"label": "Kontaktuj ma"},
}
app.layout = dmc.MantineProvider(
[
dcc.Store(id="ulozisko-temy", storage_type="local"),
navigacny_panel(links, "tabler:square-rounded-letter-l"),
html.Div(page_container, style={"margin-top": "40px"}),
],
theme={"colorScheme": "dark"},
withGlobalStyles=True,
id="provider-temy",
)
clientside_callback(
"""function(n_clicks, opened) { return !opened }""",
Output("vysuvacie-menu", "opened"),
Input("tlacidlo-menu", "n_clicks"),
State("vysuvacie-menu", "opened"),
prevent_initial_call=True,
)
clientside_callback(
"""function(n_clicks, data) {
if (data) {
if (n_clicks) {
const scheme = data["colorScheme"] == "dark" ? "light" : "dark"
return { colorScheme: scheme }
}
return dash_clientside.no_update
} else {
return { colorScheme: "dark" }
}
}""",
Output("ulozisko-temy", "data"),
Input("tlacidlo-zmena-temy", "n_clicks"),
State("ulozisko-temy", "data"),
)
clientside_callback(
""" function(data) { return data } """,
Output("provider-temy", "theme"),
Input("ulozisko-temy", "data"),
)
clientside_callback(
"""
function (i) {
return false
}
""",
Output("vysuvacie-menu", "opened", allow_duplicate=True),
Input({"index": ALL, "type": "odkaz-menu"}, "n_clicks"),
prevent_initial_call=True,
)
if __name__ == "__main__":
app.run(debug=False)