From fbc383decf62cd1c7d032cd33ebda65c4ade0e71 Mon Sep 17 00:00:00 2001 From: philipcheung Date: Sat, 12 Sep 2026 10:01:04 +0800 Subject: [PATCH] Add ImageField component and client-side upload script --- src/components/admin/ImageField.astro | 28 ++++++++++ src/layouts/AdminLayout.astro | 73 +++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 src/components/admin/ImageField.astro diff --git a/src/components/admin/ImageField.astro b/src/components/admin/ImageField.astro new file mode 100644 index 0000000..781eb2a --- /dev/null +++ b/src/components/admin/ImageField.astro @@ -0,0 +1,28 @@ +--- +interface Props { + name: string; + label: string; + value?: string | null; + scope: "settings" | "cases" | "posts"; + id?: string; +} + +const { name, label, value = "", scope, id = name } = Astro.props; +--- + +
+ + +
+ + +
+ +
diff --git a/src/layouts/AdminLayout.astro b/src/layouts/AdminLayout.astro index fedcc2f..afa2013 100644 --- a/src/layouts/AdminLayout.astro +++ b/src/layouts/AdminLayout.astro @@ -49,6 +49,73 @@ const isActive = (href: string) =>
+ @@ -114,5 +181,11 @@ const isActive = (href: string) => .err { color: #a32d2d; font-size: 13px; font-weight: 600; } .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } @media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } } + .image-field { display: block; } + .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-status { font-size: 12.5px; font-weight: 600; color: #0b8a5e; } + .image-preview { display: block; margin-top: 10px; max-width: 220px; border-radius: 10px; } + .image-preview[hidden] { display: none; } .row { display: grid; gap: 12px; grid-template-columns: 1fr; }