Update app.py
Browse files
app.py
CHANGED
|
@@ -23,7 +23,7 @@ THEME: Dict[str, Any] = {
|
|
| 23 |
"tagline_font": 15, # px
|
| 24 |
"bg1": "#1565C0", # strip gradient start
|
| 25 |
"bg2": "#1565C0", # strip gradient end
|
| 26 |
-
"text": "#FFFFFF",
|
| 27 |
"tagline_color": "#000000",
|
| 28 |
},
|
| 29 |
"page": {
|
|
@@ -47,8 +47,8 @@ THEME: Dict[str, Any] = {
|
|
| 47 |
"pad_h": 20, # px
|
| 48 |
"border": "#0B1220", # dark outline
|
| 49 |
"border_hover": "#1E293B",
|
| 50 |
-
"bg_top": "#1565C0", #
|
| 51 |
-
"bg_bot": "#1565C0",
|
| 52 |
"title_color": "#0B1220",
|
| 53 |
"blurb_color": "#566275",
|
| 54 |
},
|
|
@@ -70,21 +70,16 @@ THEME: Dict[str, Any] = {
|
|
| 70 |
}
|
| 71 |
|
| 72 |
# ========= CARDS (content + per-card overrides) =========
|
|
|
|
| 73 |
CARDS = [
|
| 74 |
{
|
| 75 |
"title": "ST_Log_GR",
|
| 76 |
"blurb": "Real-time gamma-ray log prediction.",
|
| 77 |
"url": "https://smart-thinking-gr.hf.space/",
|
| 78 |
"icon": ASSETS / "GR_logo.png",
|
| 79 |
-
# Optional per-card overrides:
|
| 80 |
"style": {
|
| 81 |
-
"bg_top": "rgba(14,116,144,0.
|
| 82 |
-
"bg_bot": "rgba(14,116,144,0.
|
| 83 |
-
# "border": "#0B1220",
|
| 84 |
-
# "title_color": "#0B1220",
|
| 85 |
-
# "blurb_color": "#566275",
|
| 86 |
-
# "width": 360, "radius": 24, "pad_v": 26, "pad_h": 22,
|
| 87 |
-
# "btn_bg1": "#0B1220", "btn_bg2": "#1F2937", "btn_text": "#FFFFFF",
|
| 88 |
},
|
| 89 |
},
|
| 90 |
{
|
|
@@ -93,8 +88,8 @@ CARDS = [
|
|
| 93 |
"url": "https://smart-thinking-sonic-ts.hf.space",
|
| 94 |
"icon": ASSETS / "Ts_logo.png",
|
| 95 |
"style": {
|
| 96 |
-
"bg_top": "rgba(2,132,199,0.
|
| 97 |
-
"bg_bot": "rgba(2,132,199,0.
|
| 98 |
},
|
| 99 |
},
|
| 100 |
{
|
|
@@ -103,8 +98,8 @@ CARDS = [
|
|
| 103 |
"url": "https://smart-thinking-sonic-tc.hf.space",
|
| 104 |
"icon": ASSETS / "Tc_logo.png",
|
| 105 |
"style": {
|
| 106 |
-
"bg_top": "rgba(99,102,241,0.
|
| 107 |
-
"bg_bot": "rgba(99,102,241,0.
|
| 108 |
},
|
| 109 |
},
|
| 110 |
]
|
|
@@ -127,13 +122,6 @@ def img_tag(path: Path, alt: str, cls: str = "", style: str = "") -> str:
|
|
| 127 |
style_attr = f' style="{style}"' if style else ""
|
| 128 |
return f'<img{cls_attr}{style_attr} src="{uri}" alt="{escape(alt)}" />'
|
| 129 |
|
| 130 |
-
def get_style(card_style: Dict[str, Any], key: str, fallback_key: str = None):
|
| 131 |
-
if key in card_style:
|
| 132 |
-
return card_style[key]
|
| 133 |
-
if fallback_key:
|
| 134 |
-
return THEME["card"][fallback_key]
|
| 135 |
-
return None
|
| 136 |
-
|
| 137 |
# ========= CSS (driven from THEME) =========
|
| 138 |
strip = THEME["strip"]; page = THEME["page"]; hero = THEME["hero"]
|
| 139 |
grid = THEME["grid"]; card = THEME["card"]; icon = THEME["icon"]; button = THEME["button"]
|
|
@@ -172,10 +160,6 @@ st.markdown(f"""
|
|
| 172 |
--icon-d: {icon["diam"]}px;
|
| 173 |
--icon-img: {icon["img"]}px;
|
| 174 |
|
| 175 |
-
--title-fs: 25px;
|
| 176 |
-
--blurb-fs: 16px;
|
| 177 |
-
--btn-fs: {button["pad_v"] + 4}px; /* just a simple mapping; override below if desired */
|
| 178 |
-
|
| 179 |
--stripBg1: {strip["bg1"]};
|
| 180 |
--stripBg2: {strip["bg2"]};
|
| 181 |
--stripText: {strip["text"]};
|
|
@@ -247,7 +231,7 @@ st.markdown(f"""
|
|
| 247 |
.grid {{ grid-template-columns: 1fr; }}
|
| 248 |
}}
|
| 249 |
|
| 250 |
-
/* ===== CARD
|
| 251 |
.card {{
|
| 252 |
position: relative;
|
| 253 |
width: var(--c-w, var(--card-w));
|
|
@@ -255,10 +239,11 @@ st.markdown(f"""
|
|
| 255 |
padding: var(--c-pv, var(--card-pv)) var(--c-ph, var(--card-ph));
|
| 256 |
background: linear-gradient(180deg, var(--c-bg-top, {card["bg_top"]}) 0%, var(--c-bg-bot, {card["bg_bot"]}) 100%);
|
| 257 |
border: var(--c-bw, var(--card-bw)) solid var(--c-border, var(--cardStroke));
|
|
|
|
| 258 |
box-shadow:
|
| 259 |
0 14px 32px rgba(2,20,35,.12),
|
| 260 |
-
0 1px 0 rgba(255,255,255,0.
|
| 261 |
-
0 -1px
|
| 262 |
transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, filter .18s ease;
|
| 263 |
text-align:center; display:flex; flex-direction:column; gap:16px; align-items: center;
|
| 264 |
}}
|
|
@@ -267,8 +252,8 @@ st.markdown(f"""
|
|
| 267 |
border-color: var(--cardStrokeHover);
|
| 268 |
box-shadow:
|
| 269 |
0 22px 56px rgba(2,20,35,.18),
|
| 270 |
-
0 1px 0 rgba(255,255,255,0.
|
| 271 |
-
0 -1px
|
| 272 |
filter: saturate(1.03);
|
| 273 |
}}
|
| 274 |
|
|
@@ -285,27 +270,26 @@ st.markdown(f"""
|
|
| 285 |
}}
|
| 286 |
|
| 287 |
.card h3 {{
|
| 288 |
-
margin: 0; font-size:
|
| 289 |
-
color:
|
| 290 |
}}
|
| 291 |
.card p {{
|
| 292 |
-
color:
|
| 293 |
-
font-size: var(--c-blurb-fs, 16px);
|
| 294 |
}}
|
| 295 |
|
| 296 |
.btn {{
|
| 297 |
-
display:inline-block; padding:
|
| 298 |
-
border-radius:
|
| 299 |
-
border: 1px solid
|
| 300 |
-
background: linear-gradient(180deg,
|
| 301 |
-
font-weight: 800; letter-spacing:.3px; font-size:
|
| 302 |
margin: 6px auto 0;
|
| 303 |
box-shadow: 0 12px 28px rgba(11,18,32,.28), inset 0 1px 0 rgba(255,255,255,.10);
|
| 304 |
-
color:
|
| 305 |
text-decoration: none;
|
| 306 |
}}
|
| 307 |
a.btn, a.btn:link, a.btn:visited, a.btn:hover, a.btn:active, a.btn:focus {{
|
| 308 |
-
color:
|
| 309 |
}}
|
| 310 |
.btn:hover {{
|
| 311 |
filter: brightness(1.03) saturate(1.04);
|
|
@@ -330,41 +314,52 @@ st.markdown(
|
|
| 330 |
)
|
| 331 |
|
| 332 |
# ========= Hero =========
|
| 333 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
st.markdown(f"<div class='hero'>{hero_html}</div>", unsafe_allow_html=True)
|
| 335 |
|
| 336 |
# ========= Cards =========
|
| 337 |
def build_card_vars(style: Dict[str, Any]) -> str:
|
| 338 |
-
"""Turn the per-card style dict into CSS variables for inline override."""
|
| 339 |
s = []
|
| 340 |
-
if "width"
|
| 341 |
-
if "radius"
|
| 342 |
-
if "pad_v"
|
| 343 |
-
if "pad_h"
|
| 344 |
-
|
| 345 |
-
if "
|
| 346 |
-
if "
|
| 347 |
-
if "border" in style: s.append(f"--c-border:{style['border']}")
|
| 348 |
if "border_width" in style: s.append(f"--c-bw:{int(style['border_width'])}px")
|
| 349 |
-
|
| 350 |
-
if "
|
| 351 |
-
if "
|
| 352 |
-
if "
|
| 353 |
-
if "
|
| 354 |
-
|
| 355 |
-
if "
|
| 356 |
-
if "
|
| 357 |
-
if "
|
| 358 |
-
if "
|
| 359 |
-
if "
|
| 360 |
-
if "
|
| 361 |
-
if "
|
| 362 |
-
|
| 363 |
-
if "
|
| 364 |
-
if "icon_img" in style: s.append(f"--c-icon-img:{int(style['icon_img'])}px")
|
| 365 |
-
if "icon_bg" in style: s.append(f"--c-icon-bg:{style['icon_bg']}")
|
| 366 |
-
if "icon_border" in style: s.append(f"--c-icon-border:{style['icon_border']}")
|
| 367 |
-
|
| 368 |
return "; ".join(s)
|
| 369 |
|
| 370 |
def app_card(card_cfg: Dict[str, Any]) -> str:
|
|
|
|
| 23 |
"tagline_font": 15, # px
|
| 24 |
"bg1": "#1565C0", # strip gradient start
|
| 25 |
"bg2": "#1565C0", # strip gradient end
|
| 26 |
+
"text": "#FFFFFF",
|
| 27 |
"tagline_color": "#000000",
|
| 28 |
},
|
| 29 |
"page": {
|
|
|
|
| 47 |
"pad_h": 20, # px
|
| 48 |
"border": "#0B1220", # dark outline
|
| 49 |
"border_hover": "#1E293B",
|
| 50 |
+
"bg_top": "#1565C0", # default gradient (overridden per-card below)
|
| 51 |
+
"bg_bot": "#1565C0",
|
| 52 |
"title_color": "#0B1220",
|
| 53 |
"blurb_color": "#566275",
|
| 54 |
},
|
|
|
|
| 70 |
}
|
| 71 |
|
| 72 |
# ========= CARDS (content + per-card overrides) =========
|
| 73 |
+
# Only changed: stronger tints (0.25 / 0.15) so the bg color is clearly visible
|
| 74 |
CARDS = [
|
| 75 |
{
|
| 76 |
"title": "ST_Log_GR",
|
| 77 |
"blurb": "Real-time gamma-ray log prediction.",
|
| 78 |
"url": "https://smart-thinking-gr.hf.space/",
|
| 79 |
"icon": ASSETS / "GR_logo.png",
|
|
|
|
| 80 |
"style": {
|
| 81 |
+
"bg_top": "rgba(14,116,144,0.25)",
|
| 82 |
+
"bg_bot": "rgba(14,116,144,0.15)",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
},
|
| 84 |
},
|
| 85 |
{
|
|
|
|
| 88 |
"url": "https://smart-thinking-sonic-ts.hf.space",
|
| 89 |
"icon": ASSETS / "Ts_logo.png",
|
| 90 |
"style": {
|
| 91 |
+
"bg_top": "rgba(2,132,199,0.25)",
|
| 92 |
+
"bg_bot": "rgba(2,132,199,0.15)",
|
| 93 |
},
|
| 94 |
},
|
| 95 |
{
|
|
|
|
| 98 |
"url": "https://smart-thinking-sonic-tc.hf.space",
|
| 99 |
"icon": ASSETS / "Tc_logo.png",
|
| 100 |
"style": {
|
| 101 |
+
"bg_top": "rgba(99,102,241,0.25)",
|
| 102 |
+
"bg_bot": "rgba(99,102,241,0.15)",
|
| 103 |
},
|
| 104 |
},
|
| 105 |
]
|
|
|
|
| 122 |
style_attr = f' style="{style}"' if style else ""
|
| 123 |
return f'<img{cls_attr}{style_attr} src="{uri}" alt="{escape(alt)}" />'
|
| 124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
# ========= CSS (driven from THEME) =========
|
| 126 |
strip = THEME["strip"]; page = THEME["page"]; hero = THEME["hero"]
|
| 127 |
grid = THEME["grid"]; card = THEME["card"]; icon = THEME["icon"]; button = THEME["button"]
|
|
|
|
| 160 |
--icon-d: {icon["diam"]}px;
|
| 161 |
--icon-img: {icon["img"]}px;
|
| 162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
--stripBg1: {strip["bg1"]};
|
| 164 |
--stripBg2: {strip["bg2"]};
|
| 165 |
--stripText: {strip["text"]};
|
|
|
|
| 231 |
.grid {{ grid-template-columns: 1fr; }}
|
| 232 |
}}
|
| 233 |
|
| 234 |
+
/* ===== CARD ===== */
|
| 235 |
.card {{
|
| 236 |
position: relative;
|
| 237 |
width: var(--c-w, var(--card-w));
|
|
|
|
| 239 |
padding: var(--c-pv, var(--card-pv)) var(--c-ph, var(--card-ph));
|
| 240 |
background: linear-gradient(180deg, var(--c-bg-top, {card["bg_top"]}) 0%, var(--c-bg-bot, {card["bg_bot"]}) 100%);
|
| 241 |
border: var(--c-bw, var(--card-bw)) solid var(--c-border, var(--cardStroke));
|
| 242 |
+
/* SOFTER inner highlights so color shows more */
|
| 243 |
box-shadow:
|
| 244 |
0 14px 32px rgba(2,20,35,.12),
|
| 245 |
+
0 1px 0 rgba(255,255,255,0.70) inset,
|
| 246 |
+
0 -1px 6px rgba(255,255,255,0.18) inset;
|
| 247 |
transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, filter .18s ease;
|
| 248 |
text-align:center; display:flex; flex-direction:column; gap:16px; align-items: center;
|
| 249 |
}}
|
|
|
|
| 252 |
border-color: var(--cardStrokeHover);
|
| 253 |
box-shadow:
|
| 254 |
0 22px 56px rgba(2,20,35,.18),
|
| 255 |
+
0 1px 0 rgba(255,255,255,0.82) inset,
|
| 256 |
+
0 -1px 10px rgba(255,255,255,0.28) inset;
|
| 257 |
filter: saturate(1.03);
|
| 258 |
}}
|
| 259 |
|
|
|
|
| 270 |
}}
|
| 271 |
|
| 272 |
.card h3 {{
|
| 273 |
+
margin: 0; font-size: 25px; font-weight: 900;
|
| 274 |
+
color: {card["title_color"]}; letter-spacing: .15px;
|
| 275 |
}}
|
| 276 |
.card p {{
|
| 277 |
+
color: {card["blurb_color"]}; min-height: 40px; margin: 0 10px; font-size: 16px;
|
|
|
|
| 278 |
}}
|
| 279 |
|
| 280 |
.btn {{
|
| 281 |
+
display:inline-block; padding: {button["pad_v"]}px {button["pad_h"]}px;
|
| 282 |
+
border-radius: {button["radius"]}px;
|
| 283 |
+
border: 1px solid {button["border"]};
|
| 284 |
+
background: linear-gradient(180deg, {button["bg1"]} 0%, {button["bg2"]} 100%);
|
| 285 |
+
font-weight: 800; letter-spacing:.3px; font-size: 16px;
|
| 286 |
margin: 6px auto 0;
|
| 287 |
box-shadow: 0 12px 28px rgba(11,18,32,.28), inset 0 1px 0 rgba(255,255,255,.10);
|
| 288 |
+
color: {button["text"]};
|
| 289 |
text-decoration: none;
|
| 290 |
}}
|
| 291 |
a.btn, a.btn:link, a.btn:visited, a.btn:hover, a.btn:active, a.btn:focus {{
|
| 292 |
+
color: {button["text"]} !important; text-decoration: none !important;
|
| 293 |
}}
|
| 294 |
.btn:hover {{
|
| 295 |
filter: brightness(1.03) saturate(1.04);
|
|
|
|
| 314 |
)
|
| 315 |
|
| 316 |
# ========= Hero =========
|
| 317 |
+
def data_uri(path: Path) -> Optional[str]:
|
| 318 |
+
if not path or not path.exists():
|
| 319 |
+
return None
|
| 320 |
+
mime, _ = mimetypes.guess_type(path.name)
|
| 321 |
+
if not mime:
|
| 322 |
+
mime = "image/png"
|
| 323 |
+
b64 = base64.b64encode(path.read_bytes()).decode("utf-8")
|
| 324 |
+
return f"data:{mime};base64,{b64}"
|
| 325 |
+
|
| 326 |
+
def img_tag(path: Path, alt: str, cls: str = "", style: str = "") -> str:
|
| 327 |
+
uri = data_uri(path)
|
| 328 |
+
if not uri:
|
| 329 |
+
return ""
|
| 330 |
+
cls_attr = f' class="{cls}"' if cls else ""
|
| 331 |
+
style_attr = f' style="{style}"' if style else ""
|
| 332 |
+
return f'<img{cls_attr}{style_attr} src="{uri}" alt="{escape(alt)}" />'
|
| 333 |
+
|
| 334 |
+
hero_html = img_tag(THEME["hero"]["logo"], "ST_LOG SUITE")
|
| 335 |
st.markdown(f"<div class='hero'>{hero_html}</div>", unsafe_allow_html=True)
|
| 336 |
|
| 337 |
# ========= Cards =========
|
| 338 |
def build_card_vars(style: Dict[str, Any]) -> str:
|
|
|
|
| 339 |
s = []
|
| 340 |
+
if "width" in style: s.append(f"--c-w:{int(style['width'])}px")
|
| 341 |
+
if "radius" in style: s.append(f"--c-radius:{int(style['radius'])}px")
|
| 342 |
+
if "pad_v" in style: s.append(f"--c-pv:{int(style['pad_v'])}px")
|
| 343 |
+
if "pad_h" in style: s.append(f"--c-ph:{int(style['pad_h'])}px")
|
| 344 |
+
if "bg_top" in style: s.append(f"--c-bg-top:{style['bg_top']}")
|
| 345 |
+
if "bg_bot" in style: s.append(f"--c-bg-bot:{style['bg_bot']}")
|
| 346 |
+
if "border" in style: s.append(f"--c-border:{style['border']}")
|
|
|
|
| 347 |
if "border_width" in style: s.append(f"--c-bw:{int(style['border_width'])}px")
|
| 348 |
+
if "title_color" in style: s.append(f"--c-title-color:{style['title_color']}")
|
| 349 |
+
if "title_fs" in style: s.append(f"--c-title-fs:{int(style['title_fs'])}px")
|
| 350 |
+
if "blurb_color" in style: s.append(f"--c-blurb-color:{style['blurb_color']}")
|
| 351 |
+
if "blurb_fs" in style: s.append(f"--c-blurb-fs:{int(style['blurb_fs'])}px")
|
| 352 |
+
if "btn_bg1" in style: s.append(f"--c-btn-bg1:{style['btn_bg1']}")
|
| 353 |
+
if "btn_bg2" in style: s.append(f"--c-btn-bg2:{style['btn_bg2']}")
|
| 354 |
+
if "btn_text" in style: s.append(f"--c-btn-text:{style['btn_text']}")
|
| 355 |
+
if "btn_border" in style: s.append(f"--c-btn-border:{style['btn_border']}")
|
| 356 |
+
if "btn_fs" in style: s.append(f"--c-btn-fs:{int(style['btn_fs'])}px")
|
| 357 |
+
if "btn_pad_v" in style: s.append(f"--c-btn-pv:{int(style['btn_pad_v'])}px")
|
| 358 |
+
if "btn_pad_h" in style: s.append(f"--c-btn-ph:{int(style['btn_pad_h'])}px")
|
| 359 |
+
if "icon_diam" in style: s.append(f"--c-icon-d:{int(style['icon_diam'])}px")
|
| 360 |
+
if "icon_img" in style: s.append(f"--c-icon-img:{int(style['icon_img'])}px")
|
| 361 |
+
if "icon_bg" in style: s.append(f"--c-icon-bg:{style['icon_bg']}")
|
| 362 |
+
if "icon_border" in style: s.append(f"--c-icon-border:{style['icon_border']}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 363 |
return "; ".join(s)
|
| 364 |
|
| 365 |
def app_card(card_cfg: Dict[str, Any]) -> str:
|