@loafacto/ui 0.1.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,295 @@
1
- import { defineComponent, ref, computed, watch, onBeforeUnmount, openBlock, createElementBlock, normalizeStyle, createCommentVNode, createElementVNode, toDisplayString, Fragment, renderList, normalizeClass, renderSlot, onUnmounted, createBlock, Teleport, createVNode, TransitionGroup, withCtx, unref, withModifiers, Transition } from "vue";
1
+ import { readonly, ref, defineComponent, computed, watch, onBeforeUnmount, openBlock, createElementBlock, normalizeStyle, createCommentVNode, createElementVNode, toDisplayString, Fragment, renderList, normalizeClass, unref, renderSlot, onUnmounted, createBlock, Teleport, createVNode, TransitionGroup, withCtx, withModifiers, Transition } from "vue";
2
2
  import { defineStore } from "pinia";
3
+ function hexToRgb(hex) {
4
+ const clean = hex.replace("#", "");
5
+ if (clean.length === 3) {
6
+ const r = parseInt(clean[0] + clean[0], 16);
7
+ const g = parseInt(clean[1] + clean[1], 16);
8
+ const b = parseInt(clean[2] + clean[2], 16);
9
+ return [r, g, b];
10
+ }
11
+ return [
12
+ parseInt(clean.slice(0, 2), 16),
13
+ parseInt(clean.slice(2, 4), 16),
14
+ parseInt(clean.slice(4, 6), 16)
15
+ ];
16
+ }
17
+ function parseRgba(color) {
18
+ const m = color.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/);
19
+ if (!m) return null;
20
+ return [parseInt(m[1]), parseInt(m[2]), parseInt(m[3])];
21
+ }
22
+ function colorToRgb(color) {
23
+ if (color.startsWith("#")) return hexToRgb(color);
24
+ const parsed = parseRgba(color);
25
+ return parsed ?? [0, 0, 0];
26
+ }
27
+ function luminance(r, g, b) {
28
+ const [rs, gs, bs] = [r, g, b].map((c) => {
29
+ const s = c / 255;
30
+ return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
31
+ });
32
+ return 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
33
+ }
34
+ function contrastRatio(l1, l2) {
35
+ const lighter = Math.max(l1, l2);
36
+ const darker = Math.min(l1, l2);
37
+ return (lighter + 0.05) / (darker + 0.05);
38
+ }
39
+ function accessibleText(bgLum, light, dark) {
40
+ const lightLum = 0.9505;
41
+ const darkLum = 88e-4;
42
+ const crLight = contrastRatio(bgLum, lightLum);
43
+ const crDark = contrastRatio(bgLum, darkLum);
44
+ return crDark >= crLight ? dark : light;
45
+ }
46
+ function surfaceFromBg(bg, amount = 0.08) {
47
+ const [r, g, b] = colorToRgb(bg);
48
+ const isLight = luminance(r, g, b) > 0.35;
49
+ const a = isLight ? Math.min(amount * 5, 0.5) : amount;
50
+ const target = 255;
51
+ const nr = Math.round(r * (1 - a) + target * a);
52
+ const ng = Math.round(g * (1 - a) + target * a);
53
+ const nb = Math.round(b * (1 - a) + target * a);
54
+ return `rgb(${nr},${ng},${nb})`;
55
+ }
56
+ function isLightBackground(color) {
57
+ const [r, g, b] = colorToRgb(color);
58
+ return luminance(r, g, b) > 0.35;
59
+ }
60
+ function deriveSemanticPalette(bg, sidebar, header, _card, accent) {
61
+ const light = isLightBackground(bg);
62
+ const [ar, ag, ab] = hexToRgb(accent.startsWith("#") ? accent : "#60a5fa");
63
+ const accentRgb = `${ar},${ag},${ab}`;
64
+ const accentLum = luminance(ar, ag, ab);
65
+ const textHeading = light ? "#111827" : "#f9fafb";
66
+ const textBody = light ? "#374151" : "#e5e7eb";
67
+ const textMuted = light ? "#6b7280" : "#9ca3af";
68
+ const border = light ? "rgba(0,0,0,0.1)" : "rgba(255,255,255,0.1)";
69
+ const hover = light ? "rgba(0,0,0,0.05)" : "rgba(255,255,255,0.05)";
70
+ const overlay = light ? "rgba(248,250,252,0.95)" : "rgba(17,24,39,0.95)";
71
+ const surface = surfaceFromBg(bg, 0.08);
72
+ const surfaceAlt = surfaceFromBg(bg, 0.04);
73
+ const accentText = accessibleText(accentLum, "#ffffff", "#111827");
74
+ const accentHover = light ? `rgba(${ar},${ag},${ab},0.85)` : `rgba(${Math.min(ar + 20, 255)},${Math.min(ag + 20, 255)},${Math.min(ab + 20, 255)},1)`;
75
+ const accentMuted = `rgba(${ar},${ag},${ab},0.12)`;
76
+ const accentMutedText = accent;
77
+ const btnPrimaryBg = accent;
78
+ const btnPrimaryText = accentText;
79
+ const btnPrimaryHover = accentHover;
80
+ const inputBg = light ? "rgba(0,0,0,0.04)" : "rgba(0,0,0,0.3)";
81
+ const inputBorder = border;
82
+ const inputFocusBorder = accent;
83
+ const inputFocusShadow = `rgba(${ar},${ag},${ab},0.3)`;
84
+ const statusSuccess = light ? "#16a34a" : "#4ade80";
85
+ const statusError = light ? "#dc2626" : "#f87171";
86
+ const statusWarning = light ? "#d97706" : "#fbbf24";
87
+ const statusInfo = light ? "#2563eb" : "#60a5fa";
88
+ const statusNeutral = light ? "#4b5563" : "#9ca3af";
89
+ const statusPurple = light ? "#9333ea" : "#c084fc";
90
+ const statusTeal = light ? "#0d9488" : "#5eead4";
91
+ const sidebarLight = isLightBackground(sidebar);
92
+ const sidebarText = sidebarLight ? "#374151" : "#e5e7eb";
93
+ const sidebarTextMuted = sidebarLight ? "#6b7280" : "#9ca3af";
94
+ const sidebarActive = sidebarLight ? `rgba(${ar},${ag},${ab},0.15)` : `rgba(${ar},${ag},${ab},0.15)`;
95
+ const headerLight = isLightBackground(header);
96
+ const headerText = headerLight ? "#111827" : "#f9fafb";
97
+ const footerBg = light ? "#1e293b" : "rgba(3, 7, 18, 0.95)";
98
+ const footerText = "#94a3b8";
99
+ const footerBorder = light ? "rgba(255,255,255,0.08)" : "rgba(255,255,255,0.06)";
100
+ return {
101
+ textHeading,
102
+ textBody,
103
+ textMuted,
104
+ border,
105
+ hover,
106
+ overlay,
107
+ surface,
108
+ surfaceAlt,
109
+ accent,
110
+ accentRgb,
111
+ accentText,
112
+ accentHover,
113
+ accentMuted,
114
+ accentMutedText,
115
+ btnPrimaryBg,
116
+ btnPrimaryText,
117
+ btnPrimaryHover,
118
+ inputBg,
119
+ inputBorder,
120
+ inputFocusBorder,
121
+ inputFocusShadow,
122
+ statusSuccess,
123
+ statusError,
124
+ statusWarning,
125
+ statusInfo,
126
+ statusNeutral,
127
+ statusPurple,
128
+ statusTeal,
129
+ sidebarText,
130
+ sidebarTextMuted,
131
+ sidebarActive,
132
+ headerText,
133
+ footerBg,
134
+ footerText,
135
+ footerBorder
136
+ };
137
+ }
138
+ function applySemanticPalette(palette) {
139
+ const el = document.documentElement;
140
+ const s = el.style;
141
+ s.setProperty("--admin-text-heading", palette.textHeading);
142
+ s.setProperty("--admin-text-body", palette.textBody);
143
+ s.setProperty("--admin-text-muted", palette.textMuted);
144
+ s.setProperty("--admin-text-primary", palette.textHeading);
145
+ s.setProperty("--admin-border", palette.border);
146
+ s.setProperty("--admin-hover", palette.hover);
147
+ s.setProperty("--admin-overlay", palette.overlay);
148
+ s.setProperty("--admin-surface", palette.surface);
149
+ s.setProperty("--admin-surface-alt", palette.surfaceAlt);
150
+ s.setProperty("--admin-accent", palette.accent);
151
+ s.setProperty("--admin-accent-rgb", palette.accentRgb);
152
+ s.setProperty("--admin-accent-text", palette.accentText);
153
+ s.setProperty("--admin-accent-hover", palette.accentHover);
154
+ s.setProperty("--admin-accent-muted", palette.accentMuted);
155
+ s.setProperty("--admin-accent-muted-text", palette.accentMutedText);
156
+ s.setProperty("--admin-btn-primary-bg", palette.btnPrimaryBg);
157
+ s.setProperty("--admin-btn-primary-text", palette.btnPrimaryText);
158
+ s.setProperty("--admin-btn-primary-hover", palette.btnPrimaryHover);
159
+ s.setProperty("--admin-input-bg", palette.inputBg);
160
+ s.setProperty("--admin-input-border", palette.inputBorder);
161
+ s.setProperty("--admin-input-focus-border", palette.inputFocusBorder);
162
+ s.setProperty("--admin-input-focus-shadow", palette.inputFocusShadow);
163
+ s.setProperty("--admin-status-success", palette.statusSuccess);
164
+ s.setProperty("--admin-status-error", palette.statusError);
165
+ s.setProperty("--admin-status-warning", palette.statusWarning);
166
+ s.setProperty("--admin-status-info", palette.statusInfo);
167
+ s.setProperty("--admin-status-neutral", palette.statusNeutral);
168
+ s.setProperty("--admin-status-purple", palette.statusPurple);
169
+ s.setProperty("--admin-status-teal", palette.statusTeal);
170
+ s.setProperty("--admin-sidebar-text", palette.sidebarText);
171
+ s.setProperty("--admin-sidebar-text-muted", palette.sidebarTextMuted);
172
+ s.setProperty("--admin-sidebar-active", palette.sidebarActive);
173
+ s.setProperty("--admin-header-text", palette.headerText);
174
+ s.setProperty("--admin-footer-bg", palette.footerBg);
175
+ s.setProperty("--admin-footer-text", palette.footerText);
176
+ s.setProperty("--admin-footer-border", palette.footerBorder);
177
+ s.setProperty("--glass-accent", palette.accent);
178
+ s.setProperty("--glass-accent-rgb", palette.accentRgb);
179
+ }
180
+ const DARK_THEME = {
181
+ bg: "#0f172a",
182
+ sidebar: "rgba(17, 24, 39, 0.6)",
183
+ header: "rgba(15, 23, 42, 0.85)",
184
+ card: "rgba(15, 23, 42, 0.6)",
185
+ accent: "#60a5fa",
186
+ skin: "default"
187
+ };
188
+ const LIGHT_THEME = {
189
+ bg: "#f6f7f9",
190
+ sidebar: "rgba(255, 255, 255, 0.75)",
191
+ header: "rgba(255, 255, 255, 0.85)",
192
+ card: "rgba(255, 255, 255, 0.9)",
193
+ accent: "#2563eb",
194
+ skin: "default"
195
+ };
196
+ const DEFAULT_THEME = DARK_THEME;
197
+ function applyTheme(config = {}) {
198
+ const c = { ...DARK_THEME, ...config };
199
+ const el = document.documentElement;
200
+ const s = el.style;
201
+ s.setProperty("--admin-bg-color", c.bg);
202
+ s.setProperty("--admin-sidebar-bg", c.sidebar);
203
+ s.setProperty("--admin-header-bg", c.header);
204
+ s.setProperty("--admin-card-bg", c.card);
205
+ s.setProperty("--admin-ui-skin", c.skin ?? "default");
206
+ const light = isLightBackground(c.bg);
207
+ s.setProperty("color-scheme", light ? "light" : "dark");
208
+ el.setAttribute("data-lf-theme", light ? "light" : "dark");
209
+ const palette = deriveSemanticPalette(c.bg, c.sidebar, c.header, c.card, c.accent);
210
+ applySemanticPalette(palette);
211
+ return palette;
212
+ }
213
+ const STORAGE_KEY = "lf-theme";
214
+ const OS_QUERY = "(prefers-color-scheme: light)";
215
+ function readStored() {
216
+ try {
217
+ const v = localStorage.getItem(STORAGE_KEY);
218
+ return v === "light" || v === "dark" ? v : null;
219
+ } catch {
220
+ return null;
221
+ }
222
+ }
223
+ function osPrefers() {
224
+ try {
225
+ return window.matchMedia(OS_QUERY).matches ? "light" : "dark";
226
+ } catch {
227
+ return "dark";
228
+ }
229
+ }
230
+ const mode = ref("dark");
231
+ const explicit = ref(false);
232
+ const presets = {
233
+ light: LIGHT_THEME,
234
+ dark: DARK_THEME
235
+ };
236
+ let wired = false;
237
+ function apply() {
238
+ applyTheme(presets[mode.value]);
239
+ }
240
+ function initTheme(options) {
241
+ if (options == null ? void 0 : options.light) presets.light = options.light;
242
+ if (options == null ? void 0 : options.dark) presets.dark = options.dark;
243
+ const stored = readStored();
244
+ explicit.value = stored !== null;
245
+ mode.value = stored ?? osPrefers();
246
+ apply();
247
+ if (wired) return;
248
+ wired = true;
249
+ try {
250
+ window.matchMedia(OS_QUERY).addEventListener("change", () => {
251
+ if (explicit.value) return;
252
+ mode.value = osPrefers();
253
+ apply();
254
+ });
255
+ } catch {
256
+ }
257
+ window.addEventListener("storage", (e) => {
258
+ if (e.key !== STORAGE_KEY) return;
259
+ const v = readStored();
260
+ explicit.value = v !== null;
261
+ mode.value = v ?? osPrefers();
262
+ apply();
263
+ });
264
+ }
265
+ function useTheme() {
266
+ function setMode(next) {
267
+ mode.value = next;
268
+ explicit.value = true;
269
+ try {
270
+ localStorage.setItem(STORAGE_KEY, next);
271
+ } catch {
272
+ }
273
+ apply();
274
+ }
275
+ return {
276
+ mode: readonly(mode),
277
+ /** 사용자가 직접 고른 상태인지. false 면 OS 설정을 따라가는 중이다. */
278
+ isExplicit: readonly(explicit),
279
+ setMode,
280
+ toggle: () => setMode(mode.value === "dark" ? "light" : "dark"),
281
+ /** 저장된 선택을 지우고 다시 OS 설정을 따르게 한다. */
282
+ followSystem() {
283
+ try {
284
+ localStorage.removeItem(STORAGE_KEY);
285
+ } catch {
286
+ }
287
+ explicit.value = false;
288
+ mode.value = osPrefers();
289
+ apply();
290
+ }
291
+ };
292
+ }
3
293
  const _hoisted_1$3 = { class: "lf-shell" };
