stable initial
This commit is contained in:
@@ -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