aileen3-core / demo /layout.py
ndurner's picture
add comments
0c163b8
from __future__ import annotations
from contextlib import contextmanager
import gradio as gr
# Shared CSS used by all "cells" in the notebook-style demo.
CELL_CSS = """
.cell-wrapper {
border: 1px solid rgba(0, 0, 0, 0.9);
border-radius: 14px;
padding: 10px;
margin-bottom: 10px;
background: transparent;
}
.cell-title {
font-size: 1.15rem;
font-weight: 600;
margin: 0 0 10px;
}
.health-box {
border-radius: 14px;
padding: 18px;
border: 1px solid transparent;
}
.health-success {
background: #dcfce7;
border-color: #86efac;
color: #14532d;
}
.health-fail {
background: #fee2e2;
border-color: #fecaca;
color: #7f1d1d;
}
.health-box ul {
margin: 12px 0 0;
padding-left: 22px;
}
.health-box li {
margin-bottom: 6px;
}
.health-placeholder {
background: #f5f5f5 !important;
border-color: #d4d4d4 !important;
color: #1f2937 !important;
}
@media (prefers-color-scheme: dark) {
.cell-wrapper {
border-color: rgba(255, 255, 255, 0.45);
}
.health-success {
background: rgba(74, 222, 128, 0.12);
border-color: rgba(74, 222, 128, 0.55);
color: #ecfdf3;
}
.health-fail {
background: rgba(248, 113, 113, 0.12);
border-color: rgba(248, 113, 113, 0.6);
color: #fee2e2;
}
.health-placeholder {
background: rgba(148, 163, 184, 0.15) !important;
border-color: rgba(148, 163, 184, 0.4) !important;
color: #e2e8f0 !important;
}
}
"""
@contextmanager
def cell(title: str):
"""Context manager that renders a titled notebook-style cell.
Usage:
with cell("My title"):
... # add components that appear inside the cell
"""
with gr.Column(elem_classes="cell-wrapper") as column:
gr.HTML(f"<div class='cell-title'>{title}</div>")
yield column