Spaces:
Sleeping
Sleeping
Use real QDB logo in login, top bar, and welcome screen
Browse files- app/core/auth.py +3 -2
- app/ui/_styles.py +37 -2
- app/ui/streamlit_app.py +5 -5
app/core/auth.py
CHANGED
|
@@ -74,10 +74,11 @@ def _login_screen(require_admin: bool) -> None:
|
|
| 74 |
)
|
| 75 |
st.stop()
|
| 76 |
|
|
|
|
| 77 |
st.markdown(
|
| 78 |
-
"""
|
| 79 |
<div class="qdb-login-hero">
|
| 80 |
-
<div
|
| 81 |
<div class="qdb-login-title">مؤسسة بنك تنمية المهارات</div>
|
| 82 |
<div class="qdb-login-subtitle">Qualification Development Bank</div>
|
| 83 |
<div style="margin-top: 1rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.15); font-size: 14px; color: rgba(255,255,255,0.9); font-weight: 500;">
|
|
|
|
| 74 |
)
|
| 75 |
st.stop()
|
| 76 |
|
| 77 |
+
from app.ui._styles import logo_html
|
| 78 |
st.markdown(
|
| 79 |
+
f"""
|
| 80 |
<div class="qdb-login-hero">
|
| 81 |
+
<div style="margin-bottom:1.5rem;">{logo_html(size_px=96, with_bg=True)}</div>
|
| 82 |
<div class="qdb-login-title">مؤسسة بنك تنمية المهارات</div>
|
| 83 |
<div class="qdb-login-subtitle">Qualification Development Bank</div>
|
| 84 |
<div style="margin-top: 1rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.15); font-size: 14px; color: rgba(255,255,255,0.9); font-weight: 500;">
|
app/ui/_styles.py
CHANGED
|
@@ -2,9 +2,25 @@
|
|
| 2 |
|
| 3 |
Importing `inject_styles()` once per page applies the full design system.
|
| 4 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
import streamlit as st
|
| 6 |
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
_CSS = """
|
| 9 |
<style>
|
| 10 |
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');
|
|
@@ -678,10 +694,16 @@ def inject_styles() -> None:
|
|
| 678 |
|
| 679 |
def brand_header() -> None:
|
| 680 |
"""Render the QDB sidebar brand block."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 681 |
st.markdown(
|
| 682 |
-
"""
|
| 683 |
<div class="qdb-brand">
|
| 684 |
-
|
| 685 |
<div>
|
| 686 |
<div class="qdb-brand-text">مساعد المعرفة</div>
|
| 687 |
<div class="qdb-brand-subtitle">مؤسسة بنك تنمية المهارات</div>
|
|
@@ -692,6 +714,19 @@ def brand_header() -> None:
|
|
| 692 |
)
|
| 693 |
|
| 694 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 695 |
def page_header(title: str, subtitle: str = "") -> None:
|
| 696 |
"""Render a styled page title + subtitle."""
|
| 697 |
st.markdown(
|
|
|
|
| 2 |
|
| 3 |
Importing `inject_styles()` once per page applies the full design system.
|
| 4 |
"""
|
| 5 |
+
import base64
|
| 6 |
+
from functools import lru_cache
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
import streamlit as st
|
| 10 |
|
| 11 |
|
| 12 |
+
_LOGO_PATH = Path(__file__).parent / "qdbank_logo.jpeg"
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
@lru_cache(maxsize=1)
|
| 16 |
+
def _logo_data_uri() -> str:
|
| 17 |
+
"""Load the QDB logo as a base64 data URI for inline HTML use."""
|
| 18 |
+
if not _LOGO_PATH.exists():
|
| 19 |
+
return ""
|
| 20 |
+
data = base64.b64encode(_LOGO_PATH.read_bytes()).decode()
|
| 21 |
+
return f"data:image/jpeg;base64,{data}"
|
| 22 |
+
|
| 23 |
+
|
| 24 |
_CSS = """
|
| 25 |
<style>
|
| 26 |
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');
|
|
|
|
| 694 |
|
| 695 |
def brand_header() -> None:
|
| 696 |
"""Render the QDB sidebar brand block."""
|
| 697 |
+
logo = _logo_data_uri()
|
| 698 |
+
logo_html = (
|
| 699 |
+
f'<img src="{logo}" alt="QDB" style="width:44px; height:44px; '
|
| 700 |
+
f'background:white; border-radius:10px; padding:4px; object-fit:contain;" />'
|
| 701 |
+
if logo else '<div class="qdb-brand-logo">QDB</div>'
|
| 702 |
+
)
|
| 703 |
st.markdown(
|
| 704 |
+
f"""
|
| 705 |
<div class="qdb-brand">
|
| 706 |
+
{logo_html}
|
| 707 |
<div>
|
| 708 |
<div class="qdb-brand-text">مساعد المعرفة</div>
|
| 709 |
<div class="qdb-brand-subtitle">مؤسسة بنك تنمية المهارات</div>
|
|
|
|
| 714 |
)
|
| 715 |
|
| 716 |
|
| 717 |
+
def logo_html(size_px: int = 64, with_bg: bool = True) -> str:
|
| 718 |
+
"""Reusable HTML snippet rendering the official QDB logo at a given size."""
|
| 719 |
+
logo = _logo_data_uri()
|
| 720 |
+
if not logo:
|
| 721 |
+
return f'<div class="qdb-brand-logo" style="width:{size_px}px;height:{size_px}px;font-size:{int(size_px*0.4)}px;">QDB</div>'
|
| 722 |
+
bg = "background:white; padding:8px;" if with_bg else ""
|
| 723 |
+
return (
|
| 724 |
+
f'<img src="{logo}" alt="QDB" '
|
| 725 |
+
f'style="width:{size_px}px; height:{size_px}px; {bg} '
|
| 726 |
+
f'border-radius:{int(size_px*0.22)}px; object-fit:contain; box-shadow:0 4px 12px rgba(0,0,0,0.08);" />'
|
| 727 |
+
)
|
| 728 |
+
|
| 729 |
+
|
| 730 |
def page_header(title: str, subtitle: str = "") -> None:
|
| 731 |
"""Render a styled page title + subtitle."""
|
| 732 |
st.markdown(
|
app/ui/streamlit_app.py
CHANGED
|
@@ -14,7 +14,7 @@ import streamlit as st
|
|
| 14 |
from app.core.auth import logout, require_login
|
| 15 |
from app.rag.generator import answer_question
|
| 16 |
from app.rag.retriever import list_sources
|
| 17 |
-
from app.ui._styles import citation_block, inject_styles
|
| 18 |
|
| 19 |
|
| 20 |
st.set_page_config(
|
|
@@ -56,7 +56,7 @@ def _render_top_bar(user) -> None:
|
|
| 56 |
f"""
|
| 57 |
<div class="qdb-topbar">
|
| 58 |
<div class="qdb-topbar-brand">
|
| 59 |
-
|
| 60 |
<div>
|
| 61 |
<div class="qdb-topbar-title">مساعد المعرفة</div>
|
| 62 |
<div class="qdb-topbar-sub">مؤسسة بنك تنمية المهارات</div>
|
|
@@ -115,10 +115,10 @@ def _render_sidebar(user) -> None:
|
|
| 115 |
def _render_welcome() -> None:
|
| 116 |
"""Centered welcome screen — ChatGPT style."""
|
| 117 |
st.markdown(
|
| 118 |
-
"""
|
| 119 |
<div class="qdb-welcome">
|
| 120 |
-
|
| 121 |
-
<div class="qdb-welcome-title">كيف يمكنني مساعدتك اليوم؟</div>
|
| 122 |
<div class="qdb-welcome-sub">اسأل عن أي سياسة أو إجراء في مراجع المؤسسة</div>
|
| 123 |
</div>
|
| 124 |
""",
|
|
|
|
| 14 |
from app.core.auth import logout, require_login
|
| 15 |
from app.rag.generator import answer_question
|
| 16 |
from app.rag.retriever import list_sources
|
| 17 |
+
from app.ui._styles import citation_block, inject_styles, logo_html
|
| 18 |
|
| 19 |
|
| 20 |
st.set_page_config(
|
|
|
|
| 56 |
f"""
|
| 57 |
<div class="qdb-topbar">
|
| 58 |
<div class="qdb-topbar-brand">
|
| 59 |
+
{logo_html(size_px=40, with_bg=False)}
|
| 60 |
<div>
|
| 61 |
<div class="qdb-topbar-title">مساعد المعرفة</div>
|
| 62 |
<div class="qdb-topbar-sub">مؤسسة بنك تنمية المهارات</div>
|
|
|
|
| 115 |
def _render_welcome() -> None:
|
| 116 |
"""Centered welcome screen — ChatGPT style."""
|
| 117 |
st.markdown(
|
| 118 |
+
f"""
|
| 119 |
<div class="qdb-welcome">
|
| 120 |
+
{logo_html(size_px=80, with_bg=False)}
|
| 121 |
+
<div class="qdb-welcome-title" style="margin-top:1.5rem;">كيف يمكنني مساعدتك اليوم؟</div>
|
| 122 |
<div class="qdb-welcome-sub">اسأل عن أي سياسة أو إجراء في مراجع المؤسسة</div>
|
| 123 |
</div>
|
| 124 |
""",
|