@basicbenframework/cms 0.6.0 → 0.7.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.
|
@@ -7,10 +7,15 @@ const strings = {
|
|
|
7
7
|
'New Post': 'Nueva entrada',
|
|
8
8
|
'New Page': 'Nueva página',
|
|
9
9
|
'Upload Media': 'Subir medios',
|
|
10
|
-
'Extend': 'Ampliar',
|
|
11
|
-
'Help': 'Ayuda',
|
|
12
10
|
'Documentation': 'Documentación',
|
|
13
11
|
'View Site': 'Ver sitio',
|
|
12
|
+
'How the site is doing, and what changed recently.': 'Cómo va el sitio y qué ha cambiado últimamente.',
|
|
13
|
+
'View all': 'Ver todo',
|
|
14
|
+
'Shortcuts': 'Atajos',
|
|
15
|
+
'A page outside the post stream': 'Una página fuera del listado de entradas',
|
|
16
|
+
'Images and files for posts and pages': 'Imágenes y archivos para entradas y páginas',
|
|
17
|
+
'Site name, reading and comments': 'Nombre del sitio, lectura y comentarios',
|
|
18
|
+
'Open the public site': 'Abrir el sitio público',
|
|
14
19
|
// Settings
|
|
15
20
|
'Settings saved successfully!': '¡Ajustes guardados correctamente!',
|
|
16
21
|
'Failed to save settings: {error}': 'No se pudieron guardar los ajustes: {error}',
|
|
@@ -2,6 +2,10 @@ import React from 'react';
|
|
|
2
2
|
interface AdminLayoutProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
title?: string;
|
|
5
|
+
/** A line under the title saying what the page is for. */
|
|
6
|
+
description?: string;
|
|
7
|
+
/** Buttons beside the title: the page's main action. */
|
|
8
|
+
actions?: React.ReactNode;
|
|
5
9
|
}
|
|
6
|
-
export default function AdminLayout({ children, title }: AdminLayoutProps): React.JSX.Element;
|
|
10
|
+
export default function AdminLayout({ children, title, description, actions }: AdminLayoutProps): React.JSX.Element;
|
|
7
11
|
export {};
|
|
@@ -85,7 +85,7 @@ function storedAppearance() {
|
|
|
85
85
|
const value = localStorage.getItem(THEME_KEY);
|
|
86
86
|
return value === 'light' || value === 'dark' ? value : 'system';
|
|
87
87
|
}
|
|
88
|
-
export default function AdminLayout({ children, title }) {
|
|
88
|
+
export default function AdminLayout({ children, title, description, actions }) {
|
|
89
89
|
const { user, logout } = useAuth();
|
|
90
90
|
const navigate = useNavigate();
|
|
91
91
|
const currentPath = usePath();
|
|
@@ -129,7 +129,7 @@ export default function AdminLayout({ children, title }) {
|
|
|
129
129
|
}, []);
|
|
130
130
|
// 'system' sets no attribute, which is what lets the media query decide.
|
|
131
131
|
const themeAttr = appearance === 'system' ? undefined : appearance;
|
|
132
|
-
return (_jsxs("div", { className: "admin-layout", "data-theme": themeAttr, children: [_jsx("style", { children: adminStyles }), _jsxs("aside", { className: `admin-sidebar ${sidebarOpen ? 'open' : 'closed'}`, children: [_jsx("div", { className: "admin-sidebar-header", children: _jsxs(Link, { href: "/", className: "admin-logo", title: "BasicBen", children: [_jsx("span", { className: "admin-logo-mark", children: "B" }), sidebarOpen && _jsx("span", { className: "admin-logo-text", children: "BasicBen" })] }) }), _jsx("nav", { className: "admin-nav", children: bySection(menuItems.filter(item => !item.capability || can(user, item.capability))).map(group => (_jsxs("div", { className: "admin-nav-group", children: [group.title && (_jsx("div", { className: "admin-nav-section", children: _jsx("span", { className: "admin-nav-section-label", children: t(group.title) }) })), group.items.map(item => (_jsxs(Link, { href: item.path, className: `admin-nav-item ${currentPath === item.path ? 'active' : ''}`, title: sidebarOpen ? undefined : t(item.label), children: [_jsx(AdminIcon, { path: item.path, fallback: item.icon, iconPath: iconPaths.get(item.path) }), sidebarOpen && _jsx("span", { className: "admin-nav-label", children: t(item.label) })] }, item.path)))] }, group.title ?? 'top'))) }), _jsxs("div", { className: "admin-sidebar-footer", children: [!__DISABLE_PUBLIC_SITE__ && (_jsxs(Link, { href: "/", className: "admin-nav-item", title: sidebarOpen ? undefined : t('View site'), children: [_jsx(AdminIcon, { name: "site" }), sidebarOpen && _jsx("span", { className: "admin-nav-label", children: t('View site') })] })), _jsxs("button", { className: "admin-nav-item admin-collapse", onClick: () => setSidebarOpen(!sidebarOpen), title: sidebarOpen ? t('Collapse sidebar') : t('Expand sidebar'), "aria-label": sidebarOpen ? t('Collapse sidebar') : t('Expand sidebar'), children: [_jsx("svg", { className: "admin-nav-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", style: { transform: sidebarOpen ? 'none' : 'rotate(180deg)' }, children: _jsx("path", { d: "M15 6l-6 6 6 6" }) }), sidebarOpen && _jsx("span", { className: "admin-nav-label", children: t('Collapse') })] })] })] }), _jsxs("div", { className: `admin-main ${sidebarOpen ? '' : 'expanded'}`, children: [
|
|
132
|
+
return (_jsxs("div", { className: "admin-layout", "data-theme": themeAttr, children: [_jsx("style", { children: adminStyles }), _jsxs("aside", { className: `admin-sidebar ${sidebarOpen ? 'open' : 'closed'}`, children: [_jsx("div", { className: "admin-sidebar-header", children: _jsxs(Link, { href: "/", className: "admin-logo", title: "BasicBen", children: [_jsx("span", { className: "admin-logo-mark", children: "B" }), sidebarOpen && _jsx("span", { className: "admin-logo-text", children: "BasicBen" })] }) }), _jsx("nav", { className: "admin-nav", children: bySection(menuItems.filter(item => !item.capability || can(user, item.capability))).map(group => (_jsxs("div", { className: "admin-nav-group", children: [group.title && (_jsx("div", { className: "admin-nav-section", children: _jsx("span", { className: "admin-nav-section-label", children: t(group.title) }) })), group.items.map(item => (_jsxs(Link, { href: item.path, className: `admin-nav-item ${currentPath === item.path ? 'active' : ''}`, title: sidebarOpen ? undefined : t(item.label), children: [_jsx(AdminIcon, { path: item.path, fallback: item.icon, iconPath: iconPaths.get(item.path) }), sidebarOpen && _jsx("span", { className: "admin-nav-label", children: t(item.label) })] }, item.path)))] }, group.title ?? 'top'))) }), _jsxs("div", { className: "admin-sidebar-footer", children: [!__DISABLE_PUBLIC_SITE__ && (_jsxs(Link, { href: "/", className: "admin-nav-item", title: sidebarOpen ? undefined : t('View site'), children: [_jsx(AdminIcon, { name: "site" }), sidebarOpen && _jsx("span", { className: "admin-nav-label", children: t('View site') })] })), _jsxs("button", { className: "admin-nav-item admin-collapse", onClick: () => setSidebarOpen(!sidebarOpen), title: sidebarOpen ? t('Collapse sidebar') : t('Expand sidebar'), "aria-label": sidebarOpen ? t('Collapse sidebar') : t('Expand sidebar'), children: [_jsx("svg", { className: "admin-nav-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", style: { transform: sidebarOpen ? 'none' : 'rotate(180deg)' }, children: _jsx("path", { d: "M15 6l-6 6 6 6" }) }), sidebarOpen && _jsx("span", { className: "admin-nav-label", children: t('Collapse') })] })] })] }), _jsxs("div", { className: `admin-main ${sidebarOpen ? '' : 'expanded'}`, children: [_jsx("header", { className: "admin-header", children: _jsxs("div", { className: "admin-header-right", children: [_jsx("div", { className: "admin-appearance", role: "group", "aria-label": t('Appearance'), children: ['system', 'light', 'dark'].map(option => (_jsx("button", { type: "button", className: `admin-appearance-option ${appearance === option ? 'active' : ''}`, onClick: () => setAppearance(option), title: option === 'system' ? t('System theme') : option === 'light' ? t('Light theme') : t('Dark theme'), "aria-pressed": appearance === option, children: option === 'system' ? '◐' : option === 'light' ? '☀' : '☾' }, option))) }), _jsx("span", { className: "admin-user", children: user?.name || t('Admin') }), _jsx("button", { className: "admin-btn admin-btn-secondary", onClick: handleLogout, children: t('Log out') })] }) }), _jsxs("main", { className: "admin-content", children: [title && (_jsxs("div", { className: "admin-page-head", children: [_jsxs("div", { children: [_jsx("h1", { className: "admin-page-title", children: title }), description && _jsx("p", { className: "admin-page-description", children: description })] }), actions && _jsx("div", { className: "admin-page-actions", children: actions })] })), children] })] })] }));
|
|
133
133
|
}
|
|
134
134
|
/*
|
|
135
135
|
One token set, themed three ways.
|
|
@@ -141,30 +141,35 @@ export default function AdminLayout({ children, title }) {
|
|
|
141
141
|
*/
|
|
142
142
|
const adminStyles = `
|
|
143
143
|
.admin-layout {
|
|
144
|
-
--bg: #
|
|
144
|
+
--bg: #f7f6f2;
|
|
145
|
+
--sidebar: #efeee9;
|
|
145
146
|
--surface: #ffffff;
|
|
146
|
-
--surface-hover: #
|
|
147
|
-
--surface-active: #
|
|
148
|
-
--border: #
|
|
149
|
-
--border-strong: #
|
|
150
|
-
--
|
|
151
|
-
--fg
|
|
152
|
-
--fg-
|
|
153
|
-
--
|
|
147
|
+
--surface-hover: #ecebe5;
|
|
148
|
+
--surface-active: #e3e2db;
|
|
149
|
+
--border: #e4e2da;
|
|
150
|
+
--border-strong: #cfccc2;
|
|
151
|
+
--card-border: #e9e7e0;
|
|
152
|
+
--fg: #1d1c1a;
|
|
153
|
+
--fg-muted: #6b6961;
|
|
154
|
+
--fg-subtle: #9a978d;
|
|
155
|
+
--accent: #1d1c1a;
|
|
154
156
|
--accent-fg: #ffffff;
|
|
155
|
-
--
|
|
156
|
-
--
|
|
157
|
+
--link: #2b6fd6;
|
|
158
|
+
--focus: #2b6fd6;
|
|
159
|
+
--danger: #d4483f;
|
|
157
160
|
--danger-fg: #ffffff;
|
|
158
|
-
--success: #
|
|
159
|
-
--warning: #
|
|
160
|
-
--info: #
|
|
161
|
-
--tint-success: #
|
|
162
|
-
--tint-warning: #
|
|
163
|
-
--tint-info: #
|
|
164
|
-
--tint-danger: #
|
|
161
|
+
--success: #1f7a44;
|
|
162
|
+
--warning: #946200;
|
|
163
|
+
--info: #2b6fd6;
|
|
164
|
+
--tint-success: #e5f2e8;
|
|
165
|
+
--tint-warning: #fbf2dc;
|
|
166
|
+
--tint-info: #e6eefb;
|
|
167
|
+
--tint-danger: #fbe8e6;
|
|
165
168
|
--radius: 8px;
|
|
166
|
-
--radius-lg:
|
|
167
|
-
--
|
|
169
|
+
--radius-lg: 16px;
|
|
170
|
+
--font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Charter,
|
|
171
|
+
"Bitstream Charter", Georgia, serif;
|
|
172
|
+
--sidebar-w: 248px;
|
|
168
173
|
--sidebar-w-closed: 60px;
|
|
169
174
|
|
|
170
175
|
display: flex;
|
|
@@ -180,52 +185,58 @@ const adminStyles = `
|
|
|
180
185
|
|
|
181
186
|
@media (prefers-color-scheme: dark) {
|
|
182
187
|
.admin-layout:not([data-theme="light"]) {
|
|
183
|
-
--bg: #
|
|
184
|
-
--
|
|
185
|
-
--surface
|
|
186
|
-
--surface-
|
|
187
|
-
--
|
|
188
|
-
--border
|
|
189
|
-
--
|
|
190
|
-
--
|
|
191
|
-
--fg
|
|
192
|
-
--
|
|
193
|
-
--
|
|
194
|
-
--
|
|
195
|
-
--
|
|
196
|
-
--
|
|
197
|
-
--
|
|
198
|
-
--
|
|
199
|
-
--
|
|
200
|
-
--
|
|
201
|
-
--
|
|
202
|
-
--
|
|
203
|
-
--tint-
|
|
188
|
+
--bg: #1c1c1b;
|
|
189
|
+
--sidebar: #191918;
|
|
190
|
+
--surface: #252524;
|
|
191
|
+
--surface-hover: #2c2c2a;
|
|
192
|
+
--surface-active: #343432;
|
|
193
|
+
--border: #30302e;
|
|
194
|
+
--border-strong: #42423f;
|
|
195
|
+
--card-border: transparent;
|
|
196
|
+
--fg: #ecebe6;
|
|
197
|
+
--fg-muted: #a5a39b;
|
|
198
|
+
--fg-subtle: #75736c;
|
|
199
|
+
--accent: #f4f3ee;
|
|
200
|
+
--accent-fg: #1c1c1b;
|
|
201
|
+
--link: #6aa5ff;
|
|
202
|
+
--focus: #4b8ef5;
|
|
203
|
+
--danger: #f0645c;
|
|
204
|
+
--danger-fg: #1c1c1b;
|
|
205
|
+
--success: #5fcf86;
|
|
206
|
+
--warning: #f0b44c;
|
|
207
|
+
--info: #6aa5ff;
|
|
208
|
+
--tint-success: #1e3326;
|
|
209
|
+
--tint-warning: #3a2f1a;
|
|
210
|
+
--tint-info: #1c2c45;
|
|
211
|
+
--tint-danger: #3d2120;
|
|
204
212
|
}
|
|
205
213
|
}
|
|
206
214
|
|
|
207
215
|
.admin-layout[data-theme="dark"] {
|
|
208
|
-
--bg: #
|
|
209
|
-
--
|
|
210
|
-
--surface
|
|
211
|
-
--surface-
|
|
212
|
-
--
|
|
213
|
-
--border
|
|
214
|
-
--
|
|
215
|
-
--
|
|
216
|
-
--fg
|
|
217
|
-
--
|
|
218
|
-
--
|
|
219
|
-
--
|
|
220
|
-
--
|
|
221
|
-
--
|
|
222
|
-
--
|
|
223
|
-
--
|
|
224
|
-
--
|
|
225
|
-
--
|
|
226
|
-
--
|
|
227
|
-
--
|
|
228
|
-
--tint-
|
|
216
|
+
--bg: #1c1c1b;
|
|
217
|
+
--sidebar: #191918;
|
|
218
|
+
--surface: #252524;
|
|
219
|
+
--surface-hover: #2c2c2a;
|
|
220
|
+
--surface-active: #343432;
|
|
221
|
+
--border: #30302e;
|
|
222
|
+
--border-strong: #42423f;
|
|
223
|
+
--card-border: transparent;
|
|
224
|
+
--fg: #ecebe6;
|
|
225
|
+
--fg-muted: #a5a39b;
|
|
226
|
+
--fg-subtle: #75736c;
|
|
227
|
+
--accent: #f4f3ee;
|
|
228
|
+
--accent-fg: #1c1c1b;
|
|
229
|
+
--link: #6aa5ff;
|
|
230
|
+
--focus: #4b8ef5;
|
|
231
|
+
--danger: #f0645c;
|
|
232
|
+
--danger-fg: #1c1c1b;
|
|
233
|
+
--success: #5fcf86;
|
|
234
|
+
--warning: #f0b44c;
|
|
235
|
+
--info: #6aa5ff;
|
|
236
|
+
--tint-success: #1e3326;
|
|
237
|
+
--tint-warning: #3a2f1a;
|
|
238
|
+
--tint-info: #1c2c45;
|
|
239
|
+
--tint-danger: #3d2120;
|
|
229
240
|
}
|
|
230
241
|
|
|
231
242
|
.admin-layout *,
|
|
@@ -236,7 +247,7 @@ const adminStyles = `
|
|
|
236
247
|
|
|
237
248
|
.admin-sidebar {
|
|
238
249
|
width: var(--sidebar-w);
|
|
239
|
-
background: var(--
|
|
250
|
+
background: var(--sidebar);
|
|
240
251
|
border-right: 1px solid var(--border);
|
|
241
252
|
display: flex;
|
|
242
253
|
flex-direction: column;
|
|
@@ -253,9 +264,8 @@ const adminStyles = `
|
|
|
253
264
|
.admin-sidebar-header {
|
|
254
265
|
display: flex;
|
|
255
266
|
align-items: center;
|
|
256
|
-
height:
|
|
257
|
-
padding: 0
|
|
258
|
-
border-bottom: 1px solid var(--border);
|
|
267
|
+
height: 64px;
|
|
268
|
+
padding: 0 14px;
|
|
259
269
|
}
|
|
260
270
|
|
|
261
271
|
.admin-logo {
|
|
@@ -278,7 +288,7 @@ const adminStyles = `
|
|
|
278
288
|
width: 24px;
|
|
279
289
|
height: 24px;
|
|
280
290
|
flex-shrink: 0;
|
|
281
|
-
border-radius:
|
|
291
|
+
border-radius: 7px;
|
|
282
292
|
background: var(--accent);
|
|
283
293
|
color: var(--accent-fg);
|
|
284
294
|
font-size: 13px;
|
|
@@ -287,11 +297,13 @@ const adminStyles = `
|
|
|
287
297
|
|
|
288
298
|
.admin-nav {
|
|
289
299
|
flex: 1;
|
|
290
|
-
padding:
|
|
300
|
+
padding: 4px 12px 12px;
|
|
291
301
|
overflow-y: auto;
|
|
292
302
|
display: flex;
|
|
293
303
|
flex-direction: column;
|
|
294
304
|
gap: 1px;
|
|
305
|
+
scrollbar-width: thin;
|
|
306
|
+
scrollbar-color: var(--border-strong) transparent;
|
|
295
307
|
}
|
|
296
308
|
|
|
297
309
|
.admin-nav-group {
|
|
@@ -327,11 +339,11 @@ const adminStyles = `
|
|
|
327
339
|
display: flex;
|
|
328
340
|
align-items: center;
|
|
329
341
|
gap: 10px;
|
|
330
|
-
padding:
|
|
331
|
-
border-radius:
|
|
342
|
+
padding: 8px 10px;
|
|
343
|
+
border-radius: 10px;
|
|
332
344
|
color: var(--fg-muted);
|
|
333
345
|
text-decoration: none;
|
|
334
|
-
font-size:
|
|
346
|
+
font-size: 14px;
|
|
335
347
|
font-weight: 450;
|
|
336
348
|
white-space: nowrap;
|
|
337
349
|
border: none;
|
|
@@ -360,7 +372,7 @@ const adminStyles = `
|
|
|
360
372
|
}
|
|
361
373
|
|
|
362
374
|
.admin-sidebar-footer {
|
|
363
|
-
padding:
|
|
375
|
+
padding: 10px 12px;
|
|
364
376
|
border-top: 1px solid var(--border);
|
|
365
377
|
display: flex;
|
|
366
378
|
flex-direction: column;
|
|
@@ -384,22 +396,41 @@ const adminStyles = `
|
|
|
384
396
|
justify-content: space-between;
|
|
385
397
|
gap: 16px;
|
|
386
398
|
height: 56px;
|
|
387
|
-
padding: 0
|
|
388
|
-
background: color-mix(in srgb, var(--
|
|
399
|
+
padding: 0 40px;
|
|
400
|
+
background: color-mix(in srgb, var(--bg) 85%, transparent);
|
|
389
401
|
backdrop-filter: blur(8px);
|
|
390
|
-
border-bottom: 1px solid var(--border);
|
|
391
402
|
position: sticky;
|
|
392
403
|
top: 0;
|
|
393
404
|
z-index: 50;
|
|
394
405
|
}
|
|
395
406
|
|
|
407
|
+
/* The page's name, in the content rather than the bar: a serif at display
|
|
408
|
+
size, with an optional line under it and the page's main action beside. */
|
|
409
|
+
.admin-page-head {
|
|
410
|
+
display: flex;
|
|
411
|
+
align-items: flex-start;
|
|
412
|
+
justify-content: space-between;
|
|
413
|
+
gap: 16px;
|
|
414
|
+
margin: 4px 0 28px;
|
|
415
|
+
}
|
|
416
|
+
|
|
396
417
|
.admin-page-title {
|
|
397
|
-
font-
|
|
398
|
-
font-
|
|
418
|
+
font-family: var(--font-display);
|
|
419
|
+
font-size: 30px;
|
|
420
|
+
font-weight: 500;
|
|
421
|
+
line-height: 1.2;
|
|
399
422
|
letter-spacing: -0.01em;
|
|
400
423
|
margin: 0;
|
|
401
424
|
}
|
|
402
425
|
|
|
426
|
+
.admin-page-description {
|
|
427
|
+
margin: 6px 0 0;
|
|
428
|
+
color: var(--fg-muted);
|
|
429
|
+
font-size: 15px;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.admin-page-actions { display: flex; gap: 8px; flex-shrink: 0; }
|
|
433
|
+
|
|
403
434
|
.admin-header-right {
|
|
404
435
|
display: flex;
|
|
405
436
|
align-items: center;
|
|
@@ -434,16 +465,18 @@ const adminStyles = `
|
|
|
434
465
|
.admin-appearance-option:hover { color: var(--fg); background: var(--surface-hover); }
|
|
435
466
|
.admin-appearance-option.active { color: var(--fg); background: var(--surface-active); }
|
|
436
467
|
|
|
437
|
-
.admin-content { padding:
|
|
468
|
+
.admin-content { padding: 8px 40px 48px; max-width: 1320px; }
|
|
438
469
|
|
|
439
470
|
/* --- Cards ------------------------------------------------------------- */
|
|
440
471
|
|
|
472
|
+
/* Filled rather than outlined: on the dark palette the border is
|
|
473
|
+
transparent and the step in surface colour is the edge. */
|
|
441
474
|
.admin-card {
|
|
442
475
|
background: var(--surface);
|
|
443
|
-
border: 1px solid var(--border);
|
|
476
|
+
border: 1px solid var(--card-border);
|
|
444
477
|
border-radius: var(--radius-lg);
|
|
445
|
-
padding:
|
|
446
|
-
margin-bottom:
|
|
478
|
+
padding: 22px 24px;
|
|
479
|
+
margin-bottom: 24px;
|
|
447
480
|
}
|
|
448
481
|
|
|
449
482
|
.admin-card-header {
|
|
@@ -455,8 +488,8 @@ const adminStyles = `
|
|
|
455
488
|
}
|
|
456
489
|
|
|
457
490
|
.admin-card-title {
|
|
458
|
-
font-size:
|
|
459
|
-
font-weight:
|
|
491
|
+
font-size: 16px;
|
|
492
|
+
font-weight: 500;
|
|
460
493
|
letter-spacing: -0.01em;
|
|
461
494
|
margin: 0;
|
|
462
495
|
}
|
|
@@ -468,28 +501,86 @@ const adminStyles = `
|
|
|
468
501
|
|
|
469
502
|
.admin-stat-card {
|
|
470
503
|
background: var(--surface);
|
|
471
|
-
border: 1px solid var(--border);
|
|
504
|
+
border: 1px solid var(--card-border);
|
|
472
505
|
border-radius: var(--radius-lg);
|
|
473
|
-
padding:
|
|
506
|
+
padding: 20px 24px 22px;
|
|
474
507
|
}
|
|
475
508
|
|
|
476
|
-
/* The
|
|
477
|
-
padding the card rather than separating the two — the number and its name
|
|
478
|
-
were tight against each other and the card was bottom-heavy. */
|
|
509
|
+
/* The name above the number, then an optional line under it. */
|
|
479
510
|
.admin-stat-label {
|
|
480
|
-
color: var(--fg
|
|
481
|
-
font-size:
|
|
482
|
-
margin: 0;
|
|
511
|
+
color: var(--fg);
|
|
512
|
+
font-size: 15px;
|
|
513
|
+
margin: 0 0 14px;
|
|
483
514
|
}
|
|
484
515
|
|
|
485
516
|
.admin-stat-value {
|
|
486
|
-
font-size:
|
|
487
|
-
font-weight:
|
|
517
|
+
font-size: 30px;
|
|
518
|
+
font-weight: 500;
|
|
488
519
|
letter-spacing: -0.02em;
|
|
489
|
-
|
|
520
|
+
line-height: 1.1;
|
|
521
|
+
margin: 0;
|
|
490
522
|
font-variant-numeric: tabular-nums;
|
|
491
523
|
}
|
|
492
524
|
|
|
525
|
+
.admin-stat-note {
|
|
526
|
+
color: var(--fg-muted);
|
|
527
|
+
font-size: 13.5px;
|
|
528
|
+
margin: 6px 0 0;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/* A heading between groups of cards, like "Spend breakdown". */
|
|
532
|
+
.admin-section-title {
|
|
533
|
+
font-size: 17px;
|
|
534
|
+
font-weight: 500;
|
|
535
|
+
margin: 8px 0 14px;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/* A link that is the way into more, in a card's header. Coloured, unlike
|
|
539
|
+
links in tables, because it is the one action the card offers. */
|
|
540
|
+
.admin-link {
|
|
541
|
+
color: var(--link);
|
|
542
|
+
font-size: 14px;
|
|
543
|
+
text-decoration: underline;
|
|
544
|
+
text-underline-offset: 3px;
|
|
545
|
+
text-decoration-thickness: 1px;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/* Rows of a short list inside a card: a title, a line under it, and
|
|
549
|
+
something on the right. */
|
|
550
|
+
.admin-list { list-style: none; margin: 0 -24px -22px; padding: 0; }
|
|
551
|
+
.admin-list-row {
|
|
552
|
+
display: flex;
|
|
553
|
+
align-items: center;
|
|
554
|
+
gap: 16px;
|
|
555
|
+
padding: 14px 24px;
|
|
556
|
+
border-top: 1px solid var(--border);
|
|
557
|
+
}
|
|
558
|
+
.admin-list-main { flex: 1; min-width: 0; }
|
|
559
|
+
.admin-list-title {
|
|
560
|
+
display: block;
|
|
561
|
+
color: var(--fg);
|
|
562
|
+
font-size: 15px;
|
|
563
|
+
overflow: hidden;
|
|
564
|
+
text-overflow: ellipsis;
|
|
565
|
+
white-space: nowrap;
|
|
566
|
+
}
|
|
567
|
+
.admin-list-sub { display: block; color: var(--fg-muted); font-size: 13.5px; }
|
|
568
|
+
.admin-list-end { display: flex; align-items: center; gap: 12px; flex-shrink: 0; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
|
|
569
|
+
|
|
570
|
+
/* A bar for a share of something: a stat against its limit. */
|
|
571
|
+
.admin-meter {
|
|
572
|
+
height: 8px;
|
|
573
|
+
border-radius: 999px;
|
|
574
|
+
background: var(--surface-active);
|
|
575
|
+
overflow: hidden;
|
|
576
|
+
}
|
|
577
|
+
.admin-meter > span {
|
|
578
|
+
display: block;
|
|
579
|
+
height: 100%;
|
|
580
|
+
border-radius: inherit;
|
|
581
|
+
background: var(--link);
|
|
582
|
+
}
|
|
583
|
+
|
|
493
584
|
/* --- Grid -------------------------------------------------------------- */
|
|
494
585
|
|
|
495
586
|
/* A grid is a section like a card is, so it carries the same space beneath
|
|
@@ -499,7 +590,7 @@ const adminStyles = `
|
|
|
499
590
|
Cards *inside* a grid are spaced by the gap, so their own margin would add
|
|
500
591
|
a second, uneven one. Only direct children are reset — a column of stacked
|
|
501
592
|
cards, which is what the editor's sidebar is, still needs its margins. */
|
|
502
|
-
.admin-grid { display: grid; gap:
|
|
593
|
+
.admin-grid { display: grid; gap: 20px; margin-bottom: 24px; }
|
|
503
594
|
.admin-grid > .admin-card { margin-bottom: 0; }
|
|
504
595
|
.admin-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
505
596
|
.admin-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
@@ -520,14 +611,14 @@ const adminStyles = `
|
|
|
520
611
|
align-items: center;
|
|
521
612
|
justify-content: center;
|
|
522
613
|
gap: 6px;
|
|
523
|
-
height:
|
|
524
|
-
padding: 0
|
|
525
|
-
border-radius:
|
|
614
|
+
height: 36px;
|
|
615
|
+
padding: 0 14px;
|
|
616
|
+
border-radius: 10px;
|
|
526
617
|
border: 1px solid var(--border-strong);
|
|
527
618
|
background: var(--surface);
|
|
528
619
|
color: var(--fg);
|
|
529
620
|
font-family: inherit;
|
|
530
|
-
font-size:
|
|
621
|
+
font-size: 14px;
|
|
531
622
|
font-weight: 500;
|
|
532
623
|
line-height: 1;
|
|
533
624
|
cursor: pointer;
|
|
@@ -969,16 +1060,14 @@ const adminStyles = `
|
|
|
969
1060
|
text-align: left;
|
|
970
1061
|
padding: 8px 12px;
|
|
971
1062
|
color: var(--fg-muted);
|
|
972
|
-
font-weight:
|
|
973
|
-
font-size:
|
|
974
|
-
text-transform: uppercase;
|
|
975
|
-
letter-spacing: 0.04em;
|
|
1063
|
+
font-weight: 450;
|
|
1064
|
+
font-size: 13px;
|
|
976
1065
|
border-bottom: 1px solid var(--border);
|
|
977
1066
|
white-space: nowrap;
|
|
978
1067
|
}
|
|
979
1068
|
|
|
980
1069
|
.admin-table td {
|
|
981
|
-
padding:
|
|
1070
|
+
padding: 13px 12px;
|
|
982
1071
|
border-bottom: 1px solid var(--border);
|
|
983
1072
|
vertical-align: middle;
|
|
984
1073
|
}
|
|
@@ -991,10 +1080,10 @@ const adminStyles = `
|
|
|
991
1080
|
.admin-badge {
|
|
992
1081
|
display: inline-flex;
|
|
993
1082
|
align-items: center;
|
|
994
|
-
height:
|
|
995
|
-
padding: 0
|
|
1083
|
+
height: 22px;
|
|
1084
|
+
padding: 0 10px;
|
|
996
1085
|
border-radius: 999px;
|
|
997
|
-
font-size:
|
|
1086
|
+
font-size: 12.5px;
|
|
998
1087
|
font-weight: 500;
|
|
999
1088
|
background: var(--surface-active);
|
|
1000
1089
|
color: var(--fg-muted);
|
|
@@ -1028,6 +1117,9 @@ const adminStyles = `
|
|
|
1028
1117
|
underline on hover is what marks them as links. */
|
|
1029
1118
|
.admin-content a:not([class*="admin-btn"]):hover { text-decoration: underline; }
|
|
1030
1119
|
|
|
1120
|
+
/* After the two rules above, which would otherwise take its colour. */
|
|
1121
|
+
.admin-layout a.admin-link { color: var(--link); text-decoration: underline; }
|
|
1122
|
+
|
|
1031
1123
|
@media (max-width: 700px) {
|
|
1032
1124
|
.admin-sidebar { width: var(--sidebar-w-closed); }
|
|
1033
1125
|
.admin-sidebar .admin-nav-label,
|
|
@@ -1040,7 +1132,9 @@ const adminStyles = `
|
|
|
1040
1132
|
border-top: 1px solid var(--border);
|
|
1041
1133
|
}
|
|
1042
1134
|
.admin-main { margin-left: var(--sidebar-w-closed); }
|
|
1043
|
-
.admin-content { padding: 16px; }
|
|
1135
|
+
.admin-content { padding: 4px 16px 32px; }
|
|
1044
1136
|
.admin-header { padding: 0 16px; }
|
|
1137
|
+
.admin-page-head { flex-direction: column; }
|
|
1138
|
+
.admin-page-title { font-size: 26px; }
|
|
1045
1139
|
}
|
|
1046
1140
|
`;
|
|
@@ -59,8 +59,16 @@ export default function AdminDashboard() {
|
|
|
59
59
|
{ label: t('Pending Comments'), value: stats?.pendingComments },
|
|
60
60
|
{ label: t('Media Files'), value: stats?.media }
|
|
61
61
|
].filter((card) => typeof card.value === 'number');
|
|
62
|
+
const newPost = (_jsx(Link, { href: "/admin/posts/new", className: "admin-btn admin-btn-primary", children: t('New Post') }));
|
|
62
63
|
if (loading) {
|
|
63
|
-
return (_jsx(AdminLayout, { title: t('Dashboard'), children: _jsx("div", { className: "admin-loading", children: t('Loading...') }) }));
|
|
64
|
+
return (_jsx(AdminLayout, { title: t('Dashboard'), description: t('How the site is doing, and what changed recently.'), children: _jsx("div", { className: "admin-loading", children: t('Loading...') }) }));
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
+
const shortcuts = [
|
|
67
|
+
{ href: '/admin/pages/new', label: t('New Page'), sub: t('A page outside the post stream') },
|
|
68
|
+
{ href: '/admin/media', label: t('Upload Media'), sub: t('Images and files for posts and pages') },
|
|
69
|
+
{ href: '/admin/settings', label: t('Settings'), sub: t('Site name, reading and comments') },
|
|
70
|
+
{ href: 'https://basicben.com/docs', label: t('Documentation'), sub: 'basicben.com/docs', external: true },
|
|
71
|
+
{ href: '/', label: t('View Site'), sub: t('Open the public site') }
|
|
72
|
+
];
|
|
73
|
+
return (_jsxs(AdminLayout, { title: t('Dashboard'), description: t('How the site is doing, and what changed recently.'), actions: newPost, children: [cards.length > 0 && (_jsx("div", { className: `admin-grid admin-grid-${Math.min(4, Math.max(2, cards.length))}`, children: cards.map(card => (_jsxs("div", { className: "admin-stat-card", children: [_jsx("div", { className: "admin-stat-label", children: card.label }), _jsx("div", { className: "admin-stat-value", children: card.value.toLocaleString(locale) })] }, card.label))) })), _jsxs("div", { className: "admin-grid admin-grid-2", children: [_jsxs("div", { className: "admin-card", children: [_jsxs("div", { className: "admin-card-header", children: [_jsx("h2", { className: "admin-card-title", children: t('Recent Posts') }), _jsx(Link, { href: "/admin/posts", className: "admin-link", children: t('View all') })] }), recentPosts.length === 0 ? (_jsx("p", { style: { color: 'var(--fg-muted)', margin: 0 }, children: t('No posts yet. Create your first post!') })) : (_jsx("ul", { className: "admin-list", children: recentPosts.map(post => (_jsxs("li", { className: "admin-list-row", children: [_jsxs("div", { className: "admin-list-main", children: [_jsx(Link, { href: `/admin/posts/${post.id}/edit`, className: "admin-list-title", children: post.title }), _jsx("span", { className: "admin-list-sub", children: new Date(post.created_at).toLocaleDateString(locale, { dateStyle: 'medium' }) })] }), _jsx("div", { className: "admin-list-end", children: _jsx("span", { className: `admin-badge ${post.published ? 'admin-badge-success' : 'admin-badge-warning'}`, children: post.published ? t('Published') : t('Draft') }) })] }, post.id))) }))] }), _jsxs("div", { className: "admin-card", children: [_jsx("div", { className: "admin-card-header", children: _jsx("h2", { className: "admin-card-title", children: t('Shortcuts') }) }), _jsx("ul", { className: "admin-list", children: shortcuts.map(item => (_jsxs("li", { className: "admin-list-row", children: [_jsxs("div", { className: "admin-list-main", children: [_jsx(Link, { href: item.href, className: "admin-list-title", ...(item.external ? { target: '_blank', rel: 'noopener noreferrer' } : {}), children: item.label }), _jsx("span", { className: "admin-list-sub", children: item.sub })] }), _jsx("span", { className: "admin-list-end", "aria-hidden": "true", children: item.external ? '↗' : '→' })] }, item.href))) })] })] })] }));
|
|
66
74
|
}
|