"""Left sidebar navigation component matching 01_nhs_classic.html design."""
from urllib.parse import quote as url_quote
from dash import html
def _svg_icon(svg_body):
"""Wrap an SVG body string into an html.Img using a data URI.
This avoids needing dash-svg or dangerouslySetInnerHTML.
The SVG icons are copied from 01_nhs_classic.html.
"""
svg = (
f''
)
return html.Img(
src=f"data:image/svg+xml,{url_quote(svg)}",
className="sidebar__icon",
)
# SVG icon bodies from 01_nhs_classic.html
_ICONS = {
"pathway": '',
"drug": '',
"trust": '',
"directory": '',
"indication": '',
"cost": '',
"export": '',
}
def make_sidebar():
"""Return the fixed left sidebar navigation."""
return html.Nav(
className="sidebar",
**{"aria-label": "Main navigation"},
children=[
# Analysis section
html.Div(
className="sidebar__section",
children=[
html.Div("Analysis", className="sidebar__label"),
_sidebar_item("Pathway Overview", "pathway", active=True),
_sidebar_item(
"Drug Selection", "drug", item_id="sidebar-drug-selection"
),
_sidebar_item("Trust Selection", "trust"),
_sidebar_item("Directory Selection", "directory"),
_sidebar_item(
"Indications", "indication", item_id="sidebar-indications"
),
],
),
# Reports section
html.Div(
className="sidebar__section",
children=[
html.Div("Reports", className="sidebar__label"),
_sidebar_item("Cost Analysis", "cost"),
_sidebar_item("Export Data", "export"),
],
),
# Footer
html.Div(
className="sidebar__footer",
children=[
"NHS Norfolk & Waveney ICB",
html.Br(),
"High Cost Drugs Programme",
],
),
],
)
def _sidebar_item(label, icon_key, active=False, item_id=None):
"""Create a single sidebar navigation item."""
class_name = "sidebar__item"
if active:
class_name += " sidebar__item--active"
props = {"className": class_name}
if item_id:
props["id"] = item_id
props["n_clicks"] = 0
return html.A(
**props,
children=[
_svg_icon(_ICONS[icon_key]),
label,
],
)