4
294
  const _hoisted_2$2 = { class: "lf-topbar" };
5
295
  const _hoisted_3$2 = { class: "lf-topbar__inner" };
@@ -41,26 +331,36 @@ const _hoisted_17 = {
41
331
  "aria-hidden": "true"
42
332
  };
43
333
  const _hoisted_18 = ["d"];
44
- const _hoisted_19 = {
45
- key: 2,
46
- class: "lf-user"
334
+ const _hoisted_19 = ["title", "aria-label"];
335
+ const _hoisted_20 = {
336
+ viewBox: "0 0 24 24",
337
+ "aria-hidden": "true"
47
338
  };
48
- const _hoisted_20 = ["src"];
49
- const _hoisted_21 = {
339
+ const _hoisted_21 = ["d"];
340
+ const _hoisted_22 = ["aria-expanded"];
341
+ const _hoisted_23 = ["src"];
342
+ const _hoisted_24 = {
50
343
  key: 1,
51
344
  class: "lf-user__avatar lf-user__avatar--fallback"
52
345
  };
53
- const _hoisted_22 = { class: "lf-user__name" };
54
- const _hoisted_23 = { class: "lf-content" };
55
- const _hoisted_24 = { class: "site-footer" };
56
- const _hoisted_25 = { class: "site-footer-inner" };
57
- const _hoisted_26 = { class: "site-footer-copy" };
346
+ const _hoisted_25 = { class: "lf-user__name" };
347
+ const _hoisted_26 = {
348
+ key: 0,
349
+ class: "lf-user__email"
350
+ };
351
+ const _hoisted_27 = { class: "lf-content" };
352
+ const _hoisted_28 = { class: "site-footer" };
353
+ const _hoisted_29 = { class: "site-footer-inner" };
354
+ const _hoisted_30 = { class: "site-footer-copy" };
355
+ const ICON_SUN = "M12 7a5 5 0 1 0 0 10 5 5 0 0 0 0-10zm0-5v3h0V2zm0 17v3h0v-3zM2 11h3v2H2v-2zm17 0h3v2h-3v-2zM4.2 4.2l2.1 2.1L4.9 7.7 2.8 5.6l1.4-1.4zm13.5 13.5 2.1 2.1-1.4 1.4-2.1-2.1 1.4-1.4zM19.8 4.2l1.4 1.4-2.1 2.1-1.4-1.4 2.1-2.1zM6.3 17.7l1.4 1.4-2.1 2.1-1.4-1.4 2.1-2.1z";
356
+ const ICON_MOON = "M12.3 3a7 7 0 1 0 8.7 8.7A9 9 0 1 1 12.3 3z";
58
357
  const _sfc_main$3 = /* @__PURE__ */ defineComponent({
59
358
  __name: "AppShell",
60
359
  props: {
61
360
  services: { default: () => [] },
62
361
  currentServiceId: {},
63
362
  shortcuts: { default: () => [] },
363
+ themeToggle: { type: Boolean, default: true },
64
364
  brandName: { default: "Loafacto" },
65
365
  brandHref: { default: "/" },
66
366
  logoUrl: {},
@@ -71,10 +371,14 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
71
371
  },
72
372
  emits: ["navigate"],
73
373
  setup(__props, { emit: __emit }) {
374
+ const { mode: mode2, toggle } = useTheme();
74
375
  const props = __props;
75
376
  const emit = __emit;
76
377
  const switcherOpen = ref(false);
77
378
  const switcherEl = ref(null);
379
+ const userOpen = ref(false);
380
+ const userEl = ref(null);
381
+ const anyOpen = computed(() => switcherOpen.value || userOpen.value);
78
382
  const currentService = computed(
79
383
  () => props.services.find((s) => s.id === props.currentServiceId)
80
384
  );
@@ -94,13 +398,17 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
94
398
  onNavigate(event, svc.path, svc);
95
399
  }
96
400
  function onDocumentPointerDown(e) {
97
- var _a;
98
- if (!((_a = switcherEl.value) == null ? void 0 : _a.contains(e.target))) switcherOpen.value = false;
401
+ var _a, _b;
402
+ const target = e.target;
403
+ if (!((_a = switcherEl.value) == null ? void 0 : _a.contains(target))) switcherOpen.value = false;
404
+ if (!((_b = userEl.value) == null ? void 0 : _b.contains(target))) userOpen.value = false;
99
405
  }
100
406
  function onDocumentKeydown(e) {
101
- if (e.key === "Escape") switcherOpen.value = false;
407
+ if (e.key !== "Escape") return;
408
+ switcherOpen.value = false;
409
+ userOpen.value = false;
102
410
  }
103
- watch(switcherOpen, (open) => {
411
+ watch(anyOpen, (open) => {
104
412
  if (open) {
105
413
  document.addEventListener("pointerdown", onDocumentPointerDown);
106
414
  document.addEventListener("keydown", onDocumentKeydown);
@@ -109,6 +417,12 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
109
417
  document.removeEventListener("keydown", onDocumentKeydown);
110
418
  }
111
419
  });
420
+ watch(switcherOpen, (open) => {
421
+ if (open) userOpen.value = false;
422
+ });
423
+ watch(userOpen, (open) => {
424
+ if (open) switcherOpen.value = false;
425
+ });
112
426
  onBeforeUnmount(() => {
113
427
  document.removeEventListener("pointerdown", onDocumentPointerDown);
114
428
  document.removeEventListener("keydown", onDocumentKeydown);
@@ -147,13 +461,13 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
147
461
  }, [
148
462
  createElementVNode("button", {
149
463
  type: "button",
150
- class: "lf-switcher__trigger",
464
+ class: "lf-glass lf-switcher__trigger",
151
465
  "aria-expanded": switcherOpen.value,
152
466
  "aria-haspopup": "menu",
153
467
  onClick: _cache[1] || (_cache[1] = ($event) => switcherOpen.value = !switcherOpen.value)
154
468
  }, [
155
469
  createElementVNode("span", null, toDisplayString(((_a = currentService.value) == null ? void 0 : _a.name) ?? "서비스"), 1),
156
- _cache[2] || (_cache[2] = createElementVNode("svg", {
470
+ _cache[5] || (_cache[5] = createElementVNode("svg", {
157
471
  class: "lf-switcher__caret",
158
472
  viewBox: "0 0 24 24",
159
473
  "aria-hidden": "true"
@@ -188,12 +502,12 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
188
502
  }), 128))
189
503
  ])) : createCommentVNode("", true)
190
504
  ], 512)) : createCommentVNode("", true),
191
- _cache[3] || (_cache[3] = createElementVNode("div", { class: "lf-topbar__spacer" }, null, -1)),
505
+ _cache[7] || (_cache[7] = createElementVNode("div", { class: "lf-topbar__spacer" }, null, -1)),
192
506
  __props.shortcuts.length ? (openBlock(), createElementBlock("nav", _hoisted_15, [
193
507
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.shortcuts, (s) => {
194
508
  return openBlock(), createElementBlock("a", {
195
509
  key: s.id,
196
- class: "lf-shortcut",
510
+ class: "lf-glass lf-icon-btn",
197
511
  href: s.href,
198
512
  target: "_blank",
199
513
  rel: "noopener noreferrer",
@@ -209,26 +523,73 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
209
523
  ], 8, _hoisted_16);
210
524
  }), 128))
211
525
  ])) : createCommentVNode("", true),
526
+ __props.themeToggle ? (openBlock(), createElementBlock("button", {
527
+ key: 2,
528
+ type: "button",
529
+ class: "lf-glass lf-icon-btn",
530
+ title: unref(mode2) === "dark" ? "밝은 테마로" : "어두운 테마로",
531
+ "aria-label": unref(mode2) === "dark" ? "밝은 테마로 전환" : "어두운 테마로 전환",
532
+ onClick: _cache[2] || (_cache[2] = //@ts-ignore
533
+ (...args) => unref(toggle) && unref(toggle)(...args))
534
+ }, [
535
+ (openBlock(), createElementBlock("svg", _hoisted_20, [
536
+ createElementVNode("path", {
537
+ d: unref(mode2) === "dark" ? ICON_SUN : ICON_MOON,
538
+ fill: "currentColor"
539
+ }, null, 8, _hoisted_21)
540
+ ]))
541
+ ], 8, _hoisted_19)) : createCommentVNode("", true),
212
542
  renderSlot(_ctx.$slots, "actions", {}, void 0, true),
213
- __props.user ? (openBlock(), createElementBlock("div", _hoisted_19, [
214
- __props.user.avatarUrl ? (openBlock(), createElementBlock("img", {
543
+ __props.user ? (openBlock(), createElementBlock("div", {
544
+ key: 3,
545
+ ref_key: "userEl",
546
+ ref: userEl,
547
+ class: "lf-user"
548
+ }, [
549
+ createElementVNode("button", {
550
+ type: "button",
551
+ class: "lf-glass lf-user__trigger",
552
+ "aria-expanded": userOpen.value,
553
+ "aria-haspopup": "menu",
554
+ onClick: _cache[3] || (_cache[3] = ($event) => userOpen.value = !userOpen.value)
555
+ }, [
556
+ __props.user.avatarUrl ? (openBlock(), createElementBlock("img", {
557
+ key: 0,
558
+ src: __props.user.avatarUrl,
559
+ alt: "",
560
+ class: "lf-user__avatar"
561
+ }, null, 8, _hoisted_23)) : (openBlock(), createElementBlock("span", _hoisted_24, toDisplayString(userInitial.value), 1)),
562
+ createElementVNode("span", _hoisted_25, toDisplayString(__props.user.displayName), 1),
563
+ _cache[6] || (_cache[6] = createElementVNode("svg", {
564
+ class: "lf-user__caret",
565
+ viewBox: "0 0 24 24",
566
+ "aria-hidden": "true"
567
+ }, [
568
+ createElementVNode("path", {
569
+ d: "M7 10l5 5 5-5z",
570
+ fill: "currentColor"
571
+ })
572
+ ], -1))
573
+ ], 8, _hoisted_22),
574
+ userOpen.value ? (openBlock(), createElementBlock("div", {
215
575
  key: 0,
216
- src: __props.user.avatarUrl,
217
- alt: "",
218
- class: "lf-user__avatar"
219
- }, null, 8, _hoisted_20)) : (openBlock(), createElementBlock("span", _hoisted_21, toDisplayString(userInitial.value), 1)),
220
- createElementVNode("span", _hoisted_22, toDisplayString(__props.user.displayName), 1),
221
- renderSlot(_ctx.$slots, "user-menu", {}, void 0, true)
222
- ])) : renderSlot(_ctx.$slots, "auth-actions", {}, void 0, true, 3)
576
+ class: "lf-user__menu",
577
+ role: "menu",
578
+ onClick: _cache[4] || (_cache[4] = ($event) => userOpen.value = false)
579
+ }, [
580
+ __props.user.email ? (openBlock(), createElementBlock("p", _hoisted_26, toDisplayString(__props.user.email), 1)) : createCommentVNode("", true),
581
+ renderSlot(_ctx.$slots, "user-menu", {}, void 0, true)
582
+ ])) : createCommentVNode("", true)
583
+ ], 512)) : renderSlot(_ctx.$slots, "auth-actions", {}, void 0, true, 4)
223
584
  ])
224
585
  ]),
