stable initial
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
from .navigation import Navigation
|
||||
from .header import Header
|
||||
from .news_post import NewsPost
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
from pathlib import Path
|
||||
|
||||
import rio
|
||||
from from_root import from_root
|
||||
|
||||
|
||||
class Header(rio.Component):
|
||||
def build(self) -> rio.Component:
|
||||
return rio.Column(
|
||||
rio.Rectangle(
|
||||
content=rio.Column(
|
||||
rio.Link(
|
||||
rio.Image(from_root("ezgg_website/assets/placeholder_logo.png"), align_x=0, width=8),
|
||||
"/"
|
||||
),
|
||||
margin=1
|
||||
),
|
||||
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_top=1,
|
||||
margin_left=1,
|
||||
margin_right=1,
|
||||
height=4
|
||||
)
|
||||
@@ -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
|
||||
)
|
||||
@@ -0,0 +1,38 @@
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
import rio
|
||||
|
||||
|
||||
class NewsPost(rio.Component):
|
||||
def __init__(self, header: str, article_text: Union[str, Path], date: str):
|
||||
super().__init__()
|
||||
self.align_y = 0
|
||||
self.margin_top = 1
|
||||
self.margin_right = 1
|
||||
self._header = header
|
||||
self._date = date
|
||||
if isinstance(article_text, str):
|
||||
self._article_text = article_text
|
||||
elif isinstance(article_text, Path):
|
||||
with open(article_text, "r") as f:
|
||||
self._article_text = f.read()
|
||||
|
||||
def build(self) -> rio.Component:
|
||||
return rio.Rectangle(
|
||||
content=rio.Column(
|
||||
rio.Row(
|
||||
rio.Text(self._header, align_x=0.1, style="heading2"),
|
||||
rio.Text(self._date, align_x=0.9, style=rio.TextStyle(italic=True)),
|
||||
margin_top=0.5
|
||||
),
|
||||
rio.Column(
|
||||
rio.Markdown(self._article_text, margin=1)
|
||||
)
|
||||
),
|
||||
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
|
||||
)
|
||||
Reference in New Issue
Block a user