initial feature/react-migration commit
This commit is contained in:
72
dashboard-dash-backup/components/sidebar.py
Normal file
72
dashboard-dash-backup/components/sidebar.py
Normal file
@@ -0,0 +1,72 @@
|
||||
# dashboard/components/sidebar.py
|
||||
|
||||
from dash import html
|
||||
import dash_bootstrap_components as dbc
|
||||
from dash_iconify import DashIconify
|
||||
|
||||
def Sidebar(collapsed: bool = False):
|
||||
"""
|
||||
Gibt nur den Inhalt der Sidebar zurück (ohne das äußere div mit id="sidebar").
|
||||
Das äußere div wird bereits in app.py definiert.
|
||||
"""
|
||||
|
||||
nav_items = [
|
||||
{"label": "Übersicht", "href": "/overview", "icon": "mdi:view-dashboard"},
|
||||
{"label": "Termine", "href": "/appointments","icon": "mdi:calendar"},
|
||||
{"label": "Bildschirme", "href": "/clients", "icon": "mdi:monitor"},
|
||||
{"label": "Einstellungen","href": "/settings", "icon": "mdi:cog"},
|
||||
{"label": "Benutzer", "href": "/users", "icon": "mdi:account"},
|
||||
]
|
||||
|
||||
if collapsed:
|
||||
nav_links = [
|
||||
dbc.NavLink(
|
||||
DashIconify(icon=item["icon"], width=24),
|
||||
href=item["href"],
|
||||
active="exact",
|
||||
className="sidebar-item-collapsed",
|
||||
id={"type": "nav-item", "index": item["label"]},
|
||||
)
|
||||
for item in nav_items
|
||||
]
|
||||
else:
|
||||
nav_links = [
|
||||
dbc.NavLink(
|
||||
[
|
||||
DashIconify(icon=item["icon"], width=24),
|
||||
html.Span(item["label"], className="ms-2 sidebar-label"),
|
||||
],
|
||||
href=item["href"],
|
||||
active="exact",
|
||||
className="sidebar-item",
|
||||
id={"type": "nav-item", "index": item["label"]},
|
||||
)
|
||||
for item in nav_items
|
||||
]
|
||||
|
||||
return [
|
||||
html.Div(
|
||||
className="sidebar-toggle",
|
||||
children=html.Button(
|
||||
DashIconify(icon="mdi:menu", width=28),
|
||||
id="btn-toggle-sidebar",
|
||||
className="toggle-button",
|
||||
)
|
||||
),
|
||||
dbc.Collapse(
|
||||
dbc.Nav(
|
||||
nav_links,
|
||||
vertical=True,
|
||||
pills=True,
|
||||
className="sidebar-nav",
|
||||
),
|
||||
is_open=not collapsed,
|
||||
className="sidebar-nav",
|
||||
) if not collapsed else
|
||||
dbc.Nav(
|
||||
nav_links,
|
||||
vertical=True,
|
||||
pills=True,
|
||||
className="sidebar-nav-collapsed",
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user