Spaces:
Sleeping
Sleeping
Deepa Shalini commited on
Commit ·
74081f6
1
Parent(s): 7035297
aside component for appshell
Browse files
app.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
import dash
|
|
|
|
| 2 |
from dash import html, _dash_renderer
|
| 3 |
import dash_mantine_components as dmc
|
| 4 |
import dash_bootstrap_components as dbc
|
|
|
|
| 5 |
|
| 6 |
_dash_renderer._set_react_version("18.2.0")
|
| 7 |
|
|
@@ -22,11 +24,10 @@ header = dmc.Flex(
|
|
| 22 |
)
|
| 23 |
|
| 24 |
left_nav_bar = html.Div(
|
| 25 |
-
[
|
| 26 |
dmc.NavLink(
|
| 27 |
label="Overview",
|
| 28 |
-
href="/"
|
| 29 |
-
active=True
|
| 30 |
),
|
| 31 |
dmc.NavLink(
|
| 32 |
label="ChaRtBot",
|
|
@@ -35,7 +36,7 @@ left_nav_bar = html.Div(
|
|
| 35 |
opened=True,
|
| 36 |
children=[
|
| 37 |
dmc.NavLink(label="English Women's Football Matches (2011 - 2024)", description="Demo data", href="/chartbot/football"),
|
| 38 |
-
dmc.NavLink(label="
|
| 39 |
dmc.NavLink(label="Space Missions (2000 - 2022)", description="Demo data", href="/chartbot/space-missions"),
|
| 40 |
dmc.NavLink(label="Amazon Purchases 2021 Sample", description="Demo data", href="/chartbot/amazon-purchases"),
|
| 41 |
dmc.NavLink(label="Upload your data", href="/chartbot")
|
|
@@ -49,26 +50,51 @@ left_nav_bar = html.Div(
|
|
| 49 |
href="/faqs",
|
| 50 |
)
|
| 51 |
],
|
|
|
|
| 52 |
style={"width": 240, "margin-top": 10, "margin-left": 10, "font-weight": "bold"}
|
| 53 |
)
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
app_shell = dmc.AppShell(
|
| 56 |
[
|
|
|
|
| 57 |
dmc.AppShellHeader(header),
|
| 58 |
dmc.AppShellNavbar(left_nav_bar),
|
|
|
|
| 59 |
dmc.AppShellMain([dash.page_container]),
|
| 60 |
],
|
| 61 |
header={"height": 70},
|
| 62 |
padding="xl",
|
| 63 |
-
zIndex=1400,
|
| 64 |
navbar={
|
| 65 |
"width": 260,
|
| 66 |
"breakpoint": "sm",
|
| 67 |
"collapsed": {"mobile": True},
|
| 68 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
)
|
| 70 |
|
| 71 |
app.layout = dmc.MantineProvider([app_shell])
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
if __name__ == "__main__":
|
| 74 |
app.run_server(debug=True)
|
|
|
|
| 1 |
import dash
|
| 2 |
+
from dash_iconify import DashIconify
|
| 3 |
from dash import html, _dash_renderer
|
| 4 |
import dash_mantine_components as dmc
|
| 5 |
import dash_bootstrap_components as dbc
|
| 6 |
+
from dash import dcc, callback, Output, Input
|
| 7 |
|
| 8 |
_dash_renderer._set_react_version("18.2.0")
|
| 9 |
|
|
|
|
| 24 |
)
|
| 25 |
|
| 26 |
left_nav_bar = html.Div(
|
| 27 |
+
[
|
| 28 |
dmc.NavLink(
|
| 29 |
label="Overview",
|
| 30 |
+
href="/"
|
|
|
|
| 31 |
),
|
| 32 |
dmc.NavLink(
|
| 33 |
label="ChaRtBot",
|
|
|
|
| 36 |
opened=True,
|
| 37 |
children=[
|
| 38 |
dmc.NavLink(label="English Women's Football Matches (2011 - 2024)", description="Demo data", href="/chartbot/football"),
|
| 39 |
+
dmc.NavLink(label="USA Presidential Elections (1976-2020)", description="Demo data", href="/chartbot/us-elections"),
|
| 40 |
dmc.NavLink(label="Space Missions (2000 - 2022)", description="Demo data", href="/chartbot/space-missions"),
|
| 41 |
dmc.NavLink(label="Amazon Purchases 2021 Sample", description="Demo data", href="/chartbot/amazon-purchases"),
|
| 42 |
dmc.NavLink(label="Upload your data", href="/chartbot")
|
|
|
|
| 50 |
href="/faqs",
|
| 51 |
)
|
| 52 |
],
|
| 53 |
+
id="navbar",
|
| 54 |
style={"width": 240, "margin-top": 10, "margin-left": 10, "font-weight": "bold"}
|
| 55 |
)
|
| 56 |
|
| 57 |
+
aside = html.Div(
|
| 58 |
+
[
|
| 59 |
+
dmc.Title("On this page", order=4, style={'padding-bottom': 10}),
|
| 60 |
+
dmc.NavLink(label="Dataset", href="#dataset", leftSection=DashIconify(icon="bx:data", height=20)),
|
| 61 |
+
dmc.NavLink(label="Chart", href="#chart", leftSection=DashIconify(icon="healthicons:chart-line", height=20)),
|
| 62 |
+
dmc.NavLink(label="Python code", href="#python-code", leftSection=DashIconify(icon="ph:code", height=20)),
|
| 63 |
+
], style={"padding-top": 20, "margin-left": 10, 'fontFamily': 'Helvetica'}
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
app_shell = dmc.AppShell(
|
| 67 |
[
|
| 68 |
+
dcc.Location(id='current-page'),
|
| 69 |
dmc.AppShellHeader(header),
|
| 70 |
dmc.AppShellNavbar(left_nav_bar),
|
| 71 |
+
dmc.AppShellAside(aside, id="shell-aside", withBorder=False),
|
| 72 |
dmc.AppShellMain([dash.page_container]),
|
| 73 |
],
|
| 74 |
header={"height": 70},
|
| 75 |
padding="xl",
|
|
|
|
| 76 |
navbar={
|
| 77 |
"width": 260,
|
| 78 |
"breakpoint": "sm",
|
| 79 |
"collapsed": {"mobile": True},
|
| 80 |
},
|
| 81 |
+
aside={
|
| 82 |
+
"width": 300,
|
| 83 |
+
"breakpoint": "xl",
|
| 84 |
+
},
|
| 85 |
+
id="app-shell"
|
| 86 |
)
|
| 87 |
|
| 88 |
app.layout = dmc.MantineProvider([app_shell])
|
| 89 |
|
| 90 |
+
@callback(
|
| 91 |
+
Output("app-shell", "aside"),
|
| 92 |
+
Input("current-page", "pathname")
|
| 93 |
+
)
|
| 94 |
+
def toggle_aside(pathname):
|
| 95 |
+
if pathname == "/":
|
| 96 |
+
return {"width": 0}
|
| 97 |
+
return {"width": 300}
|
| 98 |
+
|
| 99 |
if __name__ == "__main__":
|
| 100 |
app.run_server(debug=True)
|