mirror of
https://github.com/thegeneralist01/archivr
synced 2026-12-04 18:56:44 +01:00
feat(frontend): dark mode
This commit is contained in:
parent
f41697c800
commit
eb5e94bfd9
15 changed files with 575 additions and 67 deletions
|
|
@ -95,6 +95,9 @@ async fn setup_guard(State(state): State<AppState>, req: Request, next: Next) ->
|
|||
let exempt = path.starts_with("/api/auth/")
|
||||
|| path.starts_with("/assets")
|
||||
|| path == "/"
|
||||
|| path == "/theme-init.js"
|
||||
|| path == "/favicon.ico"
|
||||
|| path == "/favicon.svg"
|
||||
|| path == "/health";
|
||||
if !exempt {
|
||||
if let Ok(conn) = database::open_auth_db(&state.auth_db_path) {
|
||||
|
|
@ -6253,6 +6256,21 @@ mod tests {
|
|||
assert_eq!(json["setup_required"], true);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn theme_init_exempt_from_setup_guard() {
|
||||
let (test_app, _dir) = make_setup_test_app();
|
||||
let response = test_app
|
||||
.oneshot(
|
||||
Request::builder()
|
||||
.uri("/theme-init.js")
|
||||
.body(Body::empty())
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_ne!(response.status(), StatusCode::SERVICE_UNAVAILABLE);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn setup_post_returns_409_on_repeat() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
|
|
|
|||
|
|
@ -6,8 +6,9 @@
|
|||
<title>Archivr</title>
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
||||
<script type="module" crossorigin src="/assets/index-CSEU9J6M.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-D-bTRI4I.css">
|
||||
<script src="/theme-init.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-C6nWFmj8.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-wmXsSAqS.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ Contributing? See the [contributor guide](../CONTRIBUTING.md) and its ecosystem
|
|||
- **LLM summaries** — regenerable per-entry summary via the Anthropic HTTP API, an OpenAI-compatible HTTP API, a local `claude` CLI, or a local `codex` CLI; triggered manually from the entry rail, never automatically on capture; text-only by default, with an explicit `Include attached images` option; YouTube videos are summarized from their subtitles
|
||||
- **Text notes** — capture a plain-text or Markdown note with a title and no URL; the byte-preserving note is stored as a normal deduplicated blob and opens in the usual entry-rail preview
|
||||
- **In-progress capture indicator** — running captures appear as a compact spinner row in the entries list until they finish, replacing the earlier grey skeleton block
|
||||
- **Dark mode** — toggle light/dark from the topbar or auth screen, or configure System/Light/Dark under **Settings › Profile**
|
||||
|
||||
## Quick Start
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<title>Archivr</title>
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
||||
<script src="/theme-init.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
|
|
|||
9
frontend/public/theme-init.js
Normal file
9
frontend/public/theme-init.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(function () {
|
||||
try {
|
||||
var stored = localStorage.getItem('archivr-theme');
|
||||
var isDark = stored === 'dark' || (stored !== 'light' && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
document.documentElement.dataset.theme = isDark ? 'dark' : 'light';
|
||||
} catch (e) {
|
||||
/* ignore storage access error */
|
||||
}
|
||||
})();
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import { useState } from 'react';
|
||||
import { login } from '../api.js';
|
||||
import ThemeToggle from './ThemeToggle.jsx';
|
||||
|
||||
export default function LoginPage({ onLogin }) {
|
||||
const [username, setUsername] = useState('');
|
||||
|
|
@ -23,6 +24,7 @@ export default function LoginPage({ onLogin }) {
|
|||
|
||||
return (
|
||||
<div className="login-page">
|
||||
<ThemeToggle className="auth-page-theme-toggle" />
|
||||
<div className="login-card">
|
||||
<h1 className="login-brand">Archivr</h1>
|
||||
<p className="login-tagline">Sign in to your archive</p>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import {
|
|||
getYtDlpStatus, updateYtDlp,
|
||||
} from '../api.js'
|
||||
import { describeExpiry, formatTimestamp } from '../utils.js'
|
||||
import { useTheme } from '../useTheme.js'
|
||||
|
||||
const ROLE_ADMIN = 4
|
||||
const ROLE_OWNER = 8
|
||||
|
|
@ -54,6 +55,7 @@ export default function SettingsView({ tab, onTabChange, archiveId }) {
|
|||
|
||||
function ProfileTab({ currentUser, setCurrentUser }) {
|
||||
const [displayName, setDisplayName] = useState(currentUser?.display_name ?? '')
|
||||
const { preference, resolved, setPreference } = useTheme()
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [saveMsg, setSaveMsg] = useState(null)
|
||||
|
||||
|
|
@ -133,6 +135,22 @@ function ProfileTab({ currentUser, setCurrentUser }) {
|
|||
<p className="muted" style={{ fontSize: 13, margin: '4px 0 0' }}>
|
||||
When on, tag paths show as "X / Articles" instead of "x/articles".
|
||||
</p>
|
||||
<div className="form-field" style={{ marginTop: 16 }}>
|
||||
<label className="form-label" htmlFor="theme-select">Theme</label>
|
||||
<select
|
||||
id="theme-select"
|
||||
className="field-input"
|
||||
value={preference}
|
||||
onChange={e => setPreference(e.target.value)}
|
||||
>
|
||||
<option value="system">System ({resolved})</option>
|
||||
<option value="light">Light</option>
|
||||
<option value="dark">Dark</option>
|
||||
</select>
|
||||
<p className="muted" style={{ fontSize: 13, margin: '4px 0 0' }}>
|
||||
Choose light, dark, or follow your operating system settings.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="form-section">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { useState } from 'react';
|
||||
import { doSetup } from '../api.js';
|
||||
import ThemeToggle from './ThemeToggle.jsx';
|
||||
|
||||
export default function SetupPage({ onComplete }) {
|
||||
const [username, setUsername] = useState('');
|
||||
|
|
@ -32,6 +33,7 @@ export default function SetupPage({ onComplete }) {
|
|||
|
||||
return (
|
||||
<div className="setup-page">
|
||||
<ThemeToggle className="auth-page-theme-toggle" />
|
||||
<div className="setup-card">
|
||||
<h1 className="setup-brand">Archivr</h1>
|
||||
<p className="setup-tagline">Create your owner account to get started.</p>
|
||||
|
|
|
|||
40
frontend/src/components/ThemeToggle.jsx
Normal file
40
frontend/src/components/ThemeToggle.jsx
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { useTheme } from '../useTheme.js'
|
||||
|
||||
export function SunIcon() {
|
||||
return (
|
||||
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
||||
<circle cx="8" cy="8" r="3" />
|
||||
<line x1="8" y1="1" x2="8" y2="2.5" />
|
||||
<line x1="8" y1="13.5" x2="8" y2="15" />
|
||||
<line x1="3.05" y1="3.05" x2="4.11" y2="4.11" />
|
||||
<line x1="11.89" y1="11.89" x2="12.95" y2="12.95" />
|
||||
<line x1="1" y1="8" x2="2.5" y2="8" />
|
||||
<line x1="13.5" y1="8" x2="15" y2="8" />
|
||||
<line x1="3.05" y1="12.95" x2="4.11" y2="11.89" />
|
||||
<line x1="11.89" y1="4.11" x2="12.95" y2="3.05" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export function MoonIcon() {
|
||||
return (
|
||||
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
||||
<path d="M13.5 9.8A6 6 0 1 1 6.2 2.5a4.7 4.7 0 0 0 7.3 7.3z" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default function ThemeToggle({ className = 'theme-toggle-btn' }) {
|
||||
const { preference, resolved, toggleTheme } = useTheme()
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={className}
|
||||
aria-label={`Switch to ${resolved === 'dark' ? 'light' : 'dark'} mode`}
|
||||
title={`Theme: ${preference} (${resolved}). Click to toggle.`}
|
||||
onClick={toggleTheme}
|
||||
>
|
||||
{resolved === 'dark' ? <SunIcon /> : <MoonIcon />}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import { useContext, useState } from 'react';
|
||||
import { AuthContext } from '../App.jsx';
|
||||
import { logout as apiLogout } from '../api.js';
|
||||
import ThemeToggle from './ThemeToggle.jsx';
|
||||
|
||||
export default function Topbar({ archives, archiveId, onArchiveChange, view, onViewChange, onCaptureClick, collections, selectedCollectionUid, onCollectionChange, isPublicSession, onSignInClick }) {
|
||||
const { currentUser, setCurrentUser } = useContext(AuthContext) ?? {};
|
||||
|
|
@ -51,6 +52,9 @@ export default function Topbar({ archives, archiveId, onArchiveChange, view, onV
|
|||
<>
|
||||
<span style={{ flex: 1 }} />
|
||||
<button className="logout-btn" onClick={onSignInClick}>Sign in</button>
|
||||
<div className="user-menu">
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
|
|
@ -63,14 +67,17 @@ export default function Topbar({ archives, archiveId, onArchiveChange, view, onV
|
|||
))}
|
||||
</nav>
|
||||
<button className="capture-button" onClick={onCaptureClick}>Capture</button>
|
||||
{currentUser && (
|
||||
<div className="user-menu">
|
||||
<span className="user-name">{currentUser.display_name || currentUser.username}</span>
|
||||
<button className="logout-btn" onClick={handleLogout} disabled={loggingOut}>
|
||||
{loggingOut ? 'Logging out\u2026' : 'Log out'}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
<div className="user-menu">
|
||||
<ThemeToggle />
|
||||
{currentUser && (
|
||||
<>
|
||||
<span className="user-name">{currentUser.display_name || currentUser.username}</span>
|
||||
<button className="logout-btn" onClick={handleLogout} disabled={loggingOut}>
|
||||
{loggingOut ? 'Logging out\u2026' : 'Log out'}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</header>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,36 @@
|
|||
--link: #245f72;
|
||||
--top: #141d18;
|
||||
--field: #fffdf7;
|
||||
--lift: #fff;
|
||||
--row-alt: #f2ede5;
|
||||
--row-selected: #eee2d2;
|
||||
--child-row-a: #fafaf8;
|
||||
--child-row-b: #f2f0ec;
|
||||
--url-ink: #555b55;
|
||||
--pill-bg: #d8e3df;
|
||||
--pill-ink: #275a5f;
|
||||
--pill-line: #bfd0ca;
|
||||
--ok-bg: #d8eddf;
|
||||
--ok-ink: #235c35;
|
||||
--ok-line: #b4d9be;
|
||||
--err-bg: #f5ddd8;
|
||||
--err-ink: #8d3f30;
|
||||
--err-line: #e0b8b0;
|
||||
--err-row: #fdf0ed;
|
||||
--warn-bg: #fdefd8;
|
||||
--warn-ink: #8a4f10;
|
||||
--warn-line: #f0cfa0;
|
||||
--conflict-ink: #c07000;
|
||||
--conflict-bg: #fff3cd;
|
||||
--conflict-line: #e0a000;
|
||||
--alert: #c05000;
|
||||
--disabled-bg: #ede8e0;
|
||||
--ink-hover: #2c332b;
|
||||
/* Primary buttons: dark-on-light page, light-on-dark page. */
|
||||
--strong: var(--top);
|
||||
--on-strong: #f5f0e7;
|
||||
/* Text on --accent fills; stays light in both themes. */
|
||||
--on-accent: #f5f0e7;
|
||||
--r: 3px;
|
||||
--r2: 6px;
|
||||
--r3: 10px;
|
||||
|
|
@ -23,6 +53,52 @@
|
|||
--display: "Cormorant Garamond", Georgia, serif;
|
||||
}
|
||||
|
||||
/* data-theme is always resolved to light|dark by /theme-init.js before first
|
||||
paint and kept in sync by src/theme.js. */
|
||||
:root[data-theme="dark"] {
|
||||
color-scheme: dark;
|
||||
--ink: #e6dfd1;
|
||||
--muted: #a29d91;
|
||||
--muted-2: #858074;
|
||||
--paper: #171916;
|
||||
--paper-2: #23261f;
|
||||
--paper-3: #1d201b;
|
||||
--line: #3a3e35;
|
||||
--line-soft: #2b2e27;
|
||||
--accent: #b85d46;
|
||||
--accent-2: #c9944f;
|
||||
--link: #79b4c6;
|
||||
--top: #0e110f;
|
||||
--field: #1a1d18;
|
||||
--lift: #33372f;
|
||||
--row-alt: #191c17;
|
||||
--row-selected: #352d25;
|
||||
--child-row-a: #1b1e19;
|
||||
--child-row-b: #181b16;
|
||||
--url-ink: #9b9e94;
|
||||
--pill-bg: #1d3236;
|
||||
--pill-ink: #9ccdd6;
|
||||
--pill-line: #2f4c51;
|
||||
--ok-bg: #1b3223;
|
||||
--ok-ink: #8fd0a2;
|
||||
--ok-line: #2d5038;
|
||||
--err-bg: #3b211b;
|
||||
--err-ink: #f0a08e;
|
||||
--err-line: #5c3329;
|
||||
--err-row: #2a1b17;
|
||||
--warn-bg: #382a15;
|
||||
--warn-ink: #e6b169;
|
||||
--warn-line: #5a4321;
|
||||
--conflict-ink: #e9a646;
|
||||
--conflict-bg: #352a11;
|
||||
--conflict-line: #7d5c12;
|
||||
--alert: #f08b4f;
|
||||
--disabled-bg: #262922;
|
||||
--ink-hover: #d3ccbe;
|
||||
--strong: var(--ink);
|
||||
--on-strong: var(--paper);
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
|
@ -216,7 +292,7 @@ select {
|
|||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 12px 22px;
|
||||
background: color-mix(in srgb, var(--paper) 88%, white);
|
||||
background: color-mix(in srgb, var(--paper) 88%, var(--lift));
|
||||
border-bottom: 1px solid var(--line-soft);
|
||||
}
|
||||
.search-field {
|
||||
|
|
@ -286,7 +362,7 @@ select {
|
|||
position: sticky;
|
||||
top: 67px;
|
||||
z-index: 2;
|
||||
background: color-mix(in srgb, var(--paper) 92%, white);
|
||||
background: color-mix(in srgb, var(--paper) 92%, var(--lift));
|
||||
border-bottom: 1px solid var(--line-soft);
|
||||
color: var(--muted);
|
||||
font-size: 10.5px;
|
||||
|
|
@ -303,17 +379,17 @@ select {
|
|||
}
|
||||
#entries-body > div > div { padding: 7px 10px; flex-shrink: 0; overflow: hidden; }
|
||||
/* Pending capture rows (no index class) fall back to nth-child; real rows use explicit classes. */
|
||||
#entries-body > div:not(.entry-row-outer):nth-child(even) { background: #f2ede5; }
|
||||
#entries-body > div:not(.entry-row-outer):nth-child(even) { background: var(--row-alt); }
|
||||
#entries-body > div:not(.entry-row-outer):nth-child(odd) { background: var(--paper-3); }
|
||||
/* Index-based stripes for real entry rows — immune to pending-capture sibling count. */
|
||||
#entries-body > .entry-row-outer--light { background: var(--paper-3); }
|
||||
#entries-body > .entry-row-outer--dark { background: #f2ede5; }
|
||||
#entries-body > .entry-row-outer--dark { background: var(--row-alt); }
|
||||
#entries-body > div.is-selected {
|
||||
background: #eee2d2;
|
||||
background: var(--row-selected);
|
||||
box-shadow: inset 0 0 0 2px var(--accent);
|
||||
}
|
||||
#entries-body > div.is-multi-selected {
|
||||
background: #eee2d2;
|
||||
background: var(--row-selected);
|
||||
box-shadow: inset 0 0 0 2px var(--accent);
|
||||
}
|
||||
|
||||
|
|
@ -340,12 +416,33 @@ select {
|
|||
|
||||
.entry-title { color: var(--link); font-weight: 700; min-width: 0; }
|
||||
.entry-header-row > div { padding: 9px 10px; flex-shrink: 0; font-weight: 600; }
|
||||
.source-icon { display: flex; align-items: center; justify-content: center; width: 1.05em; height: 1.05em; flex-shrink: 0; }
|
||||
.source-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 1.05em;
|
||||
height: 1.05em;
|
||||
flex-shrink: 0;
|
||||
color: var(--ink);
|
||||
opacity: 0.88;
|
||||
}
|
||||
.source-icon:hover,
|
||||
#entries-body > div:hover .source-icon,
|
||||
#entries-body > div.is-selected .source-icon,
|
||||
.child-entry-row:hover .source-icon,
|
||||
.child-entry-row.is-selected .source-icon {
|
||||
opacity: 1;
|
||||
}
|
||||
.source-icon > * { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
|
||||
.source-icon svg { width: 100%; height: 100%; }
|
||||
.url-cell { color: #555b55; white-space: nowrap; text-overflow: ellipsis; word-break: break-all; }
|
||||
.source-icon svg path:not([fill]) { fill: currentColor; }
|
||||
:root[data-theme="dark"] .favicon-img {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-radius: 3px;
|
||||
}
|
||||
.url-cell { color: var(--url-ink); white-space: nowrap; text-overflow: ellipsis; word-break: break-all; }
|
||||
#entries-body .url-cell:hover { overflow: visible; white-space: normal; }
|
||||
.type-pill { display: inline-block; padding: 2px 6px; background: #d8e3df; color: #275a5f; border: 1px solid #bfd0ca; border-radius: var(--r); }
|
||||
.type-pill { display: inline-block; padding: 2px 6px; background: var(--pill-bg); color: var(--pill-ink); border: 1px solid var(--pill-line); border-radius: var(--r); }
|
||||
|
||||
/* ── Multi-select checkbox column ───────────────────────────────────────── */
|
||||
/* Hidden on desktop (pointer:fine); always visible on touch/mobile */
|
||||
|
|
@ -408,7 +505,7 @@ select {
|
|||
z-index: 1;
|
||||
text-align: left;
|
||||
padding: 10px;
|
||||
background: color-mix(in srgb, var(--paper) 92%, white);
|
||||
background: color-mix(in srgb, var(--paper) 92%, var(--lift));
|
||||
color: var(--muted);
|
||||
border-bottom: 1px solid var(--line-soft);
|
||||
font-size: 10.5px;
|
||||
|
|
@ -420,7 +517,7 @@ select {
|
|||
border-bottom: 1px solid var(--line-soft);
|
||||
vertical-align: top;
|
||||
}
|
||||
#runs-view .entry-table tr:nth-child(even) td { background: #f2ede5; }
|
||||
#runs-view .entry-table tr:nth-child(even) td { background: var(--row-alt); }
|
||||
#runs-view .entry-table tr:nth-child(odd) td { background: var(--paper-3); }
|
||||
|
||||
/* ── Context rail ────────────────────────────────────────────────────────── */
|
||||
|
|
@ -578,7 +675,7 @@ select {
|
|||
text-transform: uppercase; border-radius: var(--r);
|
||||
cursor: pointer; white-space: nowrap;
|
||||
}
|
||||
.tag-add-btn:hover { background: #2c332b; }
|
||||
.tag-add-btn:hover { background: var(--ink-hover); }
|
||||
|
||||
/* collections in rail */
|
||||
.coll-row {
|
||||
|
|
@ -1046,7 +1143,7 @@ select {
|
|||
color: var(--muted);
|
||||
font-style: italic;
|
||||
}
|
||||
.capture-quality-hint--error { color: #c05000; font-style: normal; }
|
||||
.capture-quality-hint--error { color: var(--alert); font-style: normal; }
|
||||
|
||||
/* Status dot */
|
||||
.cap-dot {
|
||||
|
|
@ -1061,9 +1158,9 @@ select {
|
|||
line-height: 1;
|
||||
}
|
||||
.cap-dot--idle { background: var(--paper-2); }
|
||||
.cap-dot--running { background: #fdefd8; color: #8a4f10; }
|
||||
.cap-dot--ok { background: #d8eddf; color: #235c35; }
|
||||
.cap-dot--err { background: #f5ddd8; color: #8d3f30; }
|
||||
.cap-dot--running { background: var(--warn-bg); color: var(--warn-ink); }
|
||||
.cap-dot--ok { background: var(--ok-bg); color: var(--ok-ink); }
|
||||
.cap-dot--err { background: var(--err-bg); color: var(--err-ink); }
|
||||
|
||||
/* Spinner inside the running dot */
|
||||
.cap-spinner {
|
||||
|
|
@ -1317,12 +1414,12 @@ select {
|
|||
line-height: 1;
|
||||
}
|
||||
.capture-file-badge--done {
|
||||
background: #d8eddf;
|
||||
color: #235c35;
|
||||
background: var(--ok-bg);
|
||||
color: var(--ok-ink);
|
||||
}
|
||||
.capture-file-badge--error {
|
||||
background: #f5ddd8;
|
||||
color: #8d3f30;
|
||||
background: var(--err-bg);
|
||||
color: var(--err-ink);
|
||||
}
|
||||
|
||||
/* ── Toast stack ─────────────────────────────────────────────────────────── */
|
||||
|
|
@ -1877,7 +1974,7 @@ select {
|
|||
cursor: pointer;
|
||||
border-radius: var(--r);
|
||||
}
|
||||
.coll-delete-btn:hover { background: var(--accent); color: var(--paper); }
|
||||
.coll-delete-btn:hover { background: var(--accent); color: var(--on-accent); }
|
||||
.coll-detail-vis {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
@ -2042,8 +2139,32 @@ select {
|
|||
white-space: nowrap;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
.logout-btn:hover { background: rgba(255,255,255,0.1); color: var(--paper); }
|
||||
.logout-btn:hover { background: rgba(255,255,255,0.1); color: #f5f0e7; }
|
||||
.logout-btn:disabled { opacity: 0.5; cursor: default; }
|
||||
.theme-toggle-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
padding: 0;
|
||||
border: 1px solid rgba(255,255,255,0.18);
|
||||
background: transparent;
|
||||
color: #c8bfb0;
|
||||
border-radius: var(--r);
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, color 0.15s, border-color 0.15s;
|
||||
}
|
||||
.theme-toggle-btn:hover {
|
||||
background: rgba(255,255,255,0.1);
|
||||
color: #f5f0e7;
|
||||
border-color: rgba(255,255,255,0.32);
|
||||
}
|
||||
.theme-toggle-btn svg {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* ── Login / Setup pages ─────────────────────────────────────────────────── */
|
||||
.login-page,
|
||||
|
|
@ -2054,6 +2175,7 @@ select {
|
|||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--paper);
|
||||
position: relative;
|
||||
}
|
||||
.login-card,
|
||||
.setup-card {
|
||||
|
|
@ -2065,6 +2187,32 @@ select {
|
|||
border-radius: var(--r3);
|
||||
box-shadow: 0 2px 20px rgba(20,29,24,0.07);
|
||||
}
|
||||
.auth-page-theme-toggle {
|
||||
position: absolute;
|
||||
top: 18px;
|
||||
right: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
padding: 0;
|
||||
border: 1px solid var(--line);
|
||||
background: var(--paper-2);
|
||||
color: var(--ink);
|
||||
border-radius: var(--r2);
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, border-color 0.15s;
|
||||
}
|
||||
.auth-page-theme-toggle:hover {
|
||||
background: var(--field);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.auth-page-theme-toggle svg {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: block;
|
||||
}
|
||||
.login-brand,
|
||||
.setup-brand {
|
||||
font-family: var(--display);
|
||||
|
|
@ -2120,8 +2268,8 @@ select {
|
|||
width: 100%;
|
||||
margin-top: 8px;
|
||||
border: none;
|
||||
background: var(--top);
|
||||
color: var(--paper);
|
||||
background: var(--strong);
|
||||
color: var(--on-strong);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
padding: 11px 16px;
|
||||
|
|
@ -2204,8 +2352,8 @@ select {
|
|||
.form-msg--err { color: var(--accent); }
|
||||
.btn-primary {
|
||||
border: none;
|
||||
background: var(--top);
|
||||
color: var(--paper);
|
||||
background: var(--strong);
|
||||
color: var(--on-strong);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
padding: 8px 16px;
|
||||
|
|
@ -2234,7 +2382,7 @@ select {
|
|||
border-radius: var(--r);
|
||||
cursor: pointer;
|
||||
}
|
||||
.btn-danger:hover { background: var(--accent); color: var(--paper); }
|
||||
.btn-danger:hover { background: var(--accent); color: var(--on-accent); }
|
||||
|
||||
/* ── Admin view overrides ────────────────────────────────────────────────── */
|
||||
.admin-view h1 { font-family: var(--display); font-weight: 600; font-size: 26px; margin: 0 0 20px; }
|
||||
|
|
@ -2324,8 +2472,8 @@ select {
|
|||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
.status-active { background: #d8eddf; color: #235c35; border: 1px solid #b4d9be; }
|
||||
.status-disabled { background: #ede8e0; color: var(--muted); border: 1px solid var(--line); }
|
||||
.status-active { background: var(--ok-bg); color: var(--ok-ink); border: 1px solid var(--ok-line); }
|
||||
.status-disabled { background: var(--disabled-bg); color: var(--muted); border: 1px solid var(--line); }
|
||||
|
||||
/* ── Runs view improvements ──────────────────────────────────────────────── */
|
||||
.run-status {
|
||||
|
|
@ -2337,13 +2485,13 @@ select {
|
|||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
.run-status--completed { background: #d8eddf; color: #235c35; border: 1px solid #b4d9be; }
|
||||
.run-status--failed { background: #f5ddd8; color: #8d3f30; border: 1px solid #e0b8b0; }
|
||||
.run-status--in-progress { background: #fdefd8; color: #8a4f10; border: 1px solid #f0cfa0; }
|
||||
.run-status--completed { background: var(--ok-bg); color: var(--ok-ink); border: 1px solid var(--ok-line); }
|
||||
.run-status--failed { background: var(--err-bg); color: var(--err-ink); border: 1px solid var(--err-line); }
|
||||
.run-status--in-progress { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); }
|
||||
|
||||
/* Clickable failed run rows and expandable error detail */
|
||||
.run-row--failed { cursor: pointer; }
|
||||
.run-row--failed:hover td { background: #fdf0ed !important; }
|
||||
.run-row--failed:hover td { background: var(--err-row) !important; }
|
||||
.run-expand-hint {
|
||||
margin-left: 6px;
|
||||
font-size: 10px;
|
||||
|
|
@ -2369,8 +2517,8 @@ select {
|
|||
|
||||
/* ── Token created banner ────────────────────────────────────────────────── */
|
||||
.token-banner {
|
||||
background: #d8eddf;
|
||||
border: 1px solid #b4d9be;
|
||||
background: var(--ok-bg);
|
||||
border: 1px solid var(--ok-line);
|
||||
padding: 12px 14px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 13px;
|
||||
|
|
@ -2425,7 +2573,7 @@ select {
|
|||
color: var(--muted);
|
||||
background: var(--paper-2);
|
||||
}
|
||||
.session-badge { background: #d8eddf; color: #235c35; border-color: #b4d9be; }
|
||||
.session-badge { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--ok-line); }
|
||||
.token-expiry { font-size: 12px; color: var(--muted); margin-top: 2px; }
|
||||
.token-expiry--expired { color: var(--accent); }
|
||||
.session-row {
|
||||
|
|
@ -2440,7 +2588,7 @@ select {
|
|||
}
|
||||
.session-row .muted { font-size: 12px; margin-top: 2px; }
|
||||
.admin-action-btn--danger { color: var(--accent); border-color: var(--accent); }
|
||||
.admin-action-btn--danger:hover { background: #f5ddd8; }
|
||||
.admin-action-btn--danger:hover { background: var(--err-bg); }
|
||||
|
||||
/* ── Instance settings checkboxes ───────────────────────────────────────── */
|
||||
.checkbox-row {
|
||||
|
|
@ -3079,7 +3227,7 @@ google-cast-launcher.video-tv-btn {
|
|||
height: 38px;
|
||||
border-radius: 50%;
|
||||
background: var(--accent);
|
||||
color: var(--paper);
|
||||
color: var(--on-accent);
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
|
|
@ -3235,7 +3383,7 @@ google-cast-launcher.video-tv-btn {
|
|||
padding: 8px 12px;
|
||||
margin-bottom: 16px;
|
||||
background: var(--accent);
|
||||
color: var(--paper);
|
||||
color: var(--on-accent);
|
||||
border: none;
|
||||
border-radius: var(--r3);
|
||||
font-size: 13px;
|
||||
|
|
@ -3340,11 +3488,11 @@ body.has-audio-bar { padding-bottom: 56px; }
|
|||
#entries-body > .entry-row-outer.is-selected { background: unset; outline: none; box-shadow: none; }
|
||||
#entries-body > .entry-row-outer.is-multi-selected { background: unset; outline: none; box-shadow: none; }
|
||||
#entries-body > .entry-row-outer.is-selected > .entry-row-main {
|
||||
background: #eee2d2;
|
||||
background: var(--row-selected);
|
||||
box-shadow: inset 0 0 0 2px var(--accent);
|
||||
}
|
||||
#entries-body > .entry-row-outer.is-multi-selected > .entry-row-main {
|
||||
background: #eee2d2;
|
||||
background: var(--row-selected);
|
||||
box-shadow: inset 0 0 0 2px var(--accent);
|
||||
}
|
||||
|
||||
|
|
@ -3371,15 +3519,15 @@ body.has-audio-bar { padding-bottom: 56px; }
|
|||
}
|
||||
.child-entry-row:hover { opacity: 1; }
|
||||
.child-entry-row:last-child { border-bottom: none; }
|
||||
.child-entry-row--light { background: #fafaf8; }
|
||||
.child-entry-row--dark { background: #f2f0ec; }
|
||||
.child-entry-row--light { background: var(--child-row-a); }
|
||||
.child-entry-row--dark { background: var(--child-row-b); }
|
||||
.child-entry-row.is-selected {
|
||||
background: #eee2d2;
|
||||
background: var(--row-selected);
|
||||
box-shadow: inset 0 0 0 2px var(--accent);
|
||||
opacity: 1;
|
||||
}
|
||||
.child-entry-row.is-multi-selected {
|
||||
background: #eee2d2;
|
||||
background: var(--row-selected);
|
||||
box-shadow: inset 0 0 0 2px var(--accent);
|
||||
opacity: 1;
|
||||
}
|
||||
|
|
@ -3515,9 +3663,9 @@ body.has-audio-bar { padding-bottom: 56px; }
|
|||
|
||||
.capture-conflict-badge {
|
||||
font-size: 0.7rem;
|
||||
color: #c07000;
|
||||
background: #fff3cd;
|
||||
border: 1px solid #e0a000;
|
||||
color: var(--conflict-ink);
|
||||
background: var(--conflict-bg);
|
||||
border: 1px solid var(--conflict-line);
|
||||
border-radius: 4px;
|
||||
padding: 1px 6px;
|
||||
margin-left: 6px;
|
||||
|
|
@ -3542,8 +3690,8 @@ body.has-audio-bar { padding-bottom: 56px; }
|
|||
}
|
||||
.capture-playlist-item:last-of-type { border-bottom: none; }
|
||||
.capture-playlist-item--conflict {
|
||||
border-left-color: #c07000;
|
||||
background: color-mix(in srgb, #c07000 6%, transparent);
|
||||
border-left-color: var(--conflict-ink);
|
||||
background: color-mix(in srgb, var(--conflict-ink) 6%, transparent);
|
||||
}
|
||||
.capture-playlist-item-title {
|
||||
flex: 1;
|
||||
|
|
@ -3566,7 +3714,7 @@ body.has-audio-bar { padding-bottom: 56px; }
|
|||
.capture-playlist-conflict-badge {
|
||||
font-size: 0.68rem;
|
||||
font-weight: 600;
|
||||
color: #c07000;
|
||||
color: var(--conflict-ink);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
|
@ -3588,7 +3736,7 @@ body.has-audio-bar { padding-bottom: 56px; }
|
|||
}
|
||||
.capture-playlist-item:hover .capture-playlist-item-remove,
|
||||
.capture-playlist-item-remove:focus-visible { opacity: 1; }
|
||||
.capture-playlist-item-remove:hover { color: #c04000; opacity: 1; }
|
||||
.capture-playlist-item-remove:hover { color: var(--alert); opacity: 1; }
|
||||
@media (pointer: coarse) { .capture-playlist-item-remove { opacity: 1; } }
|
||||
.capture-playlist-item-remove { font-size: 0.75rem; line-height: 1; }
|
||||
|
||||
|
|
|
|||
113
frontend/src/theme.js
Normal file
113
frontend/src/theme.js
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
export const THEME_KEY = 'archivr-theme'
|
||||
export const THEMES = ['system', 'light', 'dark']
|
||||
|
||||
export function parseThemePreference(val) {
|
||||
return val === 'light' || val === 'dark' ? val : 'system'
|
||||
}
|
||||
|
||||
export function getStoredThemePreference() {
|
||||
if (typeof window === 'undefined' || !window.localStorage) return 'system'
|
||||
try {
|
||||
return parseThemePreference(window.localStorage.getItem(THEME_KEY))
|
||||
} catch {
|
||||
return 'system'
|
||||
}
|
||||
}
|
||||
|
||||
export function systemPrefersDark() {
|
||||
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return false
|
||||
try {
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveTheme(preference, isDark) {
|
||||
const pref = parseThemePreference(preference)
|
||||
if (pref === 'system') return isDark ? 'dark' : 'light'
|
||||
return pref
|
||||
}
|
||||
|
||||
export function applyTheme(preference) {
|
||||
if (typeof document === 'undefined') return 'light'
|
||||
const isDark = systemPrefersDark()
|
||||
const resolved = resolveTheme(preference, isDark)
|
||||
document.documentElement.dataset.theme = resolved
|
||||
return resolved
|
||||
}
|
||||
|
||||
const listeners = new Set()
|
||||
|
||||
function notify() {
|
||||
for (const cb of listeners) {
|
||||
try { cb() } catch { /* ignore subscriber error */ }
|
||||
}
|
||||
}
|
||||
|
||||
export function setThemePreference(preference) {
|
||||
const valid = parseThemePreference(preference)
|
||||
if (typeof window !== 'undefined' && window.localStorage) {
|
||||
try {
|
||||
if (valid === 'system') {
|
||||
window.localStorage.removeItem(THEME_KEY)
|
||||
} else {
|
||||
window.localStorage.setItem(THEME_KEY, valid)
|
||||
}
|
||||
} catch {
|
||||
// storage unavailable / quota exceeded
|
||||
}
|
||||
}
|
||||
applyTheme(valid)
|
||||
notify()
|
||||
return valid
|
||||
}
|
||||
|
||||
// Attach listeners once in browser environments
|
||||
let mediaQueryList = null
|
||||
if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') {
|
||||
try {
|
||||
mediaQueryList = window.matchMedia('(prefers-color-scheme: dark)')
|
||||
const onMediaChange = () => {
|
||||
const currentPref = getStoredThemePreference()
|
||||
if (currentPref === 'system') {
|
||||
applyTheme('system')
|
||||
notify()
|
||||
}
|
||||
}
|
||||
if (typeof mediaQueryList.addEventListener === 'function') {
|
||||
mediaQueryList.addEventListener('change', onMediaChange)
|
||||
} else if (typeof mediaQueryList.addListener === 'function') {
|
||||
mediaQueryList.addListener(onMediaChange)
|
||||
}
|
||||
} catch {
|
||||
// ignore matchMedia setup failures
|
||||
}
|
||||
|
||||
window.addEventListener('storage', (e) => {
|
||||
if (e.key === THEME_KEY) {
|
||||
applyTheme(getStoredThemePreference())
|
||||
notify()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function subscribeTheme(callback) {
|
||||
listeners.add(callback)
|
||||
return () => {
|
||||
listeners.delete(callback)
|
||||
}
|
||||
}
|
||||
|
||||
export function getThemeSnapshot() {
|
||||
const preference = getStoredThemePreference()
|
||||
const resolved = resolveTheme(preference, systemPrefersDark())
|
||||
return `${preference}:${resolved}`
|
||||
}
|
||||
if (typeof document !== 'undefined') {
|
||||
try {
|
||||
applyTheme(getStoredThemePreference())
|
||||
} catch {
|
||||
/* ignore in environments with partial DOM mocks */
|
||||
}
|
||||
}
|
||||
116
frontend/src/theme.test.js
Normal file
116
frontend/src/theme.test.js
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
import { describe, it, expect, beforeEach, afterAll } from 'bun:test'
|
||||
|
||||
function makeStorage() {
|
||||
const store = new Map()
|
||||
return {
|
||||
getItem: (k) => (store.has(k) ? store.get(k) : null),
|
||||
setItem: (k, v) => store.set(k, String(v)),
|
||||
removeItem: (k) => store.delete(k),
|
||||
clear: () => store.clear(),
|
||||
}
|
||||
}
|
||||
|
||||
const originalWindow = globalThis.window
|
||||
const mockStorage = makeStorage()
|
||||
globalThis.window = {
|
||||
localStorage: mockStorage,
|
||||
matchMedia: (query) => ({
|
||||
matches: false,
|
||||
media: query,
|
||||
addEventListener: () => {},
|
||||
removeEventListener: () => {},
|
||||
}),
|
||||
addEventListener: () => {},
|
||||
removeEventListener: () => {},
|
||||
}
|
||||
|
||||
const {
|
||||
THEME_KEY,
|
||||
parseThemePreference,
|
||||
resolveTheme,
|
||||
getStoredThemePreference,
|
||||
setThemePreference,
|
||||
subscribeTheme,
|
||||
applyTheme,
|
||||
} = await import('./theme.js')
|
||||
|
||||
describe('theme preference and resolution', () => {
|
||||
beforeEach(() => {
|
||||
mockStorage.clear()
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
globalThis.window = originalWindow
|
||||
})
|
||||
|
||||
it('parses valid and invalid preference strings', () => {
|
||||
expect(parseThemePreference('light')).toBe('light')
|
||||
expect(parseThemePreference('dark')).toBe('dark')
|
||||
expect(parseThemePreference('system')).toBe('system')
|
||||
expect(parseThemePreference('auto')).toBe('system')
|
||||
expect(parseThemePreference('')).toBe('system')
|
||||
expect(parseThemePreference(null)).toBe('system')
|
||||
expect(parseThemePreference(undefined)).toBe('system')
|
||||
expect(parseThemePreference('DARK')).toBe('system')
|
||||
})
|
||||
|
||||
it('resolves explicit preference over system state', () => {
|
||||
expect(resolveTheme('light', true)).toBe('light')
|
||||
expect(resolveTheme('light', false)).toBe('light')
|
||||
expect(resolveTheme('dark', true)).toBe('dark')
|
||||
expect(resolveTheme('dark', false)).toBe('dark')
|
||||
})
|
||||
|
||||
it('resolves system preference according to system state', () => {
|
||||
expect(resolveTheme('system', true)).toBe('dark')
|
||||
expect(resolveTheme('system', false)).toBe('light')
|
||||
expect(resolveTheme('unknown', true)).toBe('dark')
|
||||
expect(resolveTheme('unknown', false)).toBe('light')
|
||||
})
|
||||
|
||||
it('stores explicit preference and removes item for system', () => {
|
||||
setThemePreference('dark')
|
||||
expect(mockStorage.getItem(THEME_KEY)).toBe('dark')
|
||||
expect(getStoredThemePreference()).toBe('dark')
|
||||
|
||||
setThemePreference('light')
|
||||
expect(mockStorage.getItem(THEME_KEY)).toBe('light')
|
||||
expect(getStoredThemePreference()).toBe('light')
|
||||
|
||||
setThemePreference('system')
|
||||
expect(mockStorage.getItem(THEME_KEY)).toBeNull()
|
||||
expect(getStoredThemePreference()).toBe('system')
|
||||
})
|
||||
|
||||
it('notifies subscribers when preference changes', () => {
|
||||
let callCount = 0
|
||||
const unsubscribe = subscribeTheme(() => {
|
||||
callCount += 1
|
||||
})
|
||||
|
||||
setThemePreference('dark')
|
||||
expect(callCount).toBe(1)
|
||||
|
||||
setThemePreference('light')
|
||||
expect(callCount).toBe(2)
|
||||
|
||||
unsubscribe()
|
||||
setThemePreference('system')
|
||||
expect(callCount).toBe(2)
|
||||
})
|
||||
|
||||
it('applies theme to document element dataset when document exists', () => {
|
||||
const originalDoc = globalThis.document
|
||||
const htmlEl = { dataset: {} }
|
||||
globalThis.document = { documentElement: htmlEl }
|
||||
|
||||
try {
|
||||
applyTheme('dark')
|
||||
expect(htmlEl.dataset.theme).toBe('dark')
|
||||
applyTheme('light')
|
||||
expect(htmlEl.dataset.theme).toBe('light')
|
||||
} finally {
|
||||
globalThis.document = originalDoc
|
||||
}
|
||||
})
|
||||
})
|
||||
32
frontend/src/useTheme.js
Normal file
32
frontend/src/useTheme.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { useSyncExternalStore, useCallback } from 'react'
|
||||
import {
|
||||
getStoredThemePreference,
|
||||
systemPrefersDark,
|
||||
resolveTheme,
|
||||
setThemePreference,
|
||||
subscribeTheme,
|
||||
getThemeSnapshot,
|
||||
} from './theme.js'
|
||||
|
||||
export function useTheme() {
|
||||
const snapshot = useSyncExternalStore(subscribeTheme, getThemeSnapshot, () => 'system:light')
|
||||
const [preference, resolved] = snapshot.split(':')
|
||||
|
||||
const setPreference = useCallback((next) => {
|
||||
setThemePreference(next)
|
||||
}, [])
|
||||
|
||||
const toggleTheme = useCallback(() => {
|
||||
// If currently resolving to dark -> switch to light. Otherwise -> switch to dark.
|
||||
const currentResolved = resolveTheme(getStoredThemePreference(), systemPrefersDark())
|
||||
const next = currentResolved === 'dark' ? 'light' : 'dark'
|
||||
setThemePreference(next)
|
||||
}, [])
|
||||
|
||||
return {
|
||||
preference,
|
||||
resolved,
|
||||
setPreference,
|
||||
toggleTheme,
|
||||
}
|
||||
}
|
||||
|
|
@ -49,15 +49,15 @@ export const SOURCE_ICONS = {
|
|||
youtube: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="#FF0000" d="M23.5 6.2a3 3 0 0 0-2.1-2.1C19.5 3.6 12 3.6 12 3.6s-7.5 0-9.4.5A3 3 0 0 0 .5 6.2C0 8.1 0 12 0 12s0 3.9.5 5.8a3 3 0 0 0 2.1 2.1c1.9.5 9.4.5 9.4.5s7.5 0 9.4-.5a3 3 0 0 0 2.1-2.1C24 15.9 24 12 24 12s0-3.9-.5-5.8z"/><polygon fill="#fff" points="9.6,15.6 15.8,12 9.6,8.4"/></svg>`,
|
||||
youtube_music: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="12" fill="#FF0000"/><polygon fill="#fff" points="9.6,15.6 15.8,12 9.6,8.4"/></svg>`,
|
||||
spotify: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="12" fill="#1DB954"/><path fill="#fff" d="M17.9 10.9c-3.2-1.9-8.5-2.1-11.6-1.1-.5.1-1-.2-1.1-.6-.1-.5.2-1 .6-1.1 3.5-1.1 9.4-.9 13 1.3.4.2.6.8.3 1.2-.2.5-.8.6-1.2.3zm-.1 2.9c-.2.4-.7.5-1.1.3-2.7-1.6-6.7-2.1-9.9-1.1-.4.1-.9-.1-1-.5-.1-.4.1-.9.5-1 3.6-1.1 8-.5 11.1 1.3.4.2.5.7.4 1zm-1.3 2.8c-.2.3-.6.4-.9.2-2.3-1.4-5.2-1.7-8.6-.9-.3.1-.7-.1-.8-.5-.1-.3.1-.7.4-.8 3.7-.9 7-.5 9.6 1 .4.2.5.6.3.9z"/></svg>`,
|
||||
x: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M18.2 2h3.3l-7.2 8.2L23 22h-6.6l-5.2-6.8L5 22H1.7l7.7-8.8L1 2h6.8l4.7 6.2zm-1.1 18h1.8L6.9 3.9H5z"/></svg>`,
|
||||
x: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M18.2 2h3.3l-7.2 8.2L23 22h-6.6l-5.2-6.8L5 22H1.7l7.7-8.8L1 2h6.8l4.7 6.2zm-1.1 18h1.8L6.9 3.9H5z"/></svg>`,
|
||||
instagram: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="ig" x1="0%" y1="100%" x2="100%" y2="0%"><stop offset="0%" stop-color="#f09433"/><stop offset="25%" stop-color="#e6683c"/><stop offset="50%" stop-color="#dc2743"/><stop offset="75%" stop-color="#cc2366"/><stop offset="100%" stop-color="#bc1888"/></linearGradient></defs><rect width="24" height="24" rx="5" fill="url(#ig)"/><rect x="2.5" y="2.5" width="19" height="19" rx="4" fill="none" stroke="#fff" stroke-width="1.5"/><circle cx="12" cy="12" r="4" fill="none" stroke="#fff" stroke-width="1.5"/><circle cx="17.5" cy="6.5" r="1" fill="#fff"/></svg>`,
|
||||
facebook: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="24" rx="4" fill="#1877F2"/><path fill="#fff" d="M16 8h-2c-.6 0-1 .4-1 1v2h3l-.4 3H13v8h-3v-8H8v-3h2V9a4 4 0 0 1 4-4h2v3z"/></svg>`,
|
||||
tiktok: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M19.6 5.4a4.8 4.8 0 0 1-4.8-4.8h-3v14.7a2 2 0 1 1-2-2l.1-3a5 5 0 1 0 4.9 5V8.4a8 8 0 0 0 4.8 1.6V6.7a4.8 4.8 0 0 1-0-.2l0 0 .1.9z" fill="#000"/><path d="M18.6 4.4a4.8 4.8 0 0 1-4.8-4.8h-3v14.7a2 2 0 1 1-2-2l.1-3a5 5 0 1 0 4.9 5V7.4a8 8 0 0 0 4.8 1.6V5.7" fill="none" stroke="#69C9D0" stroke-width="1.5"/></svg>`,
|
||||
tiktok: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M19.6 5.4a4.8 4.8 0 0 1-4.8-4.8h-3v14.7a2 2 0 1 1-2-2l.1-3a5 5 0 1 0 4.9 5V8.4a8 8 0 0 0 4.8 1.6V6.7a4.8 4.8 0 0 1-0-.2l0 0 .1.9z" fill="currentColor"/><path d="M18.6 4.4a4.8 4.8 0 0 1-4.8-4.8h-3v14.7a2 2 0 1 1-2-2l.1-3a5 5 0 1 0 4.9 5V7.4a8 8 0 0 0 4.8 1.6V5.7" fill="none" stroke="#69C9D0" stroke-width="1.5"/></svg>`,
|
||||
reddit: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="12" fill="#FF4500"/><path fill="#fff" d="M20 12a2 2 0 0 0-2-2 2 2 0 0 0-1.3.5c-1.3-.9-3-.9-4.6-.9l.8-3.7 2.6.5a1.4 1.4 0 1 0 1.4-1.3 1.4 1.4 0 0 0-1.3.8l-2.9-.5a.3.3 0 0 0-.4.3l-.9 4.1c-1.6 0-3.1.1-4.3.9A2 2 0 0 0 4 12a2 2 0 0 0 1 1.7 3.3 3.3 0 0 0 0 .5c0 2.6 3 4.8 6.8 4.8s6.8-2.1 6.8-4.8a3.3 3.3 0 0 0 0-.5A2 2 0 0 0 20 12zm-13.6 1a1.1 1.1 0 1 1 1.1 1.1A1.1 1.1 0 0 1 6.4 13zm6.2 3.1a3.5 3.5 0 0 1-2.3.7 3.5 3.5 0 0 1-2.3-.7.3.3 0 0 1 .4-.4 3 3 0 0 0 1.9.5 3 3 0 0 0 1.9-.5.3.3 0 0 1 .4.4zm-.3-2a1.1 1.1 0 1 1 1.1-1.1A1.1 1.1 0 0 1 12.3 14.1z"/></svg>`,
|
||||
snapchat: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="24" rx="4" fill="#FFFC00"/><path d="M12 3.5c-2.4 0-4.4 2-4.4 4.4v1.3l-.8.1c-.3 0-.5.2-.5.5s.3.5.6.6c.3.1.5.3.5.8 0 .3-.1.5-.3.7-.6.8-1.5 1.3-2.2 1.4-.1.7.7 1 1.7 1.2.1.6.3.8.8.8.6 0 1.1.4 2.7.4 1.5 0 2.1-.4 2.7-.4.5 0 .7-.2.8-.8 1-.2 1.8-.5 1.7-1.2-.7-.1-1.6-.6-2.2-1.4-.2-.2-.3-.4-.3-.7 0-.5.2-.7.5-.8.3-.1.6-.3.6-.6s-.2-.5-.5-.5l-.8-.1V7.9C16.4 5.5 14.4 3.5 12 3.5z"/></svg>`,
|
||||
local: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="#666" stroke-width="1.5" stroke-linejoin="round" d="M4 4h7l2 2h7v14H4z"/></svg>`,
|
||||
web: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" fill="none" stroke="#555" stroke-width="1.5"/><ellipse cx="12" cy="12" rx="4" ry="10" fill="none" stroke="#555" stroke-width="1.5"/><line x1="2" y1="9" x2="22" y2="9" stroke="#555" stroke-width="1.5"/><line x1="2" y1="15" x2="22" y2="15" stroke="#555" stroke-width="1.5"/></svg>`,
|
||||
other: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" fill="none" stroke="#999" stroke-width="1.5"/><text x="12" y="16" text-anchor="middle" font-size="12" fill="#999">?</text></svg>`,
|
||||
local: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round" d="M4 4h7l2 2h7v14H4z"/></svg>`,
|
||||
web: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="1.5"/><ellipse cx="12" cy="12" rx="4" ry="10" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="2" y1="9" x2="22" y2="9" stroke="currentColor" stroke-width="1.5"/><line x1="2" y1="15" x2="22" y2="15" stroke="currentColor" stroke-width="1.5"/></svg>`,
|
||||
other: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="1.5"/><text x="12" y="16" text-anchor="middle" font-size="12" fill="currentColor">?</text></svg>`,
|
||||
};
|
||||
|
||||
export function sourceIconSvg(kind) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue