chatbot / src /brand.py
SuhasGholkar's picture
Update src/brand.py
3f43c7a verified
Raw History Blame Contribute Delete
11.8 kB
# src/brand.py
from __future__ import annotations
import streamlit as st
from string import Template
# Brand palette
PRIMARY = "#2563EB" # Indigo 600
PRIMARY_DARK = "#1E40AF" # Indigo 800
PRIMARY_700 = "#1B2F7A"
SUCCESS = "#10B981" # Emerald 500
WARNING = "#F59E0B" # Amber 500
DANGER = "#DC2626" # Red 600
TEXT = "#111827" # Gray 900
MUTED = "#6B7280" # Gray 500
PAGE_BG = "#F7F8FB"
CARD_BG = "#FFFFFF"
CARD_BORDER = "#E7E9F1"
# src/brand.py
import streamlit as st
def inject_brand_css():
st.markdown("""
<style>
/* ================================
BRAND TOKENS (Enterprise Blue)
================================= */
:root{
--brand-bg: #F8FAFC; /* page base */
--brand-surface: #FFFFFF; /* cards/panels */
--brand-surface-2: #F1F5F9; /* muted blocks */
--brand-text: #0F172A; /* Slate-900 */
--brand-text-2: #334155; /* Slate-700 */
--brand-primary: #1E3A8A; /* Indigo-900 (brand) */
--brand-primary-2: #1D4ED8; /* Indigo-600 (action) */
--brand-primary-3: #3B82F6; /* Blue-500 (hover/focus) */
--brand-border: #E2E8F0; /* Slate-200 */
--brand-accent: #0EA5E9; /* Cyan-500 (badges/links) */
--brand-success: #10B981; /* Green-500 */
--brand-warn: #F59E0B; /* Amber-500 */
--brand-error: #EF4444; /* Red-500 */
--radius-lg: 12px;
--radius-md: 10px;
--radius-sm: 8px;
--shadow-1: 0 2px 10px rgba(15,23,42,.05);
--shadow-2: 0 8px 30px rgba(15,23,42,.08);
}
/* Page base */
html, body, [data-testid="stAppViewContainer"]{
background: var(--brand-bg) !important;
color: var(--brand-text);
}
/* ================================
TYPOGRAPHY & HEADINGS
================================= */
h1, .stMarkdown h1{
font-size: 2.0rem !important;
font-weight: 800 !important;
color: var(--brand-text);
letter-spacing: .2px;
}
h2, .stMarkdown h2{
font-size: 1.4rem !important;
font-weight: 700 !important;
color: var(--brand-text);
}
h3, .stMarkdown h3{
font-size: 1.1rem !important;
font-weight: 700 !important;
color: var(--brand-text);
}
/* Small mute */
small, .stCaption, .stMarkdown p small{
color: var(--brand-text-2) !important;
}
/* ================================
CARDS (generic wrapper utility)
================================= */
.app-card{
background: var(--brand-surface);
border: 1px solid var(--brand-border);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-1);
padding: 16px;
}
.app-card.soft{
background: var(--brand-surface-2);
}
/* Streamlit native bordered containers */
[data-testid="stVerticalBlock"] > [data-testid="stVerticalBlock"] > div[style*="border: 1px"]{
border-radius: var(--radius-lg) !important;
box-shadow: var(--shadow-1) !important;
border-color: var(--brand-border) !important;
}
/* ================================
INPUTS & SELECTS
================================= */
input, textarea, select{
border-radius: var(--radius-md) !important;
border: 1px solid var(--brand-border) !important;
background: var(--brand-surface) !important;
color: var(--brand-text) !important;
box-shadow: none !important;
}
input:focus, textarea:focus, select:focus{
outline: 2px solid var(--brand-primary-3) !important;
border-color: var(--brand-primary-3) !important;
}
/* Label color */
label, .stCheckbox, .stRadio{
color: var(--brand-text-2) !important;
font-weight: 500;
}
/* ================================
BUTTONS
================================= */
[data-testid="stButton"] > button{
border-radius: var(--radius-md) !important;
border: 1px solid var(--brand-primary-2) !important;
background: var(--brand-primary-2) !important;
color: #fff !important;
padding: .6rem 1.1rem !important;
box-shadow: var(--shadow-1) !important;
}
[data-testid="stButton"] > button:hover{
background: var(--brand-primary-3) !important;
border-color: var(--brand-primary-3) !important;
}
/* Secondary/link buttons */
[data-testid="stButton"] > button[kind="secondary"]{
background: transparent !important;
color: var(--brand-primary-2) !important;
border: 1px solid var(--brand-primary-2) !important;
}
[data-testid="stButton"] > button[kind="secondary"]:hover{
background: rgba(59,130,246,.08) !important;
}
/* ================================
TABS
================================= */
.stTabs [role="tablist"]{
border-bottom: 1px solid var(--brand-border) !important;
}
.stTabs [role="tab"]{
padding: .6rem 1rem !important;
color: var(--brand-text-2) !important;
font-weight: 600 !important;
border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important;
}
.stTabs [aria-selected="true"]{
color: var(--brand-primary) !important;
border-bottom: 3px solid var(--brand-primary) !important;
}
/* ================================
TABLES
================================= */
.stDataFrame, .stTable{
border-radius: var(--radius-lg) !important;
border: 1px solid var(--brand-border) !important;
box-shadow: var(--shadow-1) !important;
}
.stDataFrame table thead th{
background: var(--brand-surface-2) !important;
color: var(--brand-text) !important;
font-weight: 700 !important;
}
/* ================================
CHAT BUBBLES
================================= */
.msg-user{
background: #E0EAFF; /* softened indigo */
border: 1px solid #CAD8FF;
color: var(--brand-text);
border-radius: var(--radius-lg);
padding: .9rem 1rem;
box-shadow: var(--shadow-1);
}
.msg-bot{
background: #E9FBF3; /* soft green */
border: 1px solid #C6F4DF;
color: var(--brand-text);
border-radius: var(--radius-lg);
padding: .9rem 1rem;
box-shadow: var(--shadow-1);
}
.msg-meta{
font-size: .78rem;
color: var(--brand-text-2);
}
/* Analysis panel */
.analysis-card{
background: var(--brand-surface) !important;
border: 1px solid var(--brand-border) !important;
border-left: 4px solid var(--brand-primary) !important;
border-radius: var(--radius-lg) !important;
padding: 12px 16px !important;
box-shadow: var(--shadow-1) !important;
}
/* ================================
LINKS
================================= */
a{
color: var(--brand-accent) !important;
}
a:hover{
color: var(--brand-primary-3) !important;
text-decoration: underline;
}
/* ================================
SIDEBAR
================================= */
[data-testid="stSidebar"]{
background: var(--brand-surface) !important;
border-right: 1px solid var(--brand-border) !important;
}
</style>
""", unsafe_allow_html=True)
def page_header(title: str, subtitle: str | None = None, icon: str | None = None) -> None:
ico = f"<span style='font-size:26px;margin-right:8px'>{icon}</span>" if icon else ""
sub = f"<div style='color:var(--brand-muted);margin-top:4px'>{subtitle}</div>" if subtitle else ""
st.markdown(
f"<div style='margin-bottom:10px'><div style='font-weight:800;font-size:26px'>{ico}{title}</div>{sub}</div>",
unsafe_allow_html=True,
)
def card_start() -> None:
st.markdown("<div class='card'>", unsafe_allow_html=True)
def card_end() -> None:
st.markdown("</div>", unsafe_allow_html=True)
# src/brand.py
import streamlit as st
def inject_enterprise_chat_css():
st.markdown(
"""
<style>
:root{
--bg-app: #f5f7fb; /* light app background */
--bg-card: #ffffff; /* cards / bubbles */
--bg-customer: #eaf1ff; /* customer bubble */
--bg-agent: #e8fff2; /* agent bubble */
--border: #e2e8f0; /* light borders */
--ink: #0f172a; /* primary text */
--ink-muted:#4b5563; /* secondary text */
--primary:#2563eb; /* accents */
--success:#059669;
--warning:#b45309;
--neutral:#64748b;
--shadow: 0 6px 20px rgba(15, 23, 42, .06);
--radius: 14px;
}
/* App background */
.stApp, .stApp > header, .stApp > div[data-testid="stSidebar"] + section {
background: var(--bg-app) !important;
}
/* Make the main block full-width feeling on light bg */
section.main > div.block-container{
padding-top: 1.4rem;
}
/* Titles */
h1, h2, h3, h4, h5, h6, .stMarkdown, .stText, .stHeader {
color: var(--ink) !important;
}
/* Inputs (text, select, checkbox label) */
label, .stTextInput label, .stCheckbox label{
color: var(--ink-muted) !important;
font-weight: 600;
}
.stTextInput textarea, .stTextInput input{
background: #fff !important;
border: 1px solid var(--border) !important;
color: var(--ink) !important;
border-radius: 10px !important;
}
/* Button */
.stButton button{
background: var(--primary) !important;
color: #fff !important;
border: none !important;
border-radius: 10px !important;
box-shadow: var(--shadow);
}
.stButton button:hover{
filter: brightness(0.95);
}
/* Generic card */
.card.soft{
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 14px 16px;
box-shadow: var(--shadow);
margin: 10px 0 16px 0;
}
.card.soft .card-title{
font-weight: 800; color: var(--ink-muted); margin-bottom: 8px;
}
/* Chat bubbles */
.chat-bubble{
border-radius: var(--radius);
padding: 14px 16px;
border: 1px solid var(--border);
box-shadow: var(--shadow);
margin: 6px 0 18px 0;
line-height: 1.5;
color: var(--ink);
background: var(--bg-card);
}
.chat-bubble.customer{ background: var(--bg-customer); }
.chat-bubble.agent{ background: var(--bg-agent); }
.chat-meta{
display:block;
font-size: 12px;
color: var(--ink-muted);
margin-bottom: 6px;
}
/* Conversation stack spacing */
.stack > div.msg{ margin: 6px 0 10px 0; }
.msg.user{ background: var(--bg-customer); }
.msg.bot{ background: var(--bg-agent); }
.msg{
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 12px 14px;
box-shadow: var(--shadow);
}
.msg .meta{
display:block; font-size:12px; color:var(--ink-muted); margin-bottom:6px;
}
/* Badges */
.badge{
display:inline-block; padding:2px 8px; border-radius:999px;
font-size: 12px; font-weight:700; border:1px solid var(--border);
background:#fff; color:var(--ink-muted); margin-left:6px;
}
.badge.ok{ color: var(--success); border-color: #bbf7d0; background:#ecfdf5; }
.badge.intent{ color: var(--primary); border-color: #bfdbfe; background:#eff6ff; }
.badge.neutral{ color: var(--neutral); background:#f1f5f9; }
.badge.slow{ color: var(--warning); background:#fffbeb; border-color:#fde68a; }
/* DataFrames on light bg */
div[data-testid="stDataFrame"]{
border: 1px solid var(--border);
border-radius: 10px;
box-shadow: var(--shadow);
background: #fff;
}
/* Section title */
.section-title{
margin-top: 12px; margin-bottom: 6px;
font-weight: 800; color: var(--ink);
}
</style>
""",
unsafe_allow_html=True,
)