# ui_theme.py import base64 import datetime import streamlit as st import streamlit.components.v1 as components # ===== [1] 페이지 기본 세팅 ===== def set_page( title: str = "AJIN Industrial Co., Ltd", layout: str = "wide", initial_sidebar_state: str = "expanded", # 기본은 열림. 토글은 사용자 자유 ): st.set_page_config( page_title=title, layout=layout, initial_sidebar_state=initial_sidebar_state, ) # ===== [2] 유틸: 이미지 → base64 ===== def _img_to_base64(path: str) -> str: with open(path, "rb") as f: return base64.b64encode(f.read()).decode() # ===== [3] 전역 CSS (상단바 유지, 사이드바 폭 연동, 배너/본문 밀림) ===== def inject_global_css( *, banner_h: str = "72px", header_h_default: str = "58px", # 초기 추정 높이 (JS로 실제값 동기화) navy_900: str = "#0a1424", navy_800: str = "#101d33", line: str = "#2a3a5a", text: str = "#e9eef7", muted: str = "#aeb7c6", yellow: str = "#ffbd39", green: str = "#69d06d", red: str = "#ff5858", hide_menu_footer: bool = False, # 메뉴/푸터 숨김 여부 (원하면 True) ): st.markdown( f""" """, unsafe_allow_html=True, ) # ===== [4] 고정 상단 배너 ===== def render_fixed_banner(*, logo_path: str, title: str): logo_b64 = _img_to_base64(logo_path) now_txt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") st.markdown( f"""
{title}
{now_txt}
""", unsafe_allow_html=True, ) # ===== [5] 사이드바: 날짜·시계 (필수) ===== def render_sidebar_clock(show_seconds: bool = False): now = datetime.datetime.now() time_fmt = "%H:%M:%S" if show_seconds else "%H:%M" st.sidebar.markdown( f"""
{now.strftime("%Y.%m.%d (%a)")}
{now.strftime(time_fmt)}
""", unsafe_allow_html=True, ) def enable_header_height_sync(): components.html( """ """, height=0, ) def enable_sidebar_width_sync(): """ 사이드바의 '보이는 너비'를 측정해 CSS 변수 --sbw 에 반영. 열림/닫힘/반응형 변화에 따라 배너와 본문이 같이 밀려납니다. """ components.html( """ """, height=0, ) # def render_sidebar_main_button(main_script: str = "HOME.py", # label: str = "Go to the main page"): # """ # 사이드바에 둥근 직사각형 네비 버튼을 렌더링합니다. # - main_script: 메인 페이지 파일명 (루트에 있는 스크립트) # - label: 버튼 라벨 # """ # # 버튼 스타일 (사이드바에만 적용) # st.sidebar.markdown(""" # # """, unsafe_allow_html=True) # with st.sidebar: # st.markdown('
', unsafe_allow_html=True) # # 아이콘 없이 텍스트만 표기 (항상 메인으로 이동) # st.page_link(main_script, label=label) # st.markdown('
', unsafe_allow_html=True) def render_sidebar_nav(): with st.sidebar: st.markdown('
', unsafe_allow_html=True) st.page_link("pages/01_라인별_가동_현황.py", label="라인별 가동 현황") st.page_link("pages/02_비가동_일지.py", label="비가동 일지") st.page_link("pages/03_수리_이력.py", label="수리 이력") st.page_link("pages/04_스페어_현황_리포트.py", label="스페어 현황 리포트") st.markdown('
', unsafe_allow_html=True)