1 parent
7a18682b0e
commit
24fecc90f3
107 files changed
+14935
-1919
No files matched your search
@@ -0,0 +1,114 @@
|
||||
import { useState } from 'react';
|
||||
import { safeCall, toast } from '../lib/app';
|
||||
import { renderTsMarkup } from '../lib/tsMarkup';
|
||||
import { Modal } from './Modal';
|
||||
import { t } from '../i18n';
|
||||
|
||||
// Announce composer with a live TS6-markdown/BBCode preview (item 14).
|
||||
// Replaces the old prompt(). A small toolbar wraps the selection in common
|
||||
// formatting tags; the preview renders exactly what subscribers will see.
|
||||
const TOOLBAR: Array<{ label: string; before: string; after: string }> = [
|
||||
{ label: 'B', before: '**', after: '**' },
|
||||
{ label: 'I', before: '*', after: '*' },
|
||||
{ label: 'U', before: '[u]', after: '[/u]' },
|
||||
{ label: 'S', before: '~~', after: '~~' },
|
||||
{ label: '</>', before: '`', after: '`' },
|
||||
{ label: '🔗', before: '[', after: '](https://)' },
|
||||
{ label: 'H', before: '# ', after: '' },
|
||||
{ label: '❝', before: '> ', after: '' },
|
||||
];
|
||||
|
||||
export function AnnounceModal({ onClose }: { onClose: () => void }) {
|
||||
const [text, setText] = useState('');
|
||||
const [sending, setSending] = useState(false);
|
||||
let ref: HTMLTextAreaElement | null = null;
|
||||
|
||||
const wrap = (before: string, after: string) => {
|
||||
const el = ref;
|
||||
if (!el) return;
|
||||
const start = el.selectionStart;
|
||||
const end = el.selectionEnd;
|
||||
const selected = text.slice(start, end);
|
||||
const next =
|
||||
text.slice(0, start) + before + selected + after + text.slice(end);
|
||||
setText(next);
|
||||
// Restore focus with the caret after the inserted opening tag.
|
||||
queueMicrotask(() => {
|
||||
el.focus();
|
||||
const pos = start + before.length + selected.length;
|
||||
el.setSelectionRange(pos, pos);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('Compose announcement')}
|
||||
onClose={onClose}
|
||||
wide
|
||||
footer={
|
||||
<>
|
||||
<button className="btn btn-ghost" onClick={onClose}>
|
||||
{t('Cancel')}
|
||||
</button>
|
||||
<button
|
||||
className="btn btn-accent"
|
||||
disabled={!text.trim() || sending}
|
||||
onClick={async () => {
|
||||
setSending(true);
|
||||
const res = await safeCall<{ message?: string }>(
|
||||
'Announce',
|
||||
{ text: text.trim() }
|
||||
);
|
||||
setSending(false);
|
||||
if (res) {
|
||||
toast(res.message || t('Announcement sent'));
|
||||
onClose();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t('Send announcement')}
|
||||
</button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<div className="announce-toolbar">
|
||||
{TOOLBAR.map((b) => (
|
||||
<button
|
||||
key={b.label}
|
||||
className="btn btn-ghost"
|
||||
type="button"
|
||||
onClick={() => wrap(b.before, b.after)}
|
||||
>
|
||||
{b.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="announce-grid">
|
||||
<textarea
|
||||
ref={(el) => {
|
||||
ref = el;
|
||||
}}
|
||||
className="announce-input"
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
placeholder={t('Announcement to all subscribers:')}
|
||||
rows={10}
|
||||
/>
|
||||
<div className="announce-preview">
|
||||
<div className="announce-preview-label">
|
||||
{t('Preview')}
|
||||
</div>
|
||||
<div className="ts-markup">
|
||||
{text.trim() ? (
|
||||
renderTsMarkup(text)
|
||||
) : (
|
||||
<span className="muted">
|
||||
{t('Nothing to preview yet')}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { avatarColor } from '../lib/format';
|
||||
|
||||
// User avatar: tries the TeamSpeak avatar served at /avatar/<uid>, falling
|
||||
// back to the initial-letter-on-gradient avatar when the image is missing.
|
||||
// `uid` is the stable TeamSpeak unique id.
|
||||
//
|
||||
// The server fetches avatars from TeamSpeak lazily (it must first sync the
|
||||
// client's avatar hash, then download the file), so the first few requests can
|
||||
// 404 while that completes. We retry a handful of times with a growing delay,
|
||||
// bypassing the browser's negative cache with a ?v=N buster, before giving up
|
||||
// and showing initials.
|
||||
const RETRY_DELAYS_MS = [2500, 4000, 6000, 9000];
|
||||
|
||||
export function Avatar(props: {
|
||||
name: string;
|
||||
uid?: string | null;
|
||||
size?: number;
|
||||
className?: string;
|
||||
}) {
|
||||
const { name, uid, size, className } = props;
|
||||
const [attempt, setAttempt] = useState(0);
|
||||
const [failed, setFailed] = useState(false);
|
||||
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
// Reset retry state whenever the target uid changes.
|
||||
useEffect(() => {
|
||||
setAttempt(0);
|
||||
setFailed(false);
|
||||
return () => {
|
||||
if (timer.current) clearTimeout(timer.current);
|
||||
};
|
||||
}, [uid]);
|
||||
|
||||
const style: React.CSSProperties = size
|
||||
? { width: `${size}px`, height: `${size}px` }
|
||||
: {};
|
||||
|
||||
if (uid && !failed) {
|
||||
const src =
|
||||
`/avatar/${encodeURIComponent(uid)}` +
|
||||
(attempt > 0 ? `?v=${attempt}` : '');
|
||||
return (
|
||||
<img
|
||||
className={'avatar avatar-img' + (className ? ` ${className}` : '')}
|
||||
style={style}
|
||||
src={src}
|
||||
alt={name}
|
||||
onError={() => {
|
||||
if (attempt < RETRY_DELAYS_MS.length) {
|
||||
const delay = RETRY_DELAYS_MS[attempt];
|
||||
if (timer.current) clearTimeout(timer.current);
|
||||
timer.current = setTimeout(
|
||||
() => setAttempt((a) => a + 1),
|
||||
delay
|
||||
);
|
||||
} else {
|
||||
setFailed(true);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<span
|
||||
className={'avatar' + (className ? ` ${className}` : '')}
|
||||
style={{ ...style, background: avatarColor(name || '?') }}
|
||||
>
|
||||
{(name || '?').charAt(0).toUpperCase()}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import { useRef, useState } from 'react';
|
||||
|
||||
// Pointer-drag on a bar: the fill tracks the pointer while dragging and
|
||||
// onCommit fires once on release (a plain click is a zero-length drag).
|
||||
// Port of app.js makeDraggableBar.
|
||||
//
|
||||
// When `formatValue` is given, a tooltip bubble follows the pointer on hover
|
||||
// and drag showing the value at that position (item 14) — e.g. a seek time or
|
||||
// a volume percentage.
|
||||
export function Bar(props: {
|
||||
pct: number; // 0..100, authoritative fill when not dragging
|
||||
bufferPct?: number; // 0..100, second fill layer behind the progress
|
||||
slim?: boolean;
|
||||
className?: string;
|
||||
onCommit?: (fraction: number) => void;
|
||||
onDragStart?: () => boolean; // return false to refuse the drag
|
||||
live?: boolean; // live drag feedback: onCommit also fires on move
|
||||
formatValue?: (fraction: number) => string; // tooltip text at a fraction
|
||||
}) {
|
||||
const el = useRef<HTMLDivElement>(null);
|
||||
const [dragPct, setDragPct] = useState<number | null>(null);
|
||||
// Pointer position (0..100) for the tooltip; null when the pointer is away.
|
||||
const [hoverPct, setHoverPct] = useState<number | null>(null);
|
||||
|
||||
const fraction = (e: React.PointerEvent) => {
|
||||
const r = el.current!.getBoundingClientRect();
|
||||
return Math.min(1, Math.max(0, (e.clientX - r.left) / r.width));
|
||||
};
|
||||
|
||||
const tipPct = dragPct ?? hoverPct;
|
||||
const showTip = props.formatValue && tipPct != null;
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={el}
|
||||
className={
|
||||
'bar' +
|
||||
(props.slim ? ' bar-slim' : '') +
|
||||
(props.className ? ` ${props.className}` : '')
|
||||
}
|
||||
onPointerDown={(e) => {
|
||||
if (props.onDragStart && !props.onDragStart()) return;
|
||||
e.currentTarget.setPointerCapture(e.pointerId);
|
||||
const f = fraction(e);
|
||||
setDragPct(f * 100);
|
||||
if (props.live) props.onCommit?.(f);
|
||||
}}
|
||||
onPointerMove={(e) => {
|
||||
const f = fraction(e);
|
||||
setHoverPct(f * 100);
|
||||
if (dragPct == null) return;
|
||||
setDragPct(f * 100);
|
||||
if (props.live) props.onCommit?.(f);
|
||||
}}
|
||||
onPointerLeave={() => setHoverPct(null)}
|
||||
onPointerUp={(e) => {
|
||||
if (dragPct == null) return;
|
||||
setDragPct(null);
|
||||
if (!props.live) props.onCommit?.(fraction(e));
|
||||
}}
|
||||
>
|
||||
{props.bufferPct != null && (
|
||||
<div
|
||||
className="bar-buffer"
|
||||
style={{ width: `${Math.min(100, props.bufferPct)}%` }}
|
||||
/>
|
||||
)}
|
||||
<div
|
||||
className="bar-fill"
|
||||
style={{ width: `${dragPct ?? props.pct}%` }}
|
||||
/>
|
||||
{showTip && (
|
||||
<div
|
||||
className="bar-tip"
|
||||
style={{ left: `${tipPct}%` }}
|
||||
>
|
||||
{props.formatValue!((tipPct as number) / 100)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { Modal } from './Modal';
|
||||
import { useStore } from '../lib/store';
|
||||
import { dialogStore, resolveConfirm, resolvePrompt } from '../lib/dialog';
|
||||
import { t } from '../i18n';
|
||||
|
||||
// Renders the active custom dialog (confirm/prompt). Mounted once at the app
|
||||
// root; see lib/dialog.ts for the confirmDialog/promptDialog helpers.
|
||||
export function DialogHost() {
|
||||
const { current } = useStore(dialogStore);
|
||||
const [text, setText] = useState('');
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
// Seed the prompt field with its initial value and focus it each time a
|
||||
// new prompt opens.
|
||||
useEffect(() => {
|
||||
if (current && current.kind === 'prompt') {
|
||||
setText(current.initial || '');
|
||||
// Focus after the modal mounts.
|
||||
setTimeout(() => inputRef.current?.focus(), 0);
|
||||
}
|
||||
}, [current]);
|
||||
|
||||
if (!current) return null;
|
||||
|
||||
if (current.kind === 'confirm') {
|
||||
return (
|
||||
<Modal
|
||||
title={current.title}
|
||||
onClose={() => resolveConfirm(false)}
|
||||
footer={
|
||||
<>
|
||||
<button
|
||||
className="btn btn-ghost"
|
||||
onClick={() => resolveConfirm(false)}
|
||||
>
|
||||
{current.cancelLabel || t('Cancel')}
|
||||
</button>
|
||||
<button
|
||||
className={
|
||||
'btn ' +
|
||||
(current.danger ? 'btn-danger' : 'btn-accent')
|
||||
}
|
||||
onClick={() => resolveConfirm(true)}
|
||||
>
|
||||
{current.confirmLabel || t('Confirm')}
|
||||
</button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<p>{current.message}</p>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={current.title}
|
||||
onClose={() => resolvePrompt(null)}
|
||||
footer={
|
||||
<>
|
||||
<button
|
||||
className="btn btn-ghost"
|
||||
onClick={() => resolvePrompt(null)}
|
||||
>
|
||||
{current.cancelLabel || t('Cancel')}
|
||||
</button>
|
||||
<button
|
||||
className="btn btn-accent"
|
||||
onClick={() => resolvePrompt(text.trim() || null)}
|
||||
>
|
||||
{current.confirmLabel || t('OK')}
|
||||
</button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
resolvePrompt(text.trim() || null);
|
||||
}}
|
||||
>
|
||||
{current.message && <p>{current.message}</p>}
|
||||
<input
|
||||
ref={inputRef}
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
placeholder={current.placeholder}
|
||||
autoComplete="off"
|
||||
/>
|
||||
</form>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useStore } from '../lib/store';
|
||||
import { emojiStore, loadCustomEmojis } from '../lib/emoji';
|
||||
import { safeCall, toast } from '../lib/app';
|
||||
import { CloseIcon } from './icons';
|
||||
import { t } from '../i18n';
|
||||
|
||||
// Admin custom-emoji manager (item 16): upload an image (≤64KB) under a
|
||||
// shortcode name, list existing ones, and remove them. The image is sent as
|
||||
// base64 to AddCustomEmoji and served back at /emoji/<name>.
|
||||
export function EmojiManager() {
|
||||
const { custom } = useStore(emojiStore);
|
||||
const [name, setName] = useState('');
|
||||
const [busy, setBusy] = useState(false);
|
||||
const fileRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
loadCustomEmojis();
|
||||
}, []);
|
||||
|
||||
const upload = async () => {
|
||||
const file = fileRef.current?.files?.[0];
|
||||
const clean = name.trim().toLowerCase();
|
||||
if (!/^[a-z0-9_]{1,32}$/.test(clean)) {
|
||||
toast(t('Emoji name must be 1-32 chars of a-z, 0-9, _'));
|
||||
return;
|
||||
}
|
||||
if (!file) {
|
||||
toast(t('Choose an image file'));
|
||||
return;
|
||||
}
|
||||
if (file.size > 64 * 1024) {
|
||||
toast(t('Emoji image too large (max ~64KB)'));
|
||||
return;
|
||||
}
|
||||
setBusy(true);
|
||||
const dataBase64 = await new Promise<string>((resolve) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
const res = String(reader.result);
|
||||
resolve(res.slice(res.indexOf(',') + 1)); // strip data: prefix
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
const res = await safeCall('AddCustomEmoji', {
|
||||
name: clean,
|
||||
mime: file.type,
|
||||
dataBase64,
|
||||
});
|
||||
setBusy(false);
|
||||
if (res) {
|
||||
toast(t('Emoji added'));
|
||||
setName('');
|
||||
if (fileRef.current) fileRef.current.value = '';
|
||||
loadCustomEmojis();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="card">
|
||||
<div className="card-head">
|
||||
<h2>
|
||||
{t('Custom emojis')}{' '}
|
||||
<span className="muted">
|
||||
{custom.length ? `· ${custom.length}` : ''}
|
||||
</span>
|
||||
</h2>
|
||||
</div>
|
||||
<div className="emoji-manage-row">
|
||||
<input
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
placeholder={t('shortcode (a-z0-9_)')}
|
||||
maxLength={32}
|
||||
/>
|
||||
<input ref={fileRef} type="file" accept="image/*" />
|
||||
<button
|
||||
className="btn btn-accent"
|
||||
disabled={busy}
|
||||
onClick={upload}
|
||||
>
|
||||
{t('Add emoji')}
|
||||
</button>
|
||||
</div>
|
||||
<div className="emoji-manage-grid">
|
||||
{custom.map((c) => (
|
||||
<div key={c.name} className="emoji-manage-item">
|
||||
<img
|
||||
className="emoji-img-lg"
|
||||
src={`/emoji/${c.name}`}
|
||||
alt={c.name}
|
||||
/>
|
||||
<span className="mono">:{c.name}:</span>
|
||||
<button
|
||||
className="icon-btn danger"
|
||||
title={t('Remove')}
|
||||
onClick={async () => {
|
||||
await safeCall('RemoveCustomEmoji', {
|
||||
name: c.name,
|
||||
});
|
||||
toast(t('Emoji removed'));
|
||||
loadCustomEmojis();
|
||||
}}
|
||||
>
|
||||
<CloseIcon />
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { useStore } from '../lib/store';
|
||||
import {
|
||||
EMOJI_CATEGORIES,
|
||||
emojiStore,
|
||||
rememberEmoji,
|
||||
} from '../lib/emoji';
|
||||
import { t } from '../i18n';
|
||||
|
||||
// A popover emoji picker: recently-used, curated Unicode categories, and the
|
||||
// server's custom image emojis. `onPick` receives either a unicode char or a
|
||||
// :shortcode: for a custom emoji.
|
||||
export function EmojiPicker(props: {
|
||||
onPick: (token: string) => void;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const { custom, recent } = useStore(emojiStore);
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const onDoc = (e: MouseEvent) => {
|
||||
if (ref.current && !ref.current.contains(e.target as Node)) {
|
||||
props.onClose();
|
||||
}
|
||||
};
|
||||
// Defer so the opening click doesn't immediately close it.
|
||||
const id = setTimeout(
|
||||
() => document.addEventListener('mousedown', onDoc),
|
||||
0
|
||||
);
|
||||
return () => {
|
||||
clearTimeout(id);
|
||||
document.removeEventListener('mousedown', onDoc);
|
||||
};
|
||||
}, [props]);
|
||||
|
||||
const pick = (token: string) => {
|
||||
rememberEmoji(token);
|
||||
props.onPick(token);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="emoji-picker" ref={ref}>
|
||||
{recent.length > 0 && (
|
||||
<div className="emoji-section">
|
||||
<div className="emoji-section-label">{t('Recent')}</div>
|
||||
<div className="emoji-grid">
|
||||
{recent.map((token, i) =>
|
||||
token.startsWith(':') ? (
|
||||
<button
|
||||
key={i}
|
||||
className="emoji-btn"
|
||||
onClick={() => pick(token)}
|
||||
>
|
||||
<img
|
||||
src={`/emoji/${token.slice(1, -1)}`}
|
||||
alt={token}
|
||||
className="emoji-img"
|
||||
/>
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
key={i}
|
||||
className="emoji-btn"
|
||||
onClick={() => pick(token)}
|
||||
>
|
||||
{token}
|
||||
</button>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{custom.length > 0 && (
|
||||
<div className="emoji-section">
|
||||
<div className="emoji-section-label">{t('Custom')}</div>
|
||||
<div className="emoji-grid">
|
||||
{custom.map((c) => (
|
||||
<button
|
||||
key={c.name}
|
||||
className="emoji-btn"
|
||||
title={`:${c.name}:`}
|
||||
onClick={() => pick(`:${c.name}:`)}
|
||||
>
|
||||
<img
|
||||
src={`/emoji/${c.name}`}
|
||||
alt={c.name}
|
||||
className="emoji-img"
|
||||
/>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{EMOJI_CATEGORIES.map((cat) => (
|
||||
<div key={cat.label} className="emoji-section">
|
||||
<div className="emoji-section-label">{cat.label}</div>
|
||||
<div className="emoji-grid">
|
||||
{cat.emoji.map((e) => (
|
||||
<button
|
||||
key={e}
|
||||
className="emoji-btn"
|
||||
onClick={() => pick(e)}
|
||||
>
|
||||
{e}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { appStore, safeCall } from '../lib/app';
|
||||
import { useStore } from '../lib/store';
|
||||
import type { LyricsResult } from '../lib/types';
|
||||
import { t } from '../i18n';
|
||||
|
||||
// Lyrics for the current track (via the bot's GetLyrics → lrclib). When the
|
||||
// provider returns time-synced lines we highlight the active one against the
|
||||
// shared playback clock (appStore.positionMs) and keep it scrolled into view;
|
||||
// otherwise we show plain scrollable text. Collapsed by default so we only
|
||||
// fetch when the listener asks for it.
|
||||
export function LyricsPanel() {
|
||||
const s = useStore(appStore);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [lyrics, setLyrics] = useState<LyricsResult | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const activeRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const track = s.current;
|
||||
// Refetch when the track identity changes (url is stable per track).
|
||||
const key = track ? track.url || track.title || '' : '';
|
||||
|
||||
useEffect(() => {
|
||||
if (!open || !key) {
|
||||
return;
|
||||
}
|
||||
let cancelled = false;
|
||||
setLoading(true);
|
||||
setLyrics(null);
|
||||
safeCall<LyricsResult>('GetLyrics').then((res) => {
|
||||
if (!cancelled) {
|
||||
setLyrics(res);
|
||||
setLoading(false);
|
||||
}
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [key, open]);
|
||||
|
||||
const synced = lyrics?.synced ?? [];
|
||||
// Index of the last line whose timestamp has passed.
|
||||
const activeIdx = useMemo(() => {
|
||||
if (!synced.length) return -1;
|
||||
let idx = -1;
|
||||
for (let i = 0; i < synced.length; i++) {
|
||||
if (synced[i].ms <= s.positionMs) idx = i;
|
||||
else break;
|
||||
}
|
||||
return idx;
|
||||
}, [synced, s.positionMs]);
|
||||
|
||||
useEffect(() => {
|
||||
activeRef.current?.scrollIntoView({ block: 'nearest' });
|
||||
}, [activeIdx]);
|
||||
|
||||
return (
|
||||
<div className="card">
|
||||
<div className="card-head">
|
||||
<h3>{t('Lyrics')}</h3>
|
||||
<button
|
||||
className="link"
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
disabled={!track}
|
||||
>
|
||||
{open ? t('Hide') : t('Show')}
|
||||
</button>
|
||||
</div>
|
||||
{open && (
|
||||
<div className="lyrics-body">
|
||||
{!track ? (
|
||||
<div className="lyrics-empty">
|
||||
{t('Nothing playing')}
|
||||
</div>
|
||||
) : loading ? (
|
||||
<div className="lyrics-empty">{t('Loading…')}</div>
|
||||
) : !lyrics || !lyrics.found ? (
|
||||
<div className="lyrics-empty">
|
||||
{t('No lyrics found')}
|
||||
</div>
|
||||
) : synced.length ? (
|
||||
<div className="lyrics-synced">
|
||||
{synced.map((line, i) => (
|
||||
<div
|
||||
key={i}
|
||||
ref={i === activeIdx ? activeRef : null}
|
||||
className={
|
||||
'lyrics-line' +
|
||||
(i === activeIdx ? ' active' : '')
|
||||
}
|
||||
>
|
||||
{line.text || '♪'}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<pre className="lyrics-plain">{lyrics.plain}</pre>
|
||||
)}
|
||||
{lyrics && lyrics.found && lyrics.source && (
|
||||
<div className="lyrics-source muted">
|
||||
{t('Lyrics via')} {lyrics.source}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { appStore, safeCall } from '../lib/app';
|
||||
import { useStore } from '../lib/store';
|
||||
import { Bar } from './Bar';
|
||||
import { coverStyle, fmtMs } from '../lib/format';
|
||||
import { PauseIcon, PlayIcon, SkipNextIcon } from './icons';
|
||||
import { t } from '../i18n';
|
||||
|
||||
async function togglePlay() {
|
||||
const st = appStore.get().status || {};
|
||||
if (st.isPlaying && !st.isPaused) await safeCall('Pause');
|
||||
else await safeCall('Resume');
|
||||
}
|
||||
|
||||
// Mini player mirrors the current track on views other than Now Playing.
|
||||
export function MiniPlayer() {
|
||||
const s = useStore(appStore);
|
||||
if (s.view === 'now' || !s.current) return null;
|
||||
const playing = !!(s.status && s.status.isPlaying && !s.status.isPaused);
|
||||
const canForceSkip = !!(
|
||||
s.identity &&
|
||||
(s.identity.isAdmin || s.identity.isDj)
|
||||
);
|
||||
const durationMs = s.durationMs || s.current.duration || 0;
|
||||
const pct =
|
||||
durationMs > 0 ? Math.min(100, (s.positionMs / durationMs) * 100) : 0;
|
||||
return (
|
||||
<div className="miniplayer">
|
||||
<div
|
||||
className="mini-cover"
|
||||
style={{ background: coverStyle(s.current) }}
|
||||
/>
|
||||
<div className="mini-info">
|
||||
<div className="mini-title">{s.current.title}</div>
|
||||
<div className="mini-artist">{s.current.artist || ''}</div>
|
||||
</div>
|
||||
<button
|
||||
className="ctrl"
|
||||
title={t('Play/Pause')}
|
||||
onClick={togglePlay}
|
||||
>
|
||||
{playing ? <PauseIcon /> : <PlayIcon />}
|
||||
</button>
|
||||
{canForceSkip && (
|
||||
<button
|
||||
className="ctrl"
|
||||
title={t('Force skip')}
|
||||
onClick={() => safeCall('Skip', { count: 1 })}
|
||||
>
|
||||
<SkipNextIcon />
|
||||
</button>
|
||||
)}
|
||||
<Bar
|
||||
slim
|
||||
className="mini-bar"
|
||||
pct={pct}
|
||||
formatValue={(f) =>
|
||||
durationMs ? fmtMs(Math.round(f * durationMs)) : ''
|
||||
}
|
||||
onDragStart={() => durationMs > 0}
|
||||
onCommit={(f) =>
|
||||
safeCall('Seek', {
|
||||
position: Math.round(f * durationMs),
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { CloseIcon } from './icons';
|
||||
|
||||
export function Modal(props: {
|
||||
title: string;
|
||||
onClose: () => void;
|
||||
children: ReactNode;
|
||||
footer?: ReactNode;
|
||||
wide?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<div className="modal-backdrop" onClick={props.onClose}>
|
||||
<div
|
||||
className={'modal' + (props.wide ? ' modal-wide' : '')}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="modal-head">
|
||||
<h2>{props.title}</h2>
|
||||
<button className="icon-btn" onClick={props.onClose}>
|
||||
<CloseIcon />
|
||||
</button>
|
||||
</div>
|
||||
<div className="modal-body">{props.children}</div>
|
||||
{props.footer && (
|
||||
<div className="modal-foot">{props.footer}</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { shouldCorrectVideoDrift } from '../lib/nowPlayingVideoSync';
|
||||
|
||||
describe('NowPlayingVideo drift correction', () => {
|
||||
it('never seeks while unstarted, cued, or buffering', () => {
|
||||
for (const state of [-1, 3, 5]) {
|
||||
expect(shouldCorrectVideoDrift(state, 0, 30, 10_000)).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
it('waits for cooldown and ignores small playing drift', () => {
|
||||
expect(shouldCorrectVideoDrift(1, 0, 30, 1000)).toBe(false);
|
||||
expect(shouldCorrectVideoDrift(1, 28, 30, 10_000)).toBe(false);
|
||||
expect(shouldCorrectVideoDrift(1, 10, 30, 10_000)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,133 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { appStore } from '../lib/app';
|
||||
import {
|
||||
loadYouTubeApi,
|
||||
YOUTUBE_EMBED_HOST,
|
||||
youtubeEmbedVars,
|
||||
} from '../lib/youtube';
|
||||
import { shouldCorrectVideoDrift } from '../lib/nowPlayingVideoSync';
|
||||
|
||||
// The muted YouTube video of the current track, shown in Now Playing when the
|
||||
// user enables it (item 11). The bot's audio is the source of truth, so the
|
||||
// video is always muted and only follows the server position — it resyncs
|
||||
// with a hard seek when it drifts past the threshold, and pauses/plays to
|
||||
// match. Purely a local visual aid; it sends nothing to the server.
|
||||
const SEEK_LEAD_SECONDS = 0.75;
|
||||
|
||||
export function NowPlayingVideo({ videoId }: { videoId: string }) {
|
||||
const mountRef = useRef<HTMLDivElement>(null);
|
||||
const playerRef = useRef<YT.Player | null>(null);
|
||||
const currentVideo = useRef<string>('');
|
||||
const pendingVideo = useRef(videoId);
|
||||
const lastSeekAt = useRef(0);
|
||||
const playIntent = useRef<boolean | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
loadYouTubeApi().then(() => {
|
||||
if (cancelled || !mountRef.current) return;
|
||||
const el = document.createElement('div');
|
||||
mountRef.current.appendChild(el);
|
||||
playerRef.current = new YT.Player(el, {
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
videoId,
|
||||
host: YOUTUBE_EMBED_HOST,
|
||||
playerVars: youtubeEmbedVars({ mute: 1 }),
|
||||
events: {
|
||||
onReady: () => {
|
||||
const p = playerRef.current;
|
||||
if (!p) return;
|
||||
const requested = pendingVideo.current;
|
||||
const startSeconds = appStore.get().positionMs / 1000;
|
||||
if (requested !== videoId) {
|
||||
p.loadVideoById({ videoId: requested, startSeconds });
|
||||
} else if (startSeconds > 0) {
|
||||
p.seekTo(startSeconds, true);
|
||||
}
|
||||
p.mute();
|
||||
currentVideo.current = requested;
|
||||
lastSeekAt.current = performance.now();
|
||||
playIntent.current = null;
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
playerRef.current?.destroy();
|
||||
playerRef.current = null;
|
||||
if (mountRef.current) mountRef.current.innerHTML = '';
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
// Load a new video id in place without recreating the player.
|
||||
useEffect(() => {
|
||||
pendingVideo.current = videoId;
|
||||
const p = playerRef.current;
|
||||
if (!p || !p.loadVideoById || currentVideo.current === videoId) return;
|
||||
p.loadVideoById({
|
||||
videoId,
|
||||
startSeconds: appStore.get().positionMs / 1000,
|
||||
});
|
||||
p.mute();
|
||||
currentVideo.current = videoId;
|
||||
lastSeekAt.current = performance.now();
|
||||
playIntent.current = null;
|
||||
}, [videoId]);
|
||||
|
||||
// Follow the server position: resync on drift, match play/pause state.
|
||||
useEffect(() => {
|
||||
const id = setInterval(() => {
|
||||
const p = playerRef.current;
|
||||
if (!p || !p.getCurrentTime || !p.seekTo) return;
|
||||
const s = appStore.get();
|
||||
const targetSec = s.positionMs / 1000;
|
||||
const playing = !!(
|
||||
s.status &&
|
||||
s.status.isPlaying &&
|
||||
!s.status.isPaused
|
||||
);
|
||||
try {
|
||||
const st = p.getPlayerState();
|
||||
const now = performance.now();
|
||||
// Seeking while CUED/BUFFERING repeatedly restarts YouTube's
|
||||
// buffer. Drift is meaningful only once the playback clock moves.
|
||||
if (shouldCorrectVideoDrift(
|
||||
st,
|
||||
p.getCurrentTime(),
|
||||
targetSec,
|
||||
now - lastSeekAt.current
|
||||
)) {
|
||||
p.seekTo(targetSec + SEEK_LEAD_SECONDS, true);
|
||||
lastSeekAt.current = now;
|
||||
}
|
||||
if (
|
||||
playing &&
|
||||
playIntent.current !== true &&
|
||||
(st === YT.PlayerState.CUED ||
|
||||
st === YT.PlayerState.PAUSED ||
|
||||
st === YT.PlayerState.ENDED)
|
||||
) {
|
||||
p.playVideo();
|
||||
playIntent.current = true;
|
||||
}
|
||||
else if (
|
||||
!playing &&
|
||||
playIntent.current !== false &&
|
||||
(st === YT.PlayerState.PLAYING || st === YT.PlayerState.BUFFERING)
|
||||
) {
|
||||
p.pauseVideo();
|
||||
playIntent.current = false;
|
||||
}
|
||||
p.mute(); // guard against unmute on state changes
|
||||
} catch {
|
||||
/* player not ready yet */
|
||||
}
|
||||
}, 1000);
|
||||
return () => clearInterval(id);
|
||||
}, []);
|
||||
|
||||
return <div className="np-video" ref={mountRef} />;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Avatar } from './Avatar';
|
||||
|
||||
export function PersonRow(props: {
|
||||
name: string;
|
||||
uid?: string | null;
|
||||
sub?: string;
|
||||
status?: string;
|
||||
statusColor?: string;
|
||||
children?: ReactNode;
|
||||
}) {
|
||||
const { name, uid, sub, status, statusColor, children } = props;
|
||||
return (
|
||||
<div className="person">
|
||||
<Avatar name={name} uid={uid} />
|
||||
<div className="person-main">
|
||||
<div className="person-name">{name}</div>
|
||||
{sub && <div className="person-sub">{sub}</div>}
|
||||
</div>
|
||||
{status && (
|
||||
<span
|
||||
className="person-status"
|
||||
style={statusColor ? { color: statusColor } : undefined}
|
||||
>
|
||||
{status}
|
||||
</span>
|
||||
)}
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { PlayerControls } from './PlayerControls';
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
function render(over: Partial<Parameters<typeof PlayerControls>[0]> = {}) {
|
||||
return renderToStaticMarkup(
|
||||
<PlayerControls
|
||||
playing={false}
|
||||
positionMs={30_000}
|
||||
durationMs={120_000}
|
||||
canControl
|
||||
volumePct={50}
|
||||
onTogglePlay={noop}
|
||||
onSeekMs={noop}
|
||||
onSeekBy={noop}
|
||||
onVolume={noop}
|
||||
{...over}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
describe('PlayerControls', () => {
|
||||
it('shows transport, times and volume when controllable', () => {
|
||||
const html = render();
|
||||
expect(html).toContain('0:30');
|
||||
expect(html).toContain('2:00');
|
||||
expect(html).toContain('Back 10 seconds');
|
||||
expect(html).toContain('Forward 10 seconds');
|
||||
expect(html).not.toContain('disabled');
|
||||
});
|
||||
|
||||
it('disables transport when canControl is false', () => {
|
||||
const html = render({ canControl: false });
|
||||
// Play/pause + the two ±10s buttons are disabled…
|
||||
expect(html.match(/disabled/g)?.length).toBe(3);
|
||||
// …but the volume bar (local) is still rendered.
|
||||
expect(html).toContain('50%');
|
||||
});
|
||||
|
||||
it('hides seek buttons and shows LIVE for live sources', () => {
|
||||
const html = render({ live: true });
|
||||
expect(html).not.toContain('Back 10 seconds');
|
||||
expect(html).toContain('LIVE');
|
||||
});
|
||||
|
||||
it('renders skip only when onSkip is given', () => {
|
||||
expect(render()).not.toContain('Play next');
|
||||
expect(render({ onSkip: noop })).toContain('Play next');
|
||||
});
|
||||
|
||||
it('hides the local row when showLocal is false', () => {
|
||||
expect(render({ showLocal: false })).not.toContain('Vol');
|
||||
});
|
||||
|
||||
it('renders the unified settings slot in the local row', () => {
|
||||
expect(render({ settings: <button>Settings gear</button> })).toContain(
|
||||
'Settings gear'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,130 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Bar } from './Bar';
|
||||
import { fmtMs } from '../lib/format';
|
||||
import {
|
||||
ForwardIcon,
|
||||
FullscreenIcon,
|
||||
PauseIcon,
|
||||
PlayIcon,
|
||||
RewindIcon,
|
||||
SkipNextIcon,
|
||||
} from './icons';
|
||||
import { t } from '../i18n';
|
||||
|
||||
// The one custom player control bar, shared by Watch Together (room /ws
|
||||
// protocol) and Now Playing (bot RPC). Purely presentational: the two sync
|
||||
// channels differ only in the callbacks the views pass in. Embedded players
|
||||
// (YouTube/Twitch/HTML5) always run with native controls hidden; this bar is
|
||||
// the only playback UI.
|
||||
export function PlayerControls(props: {
|
||||
playing: boolean;
|
||||
positionMs: number;
|
||||
durationMs: number; // 0 = unknown
|
||||
live?: boolean; // no seekable timeline (Twitch / generic embeds)
|
||||
canControl: boolean; // transport disabled when false; volume stays local
|
||||
bufferedPct?: number; // 0..100 second fill on the seek bar
|
||||
volumePct: number; // 0..100
|
||||
volumeLive?: boolean; // apply volume while dragging (local volume)
|
||||
onTogglePlay: () => void;
|
||||
onSeekMs: (ms: number) => void;
|
||||
onSeekBy?: (deltaSec: number) => void; // renders ±10s when present
|
||||
onVolume: (pct: number) => void;
|
||||
onSkip?: () => void; // renders next-track button when present
|
||||
skipDisabled?: boolean;
|
||||
onFullscreen?: () => void;
|
||||
settings?: ReactNode;
|
||||
showLocal?: boolean; // hide the volume/quality row (default shown)
|
||||
extra?: ReactNode; // view-specific buttons after the seek bar
|
||||
extraLocal?: ReactNode; // view-specific controls in the volume row
|
||||
}) {
|
||||
const { live, durationMs, positionMs, canControl } = props;
|
||||
const progressPct = live
|
||||
? 100
|
||||
: durationMs > 0
|
||||
? Math.min(100, (positionMs / durationMs) * 100)
|
||||
: 0;
|
||||
return (
|
||||
<div className="player-controls">
|
||||
<div className="watch-controls">
|
||||
<button
|
||||
className="ctrl ctrl-main"
|
||||
title={t('Play/Pause')}
|
||||
disabled={!canControl}
|
||||
onClick={props.onTogglePlay}
|
||||
>
|
||||
{props.playing ? <PauseIcon /> : <PlayIcon />}
|
||||
</button>
|
||||
{!live && props.onSeekBy && (
|
||||
<>
|
||||
<button
|
||||
className="ctrl"
|
||||
title={t('Back 10 seconds')}
|
||||
disabled={!canControl}
|
||||
onClick={() => props.onSeekBy!(-10)}
|
||||
>
|
||||
<RewindIcon />
|
||||
</button>
|
||||
<button
|
||||
className="ctrl"
|
||||
title={t('Forward 10 seconds')}
|
||||
disabled={!canControl}
|
||||
onClick={() => props.onSeekBy!(10)}
|
||||
>
|
||||
<ForwardIcon />
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{props.onSkip && (
|
||||
<button
|
||||
className="ctrl"
|
||||
title={t('Play next')}
|
||||
disabled={!canControl || props.skipDisabled}
|
||||
onClick={props.onSkip}
|
||||
>
|
||||
<SkipNextIcon />
|
||||
</button>
|
||||
)}
|
||||
<span className="mono">{live ? '—' : fmtMs(positionMs)}</span>
|
||||
<Bar
|
||||
pct={progressPct}
|
||||
bufferPct={live ? undefined : props.bufferedPct}
|
||||
formatValue={(f) =>
|
||||
live || !durationMs
|
||||
? t('LIVE')
|
||||
: fmtMs(Math.round(f * durationMs))
|
||||
}
|
||||
onDragStart={() => !live && durationMs > 0}
|
||||
onCommit={(f) => props.onSeekMs(Math.round(f * durationMs))}
|
||||
/>
|
||||
<span className="mono">
|
||||
{live ? t('LIVE') : fmtMs(durationMs)}
|
||||
</span>
|
||||
{props.extra}
|
||||
</div>
|
||||
{(props.showLocal ?? true) && (
|
||||
<div className="watch-controls watch-local">
|
||||
<span className="muted">{t('Vol')}</span>
|
||||
<Bar
|
||||
slim
|
||||
live={props.volumeLive}
|
||||
pct={props.volumePct}
|
||||
formatValue={(f) => `${Math.round(f * 100)}%`}
|
||||
onCommit={(f) => props.onVolume(Math.round(f * 100))}
|
||||
/>
|
||||
<span className="mono">{Math.round(props.volumePct)}%</span>
|
||||
{props.settings}
|
||||
{props.onFullscreen && (
|
||||
<button
|
||||
className="ctrl"
|
||||
title={t('Fullscreen')}
|
||||
onClick={props.onFullscreen}
|
||||
>
|
||||
<FullscreenIcon />
|
||||
</button>
|
||||
)}
|
||||
{props.extraLocal}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import type { PlayerExtraControl } from '../lib/embedProtocols';
|
||||
import { t } from '../i18n';
|
||||
import { GearIcon } from './icons';
|
||||
|
||||
export function PlayerSettingsMenu(props: {
|
||||
extras: PlayerExtraControl[];
|
||||
rate: number;
|
||||
rateOptions?: number[];
|
||||
canControl: boolean;
|
||||
onExtra: (id: string, value: string) => void;
|
||||
onRate: (rate: number) => void;
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const rootRef = useRef<HTMLDivElement>(null);
|
||||
const local = props.extras.filter((control) => control.scope === 'local');
|
||||
const room = props.extras.filter(
|
||||
(control) => control.scope === 'synced' && control.id !== 'speed'
|
||||
);
|
||||
const hasRoom = room.length > 0 || !!props.rateOptions?.length;
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
const close = (event: MouseEvent) => {
|
||||
if (!rootRef.current?.contains(event.target as Node)) setOpen(false);
|
||||
};
|
||||
document.addEventListener('mousedown', close);
|
||||
return () => document.removeEventListener('mousedown', close);
|
||||
}, [open]);
|
||||
|
||||
if (local.length === 0 && !hasRoom) return null;
|
||||
const renderControl = (control: PlayerExtraControl) => (
|
||||
<label className="player-setting" key={control.id}>
|
||||
<span>{t(control.label)}</span>
|
||||
<select
|
||||
value={control.current ?? ''}
|
||||
disabled={control.scope === 'synced' && !props.canControl}
|
||||
title={
|
||||
control.scope === 'synced' && !props.canControl
|
||||
? t('Only the host can change this')
|
||||
: undefined
|
||||
}
|
||||
onChange={(event) => props.onExtra(control.id, event.target.value)}
|
||||
>
|
||||
{control.current == null && <option value="">{t('Choose')}</option>}
|
||||
{control.options.map((option) => (
|
||||
<option key={option.value} value={option.value}>
|
||||
{t(option.label)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="player-settings" ref={rootRef}>
|
||||
<button
|
||||
className="ctrl"
|
||||
title={t('Settings')}
|
||||
aria-expanded={open}
|
||||
onClick={() => setOpen((value) => !value)}
|
||||
>
|
||||
<GearIcon />
|
||||
</button>
|
||||
{open && (
|
||||
<div className="player-settings-popover">
|
||||
{local.length > 0 && (
|
||||
<section>
|
||||
<div className="player-settings-heading">{t('Local')}</div>
|
||||
{local.map(renderControl)}
|
||||
</section>
|
||||
)}
|
||||
{hasRoom && (
|
||||
<section>
|
||||
<div className="player-settings-heading">{t('Room')}</div>
|
||||
{props.rateOptions && (
|
||||
<label className="player-setting">
|
||||
<span>{t('Speed')}</span>
|
||||
<select
|
||||
value={String(props.rate)}
|
||||
disabled={!props.canControl}
|
||||
onChange={(event) =>
|
||||
props.onRate(Number(event.target.value))
|
||||
}
|
||||
>
|
||||
{props.rateOptions.map((rate) => (
|
||||
<option key={rate} value={rate}>{rate}×</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
{room.map(renderControl)}
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { appStore } from '../lib/app';
|
||||
import { useStore } from '../lib/store';
|
||||
import { SHORTCUTS } from '../lib/shortcuts';
|
||||
import { t } from '../i18n';
|
||||
|
||||
// Cheat-sheet overlay for keyboard shortcuts, toggled with "?".
|
||||
export function ShortcutsHelp() {
|
||||
const s = useStore(appStore);
|
||||
if (!s.shortcutsOpen) return null;
|
||||
return (
|
||||
<div
|
||||
className="modal-backdrop"
|
||||
onClick={() => appStore.set({ shortcutsOpen: false })}
|
||||
>
|
||||
<div className="modal shortcuts-modal" onClick={(e) => e.stopPropagation()}>
|
||||
<h2>{t('Keyboard shortcuts')}</h2>
|
||||
<div className="shortcuts-list">
|
||||
{SHORTCUTS.map((sc) => (
|
||||
<div key={sc.keys} className="shortcut-row">
|
||||
<kbd>{sc.keys}</kbd>
|
||||
<span>{t(sc.label)}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<button
|
||||
className="btn btn-ghost"
|
||||
onClick={() => appStore.set({ shortcutsOpen: false })}
|
||||
>
|
||||
{t('Close')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
import { useState, type ReactNode } from 'react';
|
||||
import {
|
||||
appStore,
|
||||
changeLanguage,
|
||||
connectWithToken,
|
||||
getStoredToken,
|
||||
logout,
|
||||
requestToken,
|
||||
showView,
|
||||
type ViewName,
|
||||
} from '../lib/app';
|
||||
import { useStore } from '../lib/store';
|
||||
import { promptDialog } from '../lib/dialog';
|
||||
import { Avatar } from './Avatar';
|
||||
import {
|
||||
CodeIcon,
|
||||
GearIcon,
|
||||
HeartIcon,
|
||||
PlayIcon,
|
||||
QueueIcon,
|
||||
SearchIcon,
|
||||
StatsIcon,
|
||||
WatchIcon,
|
||||
} from './icons';
|
||||
import { t, useLanguage } from '../i18n';
|
||||
|
||||
const NAV: Array<{ view: ViewName; icon: ReactNode; label: string }> = [
|
||||
{ view: 'now', icon: <PlayIcon />, label: 'Now Playing' },
|
||||
{ view: 'queue', icon: <QueueIcon />, label: 'Queue' },
|
||||
{ view: 'search', icon: <SearchIcon />, label: 'Search' },
|
||||
{ view: 'library', icon: <HeartIcon />, label: 'Library' },
|
||||
{ view: 'stats', icon: <StatsIcon />, label: 'History & Stats' },
|
||||
{ view: 'watch', icon: <WatchIcon />, label: 'Watch Together' },
|
||||
{ view: 'server', icon: <GearIcon />, label: 'Server & Admin' },
|
||||
{ view: 'rpc', icon: <CodeIcon />, label: 'RPC / API' },
|
||||
];
|
||||
|
||||
export function Sidebar() {
|
||||
const s = useStore(appStore);
|
||||
const language = useLanguage();
|
||||
const [token, setToken] = useState(getStoredToken() || '');
|
||||
const isAdmin = !!(s.identity && s.identity.isAdmin);
|
||||
const playing = !!(
|
||||
s.status &&
|
||||
s.status.isPlaying &&
|
||||
!s.status.isPaused
|
||||
);
|
||||
const name = s.identity
|
||||
? s.identity.nickname || s.identity.uid || t('user')
|
||||
: '';
|
||||
|
||||
return (
|
||||
<aside className={'sidebar' + (s.sidebarOpen ? ' open' : '')}>
|
||||
<div className="brand">
|
||||
<div className="brand-icon">
|
||||
<svg viewBox="0 0 24 24" width="22" height="22" fill="#fff">
|
||||
<rect x="4" y="9" width="3.4" height="10" rx="1.6" />
|
||||
<rect x="10.3" y="4" width="3.4" height="15" rx="1.6" />
|
||||
<rect x="16.6" y="12" width="3.4" height="7" rx="1.6" />
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<div className="brand-name">Echoion</div>
|
||||
<div className="brand-sub">{t('MUSIC BOT · TS3')}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav className="nav">
|
||||
{NAV.filter(
|
||||
(item) => item.view !== 'server' || isAdmin
|
||||
).map((item) => (
|
||||
<button
|
||||
key={item.view}
|
||||
className={
|
||||
'nav-item' + (s.view === item.view ? ' active' : '')
|
||||
}
|
||||
onClick={() => showView(item.view)}
|
||||
>
|
||||
<span className="nav-ico">{item.icon}</span>
|
||||
{t(item.label)}
|
||||
{item.view === 'now' && playing && (
|
||||
<span className="live-dot" />
|
||||
)}
|
||||
{item.view === 'queue' && s.queue.length > 0 && (
|
||||
<span className="nav-badge">{s.queue.length}</span>
|
||||
)}
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
<div className="sidebar-foot">
|
||||
<div className="conn-row">
|
||||
<span
|
||||
className={
|
||||
'conn-dot' +
|
||||
(s.connection === 'connected'
|
||||
? ' on'
|
||||
: s.connection === 'error'
|
||||
? ' err'
|
||||
: '')
|
||||
}
|
||||
/>
|
||||
<span>{t(s.connection)}</span>
|
||||
<select
|
||||
className="lang-select"
|
||||
value={language}
|
||||
title={t('Language')}
|
||||
onChange={(e) =>
|
||||
changeLanguage(e.target.value as 'en' | 'ru')
|
||||
}
|
||||
>
|
||||
<option value="en">EN</option>
|
||||
<option value="ru">RU</option>
|
||||
</select>
|
||||
</div>
|
||||
{!s.identity ? (
|
||||
<div>
|
||||
<input
|
||||
type="password"
|
||||
placeholder={t('RPC token')}
|
||||
autoComplete="off"
|
||||
value={token}
|
||||
onChange={(e) => setToken(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
connectWithToken(token);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
className="btn btn-accent"
|
||||
onClick={() => connectWithToken(token)}
|
||||
>
|
||||
{t('Connect')}
|
||||
</button>
|
||||
<button
|
||||
className="btn btn-ghost"
|
||||
title={t('Send my token via TeamSpeak PM')}
|
||||
onClick={async () => {
|
||||
const nickname = await promptDialog({
|
||||
title: t('Get token by nickname'),
|
||||
message: t(
|
||||
'Your TeamSpeak nickname (must be subscribed):'
|
||||
),
|
||||
placeholder: t('Nickname'),
|
||||
confirmLabel: t('Send'),
|
||||
});
|
||||
if (nickname) requestToken(nickname);
|
||||
}}
|
||||
>
|
||||
{t('Get token by nickname…')}
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="whoami">
|
||||
<Avatar name={name} uid={s.identity.uid} />
|
||||
<span>{name}</span>
|
||||
{isAdmin && (
|
||||
<span className="admin-chip">{t('ADMIN')}</span>
|
||||
)}
|
||||
{!isAdmin && s.identity.isDj && (
|
||||
<span className="admin-chip">{t('DJ')}</span>
|
||||
)}
|
||||
<button
|
||||
className="btn btn-ghost"
|
||||
onClick={() => {
|
||||
logout();
|
||||
setToken('');
|
||||
}}
|
||||
>
|
||||
{t('Logout')}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import type { Track } from '../lib/types';
|
||||
import { coverStyle, fmtMs, sourceInfo } from '../lib/format';
|
||||
import { t } from '../i18n';
|
||||
|
||||
export interface TrackAction {
|
||||
icon: ReactNode;
|
||||
title: string;
|
||||
cls?: string;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
export function TrackRow(props: {
|
||||
track: Track;
|
||||
num?: number;
|
||||
playing?: boolean;
|
||||
sub?: string;
|
||||
actions?: Array<TrackAction | null | false>;
|
||||
rowProps?: React.HTMLAttributes<HTMLDivElement> & { draggable?: boolean };
|
||||
children?: ReactNode;
|
||||
}) {
|
||||
const { track, num, playing, sub, rowProps, children } = props;
|
||||
const actions = (props.actions || []).filter(Boolean) as TrackAction[];
|
||||
const src = sourceInfo(track);
|
||||
return (
|
||||
<div
|
||||
{...rowProps}
|
||||
className={
|
||||
'track-row' +
|
||||
(playing ? ' playing' : '') +
|
||||
(rowProps?.className ? ` ${rowProps.className}` : '')
|
||||
}
|
||||
>
|
||||
{num != null && (
|
||||
<span className="track-num">
|
||||
{String(num).padStart(2, '0')}
|
||||
</span>
|
||||
)}
|
||||
<div
|
||||
className="track-cover"
|
||||
style={{ background: coverStyle(track) }}
|
||||
/>
|
||||
<div className="track-main">
|
||||
<div className="track-title">
|
||||
{track.title || t('(untitled)')}
|
||||
</div>
|
||||
<div className="track-sub">
|
||||
{[track.artist, sub].filter(Boolean).join(' · ')}
|
||||
</div>
|
||||
</div>
|
||||
{src && <span className={src.cls}>{src.label}</span>}
|
||||
{!!track.duration && (
|
||||
<span className="track-dur">{fmtMs(track.duration)}</span>
|
||||
)}
|
||||
{actions.length > 0 && (
|
||||
<div className="track-actions">
|
||||
{actions.map((a, i) => (
|
||||
<button
|
||||
key={i}
|
||||
className={'icon-btn' + (a.cls ? ` ${a.cls}` : '')}
|
||||
title={a.title}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
a.onClick();
|
||||
}}
|
||||
>
|
||||
{a.icon}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function EmptyRow({ text }: { text: string }) {
|
||||
return <div className="empty">{text}</div>;
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
import { useState } from 'react';
|
||||
import { rpc } from '../lib/rpc';
|
||||
import { send, watchStore } from '../lib/watch';
|
||||
import { toast } from '../lib/app';
|
||||
import { useStore } from '../lib/store';
|
||||
import { thumbFor } from '../lib/format';
|
||||
import type { Track } from '../lib/types';
|
||||
import { t, tf } from '../i18n';
|
||||
|
||||
// Normalize a Twitch channel entry: accept a bare login name, an @handle, or a
|
||||
// full twitch.tv URL, and reduce it to the channel login the embed player
|
||||
// expects. Numeric ids pass through (best effort — resolving them to a login
|
||||
// would need the Helix API, which isn't wired up).
|
||||
function normalizeTwitchChannel(input: string): string {
|
||||
let s = input.trim();
|
||||
const m = s.match(/twitch\.tv\/([^/?#]+)/i);
|
||||
if (m) s = m[1];
|
||||
s = s.replace(/^@/, '');
|
||||
return s.toLowerCase().replace(/[^a-z0-9_]/g, '');
|
||||
}
|
||||
|
||||
// Add tracks to a watch room from inside it. YouTube uses the unauthenticated
|
||||
// SearchTracks RPC (results added by title + thumbnail); Twitch has no search
|
||||
// backend, so it offers an add-by-channel-name/id field instead.
|
||||
export function WatchSearch({ disabled }: { disabled: boolean }) {
|
||||
const w = useStore(watchStore);
|
||||
const [query, setQuery] = useState('');
|
||||
const [channel, setChannel] = useState('');
|
||||
const [results, setResults] = useState<Track[]>([]);
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
if (w.sourceChoice === 'twitch') {
|
||||
return (
|
||||
<div className="watch-search">
|
||||
<form
|
||||
className="search-row"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
const ch = normalizeTwitchChannel(channel);
|
||||
if (!ch) return;
|
||||
send({
|
||||
type: 'watch.queue.add',
|
||||
source: 'twitch',
|
||||
url: ch,
|
||||
title: ch,
|
||||
});
|
||||
toast(tf('Added “{0}” to queue', ch));
|
||||
setChannel('');
|
||||
}}
|
||||
>
|
||||
<input
|
||||
value={channel}
|
||||
onChange={(e) => setChannel(e.target.value)}
|
||||
placeholder={t(
|
||||
'Twitch channel name or id to queue…'
|
||||
)}
|
||||
autoComplete="off"
|
||||
disabled={disabled}
|
||||
/>
|
||||
<button
|
||||
className="btn btn-accent"
|
||||
type="submit"
|
||||
disabled={disabled}
|
||||
>
|
||||
{t('Add channel')}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="watch-search">
|
||||
<form
|
||||
className="search-row"
|
||||
onSubmit={async (e) => {
|
||||
e.preventDefault();
|
||||
const q = query.trim();
|
||||
if (!q) return;
|
||||
try {
|
||||
const res = await rpc.call<{ tracks?: Track[] }>(
|
||||
'SearchTracks',
|
||||
{ query: q }
|
||||
);
|
||||
setResults((res && res.tracks) || []);
|
||||
setOpen(true);
|
||||
} catch (err) {
|
||||
toast((err as { message?: string }).message || 'error');
|
||||
}
|
||||
}}
|
||||
>
|
||||
<input
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
placeholder={t('Search YouTube to queue…')}
|
||||
autoComplete="off"
|
||||
disabled={disabled}
|
||||
/>
|
||||
<button className="btn btn-accent" type="submit" disabled={disabled}>
|
||||
{t('Search')}
|
||||
</button>
|
||||
</form>
|
||||
{open && results.length > 0 && (
|
||||
<div className="watch-search-results">
|
||||
{results.slice(0, 8).map((tr, i) => (
|
||||
<button
|
||||
key={tr.url || tr.id || i}
|
||||
className="watch-search-item"
|
||||
onClick={() => {
|
||||
send({
|
||||
type: 'watch.queue.add',
|
||||
source: 'youtube',
|
||||
url: tr.url || tr.id,
|
||||
title: tr.title || '',
|
||||
});
|
||||
toast(
|
||||
tf(
|
||||
'Added “{0}” to queue',
|
||||
tr.title || ''
|
||||
)
|
||||
);
|
||||
setOpen(false);
|
||||
setQuery('');
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="track-cover"
|
||||
style={
|
||||
thumbFor(tr)
|
||||
? {
|
||||
background: `url("${thumbFor(tr)}") center/cover`,
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
<span className="watch-search-title">
|
||||
{tr.title}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import type { SVGProps } from 'react';
|
||||
|
||||
// Inline SVG icon set replacing the raw unicode glyphs (✕ ▶ ⏸ ⚙ …), which
|
||||
// rendered inconsistently across platforms and fonts. Sized in em so icons
|
||||
// scale with the button font-size; color follows currentColor.
|
||||
type IconProps = SVGProps<SVGSVGElement>;
|
||||
|
||||
function makeIcon(d: string) {
|
||||
return function Icon(props: IconProps) {
|
||||
return (
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
height="1em"
|
||||
fill="currentColor"
|
||||
aria-hidden="true"
|
||||
focusable="false"
|
||||
{...props}
|
||||
>
|
||||
<path d={d} />
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export const PlayIcon = makeIcon('M8 5v14l11-7z');
|
||||
export const PauseIcon = makeIcon('M6 19h4V5H6v14zm8-14v14h4V5h-4z');
|
||||
export const SkipNextIcon = makeIcon('M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z');
|
||||
export const SkipPrevIcon = makeIcon('M6 6h2v12H6zm3.5 6l8.5 6V6l-8.5 6z');
|
||||
export const RewindIcon = makeIcon(
|
||||
'M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z'
|
||||
);
|
||||
export const ForwardIcon = makeIcon(
|
||||
'M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z'
|
||||
);
|
||||
export const ShuffleIcon = makeIcon(
|
||||
'M10.59 9.17L5.41 4 4 5.41l5.17 5.17 1.42-1.41zM14.5 4l2.04 2.04L4 18.59 5.41 20 17.96 7.46 20 9.5V4h-5.5zm.33 9.41l-1.41 1.41 3.13 3.13L14.5 20H20v-5.5l-2.04 2.04-3.13-3.13z'
|
||||
);
|
||||
export const RepeatIcon = makeIcon(
|
||||
'M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z'
|
||||
);
|
||||
export const HeartIcon = makeIcon(
|
||||
'M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'
|
||||
);
|
||||
export const CloseIcon = makeIcon(
|
||||
'M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'
|
||||
);
|
||||
export const SearchIcon = makeIcon(
|
||||
'M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'
|
||||
);
|
||||
export const QueueIcon = makeIcon(
|
||||
'M15 6H3v2h12V6zm0 4H3v2h12v-2zM3 16h8v-2H3v2zm14-10v8.18c-.31-.11-.65-.18-1-.18-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3V8h3V6h-5z'
|
||||
);
|
||||
export const StatsIcon = makeIcon(
|
||||
'M5 9.2h3V19H5V9.2zM10.6 5h2.8v14h-2.8V5zm5.6 8H19v6h-2.8v-6z'
|
||||
);
|
||||
export const WatchIcon = makeIcon(
|
||||
'M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V6h16v12zM9.5 8.5l7 3.5-7 3.5v-7z'
|
||||
);
|
||||
export const GearIcon = makeIcon(
|
||||
'M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z'
|
||||
);
|
||||
export const CodeIcon = makeIcon(
|
||||
'M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z'
|
||||
);
|
||||
export const FullscreenIcon = makeIcon(
|
||||
'M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z'
|
||||
);
|
||||
export const PowerIcon = makeIcon(
|
||||
'M13 3h-2v10h2V3zm4.83 2.17l-1.42 1.42C17.99 7.86 19 9.81 19 12c0 3.87-3.13 7-7 7s-7-3.13-7-7c0-2.19 1.01-4.14 2.58-5.42L6.17 5.17C4.23 6.82 3 9.26 3 12c0 4.97 4.03 9 9 9s9-4.03 9-9c0-2.74-1.23-5.18-3.17-6.83z'
|
||||
);
|
||||
export const CrownIcon = makeIcon(
|
||||
'M5 16L3 6l5.5 4L12 4l3.5 6L21 6l-2 10H5zm14 3c0 .55-.45 1-1 1H6c-.55 0-1-.45-1-1v-1h14v1z'
|
||||
);
|
||||
export const RefreshIcon = makeIcon(
|
||||
'M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z'
|
||||
);
|
||||
export const PlusIcon = makeIcon('M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z');
|
||||
export const VolumeIcon = makeIcon(
|
||||
'M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z'
|
||||
);
|
||||
export const VolumeMuteIcon = makeIcon(
|
||||
'M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z'
|
||||
);
|
||||
export const HelpIcon = makeIcon(
|
||||
'M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z'
|
||||
);
|
||||
export const MenuIcon = makeIcon('M3 6h18v2H3V6zm0 5h18v2H3v-2zm0 5h18v2H3v-2z');
|
||||
export const ExternalLinkIcon = makeIcon(
|
||||
'M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z'
|
||||
);
|
||||
Reference in new issue
Block a user