@loafacto/ui 0.1.3 → 0.2.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/components/AppShell.vue.d.ts +8 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +341 -218
- package/dist/index.js.map +1 -1
- package/dist/loafacto-ui.css +62 -37
- package/dist/stores/confirm.d.ts +1 -1
- package/dist/stores/toast.d.ts +1 -1
- package/dist/theme/applyTheme.d.ts +14 -2
- package/dist/theme/useTheme.d.ts +26 -0
- package/package.json +1 -1
|
@@ -4,6 +4,13 @@ type __VLS_Props = {
|
|
|
4
4
|
currentServiceId?: string;
|
|
5
5
|
/** 다른 사이트로 나가는 링크. 상단바에 아이콘으로 놓이고 새 탭에서 열린다. */
|
|
6
6
|
shortcuts?: ShortcutLink[];
|
|
7
|
+
/**
|
|
8
|
+
* 상단바에 테마 전환 버튼을 놓는다.
|
|
9
|
+
* 서비스가 자체 토글을 이미 갖고 있다면 false 로 꺼서 중복을 피한다 —
|
|
10
|
+
* 다만 두 토글이 서로 다른 저장소를 쓰면 설정이 어긋나므로, 끄기보다는
|
|
11
|
+
* 자체 토글을 걷어내고 이쪽으로 통일하는 편이 낫다.
|
|
12
|
+
*/
|
|
13
|
+
themeToggle?: boolean;
|
|
7
14
|
brandName?: string;
|
|
8
15
|
brandHref?: string;
|
|
9
16
|
logoUrl?: string;
|
|
@@ -40,6 +47,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
40
47
|
}>, {
|
|
41
48
|
services: ServiceDescriptor[];
|
|
42
49
|
shortcuts: ShortcutLink[];
|
|
50
|
+
themeToggle: boolean;
|
|
43
51
|
brandName: string;
|
|
44
52
|
brandHref: string;
|
|
45
53
|
user: ShellUser | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export { useLoadingStore } from './stores/loading';
|
|
|
23
23
|
export { useConfirmStore, type ConfirmOptions } from './stores/confirm';
|
|
24
24
|
export { useToast } from './composables/useToast';
|
|
25
25
|
export { useConfirm } from './composables/useConfirm';
|
|
26
|
-
export { applyTheme, DEFAULT_THEME, type ThemeConfig } from './theme/applyTheme';
|
|
26
|
+
export { applyTheme, DARK_THEME, LIGHT_THEME, DEFAULT_THEME, type ThemeConfig, } from './theme/applyTheme';
|
|
27
|
+
export { initTheme, useTheme, type ThemeMode } from './theme/useTheme';
|
|
27
28
|
export { deriveSemanticPalette, applySemanticPalette, isLightBackground, colorToRgb, hexToRgb, luminance, contrastRatio, type SemanticPalette, } from './theme/themeColors';
|
|
28
29
|
export type { ServiceDescriptor, ShellUser, ShortcutLink } from './types';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,295 @@
|
|
|
1
|
-
import {
|
|
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,35 @@ const _hoisted_17 = {
|
|
|
41
331
|
"aria-hidden": "true"
|
|
42
332
|
};
|
|
43
333
|
const _hoisted_18 = ["d"];
|
|
44
|
-
const _hoisted_19 =
|
|
45
|
-
|
|
334
|
+
const _hoisted_19 = ["title", "aria-label"];
|
|
335
|
+
const _hoisted_20 = {
|
|
336
|
+
viewBox: "0 0 24 24",
|
|
337
|
+
"aria-hidden": "true"
|
|
338
|
+
};
|
|
339
|
+
const _hoisted_21 = ["d"];
|
|
340
|
+
const _hoisted_22 = {
|
|
341
|
+
key: 3,
|
|
46
342
|
class: "lf-user"
|
|
47
343
|
};
|
|
48
|
-
const
|
|
49
|
-
const
|
|
344
|
+
const _hoisted_23 = ["src"];
|
|
345
|
+
const _hoisted_24 = {
|
|
50
346
|
key: 1,
|
|
51
347
|
class: "lf-user__avatar lf-user__avatar--fallback"
|
|
52
348
|
};
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
349
|
+
const _hoisted_25 = { class: "lf-user__name" };
|
|
350
|
+
const _hoisted_26 = { class: "lf-content" };
|
|
351
|
+
const _hoisted_27 = { class: "site-footer" };
|
|
352
|
+
const _hoisted_28 = { class: "site-footer-inner" };
|
|
353
|
+
const _hoisted_29 = { class: "site-footer-copy" };
|
|
354
|
+
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";
|
|
355
|
+
const ICON_MOON = "M12.3 3a7 7 0 1 0 8.7 8.7A9 9 0 1 1 12.3 3z";
|
|
58
356
|
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
59
357
|
__name: "AppShell",
|
|
60
358
|
props: {
|
|
61
359
|
services: { default: () => [] },
|
|
62
360
|
currentServiceId: {},
|
|
63
361
|
shortcuts: { default: () => [] },
|
|
362
|
+
themeToggle: { type: Boolean, default: true },
|
|
64
363
|
brandName: { default: "Loafacto" },
|
|
65
364
|
brandHref: { default: "/" },
|
|
66
365
|
logoUrl: {},
|
|
@@ -71,6 +370,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
71
370
|
},
|
|
72
371
|
emits: ["navigate"],
|
|
73
372
|
setup(__props, { emit: __emit }) {
|
|
373
|
+
const { mode: mode2, toggle } = useTheme();
|
|
74
374
|
const props = __props;
|
|
75
375
|
const emit = __emit;
|
|
76
376
|
const switcherOpen = ref(false);
|
|
@@ -153,7 +453,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
153
453
|
onClick: _cache[1] || (_cache[1] = ($event) => switcherOpen.value = !switcherOpen.value)
|
|
154
454
|
}, [
|
|
155
455
|
createElementVNode("span", null, toDisplayString(((_a = currentService.value) == null ? void 0 : _a.name) ?? "서비스"), 1),
|
|
156
|
-
_cache[
|
|
456
|
+
_cache[3] || (_cache[3] = createElementVNode("svg", {
|
|
157
457
|
class: "lf-switcher__caret",
|
|
158
458
|
viewBox: "0 0 24 24",
|
|
159
459
|
"aria-hidden": "true"
|
|
@@ -188,7 +488,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
188
488
|
}), 128))
|
|
189
489
|
])) : createCommentVNode("", true)
|
|
190
490
|
], 512)) : createCommentVNode("", true),
|
|
191
|
-
_cache[
|
|
491
|
+
_cache[4] || (_cache[4] = createElementVNode("div", { class: "lf-topbar__spacer" }, null, -1)),
|
|
192
492
|
__props.shortcuts.length ? (openBlock(), createElementBlock("nav", _hoisted_15, [
|
|
193
493
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.shortcuts, (s) => {
|
|
194
494
|
return openBlock(), createElementBlock("a", {
|
|
@@ -209,26 +509,42 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
209
509
|
], 8, _hoisted_16);
|
|
210
510
|
}), 128))
|
|
211
511
|
])) : createCommentVNode("", true),
|
|
512
|
+
__props.themeToggle ? (openBlock(), createElementBlock("button", {
|
|
513
|
+
key: 2,
|
|
514
|
+
type: "button",
|
|
515
|
+
class: "lf-theme-btn",
|
|
516
|
+
title: unref(mode2) === "dark" ? "밝은 테마로" : "어두운 테마로",
|
|
517
|
+
"aria-label": unref(mode2) === "dark" ? "밝은 테마로 전환" : "어두운 테마로 전환",
|
|
518
|
+
onClick: _cache[2] || (_cache[2] = //@ts-ignore
|
|
519
|
+
(...args) => unref(toggle) && unref(toggle)(...args))
|
|
520
|
+
}, [
|
|
521
|
+
(openBlock(), createElementBlock("svg", _hoisted_20, [
|
|
522
|
+
createElementVNode("path", {
|
|
523
|
+
d: unref(mode2) === "dark" ? ICON_SUN : ICON_MOON,
|
|
524
|
+
fill: "currentColor"
|
|
525
|
+
}, null, 8, _hoisted_21)
|
|
526
|
+
]))
|
|
527
|
+
], 8, _hoisted_19)) : createCommentVNode("", true),
|
|
212
528
|
renderSlot(_ctx.$slots, "actions", {}, void 0, true),
|
|
213
|
-
__props.user ? (openBlock(), createElementBlock("div",
|
|
529
|
+
__props.user ? (openBlock(), createElementBlock("div", _hoisted_22, [
|
|
214
530
|
__props.user.avatarUrl ? (openBlock(), createElementBlock("img", {
|
|
215
531
|
key: 0,
|
|
216
532
|
src: __props.user.avatarUrl,
|
|
217
533
|
alt: "",
|
|
218
534
|
class: "lf-user__avatar"
|
|
219
|
-
}, null, 8,
|
|
220
|
-
createElementVNode("span",
|
|
535
|
+
}, null, 8, _hoisted_23)) : (openBlock(), createElementBlock("span", _hoisted_24, toDisplayString(userInitial.value), 1)),
|
|
536
|
+
createElementVNode("span", _hoisted_25, toDisplayString(__props.user.displayName), 1),
|
|
221
537
|
renderSlot(_ctx.$slots, "user-menu", {}, void 0, true)
|
|
222
|
-
])) : renderSlot(_ctx.$slots, "auth-actions", {}, void 0, true,
|
|
538
|
+
])) : renderSlot(_ctx.$slots, "auth-actions", {}, void 0, true, 4)
|
|
223
539
|
])
|
|
224
540
|
]),
|
|
225
|
-
createElementVNode("main",
|
|
541
|
+
createElementVNode("main", _hoisted_26, [
|
|
226
542
|
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
227
543
|
]),
|
|
228
|
-
createElementVNode("footer",
|
|
229
|
-
createElementVNode("div",
|
|
544
|
+
createElementVNode("footer", _hoisted_27, [
|
|
545
|
+
createElementVNode("div", _hoisted_28, [
|
|
230
546
|
renderSlot(_ctx.$slots, "footer", {}, () => [
|
|
231
|
-
createElementVNode("p",
|
|
547
|
+
createElementVNode("p", _hoisted_29, "© " + toDisplayString(__props.year) + " Loafacto", 1)
|
|
232
548
|
], true)
|
|
233
549
|
])
|
|
234
550
|
])
|
|
@@ -243,7 +559,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
243
559
|
}
|
|
244
560
|
return target;
|
|
245
561
|
};
|
|
246
|
-
const AppShell = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-
|
|
562
|
+
const AppShell = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-5442ab90"]]);
|
|
247
563
|
function generateId() {
|
|
248
564
|
return `toast-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
249
565
|
}
|
|
@@ -509,220 +825,27 @@ function useConfirm() {
|
|
|
509
825
|
const store = useConfirmStore();
|
|
510
826
|
return (opts) => store.ask(opts);
|
|
511
827
|
}
|
|
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
828
|
export {
|
|
710
829
|
AppConfirmModal,
|
|
711
830
|
AppLoadingOverlay,
|
|
712
831
|
AppShell,
|
|
713
832
|
AppToast,
|
|
833
|
+
DARK_THEME,
|
|
714
834
|
DEFAULT_THEME,
|
|
835
|
+
LIGHT_THEME,
|
|
715
836
|
applySemanticPalette,
|
|
716
837
|
applyTheme,
|
|
717
838
|
colorToRgb,
|
|
718
839
|
contrastRatio,
|
|
719
840
|
deriveSemanticPalette,
|
|
720
841
|
hexToRgb,
|
|
842
|
+
initTheme,
|
|
721
843
|
isLightBackground,
|
|
722
844
|
luminance,
|
|
723
845
|
useConfirm,
|
|
724
846
|
useConfirmStore,
|
|
725
847
|
useLoadingStore,
|
|
848
|
+
useTheme,
|
|
726
849
|
useToast,
|
|
727
850
|
useToastStore
|
|
728
851
|
};
|