225
- createElementVNode("main", _hoisted_23, [
586
+ createElementVNode("main", _hoisted_27, [
226
587
  renderSlot(_ctx.$slots, "default", {}, void 0, true)
227
588
  ]),
228
- createElementVNode("footer", _hoisted_24, [
229
- createElementVNode("div", _hoisted_25, [
589
+ createElementVNode("footer", _hoisted_28, [
590
+ createElementVNode("div", _hoisted_29, [
230
591
  renderSlot(_ctx.$slots, "footer", {}, () => [
231
- createElementVNode("p", _hoisted_26, "© " + toDisplayString(__props.year) + " Loafacto", 1)
592
+ createElementVNode("p", _hoisted_30, "© " + toDisplayString(__props.year) + " Loafacto", 1)
232
593
  ], true)
233
594
  ])
234
595
  ])
@@ -243,7 +604,7 @@ const _export_sfc = (sfc, props) => {
243
604
  }
244
605
  return target;
245
606
  };
246
- const AppShell = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-c5d7e70e"]]);
607
+ const AppShell = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-2533bdc5"]]);
247
608
  function generateId() {
248
609
  return `toast-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
249
610
  }
@@ -509,220 +870,27 @@ function useConfirm() {
509
870
  const store = useConfirmStore();
510
871
  return (opts) => store.ask(opts);
511
872
  }
512
- function hexToRgb(hex) {
513
- const clean = hex.replace("#", "");
514
- if (clean.length === 3) {
515
- const r = parseInt(clean[0] + clean[0], 16);
516
- const g = parseInt(clean[1] + clean[1], 16);
517
- const b = parseInt(clean[2] + clean[2], 16);
518
- return [r, g, b];
519
- }
520
- return [
521
- parseInt(clean.slice(0, 2), 16),
522
- parseInt(clean.slice(2, 4), 16),
523
- parseInt(clean.slice(4, 6), 16)
524
- ];
525
- }
526
- function parseRgba(color) {
527
- const m = color.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/);
528
- if (!m) return null;
529
- return [parseInt(m[1]), parseInt(m[2]), parseInt(m[3])];
530
- }
531
- function colorToRgb(color) {
532
- if (color.startsWith("#")) return hexToRgb(color);
533
- const parsed = parseRgba(color);
534
- return parsed ?? [0, 0, 0];
535
- }
536
- function luminance(r, g, b) {
537
- const [rs, gs, bs] = [r, g, b].map((c) => {
538
- const s = c / 255;
539
- return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
540
- });
541
- return 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
542
- }
543
- function contrastRatio(l1, l2) {
544
- const lighter = Math.max(l1, l2);
545
- const darker = Math.min(l1, l2);
546
- return (lighter + 0.05) / (darker + 0.05);
547
- }
548
- function accessibleText(bgLum, light, dark) {
549
- const lightLum = 0.9505;
550
- const darkLum = 88e-4;
551
- const crLight = contrastRatio(bgLum, lightLum);
552
- const crDark = contrastRatio(bgLum, darkLum);
553
- return crDark >= crLight ? dark : light;
554
- }
555
- function surfaceFromBg(bg, amount = 0.08) {
556
- const [r, g, b] = colorToRgb(bg);
557
- const isLight = luminance(r, g, b) > 0.35;
558
- const a = isLight ? Math.min(amount * 5, 0.5) : amount;
559
- const target = 255;
560
- const nr = Math.round(r * (1 - a) + target * a);
561
- const ng = Math.round(g * (1 - a) + target * a);
562
- const nb = Math.round(b * (1 - a) + target * a);
563
- return `rgb(${nr},${ng},${nb})`;
564
- }
565
- function isLightBackground(color) {
566
- const [r, g, b] = colorToRgb(color);
567
- return luminance(r, g, b) > 0.35;
568
- }
569
- function deriveSemanticPalette(bg, sidebar, header, _card, accent) {
570
- const light = isLightBackground(bg);
571
- const [ar, ag, ab] = hexToRgb(accent.startsWith("#") ? accent : "#60a5fa");
572
- const accentRgb = `${ar},${ag},${ab}`;
573
- const accentLum = luminance(ar, ag, ab);
574
- const textHeading = light ? "#111827" : "#f9fafb";
575
- const textBody = light ? "#374151" : "#e5e7eb";
576
- const textMuted = light ? "#6b7280" : "#9ca3af";
577
- const border = light ? "rgba(0,0,0,0.1)" : "rgba(255,255,255,0.1)";
578
- const hover = light ? "rgba(0,0,0,0.05)" : "rgba(255,255,255,0.05)";
579
- const overlay = light ? "rgba(248,250,252,0.95)" : "rgba(17,24,39,0.95)";
580
- const surface = surfaceFromBg(bg, 0.08);
581
- const surfaceAlt = surfaceFromBg(bg, 0.04);
582
- const accentText = accessibleText(accentLum, "#ffffff", "#111827");
583
- const accentHover = light ? `rgba(${ar},${ag},${ab},0.85)` : `rgba(${Math.min(ar + 20, 255)},${Math.min(ag + 20, 255)},${Math.min(ab + 20, 255)},1)`;
584
- const accentMuted = `rgba(${ar},${ag},${ab},0.12)`;
585
- const accentMutedText = accent;
586
- const btnPrimaryBg = accent;
587
- const btnPrimaryText = accentText;
588
- const btnPrimaryHover = accentHover;
589
- const inputBg = light ? "rgba(0,0,0,0.04)" : "rgba(0,0,0,0.3)";
590
- const inputBorder = border;
591
- const inputFocusBorder = accent;
592
- const inputFocusShadow = `rgba(${ar},${ag},${ab},0.3)`;
593
- const statusSuccess = light ? "#16a34a" : "#4ade80";
594
- const statusError = light ? "#dc2626" : "#f87171";
595
- const statusWarning = light ? "#d97706" : "#fbbf24";
596
- const statusInfo = light ? "#2563eb" : "#60a5fa";
597
- const statusNeutral = light ? "#4b5563" : "#9ca3af";
598
- const statusPurple = light ? "#9333ea" : "#c084fc";
599
- const statusTeal = light ? "#0d9488" : "#5eead4";
600
- const sidebarLight = isLightBackground(sidebar);
601
- const sidebarText = sidebarLight ? "#374151" : "#e5e7eb";
602
- const sidebarTextMuted = sidebarLight ? "#6b7280" : "#9ca3af";
603
- const sidebarActive = sidebarLight ? `rgba(${ar},${ag},${ab},0.15)` : `rgba(${ar},${ag},${ab},0.15)`;
604
- const headerLight = isLightBackground(header);
605
- const headerText = headerLight ? "#111827" : "#f9fafb";
606
- const footerBg = light ? "#1e293b" : "rgba(3, 7, 18, 0.95)";
607
- const footerText = "#94a3b8";
608
- const footerBorder = light ? "rgba(255,255,255,0.08)" : "rgba(255,255,255,0.06)";
609
- return {
610
- textHeading,
611
- textBody,
612
- textMuted,
613
- border,
614
- hover,
615
- overlay,
616
- surface,
617
- surfaceAlt,
618
- accent,
619
- accentRgb,
620
- accentText,
621
- accentHover,
622
- accentMuted,
623
- accentMutedText,
624
- btnPrimaryBg,
625
- btnPrimaryText,
626
- btnPrimaryHover,
627
- inputBg,
628
- inputBorder,
629
- inputFocusBorder,
630
- inputFocusShadow,
631
- statusSuccess,
632
- statusError,
633
- statusWarning,
634
- statusInfo,
635
- statusNeutral,
636
- statusPurple,
637
- statusTeal,
638
- sidebarText,
639
- sidebarTextMuted,
640
- sidebarActive,
641
- headerText,
642
- footerBg,
643
- footerText,
644
- footerBorder
645
- };
646
- }
647
- function applySemanticPalette(palette) {
648
- const el = document.documentElement;
649
- const s = el.style;
650
- s.setProperty("--admin-text-heading", palette.textHeading);
651
- s.setProperty("--admin-text-body", palette.textBody);
652
- s.setProperty("--admin-text-muted", palette.textMuted);
653
- s.setProperty("--admin-text-primary", palette.textHeading);
654
- s.setProperty("--admin-border", palette.border);
655
- s.setProperty("--admin-hover", palette.hover);
656
- s.setProperty("--admin-overlay", palette.overlay);
657
- s.setProperty("--admin-surface", palette.surface);
658
- s.setProperty("--admin-surface-alt", palette.surfaceAlt);
659
- s.setProperty("--admin-accent", palette.accent);
660
- s.setProperty("--admin-accent-rgb", palette.accentRgb);
661
- s.setProperty("--admin-accent-text", palette.accentText);
662
- s.setProperty("--admin-accent-hover", palette.accentHover);
663
- s.setProperty("--admin-accent-muted", palette.accentMuted);
664
- s.setProperty("--admin-accent-muted-text", palette.accentMutedText);
665
- s.setProperty("--admin-btn-primary-bg", palette.btnPrimaryBg);
666
- s.setProperty("--admin-btn-primary-text", palette.btnPrimaryText);
667
- s.setProperty("--admin-btn-primary-hover", palette.btnPrimaryHover);
668
- s.setProperty("--admin-input-bg", palette.inputBg);
669
- s.setProperty("--admin-input-border", palette.inputBorder);
670
- s.setProperty("--admin-input-focus-border", palette.inputFocusBorder);
671
- s.setProperty("--admin-input-focus-shadow", palette.inputFocusShadow);
672
- s.setProperty("--admin-status-success", palette.statusSuccess);
673
- s.setProperty("--admin-status-error", palette.statusError);
674
- s.setProperty("--admin-status-warning", palette.statusWarning);
675
- s.setProperty("--admin-status-info", palette.statusInfo);
676
- s.setProperty("--admin-status-neutral", palette.statusNeutral);
677
- s.setProperty("--admin-status-purple", palette.statusPurple);
678
- s.setProperty("--admin-status-teal", palette.statusTeal);
679
- s.setProperty("--admin-sidebar-text", palette.sidebarText);
680
- s.setProperty("--admin-sidebar-text-muted", palette.sidebarTextMuted);
681
- s.setProperty("--admin-sidebar-active", palette.sidebarActive);
682
- s.setProperty("--admin-header-text", palette.headerText);
683
- s.setProperty("--admin-footer-bg", palette.footerBg);
684
- s.setProperty("--admin-footer-text", palette.footerText);
685
- s.setProperty("--admin-footer-border", palette.footerBorder);
686
- s.setProperty("--glass-accent", palette.accent);
687
- s.setProperty("--glass-accent-rgb", palette.accentRgb);
688
- }
689
- const DEFAULT_THEME = {
690
- bg: "#0f172a",
691
- sidebar: "rgba(17, 24, 39, 0.6)",
692
- header: "rgba(15, 23, 42, 0.85)",
693
- card: "rgba(15, 23, 42, 0.6)",
694
- accent: "#60a5fa",
695
- skin: "default"
696
- };
697
- function applyTheme(config = {}) {
698
- const c = { ...DEFAULT_THEME, ...config };
699
- const s = document.documentElement.style;
700
- s.setProperty("--admin-bg-color", c.bg);
701
- s.setProperty("--admin-sidebar-bg", c.sidebar);
702
- s.setProperty("--admin-header-bg", c.header);
703
- s.setProperty("--admin-card-bg", c.card);
704
- s.setProperty("--admin-ui-skin", c.skin ?? "default");
705
- const palette = deriveSemanticPalette(c.bg, c.sidebar, c.header, c.card, c.accent);
706
- applySemanticPalette(palette);
707
- return palette;
708
- }
709
873
  export {
710
874
  AppConfirmModal,
711
875
  AppLoadingOverlay,
712
876
  AppShell,
713
877
  AppToast,
878
+ DARK_THEME,
714
879
  DEFAULT_THEME,
880
+ LIGHT_THEME,
715
881
  applySemanticPalette,
716
882
  applyTheme,
717
883
  colorToRgb,
718
884
  contrastRatio,
719
885
  deriveSemanticPalette,
720
886
  hexToRgb,
887
+ initTheme,
721
888
  isLightBackground,
722
889
  luminance,
723
890
  useConfirm,
724
891
  useConfirmStore,
725
892
  useLoadingStore,
893
+ useTheme,
726
894
  useToast,
727
895
  useToastStore
728
896
  };