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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# dashboard_theme/theme.py
|
| 2 |
+
# ๋ค์ค ํ๋ ํธ ์ง์ (๊ธฐ๋ณธ: NavyรAmber / ๋์: ObsidianรCyan / GraphiteรWarm Orange)
|
| 3 |
+
import streamlit as st
|
| 4 |
+
|
| 5 |
+
PALETTES = {
|
| 6 |
+
# 1) ๊ธฐ์กด ๋ค์ด๋น ร ์ฐ๋ฒ
|
| 7 |
+
"navy_amber": {
|
| 8 |
+
"bg": "#0B1220",
|
| 9 |
+
"panel": "#0F1B2D",
|
| 10 |
+
"panel2": "#0B1627",
|
| 11 |
+
"border": "rgba(255,255,255,.06)",
|
| 12 |
+
"shadow": "0 12px 28px rgba(0,0,0,.40)",
|
| 13 |
+
"text": "#FFFFFF",
|
| 14 |
+
"muted": "#9FB1C5",
|
| 15 |
+
"accent": "#F59E0B",
|
| 16 |
+
"accent_soft": "rgba(245,158,11,.12)",
|
| 17 |
+
"disabled_bg": "#2A2F3A",
|
| 18 |
+
"disabled_fg": "#E0E6ED",
|
| 19 |
+
"placeholder": "rgba(255,255,255,.9)",
|
| 20 |
+
"sidebar_bg": "#0C1828",
|
| 21 |
+
"radio_bg": "#0E1A2B",
|
| 22 |
+
"radio_hover": "#112642",
|
| 23 |
+
},
|
| 24 |
+
# 2) ์ค๋ธ์๋์ธ ร ์์
|
| 25 |
+
"obsidian_cyan": {
|
| 26 |
+
"bg": "#0B0F14",
|
| 27 |
+
"panel": "#0F1720",
|
| 28 |
+
"panel2": "#0B131C",
|
| 29 |
+
"border": "rgba(255,255,255,.08)",
|
| 30 |
+
"shadow": "0 16px 32px rgba(0,0,0,.55)",
|
| 31 |
+
"text": "#F8FAFC",
|
| 32 |
+
"muted": "#A7C4D6",
|
| 33 |
+
"accent": "#22D3EE",
|
| 34 |
+
"accent_soft": "rgba(34,211,238,.14)",
|
| 35 |
+
"disabled_bg": "#26313A",
|
| 36 |
+
"disabled_fg": "#E6F6FA",
|
| 37 |
+
"placeholder": "rgba(240,249,255,.92)",
|
| 38 |
+
"sidebar_bg": "#0F141A",
|
| 39 |
+
"radio_bg": "#0F1720",
|
| 40 |
+
"radio_hover": "#13202B",
|
| 41 |
+
},
|
| 42 |
+
# 3) Graphite ร Warm Orange (Simulation ํ์ด์ง ํค๊ณผ ์ผ์น)
|
| 43 |
+
"graphite_gold": {
|
| 44 |
+
"bg": "#2F3136", # ์ ์ฒด ๋ฐฐ๊ฒฝ(์ง์ ๊ทธ๋ ์ด)
|
| 45 |
+
"panel": "#3B3E44", # ์นด๋/ํจ๋
|
| 46 |
+
"panel2": "#2B2D31", # ํ/๋ณด์กฐ
|
| 47 |
+
"border": "rgba(255,255,255,.10)",
|
| 48 |
+
"shadow": "0 16px 40px rgba(0,0,0,.45)",
|
| 49 |
+
"text": "#F6F7F9",
|
| 50 |
+
"muted": "#C9CDD2",
|
| 51 |
+
"accent": "#F59E0B", # ๋ฐ๋ปํ ์ฃผํฉ(๋๋ถ์ฌ ์ ์)
|
| 52 |
+
"accent_soft": "rgba(245,158,11,.18)",
|
| 53 |
+
"disabled_bg": "#4A4E55",
|
| 54 |
+
"disabled_fg": "#F1F3F6",
|
| 55 |
+
"placeholder": "rgba(250,250,252,.85)",
|
| 56 |
+
"sidebar_bg": "#3A3D42",
|
| 57 |
+
"radio_bg": "#3B3E44",
|
| 58 |
+
"radio_hover": "#454950",
|
| 59 |
+
},
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
def setup_page():
|
| 63 |
+
st.set_page_config(page_title="์๋ฎฌ๋ ์ด์
", layout="wide", initial_sidebar_state="expanded")
|
| 64 |
+
|
| 65 |
+
def _css_template(c):
|
| 66 |
+
return f"""
|
| 67 |
+
<style>
|
| 68 |
+
@font-face {{
|
| 69 |
+
font-family:'Pretendard';
|
| 70 |
+
src:url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.woff2') format('woff2');
|
| 71 |
+
font-weight:100 900; font-style:normal; font-display:swap;
|
| 72 |
+
}}
|
| 73 |
+
html, body, [class*="css"] {{
|
| 74 |
+
font-family:Pretendard, Inter, system-ui, -apple-system, Segoe UI, Roboto, Noto Sans KR, Apple SD Gothic Neo, sans-serif;
|
| 75 |
+
}}
|
| 76 |
+
|
| 77 |
+
:root{{
|
| 78 |
+
--bg:{c['bg']};
|
| 79 |
+
--panel:{c['panel']};
|
| 80 |
+
--panel-2:{c['panel2']};
|
| 81 |
+
--border:{c['border']};
|
| 82 |
+
--shadow:{c['shadow']};
|
| 83 |
+
--text:{c['text']};
|
| 84 |
+
--muted:{c['muted']};
|
| 85 |
+
--accent:{c['accent']};
|
| 86 |
+
--accent-soft:{c['accent_soft']};
|
| 87 |
+
}}
|
| 88 |
+
|
| 89 |
+
html, body, .stApp, .stAppViewContainer, [data-testid="stAppViewContainer"]{{ background:var(--bg)!important; color:var(--text)!important; }}
|
| 90 |
+
[data-testid="stHeader"]{{ background:transparent!important; }}
|
| 91 |
+
section.main{{ background:transparent!important; }}
|
| 92 |
+
|
| 93 |
+
/* ์ฌ์ด๋๋ฐ */
|
| 94 |
+
section[data-testid="stSidebar"]{{ background:{c['sidebar_bg']}!important; border-right:1px solid var(--border)!important; }}
|
| 95 |
+
section[data-testid="stSidebar"] *{{ color:var(--text)!important; }}
|
| 96 |
+
section[data-testid="stSidebar"] .stMarkdown{{ color:var(--muted)!important; }}
|
| 97 |
+
|
| 98 |
+
/* ๋ผ๋์ค/ํ ๊ธํ */
|
| 99 |
+
div[role="radiogroup"] > label{{
|
| 100 |
+
border:1px solid var(--border)!important; border-radius:12px!important;
|
| 101 |
+
padding:10px 14px!important; margin-right:8px!important; background:{c['radio_bg']}!important;
|
| 102 |
+
cursor:pointer; font-weight:800; color:var(--text)!important;
|
| 103 |
+
transition:transform .08s ease, background .2s ease, box-shadow .2s ease, filter .2s ease;
|
| 104 |
+
}}
|
| 105 |
+
div[role="radiogroup"] input{{ display:none!important; }}
|
| 106 |
+
div[role="radiogroup"] > label:hover{{ background:{c['radio_hover']}!important; transform:translateY(-1px); }}
|
| 107 |
+
div[role="radiogroup"] > label[data-checked="true"]{{
|
| 108 |
+
color:#1b1b1b!important; background:var(--accent)!important; border-color:var(--accent)!important;
|
| 109 |
+
box-shadow:0 8px 22px rgba(0,0,0,.18), 0 6px 18px color-mix(in oklab, var(--accent) 30%, transparent)!important;
|
| 110 |
+
}}
|
| 111 |
+
|
| 112 |
+
/* Expander */
|
| 113 |
+
div[data-testid="stExpander"] > details{{ padding:0; border:none; background:transparent; }}
|
| 114 |
+
div[data-testid="stExpander"] > details > summary{{
|
| 115 |
+
list-style:none; height:44px; line-height:44px;
|
| 116 |
+
background:linear-gradient(180deg,var(--panel) 0%, var(--panel-2) 100%)!important;
|
| 117 |
+
border:1px solid var(--border)!important; border-radius:12px!important; padding:0 14px!important;
|
| 118 |
+
display:flex; align-items:center; color:var(--text)!important; font-weight:900;
|
| 119 |
+
}}
|
| 120 |
+
div[data-testid="stExpander"] > details > div{{
|
| 121 |
+
margin-top:10px; padding:14px; border:1px solid var(--border)!important;
|
| 122 |
+
border-radius:12px; background:var(--panel-2); box-shadow:var(--shadow);
|
| 123 |
+
}}
|
| 124 |
+
|
| 125 |
+
/* ์
๋ ฅ ์ปดํฌ๋ํธ */
|
| 126 |
+
div[data-baseweb="select"] > div{{ border:1.6px solid var(--border)!important; border-radius:12px!important; background:var(--panel-2)!important; color:var(--text)!important; }}
|
| 127 |
+
div[data-testid="stNumberInput"] > div{{ border:1.6px solid var(--border)!important; border-radius:12px!important; background:var(--panel-2)!important; }}
|
| 128 |
+
div[data-testid="stNumberInput"] input{{ background:var(--panel-2)!important; color:var(--text)!important; border:none!important; }}
|
| 129 |
+
div[data-testid="stTextInput"] input, div[data-testid="stTextArea"] textarea{{
|
| 130 |
+
background:var(--panel-2)!important; color:var(--text)!important; border:1.6px solid var(--border)!important; border-radius:12px!important;
|
| 131 |
+
}}
|
| 132 |
+
:where(input,textarea,select):focus{{
|
| 133 |
+
outline:2px solid color-mix(in oklab, var(--accent) 48%, transparent)!important;
|
| 134 |
+
box-shadow:0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent)!important;
|
| 135 |
+
}}
|
| 136 |
+
|
| 137 |
+
/* ๋ฒํผ - ๊ธฐ๋ณธ(๊ฐ์กฐ) */
|
| 138 |
+
.stButton > button{{
|
| 139 |
+
background:var(--accent)!important; border:1px solid var(--accent)!important;
|
| 140 |
+
color:#1b1b1b!important; font-weight:1000!important; border-radius:14px!important; padding:10px 16px!important;
|
| 141 |
+
box-shadow:0 8px 18px rgba(0,0,0,.22), 0 8px 18px color-mix(in oklab, var(--accent) 28%, transparent)!important;
|
| 142 |
+
transition:transform .06s ease, filter .2s ease, box-shadow .2s ease;
|
| 143 |
+
}}
|
| 144 |
+
.stButton > button:hover{{ filter:brightness(1.03)!important; transform:translateY(-1px)!important; }}
|
| 145 |
+
|
| 146 |
+
/* ๋ฒํผ - ๋นํ์ฑ/Secondary */
|
| 147 |
+
.stButton > button:disabled, .stButton > button[disabled]{{
|
| 148 |
+
background:{c['disabled_bg']}!important; color:{c['disabled_fg']}!important;
|
| 149 |
+
border:1px solid var(--border)!important; font-weight:600!important; opacity:1!important;
|
| 150 |
+
}}
|
| 151 |
+
|
| 152 |
+
/* ํจ๋ */
|
| 153 |
+
.panel{{
|
| 154 |
+
border:1px solid var(--border)!important; border-radius:18px!important;
|
| 155 |
+
padding:18px 18px 14px!important;
|
| 156 |
+
background:linear-gradient(180deg,var(--panel) 0%, var(--panel-2) 100%)!important;
|
| 157 |
+
box-shadow:var(--shadow)!important; margin:10px 0 22px!important; backdrop-filter:blur(6px);
|
| 158 |
+
}}
|
| 159 |
+
.panel-title{{ font-weight:1000!important; color:var(--text)!important; margin:0 0 10px 2px!important; font-size:18px!important; }}
|
| 160 |
+
|
| 161 |
+
/* Metric ์นด๋ */
|
| 162 |
+
.metric{{
|
| 163 |
+
border:1px solid var(--border)!important; border-radius:18px!important;
|
| 164 |
+
background:linear-gradient(180deg,var(--panel) 0%, var(--panel-2) 100%)!important;
|
| 165 |
+
box-shadow:var(--shadow)!important; padding:22px!important; min-height:164px!important;
|
| 166 |
+
display:flex; flex-direction:column; justify-content:center;
|
| 167 |
+
}}
|
| 168 |
+
.metric .label{{ font-weight:900; color:var(--muted); font-size:14px; }}
|
| 169 |
+
.metric .value{{ font-size:46px; font-weight:1000; color:var(--accent); margin:6px 0 8px; }}
|
| 170 |
+
.metric .chip{{
|
| 171 |
+
display:inline-block; padding:5px 12px; border-radius:999px; font-weight:1000; font-size:12px;
|
| 172 |
+
background:var(--accent-soft); color:var(--accent);
|
| 173 |
+
border:1px solid color-mix(in oklab, var(--accent) 26%, transparent);
|
| 174 |
+
}}
|
| 175 |
+
.metric.ok .chip{{ background:rgba(34,197,94,.16); color:#A9F0BF; }}
|
| 176 |
+
.metric.bad .chip{{ background:rgba(239,68,68,.16); color:#F7B4B4; }}
|
| 177 |
+
.metric .range{{ color:#E8EEF8; font-size:15px; font-weight:800; }}
|
| 178 |
+
|
| 179 |
+
/* DataFrame */
|
| 180 |
+
[data-testid="stDataFrame"] thead th{{ background:var(--panel)!important; color:var(--text)!important; border-bottom:1px solid var(--border)!important; }}
|
| 181 |
+
[data-testid="stDataFrame"] tbody td{{ background:var(--panel-2)!important; color:var(--text)!important; }}
|
| 182 |
+
[data-testid="stDataFrame"] tbody tr:nth-child(even) td{{ background:color-mix(in oklab, var(--panel-2) 90%, black)!important; }}
|
| 183 |
+
|
| 184 |
+
/* ๊ตฌ๋ถ์ /์บก์
/๋ฐฐ์ง */
|
| 185 |
+
hr, .stDivider{{ border-color:var(--border)!important; }}
|
| 186 |
+
small, .stCaption{{ color:var(--muted)!important; }}
|
| 187 |
+
.badge{{
|
| 188 |
+
display:inline-block; padding:4px 10px; border-radius:999px; font-size:12px; font-weight:900;
|
| 189 |
+
border:1px solid var(--border); background:var(--panel); color:var(--text); margin-right:8px; margin-bottom:6px;
|
| 190 |
+
}}
|
| 191 |
+
.badge.em{{ background:var(--accent-soft); color:var(--accent); border-color:color-mix(in oklab, var(--accent) 28%, transparent); }}
|
| 192 |
+
.badge.ok{{ background:rgba(34,197,94,.16); color:#A9F0BF; }}
|
| 193 |
+
.badge.ng{{ background:rgba(239,68,68,.16); color:#F7B4B4; }}
|
| 194 |
+
|
| 195 |
+
/* ๋ผ๋ฒจ/ํ
์คํธ ๊ณ ์ ํจ์น */
|
| 196 |
+
[data-testid="stWidgetLabel"], [data-testid="stWidgetLabel"] *, label[data-testid="stWidgetLabel"], label[data-testid="stWidgetLabel"] *{{ color:var(--text)!important; opacity:1!important; }}
|
| 197 |
+
.stRadio label, .stRadio label *, div[role="radiogroup"] > label, div[role="radiogroup"] > label *{{ color:var(--text)!important; opacity:1!important; }}
|
| 198 |
+
.stCheckbox label, .stCheckbox label *, [data-testid="stCheckbox"] label, [data-testid="stCheckbox"] label *{{ color:var(--text)!important; opacity:1!important; }}
|
| 199 |
+
[data-baseweb="checkbox"] label, [data-baseweb="checkbox"] label *, [data-baseweb="radio"] label, [data-baseweb="radio"] label *{{ color:var(--text)!important; opacity:1!important; }}
|
| 200 |
+
[data-testid="stMarkdownContainer"], [data-testid="stMarkdownContainer"] *{{ color:var(--text)!important; opacity:1!important; }}
|
| 201 |
+
|
| 202 |
+
/* Tabs */
|
| 203 |
+
div[role="tablist"]{{ border-bottom:1px solid var(--border)!important; }}
|
| 204 |
+
div[role="tablist"] button{{ background:transparent!important; border:none!important; cursor:pointer!important; }}
|
| 205 |
+
div[role="tablist"] button[aria-selected="true"], div[role="tablist"] button[aria-selected="true"] span, div[role="tablist"] button[aria-selected="true"] p{{ color:var(--text)!important; }}
|
| 206 |
+
div[role="tablist"] button[aria-selected="false"], div[role="tablist"] button[aria-selected="false"] span, div[role="tablist"] button[aria-selected="false"] p{{ color:var(--muted)!important; }}
|
| 207 |
+
div[role="tablist"] button[aria-selected="true"]::after{{ content:""; display:block; margin-top:6px; border-bottom:2px solid var(--accent)!important; }}
|
| 208 |
+
div[role="tablist"] button:hover{{ filter:brightness(1.08)!important; }}
|
| 209 |
+
|
| 210 |
+
/* placeholder */
|
| 211 |
+
::placeholder{{ color:{c['placeholder']}!important; opacity:1!important; }}
|
| 212 |
+
|
| 213 |
+
/* ์ ๋ ฌ ๋ณด์ : ์บก์
& ์ต์คํฌ๋ */
|
| 214 |
+
.tight-block .stCaption, .tight-block small {{
|
| 215 |
+
margin-top: 0 !important;
|
| 216 |
+
display: block;
|
| 217 |
+
}}
|
| 218 |
+
.tight-block [data-testid="stExpander"] > details {{
|
| 219 |
+
margin-top: 6px !important;
|
| 220 |
+
}}
|
| 221 |
+
</style>
|
| 222 |
+
"""
|
| 223 |
+
|
| 224 |
+
def inject_css(palette: str = "navy_amber"):
|
| 225 |
+
c = PALETTES.get(palette, PALETTES["navy_amber"])
|
| 226 |
+
st.markdown(_css_template(c), unsafe_allow_html=True)
|
| 227 |
+
|
| 228 |
+
def inject(palette: str = "navy_amber"):
|
| 229 |
+
"""์) inject('graphite_gold')"""
|
| 230 |
+
setup_page()
|
| 231 |
+
inject_css(palette)
|
dashboard_theme/ui_theme.py
ADDED
|
@@ -0,0 +1,302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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ui_theme.py
|
| 2 |
+
import base64
|
| 3 |
+
import datetime
|
| 4 |
+
import streamlit as st
|
| 5 |
+
import streamlit.components.v1 as components
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
# ===== [1] ํ์ด์ง ๊ธฐ๋ณธ ์ธํ
=====
|
| 9 |
+
def set_page(
|
| 10 |
+
title: str = "AJIN Industrial Co., Ltd",
|
| 11 |
+
layout: str = "wide",
|
| 12 |
+
initial_sidebar_state: str = "expanded", # ๊ธฐ๋ณธ์ ์ด๋ฆผ. ํ ๊ธ์ ์ฌ์ฉ์ ์์
|
| 13 |
+
):
|
| 14 |
+
st.set_page_config(
|
| 15 |
+
page_title=title,
|
| 16 |
+
layout=layout,
|
| 17 |
+
initial_sidebar_state=initial_sidebar_state,
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
# ===== [2] ์ ํธ: ์ด๋ฏธ์ง โ base64 =====
|
| 21 |
+
def _img_to_base64(path: str) -> str:
|
| 22 |
+
with open(path, "rb") as f:
|
| 23 |
+
return base64.b64encode(f.read()).decode()
|
| 24 |
+
|
| 25 |
+
# ===== [3] ์ ์ญ CSS (์๋จ๋ฐ ์ ์ง, ์ฌ์ด๋๋ฐ ํญ ์ฐ๋, ๋ฐฐ๋/๋ณธ๋ฌธ ๋ฐ๋ฆผ) =====
|
| 26 |
+
def inject_global_css(
|
| 27 |
+
*,
|
| 28 |
+
banner_h: str = "72px",
|
| 29 |
+
header_h_default: str = "58px", # ์ด๊ธฐ ์ถ์ ๋์ด (JS๋ก ์ค์ ๊ฐ ๋๊ธฐํ)
|
| 30 |
+
navy_900: str = "#0a1424",
|
| 31 |
+
navy_800: str = "#101d33",
|
| 32 |
+
line: str = "#2a3a5a",
|
| 33 |
+
text: str = "#e9eef7",
|
| 34 |
+
muted: str = "#aeb7c6",
|
| 35 |
+
yellow: str = "#ffbd39",
|
| 36 |
+
green: str = "#69d06d",
|
| 37 |
+
red: str = "#ff5858",
|
| 38 |
+
hide_menu_footer: bool = False, # ๋ฉ๋ด/ํธํฐ ์จ๊น ์ฌ๋ถ (์ํ๋ฉด True)
|
| 39 |
+
):
|
| 40 |
+
st.markdown(
|
| 41 |
+
f"""
|
| 42 |
+
<style>
|
| 43 |
+
:root {{
|
| 44 |
+
--banner-h: {banner_h};
|
| 45 |
+
--st-header-h: {header_h_default}; /* JS๋ก ์ค์ ๋์ด ๋๊ธฐํ๋จ */
|
| 46 |
+
--ajin-navy-900: {navy_900};
|
| 47 |
+
--ajin-navy-800: {navy_800};
|
| 48 |
+
--ajin-line: {line};
|
| 49 |
+
--ajin-text: {text};
|
| 50 |
+
--ajin-muted: {muted};
|
| 51 |
+
--ajin-yellow: {yellow};
|
| 52 |
+
--ajin-green: {green};
|
| 53 |
+
--ajin-red: {red};
|
| 54 |
+
--sbw: 0px; /* ์ฌ์ด๋๋ฐ ์ค์ ๋๋น (JS๋ก ๋๊ธฐํ) */
|
| 55 |
+
}}
|
| 56 |
+
|
| 57 |
+
html, body, .stApp {{ margin:0 !important; }}
|
| 58 |
+
.stApp {{ background: var(--ajin-navy-900); }}
|
| 59 |
+
|
| 60 |
+
/* ์๋จ๋ฐ(ํค๋/ํด๋ฐ) ์ ์ง + ์ปฌ๋ฌ ์ปค์คํฐ๋ง์ด์ฆ */
|
| 61 |
+
header[data-testid="stHeader"] {{
|
| 62 |
+
background: var(--ajin-navy-800) !important;
|
| 63 |
+
border-bottom: 1px solid var(--ajin-line) !important;
|
| 64 |
+
box-shadow: none !important;
|
| 65 |
+
}}
|
| 66 |
+
header[data-testid="stHeader"] * {{ color: var(--ajin-text) !important; }}
|
| 67 |
+
[data-testid="stToolbar"] {{ background: transparent !important; }}
|
| 68 |
+
[data-testid="stToolbar"] svg {{ fill: var(--ajin-text) !important; color: var(--ajin-text) !important; }}
|
| 69 |
+
|
| 70 |
+
/* ๋ฐฐ๋: ์๋จ๋ฐ ๋์ด๋งํผ ์๋ + ์ฌ์ด๋๋ฐ ํญ๋งํผ ์ค๋ฅธ์ชฝ ๋ฐ๋ฆผ */
|
| 71 |
+
.fixed-banner {{
|
| 72 |
+
position: fixed;
|
| 73 |
+
top: var(--st-header-h);
|
| 74 |
+
left: var(--sbw);
|
| 75 |
+
width: calc(100% - var(--sbw));
|
| 76 |
+
z-index: 100000;
|
| 77 |
+
height: var(--banner-h);
|
| 78 |
+
display:flex; align-items:center;
|
| 79 |
+
background: var(--ajin-navy-800);
|
| 80 |
+
border-bottom: 1px solid var(--ajin-line);
|
| 81 |
+
padding: 0 18px;
|
| 82 |
+
}}
|
| 83 |
+
.fixed-banner .wrap {{ display:flex; align-items:center; gap:14px; width:100%; }}
|
| 84 |
+
.fixed-banner img.logo {{ height:46px; }}
|
| 85 |
+
.fixed-banner .title {{ color:var(--ajin-text); font-weight:800; font-size:20px; letter-spacing:.3px; }}
|
| 86 |
+
.fixed-banner .right {{ margin-left:auto; color:var(--ajin-muted); font-size:13px; font-weight:600; }}
|
| 87 |
+
|
| 88 |
+
/* ๋ณธ๋ฌธ: ์๋จ(ํค๋+๋ฐฐ๋) + ์ข์ธก(์ฌ์ด๋๋ฐ ํญ) ๋ณด์ */
|
| 89 |
+
.block-container {{
|
| 90 |
+
padding-top: calc(var(--st-header-h) + var(--banner-h) + 8px) !important;
|
| 91 |
+
padding-left: var(--sbw) !important;
|
| 92 |
+
}}
|
| 93 |
+
|
| 94 |
+
/* ์ฌ์ด๋๋ฐ ์ปฌ๋ฌ๋ง ํต์ผ */
|
| 95 |
+
[data-testid="stSidebar"] {{
|
| 96 |
+
background: linear-gradient(180deg, #0e1a30 0%, #0b1527 100%);
|
| 97 |
+
border-right:1px solid var(--ajin-line);
|
| 98 |
+
}}
|
| 99 |
+
[data-testid="stSidebar"] * {{ color: var(--ajin-text) !important; }}
|
| 100 |
+
|
| 101 |
+
/* ์นด๋ ํ๋ฆฌ์
(์ต์
) */
|
| 102 |
+
.card {{
|
| 103 |
+
border:1px solid var(--ajin-line); border-radius:16px;
|
| 104 |
+
background: var(--ajin-navy-800); padding:16px 18px; color:var(--ajin-text);
|
| 105 |
+
box-shadow: 0 8px 24px rgba(0,0,0,.25);
|
| 106 |
+
}}
|
| 107 |
+
.card h3 {{ margin:0 0 12px 0; font-size:18px; }}
|
| 108 |
+
|
| 109 |
+
/* ๋ฉ๋ด/ํธํฐ ํ์ ์ฌ๋ถ */
|
| 110 |
+
{ "#MainMenu {{visibility:hidden;}} footer {{visibility:hidden;}}" if hide_menu_footer else "" }
|
| 111 |
+
|
| 112 |
+
/* ํ ๋งํฌ(์ง ์์ด์ฝ) ํฌ๊ธฐ/์ฌ๋ฐฑ ์ด์ง ์ค์ด๊ธฐ */
|
| 113 |
+
[data-testid="stPageLink"] a {{
|
| 114 |
+
font-size: 13px;
|
| 115 |
+
padding: 6px 10px;
|
| 116 |
+
border-radius: 10px;
|
| 117 |
+
background: rgba(255,255,255,0.04);
|
| 118 |
+
border: 1px solid var(--ajin-line);
|
| 119 |
+
display: inline-flex;
|
| 120 |
+
align-items: center;
|
| 121 |
+
gap: 8px;
|
| 122 |
+
}}
|
| 123 |
+
|
| 124 |
+
/* ์ํ 4๋ฒํผ ๋ ์ด์์ & ๋ฒํผ ๋ชจ์ */
|
| 125 |
+
.sb-rounds {{
|
| 126 |
+
display: grid;
|
| 127 |
+
grid-template-columns: repeat(2, 1fr);
|
| 128 |
+
gap: 10px;
|
| 129 |
+
margin-top: 10px;
|
| 130 |
+
}}
|
| 131 |
+
/* page_link ์์๋ฅผ ๋๊ทธ๋ ๋ฒํผ์ฒ๋ผ ๋ณด์ด๋๋ก */
|
| 132 |
+
.sb-rounds [data-testid="stPageLink"] a {{
|
| 133 |
+
display: flex;
|
| 134 |
+
align-items: center;
|
| 135 |
+
justify-content: center;
|
| 136 |
+
height: 64px;
|
| 137 |
+
border-radius: 999px;
|
| 138 |
+
border: 1px solid var(--ajin-line);
|
| 139 |
+
background: rgba(255,255,255,0.06);
|
| 140 |
+
font-weight: 700;
|
| 141 |
+
font-size: 12px;
|
| 142 |
+
text-align: center;
|
| 143 |
+
padding: 0 8px; /* ๊ธด ๋ผ๋ฒจ ์ค๋ฐ๊ฟ ์ฌ์ */
|
| 144 |
+
line-height: 1.1;
|
| 145 |
+
}}
|
| 146 |
+
.sb-rounds [data-testid="stPageLink"] a:hover {{
|
| 147 |
+
background: rgba(255,255,255,0.12);
|
| 148 |
+
}}
|
| 149 |
+
</style>
|
| 150 |
+
""",
|
| 151 |
+
unsafe_allow_html=True,
|
| 152 |
+
)
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
# ===== [4] ๊ณ ์ ์๋จ ๋ฐฐ๋ =====
|
| 156 |
+
def render_fixed_banner(*, logo_path: str, title: str):
|
| 157 |
+
logo_b64 = _img_to_base64(logo_path)
|
| 158 |
+
now_txt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
|
| 159 |
+
st.markdown(
|
| 160 |
+
f"""
|
| 161 |
+
<div class="fixed-banner">
|
| 162 |
+
<div class="wrap">
|
| 163 |
+
<img class="logo" src="data:image/png;base64,{logo_b64}" />
|
| 164 |
+
<div class="title">{title}</div>
|
| 165 |
+
<div class="right">{now_txt}</div>
|
| 166 |
+
</div>
|
| 167 |
+
</div>
|
| 168 |
+
""",
|
| 169 |
+
unsafe_allow_html=True,
|
| 170 |
+
)
|
| 171 |
+
|
| 172 |
+
# ===== [5] ์ฌ์ด๋๋ฐ: ๋ ์งยท์๊ณ (ํ์) =====
|
| 173 |
+
def render_sidebar_clock(show_seconds: bool = False):
|
| 174 |
+
now = datetime.datetime.now()
|
| 175 |
+
time_fmt = "%H:%M:%S" if show_seconds else "%H:%M"
|
| 176 |
+
st.sidebar.markdown(
|
| 177 |
+
f"""
|
| 178 |
+
<div style="text-align:center; padding: 6px 8px 12px 8px; border-bottom:1px solid var(--ajin-line);">
|
| 179 |
+
<div style="font-size:18px; color:var(--ajin-muted); margin-bottom:4px;">{now.strftime("%Y.%m.%d (%a)")}</div>
|
| 180 |
+
<div style="font-size:76px; line-height:1.0; font-weight:800; color:#fff; text-shadow:0 2px 8px rgba(0,0,0,.25);">{now.strftime(time_fmt)}</div>
|
| 181 |
+
</div>
|
| 182 |
+
""",
|
| 183 |
+
unsafe_allow_html=True,
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
def enable_header_height_sync():
|
| 189 |
+
components.html(
|
| 190 |
+
"""
|
| 191 |
+
<script>
|
| 192 |
+
(function(){
|
| 193 |
+
const root = window.parent?.document?.documentElement || document.documentElement;
|
| 194 |
+
|
| 195 |
+
function syncHeader(){
|
| 196 |
+
const hdr = window.parent?.document?.querySelector('header[data-testid="stHeader"]');
|
| 197 |
+
if(!hdr) return;
|
| 198 |
+
root.style.setProperty('--st-header-h', (hdr.offsetHeight || 0) + 'px');
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
function init(){
|
| 202 |
+
const hdr = window.parent?.document?.querySelector('header[data-testid="stHeader"]');
|
| 203 |
+
if(hdr){
|
| 204 |
+
syncHeader();
|
| 205 |
+
new ResizeObserver(syncHeader).observe(hdr);
|
| 206 |
+
window.addEventListener('resize', syncHeader);
|
| 207 |
+
} else {
|
| 208 |
+
const poll = setInterval(()=>{
|
| 209 |
+
const h = window.parent?.document?.querySelector('header[data-testid="stHeader"]');
|
| 210 |
+
if(h){ clearInterval(poll); syncHeader(); new ResizeObserver(syncHeader).observe(h); }
|
| 211 |
+
}, 150);
|
| 212 |
+
}
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
init();
|
| 216 |
+
})();
|
| 217 |
+
</script>
|
| 218 |
+
""",
|
| 219 |
+
height=0,
|
| 220 |
+
)
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
def enable_sidebar_width_sync():
|
| 224 |
+
"""
|
| 225 |
+
์ฌ์ด๋๋ฐ์ '๋ณด์ด๋ ๋๋น'๋ฅผ ์ธก์ ํด CSS ๋ณ์ --sbw ์ ๋ฐ์.
|
| 226 |
+
์ด๋ฆผ/๋ซํ/๋ฐ์ํ ๋ณํ์ ๋ฐ๋ผ ๋ฐฐ๋์ ๋ณธ๋ฌธ์ด ๊ฐ์ด ๋ฐ๋ ค๋ฉ๋๋ค.
|
| 227 |
+
"""
|
| 228 |
+
components.html(
|
| 229 |
+
"""
|
| 230 |
+
<script>
|
| 231 |
+
(function(){
|
| 232 |
+
const root = window.parent?.document?.documentElement || document.documentElement;
|
| 233 |
+
|
| 234 |
+
function syncSidebar(){
|
| 235 |
+
const sb = window.parent?.document?.querySelector('[data-testid="stSidebar"]');
|
| 236 |
+
let w = 0;
|
| 237 |
+
if (sb){
|
| 238 |
+
const r = sb.getBoundingClientRect();
|
| 239 |
+
// ํ๋ฉด ๋ฐ(๋ซํ)์ด๋ ๊ฑฐ์ 0์ด๋ฉด 0 ์ฒ๋ฆฌ
|
| 240 |
+
w = (r.right <= 0 || r.width < 40) ? 0 : r.width;
|
| 241 |
+
}
|
| 242 |
+
root.style.setProperty('--sbw', w + 'px');
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
function init(){
|
| 246 |
+
syncSidebar();
|
| 247 |
+
const body = window.parent?.document?.body || document.body;
|
| 248 |
+
if (body){ new ResizeObserver(syncSidebar).observe(body); }
|
| 249 |
+
const sb = window.parent?.document?.querySelector('[data-testid="stSidebar"]');
|
| 250 |
+
if (sb){ new ResizeObserver(syncSidebar).observe(sb); }
|
| 251 |
+
window.addEventListener('resize', syncSidebar);
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
init();
|
| 255 |
+
})();
|
| 256 |
+
</script>
|
| 257 |
+
""",
|
| 258 |
+
height=0,
|
| 259 |
+
)
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
# def render_sidebar_main_button(main_script: str = "HOME.py",
|
| 263 |
+
# label: str = "Go to the main page"):
|
| 264 |
+
# """
|
| 265 |
+
# ์ฌ์ด๋๋ฐ์ ๋ฅ๊ทผ ์ง์ฌ๊ฐํ ๋ค๋น ๋ฒํผ์ ๋ ๋๋งํฉ๋๋ค.
|
| 266 |
+
# - main_script: ๋ฉ์ธ ํ์ด์ง ํ์ผ๋ช
(๋ฃจํธ์ ์๋ ์คํฌ๋ฆฝํธ)
|
| 267 |
+
# - label: ๋ฒํผ ๋ผ๋ฒจ
|
| 268 |
+
# """
|
| 269 |
+
# # ๋ฒํผ ์คํ์ผ (์ฌ์ด๋๋ฐ์๋ง ์ ์ฉ)
|
| 270 |
+
# st.sidebar.markdown("""
|
| 271 |
+
# <style>
|
| 272 |
+
# .sb-mainbtn [data-testid="stPageLink"] a {
|
| 273 |
+
# display: flex; align-items: center; justify-content: center;
|
| 274 |
+
# height: 48px; width: 100%;
|
| 275 |
+
# border-radius: 999px;
|
| 276 |
+
# border: 1px solid var(--ajin-line);
|
| 277 |
+
# background: rgba(255,255,255,0.06);
|
| 278 |
+
# color: var(--ajin-text) !important;
|
| 279 |
+
# font-weight: 800; font-size: 13px;
|
| 280 |
+
# text-decoration: none;
|
| 281 |
+
# }
|
| 282 |
+
# .sb-mainbtn [data-testid="stPageLink"] a:hover {
|
| 283 |
+
# background: rgba(255,255,255,0.12);
|
| 284 |
+
# }
|
| 285 |
+
# .sb-mainbtn { margin-top: 10px; margin-bottom: 10px; }
|
| 286 |
+
# </style>
|
| 287 |
+
# """, unsafe_allow_html=True)
|
| 288 |
+
|
| 289 |
+
# with st.sidebar:
|
| 290 |
+
# st.markdown('<div class="sb-mainbtn">', unsafe_allow_html=True)
|
| 291 |
+
# # ์์ด์ฝ ์์ด ํ
์คํธ๋ง ํ๊ธฐ (ํญ์ ๋ฉ์ธ์ผ๋ก ์ด๋)
|
| 292 |
+
# st.page_link(main_script, label=label)
|
| 293 |
+
# st.markdown('</div>', unsafe_allow_html=True)
|
| 294 |
+
|
| 295 |
+
def render_sidebar_nav():
|
| 296 |
+
with st.sidebar:
|
| 297 |
+
st.markdown('<div class="sb-rounds">', unsafe_allow_html=True)
|
| 298 |
+
st.page_link("pages/01_๋ผ์ธ๋ณ_๊ฐ๋_ํํฉ.py", label="๋ผ์ธ๋ณ ๊ฐ๋ ํํฉ")
|
| 299 |
+
st.page_link("pages/02_๋น๊ฐ๋_์ผ์ง.py", label="๋น๊ฐ๋ ์ผ์ง")
|
| 300 |
+
st.page_link("pages/03_์๋ฆฌ_์ด๋ ฅ.py", label="์๋ฆฌ ์ด๋ ฅ")
|
| 301 |
+
st.page_link("pages/04_์คํ์ด_ํํฉ_๋ฆฌํฌํธ.py", label="์คํ์ด ํํฉ ๋ฆฌํฌํธ")
|
| 302 |
+
st.markdown('</div>', unsafe_allow_html=True)
|