diff --git a/src/admin/admin-css.ts b/src/admin/admin-css.ts new file mode 100644 index 0000000..5002816 --- /dev/null +++ b/src/admin/admin-css.ts @@ -0,0 +1,536 @@ +/** + * Admin shell stylesheet, extracted from _layout.tsx (Q-6, Aug 2026 quality audit; lives outside routes/ because the manifest generator treats every routes/* file as a route module) + * so the layout component is readable and the CSS lives in one reviewable place. + */ + +export function adminCss(rtl: boolean): string { + return ` + *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; } + :root { + --sidebar-w: 220px; + --topbar-h: 52px; + --accent: #4f46e5; + --accent-hover: #4338ca; + --bg: #f8f9fa; + --surface: #ffffff; + --border: #e2e8f0; + --text: #1a202c; + --text-muted: #718096; + --danger: #e53e3e; + } + body { font-family: system-ui, sans-serif; background: var(--bg); color: var(--text); } + a { color: inherit; text-decoration: none; } + + /* Layout */ + .admin-layout { display: flex; min-height: 100vh; } + .admin-sidebar { + width: var(--sidebar-w); min-height: 100vh; background: var(--surface); + border-${rtl ? "left" : "right"}: 1px solid var(--border); + display: flex; flex-direction: column; flex-shrink: 0; + position: sticky; top: 0; height: 100vh; overflow-y: auto; + } + .admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; } + .admin-content { flex: 1; padding: 24px; } + + /* Sidebar */ + .sidebar-brand { + display: flex; align-items: center; justify-content: space-between; + padding: 16px; font-size: 18px; font-weight: 700; border-bottom: 1px solid var(--border); + } + .sidebar-brand a { color: var(--text); } + .sidebar-close { display: none; background: none; border: none; cursor: pointer; font-size: 18px; } + .sidebar-nav { padding: 12px 0; } + .nav-group { margin-bottom: 4px; } + .nav-group-label { + padding: 6px 16px 2px; font-size: 10px; font-weight: 600; + text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); + } + .nav-item { + display: flex; align-items: center; gap: 10px; + padding: 8px 16px; border-radius: 6px; margin: 0 8px; + color: var(--text); font-size: 14px; transition: background .15s; + } + .nav-item:hover { background: var(--bg); } + .nav-item.active { background: #eef2ff; color: var(--accent); font-weight: 500; } + + /* Top bar */ + .admin-topbar { + height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; + padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border); + position: sticky; top: 0; z-index: 10; + } + .sidebar-toggle { + background: none; border: none; cursor: pointer; font-size: 20px; padding: 4px 8px; + } + .topbar-right { display: flex; align-items: center; gap: 12px; } + .topbar-user { font-size: 14px; color: var(--text-muted); } + + /* Buttons */ + .btn { + display: inline-flex; align-items: center; gap: 6px; + padding: 8px 16px; border-radius: 6px; font-size: 14px; font-weight: 500; + border: 1px solid var(--border); background: var(--surface); cursor: pointer; + color: var(--text); transition: background .15s; + } + .btn:hover { background: var(--bg); } + .btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); } + .btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); } + .btn-sm { padding: 4px 10px; font-size: 13px; } + .btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); } + + /* Tables */ + .admin-table { width: 100%; border-collapse: collapse; font-size: 14px; } + .admin-table th { text-align: ${ + rtl ? "right" : "left" + }; padding: 10px 12px; background: var(--bg); border-bottom: 1px solid var(--border); font-weight: 600; } + .admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); } + .admin-table tr:hover td { background: var(--bg); } + + /* Forms */ + .form-group { margin-bottom: 16px; } + label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; } + input[type=text], input[type=email], input[type=password], select, textarea { + width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; + font-size: 14px; background: var(--surface); + } + input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; } + + /* Alerts */ + .alert { padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 16px; } + .alert-error { background: #fff5f5; border: 1px solid #fed7d7; color: var(--danger); } + .alert-success { background: #f0fff4; border: 1px solid #c6f6d5; color: #276749; } + + /* Stats */ + .stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; } + .stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; } + .stat-number { font-size: 28px; font-weight: 700; color: var(--accent); } + .stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; } + + /* Badges */ + .badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; } + .badge-md { background: #ebf8ff; color: #2b6cb0; } + .badge-mdx { background: #f0fff4; color: #276749; } + .badge-tsx { background: #faf5ff; color: #6b46c1; } + + /* Overlay + mobile sidebar */ + .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; } + .sidebar-overlay.visible { display: block; } + @media (max-width: 768px) { + .admin-sidebar { + position: fixed; ${rtl ? "right" : "left"}: 0; top: 0; z-index: 50; + transform: translate${rtl ? "X(100%)" : "X(-100%)"}; + transition: transform .25s; + } + .admin-sidebar.open { transform: translateX(0); } + .sidebar-close { display: block; } + } + @media (min-width: 769px) { .sidebar-toggle { display: none; } } + + /* Island mount targets */ + .island-root { min-height: 60px; } + + /* Page editor (islands/PageEditor.tsx) — was entirely unstyled: no rule + anywhere gave .editor-body a height, so the textarea's own + height:100% resolved against an auto-height parent and collapsed to + the browser's default ~2-row textarea instead of filling the pane. */ + .editor-layout { display: flex; flex-direction: column; height: 100%; } + .editor-toolbar { + display: flex; align-items: center; justify-content: space-between; + gap: 8px; flex-wrap: wrap; flex-shrink: 0; + padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); + } + .toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; } + .editor-title { + font-weight: 600; font-size: 14px; max-width: 320px; + overflow: hidden; text-overflow: ellipsis; white-space: nowrap; + } + .toolbar-dirty { + font-size: 12px; color: #b45309; background: #fffbeb; + border: 1px solid #fde68a; border-radius: 4px; padding: 2px 8px; + } + .editor-body { display: flex; flex: 1; min-height: 0; } + .editor-sidebar { + width: 260px; flex-shrink: 0; overflow-y: auto; + padding: 16px; border-${ + rtl ? "left" : "right" + }: 1px solid var(--border); background: var(--surface); + } + .editor-sidebar h4 { + font-size: 12px; font-weight: 600; text-transform: uppercase; + letter-spacing: .06em; color: var(--text-muted); margin-bottom: 14px; + } + .editor-main { flex: 1; min-width: 0; display: flex; } + .editor-main-split { flex: 0 0 50%; } + .editor-content { flex: 1; } + .editor-preview { + flex: 1; min-width: 0; display: flex; + border-${rtl ? "right" : "left"}: 1px solid var(--border); + } + .raw-frontmatter summary { cursor: pointer; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; } + .raw-frontmatter-view { + margin-top: 8px; font-family: monospace; font-size: 12px; resize: vertical; + background: var(--bg); color: var(--text-muted); + } + .raw-frontmatter-hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; } + .translation-links { display: flex; flex-direction: column; gap: 6px; } + .translation-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; } + .badge-warning { background: #fffbeb; color: #b45309; } + .badge-lang { background: #eef2ff; color: #4338ca; text-transform: uppercase; } + @media (max-width: 900px) { + .editor-body { flex-direction: column; } + .editor-sidebar { width: 100%; border-${ + rtl ? "left" : "right" + }: none; border-bottom: 1px solid var(--border); } + } + + /* Dismissable toast (PageEditor, PageBuilder) */ + .toast { + padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; + box-shadow: 0 4px 12px rgba(0,0,0,.15); + } + .toast-error { background: #fff5f5; border: 1px solid #fed7d7; color: var(--danger); } + + /* Section headers */ + .section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; } + .section-header h2 { font-size: 20px; font-weight: 600; } + + /* Metrics dashboard */ + .metric-card { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; background: var(--surface); } + .metric-card-highlight { border-color: #fed7d7; background: #fff5f5; } + .metric-card-value { font-size: 1.5rem; font-weight: 700; color: #2d3748; } + .metric-card-value-highlight { color: var(--danger); } + .bar-track { flex: 1; height: 8px; background: #e2e8f0; border-radius: 4px; } + .bar-fill { height: 8px; border-radius: 4px; } + .bar-fill-ok { background: var(--accent); } + .bar-fill-warn { background: #f59e0b; } + .bar-fill-danger { background: var(--danger); } + .text-danger { color: var(--danger); } + + /* Buttons — additional variants referenced across admin islands but never + previously defined (the underlying .btn base already existed). */ + .btn:disabled { opacity: .5; cursor: not-allowed; } + .btn-outline { background: transparent; } + .btn-xs { padding: 2px 8px; font-size: 12px; } + .btn-enabled { background: #ecfdf5; color: #059669; border-color: #a7f3d0; } + .btn-disabled { background: #fef2f2; color: #b91c1c; border-color: #fecaca; } + + /* Badges — additional variants (badge-md/mdx/tsx already existed above) */ + .badge-fmt { background: #edf2f7; color: #4a5568; text-transform: uppercase; font-size: 10px; } + .badge-draft { background: #fffbeb; color: #b45309; } + .badge-latest { background: #ecfdf5; color: #059669; } + + /* Forms — additional pieces (.form-group/label/inputs already existed above) */ + .form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; } + .form-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; } + .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; } + + /* Modals (PageTree create dialog, MediaLibrary detail view) */ + .modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; } + .modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); } + .modal-content { + position: relative; background: var(--surface); border-radius: 10px; padding: 24px; + width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto; + box-shadow: 0 10px 40px rgba(0,0,0,.2); + } + .modal-content h3 { font-size: 18px; margin-bottom: 16px; } + .modal-wide { max-width: 720px; } + + /* Pages list (islands/PageTree.tsx) */ + .page-tree-wrap { display: flex; flex-direction: column; gap: 16px; } + .page-tree-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; } + .tree-search-form { flex: 1; min-width: 200px; } + .tree-search-form input { width: 100%; } + .page-tree { display: flex; flex-direction: column; gap: 2px; } + .page-tree-row { + display: flex; align-items: center; gap: 8px; + padding: 8px 12px; border-radius: 6px; transition: background .1s; + } + .page-tree-row:hover { background: var(--bg); } + .tree-toggle { width: 16px; text-align: center; color: var(--text-muted); font-size: 11px; user-select: none; } + .page-tree-title { + flex: 1; min-width: 0; font-weight: 500; color: var(--text); + white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + } + .page-tree-title:hover { color: var(--accent); } + .tree-route { color: var(--text-muted); font-size: 12px; font-family: ui-monospace, monospace; } + .tree-actions { display: flex; gap: 6px; opacity: 0; transition: opacity .1s; } + .page-tree-row:hover .tree-actions { opacity: 1; } + .tree-children { border-${ + rtl ? "right" : "left" + }: 1px solid var(--border); margin-${rtl ? "right" : "left"}: 8px; padding-${ + rtl ? "right" : "left" + }: 8px; } + + /* Media library (islands/MediaLibrary.tsx) */ + .media-wrap { display: flex; flex-direction: column; gap: 16px; } + .media-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; } + .media-toolbar select { width: auto; min-width: 140px; } + .media-search { flex: 1; min-width: 200px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; } + .media-count { color: var(--text-muted); font-size: 13px; margin-${ + rtl ? "right" : "left" + }: auto; } + .media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; } + .media-item { + border: 1px solid var(--border); border-radius: 8px; padding: 8px; + cursor: pointer; background: var(--surface); transition: border-color .1s; text-align: center; + } + .media-item:hover { border-color: var(--accent); } + .media-item-selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,70,229,.15); } + .media-icon { + display: flex; align-items: center; justify-content: center; height: 90px; + font-size: 32px; background: var(--bg); border-radius: 6px; margin-bottom: 8px; overflow: hidden; + } + .media-icon img { max-width: 100%; max-height: 100%; object-fit: cover; } + .media-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .media-size { font-size: 11px; color: var(--text-muted); } + .media-detail { display: flex; gap: 20px; flex-wrap: wrap; } + .media-detail-preview { flex: 1; min-width: 200px; } + .media-detail-info { flex: 1; min-width: 200px; font-size: 14px; } + .media-detail-info p { margin-bottom: 8px; } + .focal-picker-wrap { position: relative; cursor: crosshair; border-radius: 6px; overflow: hidden; } + .focal-picker-wrap img { width: 100%; display: block; } + + /* Page builder (islands/PageBuilder.tsx) */ + .bld-layout { display: flex; flex-direction: column; height: 100%; } + .bld-toolbar { + display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; + padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); + } + .bld-toolbar-left, .bld-toolbar-right { display: flex; align-items: center; gap: 8px; } + .bld-title { font-weight: 600; font-size: 14px; } + .bld-body { display: flex; flex: 1; min-height: 0; } + .bld-palette { + width: 220px; flex-shrink: 0; overflow-y: auto; padding: 16px; + border-${ + rtl ? "left" : "right" + }: 1px solid var(--border); background: var(--surface); + } + .bld-palette-item { + display: flex; align-items: center; gap: 8px; width: 100%; text-align: ${ + rtl ? "right" : "left" + }; + padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; + background: var(--bg); cursor: pointer; margin-bottom: 6px; font-size: 13px; + } + .bld-palette-item:hover { border-color: var(--accent); } + .bld-palette-icon { + display: inline-flex; align-items: center; justify-content: center; + width: 18px; height: 18px; border-radius: 4px; background: var(--accent); color: #fff; + font-size: 12px; flex-shrink: 0; + } + .bld-canvas { flex: 1; overflow-y: auto; padding: 20px; background: var(--bg); } + .bld-canvas-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); font-size: 14px; } + .bld-section { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; padding: 12px 16px; cursor: pointer; } + .bld-section-selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,70,229,.15); } + .bld-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; } + .bld-section-type { font-weight: 600; font-size: 13px; } + .bld-section-controls { display: flex; gap: 4px; } + .bld-section-preview { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-muted); } + .bld-settings { + width: 280px; flex-shrink: 0; overflow-y: auto; padding: 16px; + border-${ + rtl ? "right" : "left" + }: 1px solid var(--border); background: var(--surface); + } + .bld-settings h4 { font-size: 14px; margin-bottom: 12px; } + + /* Config editor (islands/ConfigEditor.tsx) */ + .cfg-wrap { display: flex; flex-direction: column; gap: 24px; max-width: 720px; } + .cfg-section { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 20px; } + .cfg-section h3 { font-size: 15px; margin-bottom: 16px; } + + /* Marketplace (islands/Marketplace.tsx) */ + .marketplace-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; } + .marketplace-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; display: flex; flex-direction: column; gap: 10px; } + + /* Themes (islands/ThemeSwitcher.tsx) */ + .theme-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; cursor: pointer; transition: border-color .1s; } + .theme-card:hover { border-color: var(--accent); } + .theme-card-active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,70,229,.15); } + + /* Translation memory (islands/TranslationMemory.tsx) */ + .tm-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; } + .tm-tabs { display: flex; gap: 6px; } + .tm-table td, .tm-table th { vertical-align: top; } + + /* Revision history (islands/RevisionHistory.tsx) */ + .revision-wrap { display: flex; gap: 20px; flex-wrap: wrap; } + .revision-timeline { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 10px; } + .revision-item { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; } + .revision-latest { border-color: var(--accent); } + .revision-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; } + .revision-number { font-weight: 600; font-size: 13px; } + .revision-date { color: var(--text-muted); font-size: 12px; margin-${ + rtl ? "right" : "left" + }: auto; } + .revision-message { font-size: 13px; margin-top: 4px; } + .revision-author { font-size: 12px; color: var(--text-muted); } + .revision-actions { display: flex; gap: 6px; margin-top: 8px; } + .revision-content-panel { flex: 2; min-width: 300px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; } + + /* Metrics dashboard container (metric-card/-value etc. already existed above) */ + .metrics-wrap { display: flex; flex-direction: column; gap: 20px; } + .metrics-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; } + + /* Workflow panel (islands/WorkflowPanel.tsx) */ + .workflow-panel { display: flex; flex-direction: column; gap: 16px; } + + /* Extracted from inline style="" attributes across admin islands/routes — + plugin-admin's CSP (useNonce: true) drops 'unsafe-inline' from style-src, + and Fresh only auto-nonces