feat(admin): sidebar shell and design tokens
This commit is contained in:
+151
-53
@@ -4,18 +4,34 @@ interface Props {
|
|||||||
}
|
}
|
||||||
const { title } = Astro.props;
|
const { title } = Astro.props;
|
||||||
const path = Astro.url.pathname;
|
const path = Astro.url.pathname;
|
||||||
const links = [
|
|
||||||
{ href: "/admin", label: "文章" },
|
const groups: { label: string; links: { href: string; label: string }[] }[] = [
|
||||||
|
{ label: "總覽", links: [{ href: "/admin", label: "總覽" }] },
|
||||||
|
{
|
||||||
|
label: "內容管理",
|
||||||
|
links: [
|
||||||
|
{ href: "/admin/posts", label: "文章" },
|
||||||
{ href: "/admin/content/service", label: "服務" },
|
{ href: "/admin/content/service", label: "服務" },
|
||||||
{ href: "/admin/content/feature", label: "特色" },
|
{ href: "/admin/content/feature", label: "特色" },
|
||||||
{ href: "/admin/content/step", label: "流程" },
|
{ href: "/admin/content/step", label: "流程" },
|
||||||
{ href: "/admin/content/faq", label: "常見問題" },
|
{ href: "/admin/content/faq", label: "常見問題" },
|
||||||
{ href: "/admin/cases", label: "案例" },
|
{ href: "/admin/cases", label: "完成案例" },
|
||||||
{ href: "/admin/settings", label: "設定" },
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "系統",
|
||||||
|
links: [
|
||||||
{ href: "/admin/ai", label: "AI 生成" },
|
{ href: "/admin/ai", label: "AI 生成" },
|
||||||
|
{ href: "/admin/settings", label: "網站設定" },
|
||||||
|
],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
const isActive = (href: string) =>
|
|
||||||
href === "/admin" ? path === "/admin" : path === href || path.startsWith(href + "/");
|
const isActive = (href: string) => {
|
||||||
|
if (href === "/admin") return path === "/admin";
|
||||||
|
if (href === "/admin/posts") return path === "/admin/posts" || path.startsWith("/admin/post/");
|
||||||
|
return path === href || path.startsWith(href + "/");
|
||||||
|
};
|
||||||
---
|
---
|
||||||
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
@@ -27,28 +43,45 @@ const isActive = (href: string) =>
|
|||||||
<meta name="robots" content="noindex, nofollow" />
|
<meta name="robots" content="noindex, nofollow" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header class="bar">
|
<input type="checkbox" id="nav-toggle" class="nav-toggle" hidden />
|
||||||
<div class="inner">
|
<div class="shell">
|
||||||
|
<aside class="sidebar">
|
||||||
<a class="brand" href="/admin">
|
<a class="brand" href="/admin">
|
||||||
<span class="dot"></span>
|
<span class="brand-name">盈豐太陽能</span>
|
||||||
盈豐太陽能 · 後台
|
<span class="brand-sub">後台</span>
|
||||||
</a>
|
</a>
|
||||||
<nav>
|
<nav class="nav">
|
||||||
{
|
{
|
||||||
links.map((l) => (
|
groups.map((g) => (
|
||||||
|
<>
|
||||||
|
<p class="nav-group">{g.label}</p>
|
||||||
|
{g.links.map((l) => (
|
||||||
<a href={l.href} class={isActive(l.href) ? "active" : ""}>
|
<a href={l.href} class={isActive(l.href) ? "active" : ""}>
|
||||||
{l.label}
|
{l.label}
|
||||||
</a>
|
</a>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
<a href="/" target="_blank">睇網站</a>
|
|
||||||
<a href="/admin/logout">登出</a>
|
|
||||||
</nav>
|
</nav>
|
||||||
|
<div class="sidebar-foot">
|
||||||
|
<a href="/" target="_blank">睇網站 ↗</a>
|
||||||
|
<a href="/admin/logout">登出</a>
|
||||||
</div>
|
</div>
|
||||||
|
</aside>
|
||||||
|
<div class="content">
|
||||||
|
<header class="topbar">
|
||||||
|
<label for="nav-toggle" class="hamburger" aria-label="開合導航">☰</label>
|
||||||
|
<a class="brand" href="/admin">
|
||||||
|
<span class="brand-name">盈豐太陽能</span>
|
||||||
|
<span class="brand-sub">後台</span>
|
||||||
|
</a>
|
||||||
</header>
|
</header>
|
||||||
<main class="inner">
|
<main class="main">
|
||||||
<slot />
|
<slot />
|
||||||
</main>
|
</main>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
const MAX_WIDTH = 1600;
|
const MAX_WIDTH = 1600;
|
||||||
const QUALITY = 0.85;
|
const QUALITY = 0.85;
|
||||||
@@ -136,72 +169,137 @@ const isActive = (href: string) =>
|
|||||||
|
|
||||||
<style is:global>
|
<style is:global>
|
||||||
:root {
|
:root {
|
||||||
|
--ink: #1a1917;
|
||||||
|
--ink-2: #24221f;
|
||||||
|
--ink-3: #2e2b27;
|
||||||
|
--bg: #faf8f4;
|
||||||
|
--surface: #fff;
|
||||||
|
--fg: #1a1917;
|
||||||
|
--fg-muted: #6e6862;
|
||||||
|
--border: #e7e2d9;
|
||||||
|
--brand: #d97706;
|
||||||
|
--brand-strong: #b45309;
|
||||||
|
--brand-soft: #fef3c7;
|
||||||
|
--ok: #0f6e56;
|
||||||
|
--ok-soft: #e1f5ee;
|
||||||
|
--warn: #854f0b;
|
||||||
|
--warn-soft: #faeeda;
|
||||||
|
--danger: #a32d2d;
|
||||||
|
--danger-soft: #fcebeb;
|
||||||
|
--radius-sm: 4px;
|
||||||
|
--radius: 8px;
|
||||||
|
--sidebar-w: 248px;
|
||||||
font-family: "Noto Sans HK", "PingFang HK", "Microsoft JhengHei", system-ui, sans-serif;
|
font-family: "Noto Sans HK", "PingFang HK", "Microsoft JhengHei", system-ui, sans-serif;
|
||||||
color: #0f1e1a;
|
color: var(--fg);
|
||||||
background: #f2f8f6;
|
background: var(--bg);
|
||||||
line-height: 1.65;
|
line-height: 1.65;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
}
|
}
|
||||||
* { box-sizing: border-box; }
|
* { box-sizing: border-box; }
|
||||||
body { margin: 0; }
|
body { margin: 0; }
|
||||||
a { color: #0b8a5e; text-decoration: none; }
|
a { color: var(--brand-strong); text-decoration: none; }
|
||||||
a:hover { text-decoration: underline; }
|
a:hover { text-decoration: underline; }
|
||||||
.inner { max-width: 920px; margin: 0 auto; padding: 0 24px; }
|
|
||||||
|
|
||||||
.bar { background: #fff; border-bottom: 1px solid rgba(0,0,0,.08); position: sticky; top: 0; z-index: 10; }
|
.shell { display: flex; min-height: 100vh; }
|
||||||
.bar .inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; flex-wrap: wrap; }
|
.sidebar {
|
||||||
.brand { font-weight: 800; color: #0f1e1a; display: inline-flex; align-items: center; gap: 8px; }
|
position: fixed;
|
||||||
|
inset: 0 auto 0 0;
|
||||||
|
width: var(--sidebar-w);
|
||||||
|
background: var(--ink);
|
||||||
|
color: #edeae4;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 22px 14px;
|
||||||
|
z-index: 20;
|
||||||
|
}
|
||||||
|
.brand { display: flex; flex-direction: column; gap: 2px; padding: 0 10px 18px; color: #fff; }
|
||||||
.brand:hover { text-decoration: none; }
|
.brand:hover { text-decoration: none; }
|
||||||
.dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg,#0b8a5e,#0ba5ec); display: inline-block; }
|
.brand-name { font-family: "Noto Serif HK", serif; font-weight: 900; font-size: 17px; letter-spacing: 0.02em; }
|
||||||
.bar nav { display: flex; gap: 14px; font-size: 13.5px; flex-wrap: wrap; }
|
.brand-sub { font-size: 11px; color: #9a938a; letter-spacing: 0.28em; }
|
||||||
.bar nav a { color: #33413c; }
|
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
|
||||||
.bar nav a.active { color: #0b8a5e; font-weight: 700; }
|
.nav-group { margin: 16px 10px 6px; font-size: 10.5px; letter-spacing: 0.22em; color: #7e776e; }
|
||||||
|
.nav a {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 9px 10px;
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
color: #cfc9c1;
|
||||||
|
font-size: 13.5px;
|
||||||
|
border-left: 3px solid transparent;
|
||||||
|
}
|
||||||
|
.nav a:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
|
||||||
|
.nav a.active { background: var(--ink-2); color: var(--brand); border-left-color: var(--brand); font-weight: 700; }
|
||||||
|
.sidebar-foot { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--ink-3); padding-top: 14px; }
|
||||||
|
.sidebar-foot a { padding: 8px 10px; color: #9a938a; font-size: 13px; }
|
||||||
|
.sidebar-foot a:hover { color: #fff; text-decoration: none; }
|
||||||
|
.content { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
|
||||||
|
.main { max-width: 1080px; padding: 36px 40px 100px; margin: 0 auto; }
|
||||||
|
.topbar { display: none; }
|
||||||
|
|
||||||
main { padding: 32px 24px 100px; }
|
h1 { font-family: "Noto Serif HK", serif; font-size: 24px; font-weight: 900; margin: 0 0 6px; }
|
||||||
h1 { font-size: 22px; font-weight: 800; margin: 0 0 6px; }
|
.sub { color: var(--fg-muted); font-size: 13.5px; margin: 0 0 24px; }
|
||||||
.sub { color: #5b6b66; font-size: 13.5px; margin: 0 0 24px; }
|
|
||||||
|
|
||||||
.card { background: #fff; border: 1px solid rgba(0,0,0,.08); border-radius: 14px; padding: 20px 22px; margin-bottom: 18px; }
|
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
|
||||||
.card h2 { font-size: 15px; font-weight: 700; margin: 0 0 14px; }
|
.card h2 { font-size: 15px; font-weight: 700; margin: 0 0 14px; }
|
||||||
|
|
||||||
table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid rgba(0,0,0,.08); border-radius: 14px; overflow: hidden; }
|
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
|
||||||
th { text-align: left; font-weight: 600; font-size: 12px; color: #5b6b66; padding: 10px 14px; border-bottom: 1px solid rgba(0,0,0,.08); }
|
th { text-align: left; font-weight: 600; font-size: 12px; color: var(--fg-muted); padding: 10px 14px; border-bottom: 1px solid var(--border); }
|
||||||
td { padding: 12px 14px; border-bottom: 1px solid rgba(0,0,0,.05); font-size: 14px; vertical-align: middle; }
|
td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
|
||||||
tbody tr:last-child td { border-bottom: none; }
|
tbody tr:last-child td { border-bottom: none; }
|
||||||
|
|
||||||
label { display: block; font-size: 13px; color: #5b6b66; margin: 14px 0 6px; font-weight: 600; }
|
label { display: block; font-size: 13px; color: var(--fg-muted); margin: 14px 0 6px; font-weight: 600; }
|
||||||
input[type="text"], input[type="url"], textarea, select {
|
input[type="text"], input[type="url"], input[type="password"], textarea, select {
|
||||||
width: 100%; font: inherit; font-size: 14px; padding: 9px 12px;
|
width: 100%; font: inherit; font-size: 14px; padding: 9px 12px;
|
||||||
border: 1px solid rgba(0,0,0,.15); border-radius: 9px; background: #fff; color: #0f1e1a;
|
border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg);
|
||||||
}
|
}
|
||||||
textarea { min-height: 88px; resize: vertical; }
|
textarea { min-height: 88px; resize: vertical; }
|
||||||
input:focus, textarea:focus, select:focus { outline: 2px solid #9fdcc2; border-color: #0b8a5e; }
|
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
|
||||||
|
|
||||||
button, .btn {
|
button, .btn {
|
||||||
font: inherit; font-size: 14px; font-weight: 600; padding: 9px 18px; border-radius: 9px; cursor: pointer;
|
font: inherit; font-size: 14px; font-weight: 600; padding: 9px 18px; border-radius: var(--radius-sm); cursor: pointer;
|
||||||
border: 1px solid #0b8a5e; background: #0b8a5e; color: #fff; display: inline-flex; align-items: center; gap: 6px;
|
border: 1px solid var(--ink); background: var(--ink); color: #fff; display: inline-flex; align-items: center; gap: 6px;
|
||||||
}
|
}
|
||||||
button:hover { background: #0a6f4c; }
|
button:hover, .btn:hover { background: #000; }
|
||||||
button.secondary, .btn.secondary { background: #fff; color: #0f1e1a; border-color: rgba(0,0,0,.15); }
|
button.secondary, .btn.secondary { background: var(--surface); color: var(--fg); border-color: var(--border); }
|
||||||
button.secondary:hover { background: #f2f8f6; }
|
button.secondary:hover { background: var(--bg); }
|
||||||
button.danger { background: #fff; color: #a32d2d; border-color: #f09595; }
|
button.danger { background: var(--surface); color: var(--danger); border-color: #f09595; }
|
||||||
button.mini { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
|
button.danger:hover { background: var(--danger-soft); }
|
||||||
|
button.mini { padding: 5px 10px; font-size: 12.5px; }
|
||||||
|
button:disabled { opacity: 0.45; cursor: not-allowed; }
|
||||||
.actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; flex-wrap: wrap; }
|
.actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; flex-wrap: wrap; }
|
||||||
|
|
||||||
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; border: 1px solid transparent; }
|
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; border: 1px solid transparent; }
|
||||||
.badge.published { background: #e1f5ee; color: #0f6e56; }
|
.badge.published { background: var(--ok-soft); color: var(--ok); }
|
||||||
.badge.draft { background: #faeeda; color: #854f0b; }
|
.badge.draft { background: var(--warn-soft); color: var(--warn); }
|
||||||
.muted { color: #8a9793; font-size: 13px; }
|
.notice { display: inline-block; background: var(--ok-soft); color: var(--ok); font-size: 13px; font-weight: 700; padding: 8px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; }
|
||||||
.field-error { color: #a32d2d; font-size: 12.5px; font-weight: 600; margin-left: 8px; }
|
.muted { color: var(--fg-muted); font-size: 13px; }
|
||||||
.err { color: #a32d2d; font-size: 13px; font-weight: 600; }
|
.field-error { color: var(--danger); font-size: 12.5px; font-weight: 600; margin-left: 8px; }
|
||||||
|
.err { color: var(--danger); font-size: 13px; font-weight: 600; }
|
||||||
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
|
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
|
||||||
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
|
|
||||||
.image-field { display: block; }
|
.image-field { display: block; }
|
||||||
.image-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
|
.image-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
|
||||||
.image-actions input[type="file"] { font: inherit; font-size: 13px; max-width: 100%; }
|
.image-actions input[type="file"] { font: inherit; font-size: 13px; max-width: 100%; }
|
||||||
.image-status { font-size: 12.5px; font-weight: 600; color: #0b8a5e; }
|
.image-status { font-size: 12.5px; font-weight: 600; color: var(--ok); }
|
||||||
.image-status.error { color: #a32d2d; }
|
.image-status.error { color: var(--danger); }
|
||||||
.image-preview { display: block; margin-top: 10px; max-width: 220px; border-radius: 10px; }
|
.image-preview { display: block; margin-top: 10px; max-width: 220px; border-radius: var(--radius); }
|
||||||
.image-preview[hidden] { display: none; }
|
.image-preview[hidden] { display: none; }
|
||||||
.row { display: grid; gap: 12px; grid-template-columns: 1fr; }
|
.row { display: grid; gap: 12px; grid-template-columns: 1fr; }
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.grid2 { grid-template-columns: 1fr; }
|
||||||
|
}
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
|
||||||
|
#nav-toggle:checked ~ .sidebar { transform: translateX(0); }
|
||||||
|
.content { margin-left: 0; }
|
||||||
|
.topbar {
|
||||||
|
display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 15;
|
||||||
|
background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 18px;
|
||||||
|
}
|
||||||
|
.topbar .brand { flex-direction: row; align-items: baseline; gap: 8px; padding: 0; color: var(--ink); }
|
||||||
|
.topbar .brand-sub { color: var(--fg-muted); }
|
||||||
|
.hamburger { cursor: pointer; font-size: 20px; line-height: 1; color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 10px; }
|
||||||
|
.main { padding: 24px 18px 80px; }
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user