Spaces:
Sleeping
Sleeping
Deepa Shalini commited on
Commit ·
9b0b7dc
1
Parent(s): 247a185
navlinks highlight when selected
Browse files
app.py
CHANGED
|
@@ -29,28 +29,33 @@ header = dmc.Flex(
|
|
| 29 |
|
| 30 |
left_nav_bar = html.Div(
|
| 31 |
[
|
|
|
|
| 32 |
dmc.NavLink(
|
| 33 |
label="Overview",
|
| 34 |
-
href="/"
|
|
|
|
| 35 |
),
|
| 36 |
dmc.NavLink(
|
| 37 |
label="ChaRtBot",
|
| 38 |
childrenOffset=28,
|
| 39 |
opened=True,
|
| 40 |
children=[
|
| 41 |
-
dmc.NavLink(label="USA Presidential Elections (1976-2020)", description="Sample dataset", href="/chartbot/us-elections"),
|
| 42 |
-
dmc.NavLink(label="English Women's Football Matches (2011-2024)", description="Sample dataset", href="/chartbot/football"),
|
| 43 |
-
dmc.NavLink(label="Amazon Purchases 2021 (Sample)", description="Sample dataset", href="/chartbot/amazon-purchases"),
|
| 44 |
-
dmc.NavLink(label="Space Missions (2000-2022)", description="Sample dataset", href="/chartbot/space-missions"),
|
| 45 |
-
dmc.NavLink(label="Upload your data", href="/chartbot")
|
| 46 |
],
|
| 47 |
),
|
| 48 |
dmc.NavLink(
|
| 49 |
-
label="Product roadmap"
|
|
|
|
|
|
|
| 50 |
),
|
| 51 |
dmc.NavLink(
|
| 52 |
label="FAQs",
|
| 53 |
href="/faqs",
|
|
|
|
| 54 |
)
|
| 55 |
],
|
| 56 |
id="navbar",
|
|
@@ -99,5 +104,31 @@ def toggle_aside(pathname):
|
|
| 99 |
return {"width": 0}
|
| 100 |
return {"width": 300}
|
| 101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
if __name__ == "__main__":
|
| 103 |
app.run_server(debug=False)
|
|
|
|
| 29 |
|
| 30 |
left_nav_bar = html.Div(
|
| 31 |
[
|
| 32 |
+
dcc.Location(id='url', refresh=True),
|
| 33 |
dmc.NavLink(
|
| 34 |
label="Overview",
|
| 35 |
+
href="/",
|
| 36 |
+
id="nav-overview"
|
| 37 |
),
|
| 38 |
dmc.NavLink(
|
| 39 |
label="ChaRtBot",
|
| 40 |
childrenOffset=28,
|
| 41 |
opened=True,
|
| 42 |
children=[
|
| 43 |
+
dmc.NavLink(label="USA Presidential Elections (1976-2020)", description="Sample dataset", href="/chartbot/us-elections", id="nav-us-elections"),
|
| 44 |
+
dmc.NavLink(label="English Women's Football Matches (2011-2024)", description="Sample dataset", href="/chartbot/football", id="nav-football"),
|
| 45 |
+
dmc.NavLink(label="Amazon Purchases 2021 (Sample)", description="Sample dataset", href="/chartbot/amazon-purchases", id="nav-amazon-purchases"),
|
| 46 |
+
dmc.NavLink(label="Space Missions (2000-2022)", description="Sample dataset", href="/chartbot/space-missions", id="nav-space-missions"),
|
| 47 |
+
dmc.NavLink(label="Upload your data", href="/chartbot", id="nav-upload"),
|
| 48 |
],
|
| 49 |
),
|
| 50 |
dmc.NavLink(
|
| 51 |
+
label="Product roadmap",
|
| 52 |
+
href="/product-roadmap",
|
| 53 |
+
id="nav-roadmap",
|
| 54 |
),
|
| 55 |
dmc.NavLink(
|
| 56 |
label="FAQs",
|
| 57 |
href="/faqs",
|
| 58 |
+
id="nav-faqs",
|
| 59 |
)
|
| 60 |
],
|
| 61 |
id="navbar",
|
|
|
|
| 104 |
return {"width": 0}
|
| 105 |
return {"width": 300}
|
| 106 |
|
| 107 |
+
@callback(
|
| 108 |
+
Output("nav-overview", "style"),
|
| 109 |
+
Output("nav-us-elections", "style"),
|
| 110 |
+
Output("nav-football", "style"),
|
| 111 |
+
Output("nav-amazon-purchases", "style"),
|
| 112 |
+
Output("nav-space-missions", "style"),
|
| 113 |
+
Output("nav-upload", "style"),
|
| 114 |
+
Output("nav-roadmap", "style"),
|
| 115 |
+
Output("nav-faqs", "style"),
|
| 116 |
+
Input("url", "pathname")
|
| 117 |
+
)
|
| 118 |
+
def update_navlink_styles(pathname):
|
| 119 |
+
style = {"backgroundColor": "#FFFFFF"}
|
| 120 |
+
active_style = {"backgroundColor": "#EEEEEE"}
|
| 121 |
+
|
| 122 |
+
return [
|
| 123 |
+
active_style if pathname == "/" else style,
|
| 124 |
+
active_style if pathname == "/chartbot/us-elections" else style,
|
| 125 |
+
active_style if pathname == "/chartbot/football" else style,
|
| 126 |
+
active_style if pathname == "/chartbot/amazon-purchases" else style,
|
| 127 |
+
active_style if pathname == "/chartbot/space-missions" else style,
|
| 128 |
+
active_style if pathname == "/chartbot" else style,
|
| 129 |
+
active_style if pathname == "/product-roadmap" else style,
|
| 130 |
+
active_style if pathname == "/faqs" else style
|
| 131 |
+
]
|
| 132 |
+
|
| 133 |
if __name__ == "__main__":
|
| 134 |
app.run_server(debug=False)
|