-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
79 lines (71 loc) · 2.19 KB
/
index.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
from dash import dcc, html
from dash.dependencies import Input, Output, State
import dash_bootstrap_components as dbc
from app import app
from apps import ui, data_exploration, about
dropdown = dbc.DropdownMenu(
children=[
dbc.DropdownMenuItem("About", href="/home"),
dbc.DropdownMenuItem("Data Exploration", href="/data-exploration"),
dbc.DropdownMenuItem("User Interface", href="/ui"),
],
nav = True,
in_navbar = True,
label = "Explore",
)
navbar = dbc.Navbar(
dbc.Container(
[
html.A(
# Use row and col to control vertical alignment of logo / brand
dbc.Row(
[
dbc.Col(html.Img(src="/assets/IO_logo_white.png", height="60px")),
dbc.Col(dbc.NavbarBrand("Index Zero")),
],
align="center",
),
href="/home",
),
dbc.NavbarToggler(id="navbar-toggler2"),
dbc.Collapse(
dbc.Nav(
# right align dropdown menu with ml-auto className
[dropdown], className="ml-auto", navbar=True
),
id="navbar-collapse2",
navbar=True,
),
]
),
color="dark",
dark=True,
)
def toggle_navbar_collapse(n, is_open):
if n:
return not is_open
return is_open
for i in [2]:
app.callback(
Output(f"navbar-collapse{i}", "is_open"),
[Input(f"navbar-toggler{i}", "n_clicks")],
[State(f"navbar-collapse{i}", "is_open")],
)(toggle_navbar_collapse)
# embedding the navigation bar
app.layout = html.Div([
dcc.Location(id='url', refresh=False),
navbar,
html.Div(id='page-content', style={'padding': 10, 'flex': 1, 'margin-bottom': 10})
])
# Index Callbacks
@app.callback(Output('page-content', 'children'),
[Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/ui':
return ui.layout
elif pathname == '/data-exploration':
return data_exploration.layout
else:
return about.layout
if __name__ == '__main__':
app.run_server(debug=True)