stable initial
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
import rio
|
||||
from from_root import from_root
|
||||
|
||||
|
||||
@dataclass
|
||||
class NavigationLink:
|
||||
text: str
|
||||
icon: str
|
||||
target: str
|
||||
|
||||
|
||||
NAVIGATION_LINKS = [
|
||||
NavigationLink("Start", "material/home", "/"),
|
||||
NavigationLink("Über den Verein", "material/info", "/about"),
|
||||
NavigationLink("Mitglieder", "material/groups", "/member"),
|
||||
NavigationLink("Satzung", "material/contract", "/constitution"),
|
||||
NavigationLink("Mitglied werden", "material/contract-edit", "/join"),
|
||||
NavigationLink("Galerie", "material/gallery-thumbnail", "/pics"),
|
||||
NavigationLink("Impressum", "material/data-info-alert", "/imprint"),
|
||||
NavigationLink("Datenschutz", "material/privacy-tip", "/privacy")
|
||||
]
|
||||
|
||||
class Navigation(rio.Component):
|
||||
@rio.event.on_page_change
|
||||
async def on_page_change(self) -> None:
|
||||
await self.force_refresh()
|
||||
|
||||
def build(self) -> rio.Component:
|
||||
active_page = self.session.active_page_instances[0]
|
||||
|
||||
links = [
|
||||
rio.Link(
|
||||
rio.Button(
|
||||
rio.Row(
|
||||
rio.Icon(link_data.icon),
|
||||
rio.Text(link_data.text),
|
||||
spacing=0.5,
|
||||
margin_x=1,
|
||||
margin_y=0.2,
|
||||
align_x=0,
|
||||
),
|
||||
style=("major" if active_page.page_url == link_data.target.replace("/", "") else "plain"),
|
||||
),
|
||||
link_data.target,
|
||||
)
|
||||
for link_data in NAVIGATION_LINKS
|
||||
]
|
||||
|
||||
return rio.Row(
|
||||
rio.Rectangle(
|
||||
content=rio.Column(
|
||||
*links,
|
||||
spacing=1,
|
||||
margin=1, align_x=0
|
||||
),
|
||||
fill=self.session.theme.neutral_color,
|
||||
corner_radius=self.session.theme.corner_radius_medium,
|
||||
shadow_radius=1,
|
||||
shadow_color=self.session.theme.shadow_color,
|
||||
shadow_offset_y=0.2,
|
||||
),
|
||||
align_y=0,
|
||||
margin=1,
|
||||
margin_top=0
|
||||
)
|
||||
Reference in New Issue
Block a user