-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader_panel.py
More file actions
40 lines (35 loc) · 1.46 KB
/
Copy pathheader_panel.py
File metadata and controls
40 lines (35 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Header panel for synthwave dashboards."""
from pyfiglet import Figlet
from rich.align import Align
from rich.console import Group
from rich.panel import Panel
from rich.text import Text
from sample_python_app.core import Settings
from sample_python_app.models import AstronomicalData
def build_header_panel(
astro: AstronomicalData, settings: Settings, *, preferred_height: int | None = None
) -> Panel:
"""Build the compact header panel used by dashboards.
The optional ``preferred_height`` is informational and intended to be
used by callers when placing the panel into a ``rich.layout.Layout``.
The panel itself remains flexible and does not enforce a fixed height.
"""
sunrise_local = astro.sunrise.astimezone(settings.tz)
header_main = Figlet(font="slant", width=80).renderText("SYNTHWAVE")
header_main_text = Text(header_main, style="bold magenta")
header_sub = Figlet(font="small", width=80).renderText("SUNRISE")
header_sub_text = Text(header_sub, style="bold yellow")
date_str = sunrise_local.strftime("%A, %B %d, %Y")
date_text = Text(date_str, style="bold cyan")
content = Group(
Align.center(header_main_text),
Align.center(header_sub_text),
Align.center(date_text),
)
header_panel = Panel(
Align(content, align="center", vertical="middle"),
title="[bold #ff6ec7]Synthwave[/bold #ff6ec7]",
border_style="#ff00cc",
padding=(0, 1),
)
return header_panel