mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-13 17:29:55 -05:00
Chore: Port over SeriesDetail (WIP Panels)
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
let { onClose, ...rest }: { onClose?: () => void; [k: string]: any } = $props()
|
||||
</script>
|
||||
|
||||
<div class="stub-panel">
|
||||
<button class="stub-close" onclick={onClose}>✕</button>
|
||||
<p class="stub-label">MigrateModal</p>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.stub-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 32px; min-width: 240px; }
|
||||
.stub-close { align-self: flex-end; background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 16px; }
|
||||
.stub-label { color: var(--text-faint); font-size: var(--text-sm); }
|
||||
</style>
|
||||
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
let { onClose, ...rest }: { onClose?: () => void; [k: string]: any } = $props()
|
||||
</script>
|
||||
|
||||
<div class="stub-panel">
|
||||
<button class="stub-close" onclick={onClose}>✕</button>
|
||||
<p class="stub-label">SeriesLinkPanel</p>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.stub-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 32px; min-width: 240px; }
|
||||
.stub-close { align-self: flex-end; background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 16px; }
|
||||
.stub-label { color: var(--text-faint); font-size: var(--text-sm); }
|
||||
</style>
|
||||
@@ -3,49 +3,39 @@
|
||||
|
||||
interface Props {
|
||||
children: Snippet;
|
||||
class?: string;
|
||||
class?: string;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
let { children, class: cls = "" }: Props = $props();
|
||||
let { children, class: cls = "", enabled = true }: Props = $props();
|
||||
</script>
|
||||
|
||||
<div class="hover-3d {cls}">
|
||||
<div class="hover-3d-content">
|
||||
{@render children()}
|
||||
<div class="shine"></div>
|
||||
<div class="edge-top"></div>
|
||||
<div class="edge-left"></div>
|
||||
{#if enabled}
|
||||
<div class="hover-3d {cls}">
|
||||
<div class="hover-3d-content">
|
||||
{@render children()}
|
||||
</div>
|
||||
<div></div><div></div><div></div>
|
||||
<div></div><div></div><div></div>
|
||||
<div></div><div></div>
|
||||
</div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
</div>
|
||||
{:else}
|
||||
<div class={cls}>
|
||||
{@render children()}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.hover-3d {
|
||||
display: inline-grid;
|
||||
perspective: 600px;
|
||||
--tx: 0;
|
||||
--ty: 0;
|
||||
--shine-x: 50%;
|
||||
--shine-y: 50%;
|
||||
--shadow-x: 0px;
|
||||
--shadow-y: 0px;
|
||||
--tx: 0; --ty: 0;
|
||||
--shadow-x: 0px; --shadow-y: 0px;
|
||||
--ease-out: linear(0, 0.931 13.8%, 1.196 21.4%, 1.343 29.8%, 1.378 36%, 1.365 43.2%, 1.059 78%, 1);
|
||||
--ease-hover: linear(0, 0.708 15.2%, 0.927 23.6%, 1.067 33%, 1.12 41%, 1.13 50.2%, 1.019 83.2%, 1);
|
||||
}
|
||||
|
||||
.hover-3d > :nth-child(n + 2) {
|
||||
isolation: isolate;
|
||||
z-index: 1;
|
||||
scale: 1.2;
|
||||
}
|
||||
|
||||
.hover-3d > :nth-child(n + 2) { isolation: isolate; z-index: 1; scale: 1.2; }
|
||||
.hover-3d > :nth-child(2) { grid-area: 1/1/2/2; }
|
||||
.hover-3d > :nth-child(3) { grid-area: 1/2/2/3; }
|
||||
.hover-3d > :nth-child(4) { grid-area: 1/3/2/4; }
|
||||
@@ -73,58 +63,14 @@
|
||||
0 2px 6px rgba(0,0,0,0.12);
|
||||
}
|
||||
|
||||
.hover-3d:hover > .hover-3d-content {
|
||||
--ease-out: var(--ease-hover);
|
||||
scale: 1.055;
|
||||
}
|
||||
.hover-3d:hover > .hover-3d-content { --ease-out: var(--ease-hover); scale: 1.055; }
|
||||
|
||||
.shine {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 2;
|
||||
opacity: 0;
|
||||
border-radius: inherit;
|
||||
background-image: radial-gradient(
|
||||
ellipse 80% 60% at var(--shine-x) var(--shine-y),
|
||||
rgba(255,255,255,0.22) 0%,
|
||||
rgba(255,255,255,0.08) 30%,
|
||||
transparent 65%
|
||||
);
|
||||
transition: opacity ease-out 350ms;
|
||||
mix-blend-mode: screen;
|
||||
}
|
||||
.hover-3d:hover .shine { opacity: 1; }
|
||||
|
||||
.edge-top {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0;
|
||||
height: 1px;
|
||||
z-index: 3;
|
||||
background: linear-gradient(90deg, transparent 10%, rgba(255,255,255,0.18) 50%, transparent 90%);
|
||||
opacity: 0;
|
||||
transition: opacity ease-out 350ms;
|
||||
}
|
||||
.edge-left {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
top: 0; left: 0; bottom: 0;
|
||||
width: 1px;
|
||||
z-index: 3;
|
||||
background: linear-gradient(180deg, transparent 10%, rgba(255,255,255,0.12) 50%, transparent 90%);
|
||||
opacity: 0;
|
||||
transition: opacity ease-out 350ms;
|
||||
}
|
||||
.hover-3d:hover .edge-top,
|
||||
.hover-3d:hover .edge-left { opacity: 1; }
|
||||
|
||||
.hover-3d:has(> :nth-child(2):hover) { --tx: -1; --ty: 1; --shine-x: 15%; --shine-y: 15%; --shadow-x: -8px; --shadow-y: -8px; }
|
||||
.hover-3d:has(> :nth-child(3):hover) { --tx: -1; --ty: 0; --shine-x: 50%; --shine-y: 10%; --shadow-x: 0px; --shadow-y: -8px; }
|
||||
.hover-3d:has(> :nth-child(4):hover) { --tx: -1; --ty: -1; --shine-x: 85%; --shine-y: 15%; --shadow-x: 8px; --shadow-y: -8px; }
|
||||
.hover-3d:has(> :nth-child(5):hover) { --tx: 0; --ty: 1; --shine-x: 10%; --shine-y: 50%; --shadow-x: -8px; --shadow-y: 0px; }
|
||||
.hover-3d:has(> :nth-child(6):hover) { --tx: 0; --ty: -1; --shine-x: 90%; --shine-y: 50%; --shadow-x: 8px; --shadow-y: 0px; }
|
||||
.hover-3d:has(> :nth-child(7):hover) { --tx: 1; --ty: 1; --shine-x: 15%; --shine-y: 85%; --shadow-x: -8px; --shadow-y: 8px; }
|
||||
.hover-3d:has(> :nth-child(8):hover) { --tx: 1; --ty: 0; --shine-x: 50%; --shine-y: 90%; --shadow-x: 0px; --shadow-y: 8px; }
|
||||
.hover-3d:has(> :nth-child(9):hover) { --tx: 1; --ty: -1; --shine-x: 85%; --shine-y: 85%; --shadow-x: 8px; --shadow-y: 8px; }
|
||||
.hover-3d:has(> :nth-child(2):hover) { --tx: -1; --ty: 1; --shadow-x: -8px; --shadow-y: -8px; }
|
||||
.hover-3d:has(> :nth-child(3):hover) { --tx: -1; --ty: 0; --shadow-x: 0px; --shadow-y: -8px; }
|
||||
.hover-3d:has(> :nth-child(4):hover) { --tx: -1; --ty: -1; --shadow-x: 8px; --shadow-y: -8px; }
|
||||
.hover-3d:has(> :nth-child(5):hover) { --tx: 0; --ty: 1; --shadow-x: -8px; --shadow-y: 0px; }
|
||||
.hover-3d:has(> :nth-child(6):hover) { --tx: 0; --ty: -1; --shadow-x: 8px; --shadow-y: 0px; }
|
||||
.hover-3d:has(> :nth-child(7):hover) { --tx: 1; --ty: 1; --shadow-x: -8px; --shadow-y: 8px; }
|
||||
.hover-3d:has(> :nth-child(8):hover) { --tx: 1; --ty: 0; --shadow-x: 0px; --shadow-y: 8px; }
|
||||
.hover-3d:has(> :nth-child(9):hover) { --tx: 1; --ty: -1; --shadow-x: 8px; --shadow-y: 8px; }
|
||||
</style>
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { settings } from "$lib/state/settings.svelte";
|
||||
import { getBlobUrl } from "$lib/core/cache/imageCache";
|
||||
import { platformService } from "$lib/platform-service/index";
|
||||
import { settingsState } from "$lib/state/settings.svelte";
|
||||
import { getBlobUrl } from "$lib/core/cache/imageCache";
|
||||
|
||||
let {
|
||||
src,
|
||||
@@ -23,7 +22,18 @@
|
||||
[key: string]: any;
|
||||
} = $props();
|
||||
|
||||
const isAuth = $derived((settings.serverAuthMode ?? "NONE") !== "NONE");
|
||||
function getServerUrl(): string {
|
||||
const url = settingsState.settings.serverUrl;
|
||||
return typeof url === "string" && url.trim() ? url.replace(/\/$/, "") : "http://127.0.0.1:4567";
|
||||
}
|
||||
|
||||
function plainThumbUrl(path: string): string {
|
||||
if (!path) return "";
|
||||
if (path.startsWith("http")) return path;
|
||||
return `${getServerUrl()}${path}`;
|
||||
}
|
||||
|
||||
const isAuth = $derived((settingsState.settings.serverAuthMode ?? "NONE") !== "NONE");
|
||||
|
||||
let blobUrl = $state("");
|
||||
let reqId = 0;
|
||||
@@ -35,8 +45,8 @@
|
||||
|
||||
if (!_isAuth || !_src) { blobUrl = ""; return; }
|
||||
|
||||
const id = ++reqId;
|
||||
const bareUrl = _src.startsWith("http") ? _src : `${platformService.getServerUrl()}${_src}`;
|
||||
const id = ++reqId;
|
||||
const bareUrl = _src.startsWith("http") ? _src : `${getServerUrl()}${_src}`;
|
||||
getBlobUrl(bareUrl, _priority)
|
||||
.then(u => { if (id === reqId) blobUrl = u; })
|
||||
.catch(() => { if (id === reqId) blobUrl = ""; });
|
||||
@@ -45,7 +55,7 @@
|
||||
const resolved = $derived(
|
||||
isAuth
|
||||
? (blobUrl || undefined)
|
||||
: (src ? platformService.plainThumbUrl(src) : undefined)
|
||||
: (src ? plainThumbUrl(src) : undefined)
|
||||
);
|
||||
</script>
|
||||
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
<script lang="ts">
|
||||
export interface MenuItem {
|
||||
label: string;
|
||||
icon?: any;
|
||||
onClick: () => void;
|
||||
danger?: boolean;
|
||||
disabled?: boolean;
|
||||
separator?: never;
|
||||
children?: MenuEntry[];
|
||||
}
|
||||
export interface MenuSeparator { separator: true }
|
||||
export type MenuEntry = MenuItem | MenuSeparator;
|
||||
|
||||
interface Props {
|
||||
x: number;
|
||||
y: number;
|
||||
items: MenuEntry[];
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
let { x, y, items, onClose }: Props = $props();
|
||||
|
||||
let focused = $state(-1);
|
||||
let el = $state<HTMLDivElement | undefined>(undefined);
|
||||
let measured = $state(false);
|
||||
let pos = $state({ left: 0, top: 0 });
|
||||
let subOpen = $state(-1);
|
||||
let subEls = $state<(HTMLDivElement | null)[]>([]);
|
||||
|
||||
const actionable = $derived(
|
||||
items
|
||||
.map((_, i) => i)
|
||||
.filter((i) => !("separator" in items[i]) && !(items[i] as MenuItem).disabled)
|
||||
);
|
||||
|
||||
$effect(() => { if (actionable.length && focused === -1) focused = actionable[0]; });
|
||||
|
||||
function getZoom(): number {
|
||||
const raw = parseFloat(document.documentElement.style.zoom || "1") || 1;
|
||||
return raw > 10 ? raw / 100 : raw;
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (!el) return;
|
||||
const zoom = getZoom();
|
||||
const style = getComputedStyle(document.documentElement);
|
||||
const sidebarW = parseFloat(style.getPropertyValue('--sidebar-width')) || 52;
|
||||
const titlebarH = parseFloat(style.getPropertyValue('--titlebar-height')) || 36;
|
||||
const vw = window.innerWidth / zoom;
|
||||
const vh = window.innerHeight / zoom;
|
||||
const sx = x / zoom - sidebarW / zoom;
|
||||
const sy = y / zoom - titlebarH / zoom;
|
||||
const menuW = el.offsetWidth;
|
||||
const menuH = el.offsetHeight;
|
||||
pos = {
|
||||
left: Math.max(4, sx + menuW > vw ? sx - menuW : sx),
|
||||
top: Math.max(4, sy + menuH > vh ? sy - menuH : sy),
|
||||
};
|
||||
measured = true;
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (subOpen < 0) return;
|
||||
const sub = subEls[subOpen];
|
||||
if (!sub) return;
|
||||
requestAnimationFrame(() => {
|
||||
const zoom = getZoom();
|
||||
const vw = window.innerWidth / zoom;
|
||||
const rect = sub.getBoundingClientRect();
|
||||
if (rect.right / zoom > vw) sub.classList.add("sub-flip");
|
||||
else sub.classList.remove("sub-flip");
|
||||
});
|
||||
});
|
||||
|
||||
function onMouseDown(e: MouseEvent) {
|
||||
const inMain = el?.contains(e.target as Node);
|
||||
const inSub = subOpen >= 0 && subEls[subOpen]?.contains(e.target as Node);
|
||||
if (!inMain && !inSub) onClose();
|
||||
}
|
||||
|
||||
function onTouchStartOutside(e: TouchEvent) {
|
||||
const inMain = el?.contains(e.target as Node);
|
||||
const inSub = subOpen >= 0 && subEls[subOpen]?.contains(e.target as Node);
|
||||
if (!inMain && !inSub) onClose();
|
||||
}
|
||||
|
||||
function onKey(e: KeyboardEvent) {
|
||||
if (e.key === "Escape") {
|
||||
e.stopPropagation();
|
||||
if (subOpen >= 0) { subOpen = -1; } else { onClose(); }
|
||||
return;
|
||||
}
|
||||
if (e.key === "ArrowDown") {
|
||||
e.preventDefault();
|
||||
const cur = actionable.indexOf(focused);
|
||||
focused = actionable[(cur + 1) % actionable.length] ?? actionable[0];
|
||||
return;
|
||||
}
|
||||
if (e.key === "ArrowUp") {
|
||||
e.preventDefault();
|
||||
const cur = actionable.indexOf(focused);
|
||||
focused = actionable[(cur - 1 + actionable.length) % actionable.length] ?? actionable[0];
|
||||
return;
|
||||
}
|
||||
if (e.key === "ArrowRight" && focused >= 0) {
|
||||
const item = items[focused] as MenuItem;
|
||||
if (item?.children?.length) { subOpen = focused; return; }
|
||||
}
|
||||
if (e.key === "ArrowLeft") { subOpen = -1; return; }
|
||||
if (e.key === "Enter" && focused >= 0) {
|
||||
e.preventDefault();
|
||||
const item = items[focused] as MenuItem;
|
||||
if (item?.children?.length) { subOpen = focused; return; }
|
||||
if (item && !item.disabled) { item.onClick(); onClose(); }
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
document.addEventListener("mousedown", onMouseDown, true);
|
||||
document.addEventListener("touchstart", onTouchStartOutside, true);
|
||||
document.addEventListener("keydown", onKey, true);
|
||||
return () => {
|
||||
document.removeEventListener("mousedown", onMouseDown, true);
|
||||
document.removeEventListener("touchstart", onTouchStartOutside, true);
|
||||
document.removeEventListener("keydown", onKey, true);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<div bind:this={el} class="menu" role="menu" tabindex="-1"
|
||||
style="left:{pos.left}px;top:{pos.top}px;visibility:{measured ? 'visible' : 'hidden'}"
|
||||
oncontextmenu={(e) => e.preventDefault()}>
|
||||
{#each items as item, i}
|
||||
{#if "separator" in item}
|
||||
<div class="sep"></div>
|
||||
{:else}
|
||||
{@const mi = item as MenuItem}
|
||||
{@const hasSub = !!mi.children?.length}
|
||||
<div class="item-wrap">
|
||||
<button
|
||||
class="item"
|
||||
class:danger={mi.danger}
|
||||
class:disabled={mi.disabled}
|
||||
class:focused={focused === i}
|
||||
class:has-sub={hasSub}
|
||||
disabled={mi.disabled}
|
||||
onclick={() => {
|
||||
if (mi.disabled) return;
|
||||
if (hasSub) { subOpen = subOpen === i ? -1 : i; return; }
|
||||
mi.onClick(); onClose();
|
||||
}}
|
||||
onmouseenter={() => { if (!mi.disabled) { focused = i; subOpen = hasSub ? i : -1; } }}
|
||||
onmouseleave={() => { focused = -1; }}
|
||||
>
|
||||
<span class="icon" class:icon-danger={mi.danger}>
|
||||
{#if mi.icon}<mi.icon size={13} weight="light" />{/if}
|
||||
</span>
|
||||
<span class="label">{mi.label}</span>
|
||||
{#if hasSub}<span class="sub-arrow">›</span>{/if}
|
||||
</button>
|
||||
{#if hasSub && subOpen === i}
|
||||
<div bind:this={subEls[i]} class="menu submenu" role="menu" tabindex="-1"
|
||||
onmouseenter={() => { subOpen = i; }}>
|
||||
{#each mi.children as child}
|
||||
{#if "separator" in child}
|
||||
<div class="sep"></div>
|
||||
{:else}
|
||||
{@const sc = child as MenuItem}
|
||||
<button
|
||||
class="item"
|
||||
class:danger={sc.danger}
|
||||
class:disabled={sc.disabled}
|
||||
disabled={sc.disabled}
|
||||
onclick={() => { if (!sc.disabled) { sc.onClick(); onClose(); } }}
|
||||
>
|
||||
<span class="icon" class:icon-danger={sc.danger}>
|
||||
{#if sc.icon}<sc.icon size={13} weight="light" />{/if}
|
||||
</span>
|
||||
<span class="label">{sc.label}</span>
|
||||
</button>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.menu {
|
||||
position: fixed; z-index: 200;
|
||||
background: var(--bg-raised); border: 1px solid var(--border-base);
|
||||
border-radius: var(--radius-lg); padding: var(--sp-1); min-width: 190px;
|
||||
box-shadow: 0 0 0 1px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.35), 0 16px 40px rgba(0,0,0,0.25);
|
||||
animation: scaleIn 0.1s ease both; transform-origin: top left;
|
||||
}
|
||||
.item-wrap { position: relative; }
|
||||
.submenu {
|
||||
position: absolute;
|
||||
left: 100%;
|
||||
top: 0;
|
||||
z-index: 201;
|
||||
animation: scaleIn 0.08s ease both;
|
||||
transform-origin: top left;
|
||||
}
|
||||
:global(.submenu.sub-flip) {
|
||||
left: auto;
|
||||
right: 100%;
|
||||
transform-origin: top right;
|
||||
}
|
||||
.item {
|
||||
display: flex; align-items: center; gap: var(--sp-2);
|
||||
width: 100%; padding: 5px var(--sp-2); border-radius: var(--radius-md);
|
||||
font-size: var(--text-sm); color: var(--text-secondary);
|
||||
text-align: left; cursor: pointer; background: none; border: none; outline: none;
|
||||
transition: background var(--t-fast), color var(--t-fast);
|
||||
position: relative;
|
||||
}
|
||||
.item:hover:not(.disabled), .item.focused:not(.disabled) { background: var(--bg-overlay); color: var(--text-primary); }
|
||||
.item.danger { color: var(--color-error); }
|
||||
.item.danger:hover:not(.disabled), .item.danger.focused:not(.disabled) { background: var(--color-error-bg); }
|
||||
.item.disabled { opacity: 0.3; cursor: default; pointer-events: none; }
|
||||
.icon { display: flex; align-items: center; justify-content: center; width: 18px; height: 18px; flex-shrink: 0; color: var(--text-faint); border-radius: var(--radius-sm); }
|
||||
.icon-danger { color: var(--color-error); opacity: 0.7; }
|
||||
.label { flex: 1; line-height: 1.3; }
|
||||
.sub-arrow { font-size: 14px; color: var(--text-faint); line-height: 1; margin-left: auto; padding-left: var(--sp-1); }
|
||||
.sep { height: 1px; background: var(--border-dim); margin: 3px var(--sp-1); }
|
||||
|
||||
@keyframes scaleIn { from { opacity: 0; transform: scale(0.97) } to { opacity: 1; transform: scale(1) } }
|
||||
</style>
|
||||
@@ -0,0 +1,120 @@
|
||||
<script lang="ts">
|
||||
import { MagnifyingGlass, CircleNotch, CaretDown, CaretRight } from "phosphor-svelte";
|
||||
import Thumbnail from "$lib/components/shared/manga/Thumbnail.svelte";
|
||||
import { loadSources } from "$lib/request-manager/extensions";
|
||||
import { extensionsState } from "$lib/state/extensions.svelte";
|
||||
|
||||
let lang = $state("all");
|
||||
let search = $state("");
|
||||
let expanded = $state(new Set<string>());
|
||||
|
||||
$effect(() => { loadSources() });
|
||||
|
||||
const langs = $derived(["all", ...Array.from(new Set(extensionsState.sources.map((s) => s.lang))).sort()]);
|
||||
const filtered = $derived(extensionsState.sources.filter((src) => {
|
||||
if (src.id === "0") return false;
|
||||
const matchLang = lang === "all" || src.lang === lang;
|
||||
const matchSearch = src.name.toLowerCase().includes(search.toLowerCase())
|
||||
|| src.displayName.toLowerCase().includes(search.toLowerCase());
|
||||
return matchLang && matchSearch;
|
||||
}));
|
||||
|
||||
const groups = $derived.by(() => {
|
||||
const map = new Map<string, { name: string; icon: string; sources: typeof extensionsState.sources }>();
|
||||
for (const src of filtered) {
|
||||
if (!map.has(src.name)) map.set(src.name, { name: src.name, icon: src.iconUrl, sources: [] });
|
||||
map.get(src.name)!.sources.push(src);
|
||||
}
|
||||
return Array.from(map.values());
|
||||
});
|
||||
|
||||
function toggleGroup(name: string) {
|
||||
const next = new Set(expanded);
|
||||
next.has(name) ? next.delete(name) : next.add(name);
|
||||
expanded = next;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="root">
|
||||
<div class="header">
|
||||
<h1 class="heading">Sources</h1>
|
||||
<div class="search-wrap">
|
||||
<MagnifyingGlass size={12} class="search-icon" weight="light" />
|
||||
<input class="search" placeholder="Search" bind:value={search} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="lang-row">
|
||||
{#each langs as l}
|
||||
<button class="lang-btn" class:active={lang === l} onclick={() => lang = l}>
|
||||
{l === "all" ? "All" : l.toUpperCase()}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
{#if extensionsState.loading}
|
||||
<div class="empty"><CircleNotch size={16} weight="light" class="anim-spin" style="color:var(--text-faint)" /></div>
|
||||
{:else if groups.length === 0}
|
||||
<div class="empty">No sources found.</div>
|
||||
{:else}
|
||||
<div class="list">
|
||||
{#each groups as g}
|
||||
{@const single = g.sources.length === 1}
|
||||
{@const open = expanded.has(g.name)}
|
||||
<div>
|
||||
<button class="row" onclick={() => single ? extensionsState.activeSource = g.sources[0] : toggleGroup(g.name)}>
|
||||
<Thumbnail src={g.icon} alt={g.name} class="icon" onerror={(e) => ((e.target as HTMLImageElement).style.display = "none")} />
|
||||
<div class="info">
|
||||
<span class="name">{g.name}</span>
|
||||
<span class="meta">{single ? `${g.sources[0].lang.toUpperCase()}${g.sources[0].isNsfw ? " · NSFW" : ""}` : `${g.sources.length} languages`}</span>
|
||||
</div>
|
||||
<span class="arrow">
|
||||
{#if single}→{:else if open}<CaretDown size={12} weight="light" />{:else}<CaretRight size={12} weight="light" />{/if}
|
||||
</span>
|
||||
</button>
|
||||
{#if !single && open}
|
||||
{#each g.sources as src}
|
||||
<button class="row row-indented" onclick={() => extensionsState.activeSource = src}>
|
||||
<div class="indent-spacer"></div>
|
||||
<div class="info"><span class="name">{src.lang.toUpperCase()}{src.isNsfw ? " · NSFW" : ""}</span></div>
|
||||
<span class="arrow">→</span>
|
||||
</button>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.root { display: flex; flex-direction: column; height: 100%; overflow: hidden; animation: fadeIn 0.14s ease both; }
|
||||
.content { flex: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-6) var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3); }
|
||||
.header { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-6); border-bottom: 1px solid var(--border-dim); flex-shrink: 0; }
|
||||
.heading { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: var(--weight-normal); color: var(--text-faint); letter-spacing: var(--tracking-wider); text-transform: uppercase; }
|
||||
.search-wrap { position: relative; display: flex; align-items: center; }
|
||||
.search-wrap :global(.search-icon) { position: absolute; left: 9px; color: var(--text-faint); pointer-events: none; }
|
||||
.search { background: var(--bg-raised); border: 1px solid var(--border-dim); border-radius: var(--radius-md); padding: 5px 10px 5px 26px; color: var(--text-primary); font-size: var(--text-sm); width: 180px; outline: none; transition: border-color var(--t-base); }
|
||||
.search::placeholder { color: var(--text-faint); }
|
||||
.search:focus { border-color: var(--border-strong); }
|
||||
.lang-row { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
|
||||
.lang-btn { font-family: var(--font-ui); font-size: var(--text-2xs); letter-spacing: var(--tracking-wider); padding: 3px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border-dim); background: none; color: var(--text-faint); cursor: pointer; transition: color var(--t-base), border-color var(--t-base), background var(--t-base); }
|
||||
.lang-btn:hover { color: var(--text-muted); border-color: var(--border-strong); }
|
||||
.lang-btn.active { background: var(--accent-muted); border-color: var(--accent-dim); color: var(--accent-fg); }
|
||||
.list { display: flex; flex-direction: column; gap: 1px; }
|
||||
.row { display: flex; align-items: center; gap: var(--sp-3); padding: 9px var(--sp-3); border-radius: var(--radius-md); border: 1px solid transparent; background: none; text-align: left; width: 100%; cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast); }
|
||||
.row:hover { background: var(--bg-raised); border-color: var(--border-dim); }
|
||||
.row-indented { padding-left: var(--sp-5); }
|
||||
.indent-spacer { width: 32px; flex-shrink: 0; }
|
||||
:global(.icon) { width: 32px; height: 32px; border-radius: var(--radius-md); object-fit: cover; flex-shrink: 0; background: var(--bg-raised); }
|
||||
.info { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
|
||||
.name { font-size: var(--text-base); font-weight: var(--weight-medium); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.meta { font-family: var(--font-ui); font-size: var(--text-2xs); color: var(--text-faint); letter-spacing: var(--tracking-wide); }
|
||||
.arrow { display: flex; align-items: center; font-family: var(--font-ui); font-size: var(--text-xs); color: var(--text-faint); flex-shrink: 0; opacity: 0; transition: opacity var(--t-base); }
|
||||
.row:hover .arrow { opacity: 1; }
|
||||
.empty { display: flex; align-items: center; justify-content: center; height: 160px; color: var(--text-faint); font-family: var(--font-ui); font-size: var(--text-xs); letter-spacing: var(--tracking-wide); }
|
||||
|
||||
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
|
||||
</style>
|
||||
Reference in New Issue
Block a user