-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
137 lines (122 loc) · 5.4 KB
/
Copy pathapp.py
File metadata and controls
137 lines (122 loc) · 5.4 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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import dash
import dash_mantine_components as dmc
from dash import html, Dash, dcc, Input, Output, State
from dash_iconify import DashIconify
from collections import OrderedDict
# Initialize Dash app.
app = Dash(__name__, use_pages=True, title="Dash: Polars vs Pandas", suppress_callback_exceptions=True)
# Initialize the server
server = app.server
# Create the nav pages by removing underscores and capitalizing them
nav_items = {
page['name'].replace("_", " ").title(): page['path'] for page in dash.page_registry.values()
}
nav_items = OrderedDict(sorted(nav_items.items(), key=lambda x: x[0].lower()))
def serve_layout():
return html.Div([
dcc.Location(id="url"),
dmc.MantineProvider(
id='app',
withGlobalStyles=True,
theme={"primaryColor": "blue",
"fontFamily": "'Inter', sans-serif",
"components": {
"Title": {
"styles": {
"root": {
"font-family": "Inter",
"fontWeight": 600,
}
}
},
"NavLink": {
"styles": {
"root": {
"border-radius": 8,
}
}
},
}
},
children=[
dmc.Grid(
# grow=True,
children=[
dmc.Col(
sm=12,
md=2,
p=0,
children=[
dmc.Navbar(
p="md",
withBorder=False,
children=[
dmc.Space(h=30),
# Title
dmc.Center([
dmc.Title("Dash Polars vs Pandas", order=5),
]),
dmc.Space(h=20),
*[dmc.NavLink(
label=page,
href=path,
id=page,
) for page, path in nav_items.items()],
],
)
],
),
dmc.Col(
sm=12,
md=10,
style={'backgroundColor': '#f1f5f9'},
children=[
dmc.Container(children=[
dmc.Space(h=30),
dash.page_container,
],
p='xl',
fluid=True,
),
],
),
dmc.Col(
span=12,
children=[
dmc.Group(
m="md",
children=[
"By Chad Bell",
dmc.Anchor(
href="https://www.linkedin.com/in/chadbell045/",
children=DashIconify(icon="mdi:linkedin", width=28, color="black")
),
dmc.Anchor(
href="https://github.com/CBell045/dash-polars-pandas",
children=DashIconify(icon="mdi:github", width=28, color="black")
),
dmc.Anchor(
href="mailto:chadbell045@gmail.com",
children=DashIconify(icon="heroicons:envelope-16-solid", width=28, color="black")
),
],
),
],
),
],
),
],
)
])
# Dynamically serve the layout
app.layout = serve_layout
page_outputs = [Output(label, "active") for label in nav_items.keys()]
@app.callback(
*page_outputs,
Input("url", "pathname"),
)
def set_active_navlink(pathname):
""" Set active navlinks """
return [pathname == href for href in nav_items.values()]
if __name__ == "__main__":
app.run_server(debug=True)