Pabloler21 commited on
Commit
eaa0b20
·
1 Parent(s): 673925d

feat: add render.py with render_treasure, tests passing

Browse files
Files changed (1) hide show
  1. render.py +29 -0
render.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import html
2
+
3
+ _PLACEHOLDER = "...nothing yet. but i'm listening."
4
+
5
+ _PANEL = (
6
+ "background:#0c0a12;border:1px solid #2a1f3d;border-radius:4px;"
7
+ "padding:10px;min-height:460px;"
8
+ )
9
+ _HEADER = (
10
+ "font-size:10px;letter-spacing:2px;text-transform:uppercase;color:#5a4570;"
11
+ "padding-bottom:6px;border-bottom:1px solid #1e1628;margin-bottom:8px;"
12
+ )
13
+ _ITEM = (
14
+ "background:#110d1a;border:1px solid #2a1f3d;border-left:2px solid #5a3a7a;"
15
+ "border-radius:0 3px 3px 0;padding:5px 8px;margin-bottom:6px;"
16
+ "font-size:11px;color:#9a80b8;line-height:1.4;"
17
+ )
18
+ _EMPTY = "font-size:11px;color:#4a3f56;font-style:italic;"
19
+
20
+
21
+ def render_treasure(treasure: list[str]) -> str:
22
+ header = f'<div style="{_HEADER}">✦ Treasure</div>'
23
+ if not treasure:
24
+ body = f'<div style="{_EMPTY}">{_PLACEHOLDER}</div>'
25
+ else:
26
+ body = "".join(
27
+ f'<div style="{_ITEM}">{html.escape(m)}</div>' for m in treasure
28
+ )
29
+ return f'<div style="{_PANEL}">{header}{body}</div>'