Compare commits
4 Commits
23bc808cca
...
7f2987041e
| Author | SHA1 | Date |
|---|---|---|
|
|
7f2987041e | |
|
|
663f102cd1 | |
|
|
3f675966a6 | |
|
|
810035547c |
2
bun.lock
2
bun.lock
|
|
@ -18,7 +18,7 @@
|
|||
"preact": "10.22.0",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest",
|
||||
"@types/bun": "^1.3.11",
|
||||
"@types/html-minifier": "4.0.5",
|
||||
"@types/inquirer": "9.0.7",
|
||||
"@types/web-bluetooth": "0.0.21",
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
"preact": "10.22.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest",
|
||||
"@types/bun": "^1.3.11",
|
||||
"@types/html-minifier": "4.0.5",
|
||||
"@types/inquirer": "9.0.7",
|
||||
"@types/web-bluetooth": "0.0.21",
|
||||
|
|
|
|||
|
|
@ -26,3 +26,19 @@
|
|||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--bg-active) transparent;
|
||||
}
|
||||
|
||||
html {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: 'Georgia', serif;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
width: 100dvw;
|
||||
height: 100dvh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
@import './global.css';
|
||||
|
||||
.dialog {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: transparent;
|
||||
border: none;
|
||||
outline: none;
|
||||
padding: 0;
|
||||
|
||||
&::backdrop {
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
backdrop-filter: blur(8px);
|
||||
}
|
||||
|
||||
&[open] {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
.modal {
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
border-radius: 8px;
|
||||
width: 90%;
|
||||
max-width: 960px;
|
||||
height: 80vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: var(--text);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.closeButton {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
color: var(--text-muted);
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: var(--radius);
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
|
||||
&:hover {
|
||||
color: var(--text);
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
}
|
||||
|
||||
.body {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 160px;
|
||||
flex-shrink: 0;
|
||||
border-right: 1px solid var(--border);
|
||||
padding: 8px;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.footer {
|
||||
padding: 16px 20px;
|
||||
border-top: 1px solid var(--border);
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.body {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
border-right: none;
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 4px 8px;
|
||||
flex-shrink: 0;
|
||||
scrollbar-width: none;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
padding: 12px 16px;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,267 @@
|
|||
@import "./global.css";
|
||||
|
||||
/* ─── Form Fields ─────────────────────────────────────────── */
|
||||
|
||||
.input, input, textarea {
|
||||
width: 100%;
|
||||
padding: 8px 12px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
font-family: inherit;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
}
|
||||
|
||||
.textarea {
|
||||
composes: input;
|
||||
resize: vertical;
|
||||
box-sizing: border-box;
|
||||
min-height: 80px;
|
||||
}
|
||||
|
||||
.select {
|
||||
composes: input;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.inputRow {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
/* ─── Buttons ─────────────────────────────────────────────── */
|
||||
|
||||
.button, button {
|
||||
padding: 8px 16px;
|
||||
border-radius: var(--radius);
|
||||
font-size: 14px;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background: transparent;
|
||||
transition: all var(--transition);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.buttonPrimary {
|
||||
composes: button;
|
||||
background: var(--accent);
|
||||
color: var(--bg);
|
||||
font-weight: 500;
|
||||
|
||||
&:hover {
|
||||
background: var(--accent-alt);
|
||||
}
|
||||
}
|
||||
|
||||
.buttonDanger {
|
||||
composes: button;
|
||||
background: var(--danger, #dc2626);
|
||||
color: var(--bg);
|
||||
font-weight: 500;
|
||||
|
||||
&:hover {
|
||||
background: var(--danger-alt, #b91c1c);
|
||||
}
|
||||
}
|
||||
|
||||
.buttonSecondary {
|
||||
composes: button;
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text);
|
||||
|
||||
&:hover {
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
}
|
||||
|
||||
.buttonSmall {
|
||||
padding: 4px 10px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
font-size: 12px;
|
||||
font-family: inherit;
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
transition: all var(--transition);
|
||||
|
||||
&:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
}
|
||||
|
||||
.iconButton {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
background: transparent;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
color: var(--text-muted);
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
transition: all var(--transition);
|
||||
flex-shrink: 0;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.3;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.deleteButton {
|
||||
composes: iconButton;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: var(--danger, var(--accent));
|
||||
border-color: var(--danger, var(--accent));
|
||||
color: var(--bg);
|
||||
}
|
||||
}
|
||||
|
||||
.confirmButton {
|
||||
padding: 4px 10px;
|
||||
border: 1px solid var(--accent);
|
||||
border-radius: var(--radius);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
background: var(--accent);
|
||||
color: var(--bg);
|
||||
transition: all var(--transition);
|
||||
|
||||
&:hover {
|
||||
background: var(--bg);
|
||||
color: var(--accent);
|
||||
}
|
||||
}
|
||||
|
||||
.cancelButton {
|
||||
padding: 4px 10px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
transition: all var(--transition);
|
||||
|
||||
&:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text);
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── Form Layout ─────────────────────────────────────────── */
|
||||
|
||||
.form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.formGroup {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
/* ─── Cards ───────────────────────────────────────────────── */
|
||||
|
||||
.card {
|
||||
background: var(--bg-secondary);
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.cardHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
/* ─── Editor Section Header ───────────────────────────────── */
|
||||
|
||||
.editorHeader {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
/* ─── Badges ──────────────────────────────────────────────── */
|
||||
|
||||
.badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 4px 10px;
|
||||
background: var(--bg-active);
|
||||
border-radius: 16px;
|
||||
font-size: 13px;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.badgeRemove {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
|
||||
&:hover {
|
||||
background: var(--danger, var(--accent));
|
||||
color: var(--bg);
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── Utilities ───────────────────────────────────────────── */
|
||||
|
||||
.empty {
|
||||
color: var(--text-muted);
|
||||
font-style: italic;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.divider {
|
||||
height: 1px;
|
||||
background: var(--border);
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
import type { ComponentChildren } from "preact";
|
||||
import { useCallback, useEffect, useRef } from "preact/hooks";
|
||||
import { X } from "lucide-preact";
|
||||
import clsx from "clsx";
|
||||
|
||||
import styles from '../assets/modal.module.css';
|
||||
|
||||
interface IProps {
|
||||
open: boolean;
|
||||
title?: string;
|
||||
onClose?: () => void;
|
||||
sidebar?: ComponentChildren;
|
||||
footer?: ComponentChildren;
|
||||
class?: string;
|
||||
className?: string;
|
||||
children?: ComponentChildren;
|
||||
}
|
||||
|
||||
export const Modal = ({ children, open, title, onClose, sidebar, footer, ['class']: cls, className }: IProps) => {
|
||||
const ref = useRef<HTMLDialogElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
ref.current?.showModal();
|
||||
} else {
|
||||
console.log(ref.current);
|
||||
ref.current?.close();
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
const handleBackdropMouseDown = useCallback((e: MouseEvent) => {
|
||||
if (e.target === ref.current) onClose?.();
|
||||
}, [onClose]);
|
||||
|
||||
return (
|
||||
<dialog ref={ref} class={styles.dialog} onMouseDown={handleBackdropMouseDown}>
|
||||
<div class={clsx(styles.modal, cls ?? className)} onMouseDown={(e) => e.stopPropagation()}>
|
||||
{(title != null || onClose) && (
|
||||
<div class={styles.header}>
|
||||
{title && <h2 class={styles.title}>{title}</h2>}
|
||||
{onClose && (
|
||||
<button class={styles.closeButton} onClick={onClose}>
|
||||
<X size={18} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<div class={styles.body}>
|
||||
{sidebar && <div class={styles.sidebar}>{sidebar}</div>}
|
||||
<div class={styles.content}>{children}</div>
|
||||
</div>
|
||||
{footer && <div class={styles.footer}>{footer}</div>}
|
||||
</div>
|
||||
</dialog>
|
||||
);
|
||||
};
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
.dialog {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
margin: auto;
|
||||
width: 100%;
|
||||
max-width: 1000px;
|
||||
height: fit-content;
|
||||
max-height: 80dvh;
|
||||
overflow: hidden;
|
||||
background-color: var(--backgroundColor, #333333);
|
||||
color: var(--color, white);
|
||||
border: var(--border, 1px solid white);
|
||||
outline: none;
|
||||
padding: 0;
|
||||
border-radius: var(--border-radius, 0);
|
||||
|
||||
&::backdrop {
|
||||
backdrop-filter: blur(5px);
|
||||
}
|
||||
|
||||
>.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 80dvh;
|
||||
overflow: hidden;
|
||||
|
||||
padding: 30px;
|
||||
|
||||
>.close {
|
||||
font-family: var(--emojiFont, sans-serif);
|
||||
font-size: 12px;
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
import type { ComponentChildren } from "preact";
|
||||
import { useCallback, useEffect, useRef } from "preact/hooks";
|
||||
|
||||
import styles from './Modal.module.css';
|
||||
|
||||
interface IProps {
|
||||
open: boolean;
|
||||
class?: string;
|
||||
className?: string;
|
||||
onClose?: () => void;
|
||||
children?: ComponentChildren;
|
||||
}
|
||||
|
||||
export const Modal = ({ children, open, onClose, ['class']: cls, className }: IProps) => {
|
||||
const ref = useRef<HTMLDialogElement>(null);
|
||||
const handleClickWrapper = useCallback((e: MouseEvent) => {
|
||||
if (e.currentTarget instanceof HTMLDialogElement) {
|
||||
onClose?.();
|
||||
} else {
|
||||
e.stopPropagation();
|
||||
}
|
||||
}, [onClose]);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
ref.current?.showModal();
|
||||
} else {
|
||||
ref.current?.close();
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
return (
|
||||
<dialog ref={ref} onMouseDown={handleClickWrapper} class={styles.dialog}>
|
||||
<div class={`${styles.content} ${cls ?? className ?? ''}`} onMouseDown={handleClickWrapper}>
|
||||
<div class={styles.close} onClick={onClose}>❌</div>
|
||||
{children}
|
||||
</div>
|
||||
</dialog>
|
||||
);
|
||||
};
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
.overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.modal {
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
|
||||
max-height: 80vh;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 14px 16px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.closeButton {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
color: var(--text-muted);
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: var(--radius);
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
color: var(--text);
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
}
|
||||
|
||||
.body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.footer {
|
||||
padding: 12px 16px;
|
||||
border-top: 1px solid var(--border);
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 8px;
|
||||
flex-shrink: 0;
|
||||
align-items: center;
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
.modal {
|
||||
width: 380px;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.saveBtn {
|
||||
color: var(--accent-alt) !important;
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
@import "@common/assets/global.css";
|
||||
|
||||
body {
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: 'Georgia', serif;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
width: 100dvw;
|
||||
height: 100dvh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--text-muted);
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
transition: color var(--transition), background var(--transition);
|
||||
border-radius: var(--radius);
|
||||
display: inline-flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 4px 8px;
|
||||
|
||||
&:hover {
|
||||
color: var(--text);
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
}
|
||||
|
||||
input, textarea {
|
||||
background: var(--bg-active);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
color: var(--text);
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
padding: 6px 10px;
|
||||
outline: none;
|
||||
transition: border-color var(--transition);
|
||||
|
||||
&:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
import { useEffect, useState } from "preact/hooks";
|
||||
import { X } from "lucide-preact";
|
||||
import { useHordeState } from "../../contexts/state";
|
||||
import { fetchWorker, updateWorker, deleteWorker, type WorkerData } from "../../utils/api";
|
||||
import modalStyles from "../../assets/modal.module.css";
|
||||
import styles from "../../assets/manage-workers-modal.module.css";
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
interface WorkerEdit {
|
||||
name: string;
|
||||
info: string;
|
||||
maintenance_mode: boolean;
|
||||
}
|
||||
|
||||
export const ManageWorkersModal = ({ open, onClose }: Props) => {
|
||||
const { state, dispatch } = useHordeState();
|
||||
const { user, apiKey } = state;
|
||||
|
||||
const [workerDetails, setWorkerDetails] = useState<WorkerData[]>([]);
|
||||
const [edits, setEdits] = useState<Record<string, WorkerEdit>>({});
|
||||
const [saving, setSaving] = useState<Record<string, boolean>>({});
|
||||
const [deleting, setDeleting] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open || !user || !apiKey) return;
|
||||
let cancelled = false;
|
||||
|
||||
setLoading(true);
|
||||
Promise.all(user.worker_ids.map(id => fetchWorker(id, apiKey)))
|
||||
.then(details => {
|
||||
if (cancelled) return;
|
||||
setWorkerDetails(details);
|
||||
const initialEdits: Record<string, WorkerEdit> = {};
|
||||
for (const w of details) {
|
||||
initialEdits[w.id] = { name: w.name, info: w.info ?? '', maintenance_mode: w.maintenance_mode };
|
||||
}
|
||||
setEdits(initialEdits);
|
||||
})
|
||||
.catch(console.error)
|
||||
.finally(() => { if (!cancelled) setLoading(false); });
|
||||
|
||||
return () => { cancelled = true; };
|
||||
}, [open, user?.worker_ids.join(',')]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); };
|
||||
window.addEventListener('keydown', handler);
|
||||
return () => window.removeEventListener('keydown', handler);
|
||||
}, [open]);
|
||||
|
||||
if (!open || !user) return null;
|
||||
|
||||
const setEdit = (id: string, patch: Partial<WorkerEdit>) => {
|
||||
setEdits(prev => ({ ...prev, [id]: { ...prev[id], ...patch } }));
|
||||
};
|
||||
|
||||
const save = async (id: string) => {
|
||||
if (!apiKey) return;
|
||||
setSaving(prev => ({ ...prev, [id]: true }));
|
||||
try {
|
||||
const updated = await updateWorker(id, apiKey, edits[id]);
|
||||
setWorkerDetails(prev => prev.map(w => w.id === id ? updated : w));
|
||||
} catch (e) {
|
||||
console.error('[horde] save worker error:', e);
|
||||
} finally {
|
||||
setSaving(prev => ({ ...prev, [id]: false }));
|
||||
}
|
||||
};
|
||||
|
||||
const confirmDelete = async (id: string) => {
|
||||
if (!apiKey || !confirm('Delete this worker? This cannot be undone.')) return;
|
||||
setDeleting(id);
|
||||
try {
|
||||
await deleteWorker(id, apiKey);
|
||||
setWorkerDetails(prev => prev.filter(w => w.id !== id));
|
||||
dispatch({ type: 'SET_USER', user: { ...user, worker_ids: user.worker_ids.filter(i => i !== id) } });
|
||||
} catch (e) {
|
||||
console.error('[horde] delete worker error:', e);
|
||||
} finally {
|
||||
setDeleting(null);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div class={modalStyles.overlay} onMouseDown={e => { if (e.target === e.currentTarget) onClose(); }}>
|
||||
<div class={`${modalStyles.modal} ${styles.modal}`}>
|
||||
<div class={modalStyles.header}>
|
||||
<span class={modalStyles.title}>Manage Workers</span>
|
||||
<button class={modalStyles.closeButton} onClick={onClose}><X size={16} /></button>
|
||||
</div>
|
||||
<div class={modalStyles.body}>
|
||||
{loading && <p class={styles.loading}>Loading…</p>}
|
||||
{!loading && workerDetails.map(w => {
|
||||
const edit = edits[w.id] ?? { name: w.name, info: w.info ?? '', maintenance_mode: w.maintenance_mode };
|
||||
return (
|
||||
<div key={w.id} class={styles.workerForm}>
|
||||
<div class={styles.workerName}>{w.name}</div>
|
||||
<label class={styles.label}>
|
||||
<span>Name</span>
|
||||
<input
|
||||
value={edit.name}
|
||||
onInput={e => setEdit(w.id, { name: (e.target as HTMLInputElement).value })}
|
||||
/>
|
||||
</label>
|
||||
<label class={styles.label}>
|
||||
<span>Info</span>
|
||||
<textarea
|
||||
class={styles.textarea}
|
||||
value={edit.info}
|
||||
onInput={e => setEdit(w.id, { info: (e.target as HTMLTextAreaElement).value })}
|
||||
rows={3}
|
||||
/>
|
||||
</label>
|
||||
<label class={styles.checkboxLabel}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={edit.maintenance_mode}
|
||||
onChange={e => setEdit(w.id, { maintenance_mode: (e.target as HTMLInputElement).checked })}
|
||||
/>
|
||||
<span>Maintenance mode</span>
|
||||
</label>
|
||||
<div class={styles.formActions}>
|
||||
<button class={styles.saveBtn} onClick={() => save(w.id)} disabled={saving[w.id]}>
|
||||
{saving[w.id] ? 'Saving…' : 'Save'}
|
||||
</button>
|
||||
<button class={styles.deleteBtn} onClick={() => confirmDelete(w.id)} disabled={deleting === w.id}>
|
||||
{deleting === w.id ? 'Deleting…' : 'Delete'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
import { useEffect, useState } from "preact/hooks";
|
||||
import { X } from "lucide-preact";
|
||||
import { useHordeState } from "../../contexts/state";
|
||||
import modalStyles from "../../assets/modal.module.css";
|
||||
import styles from "../../assets/options-modal.module.css";
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const OptionsModal = ({ open, onClose }: Props) => {
|
||||
const { state, dispatch } = useHordeState();
|
||||
const [draft, setDraft] = useState(state.apiKey);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) setDraft(state.apiKey);
|
||||
}, [open]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); };
|
||||
window.addEventListener('keydown', handler);
|
||||
return () => window.removeEventListener('keydown', handler);
|
||||
}, [open]);
|
||||
|
||||
if (!open) return null;
|
||||
|
||||
const save = () => {
|
||||
dispatch({ type: 'SET_API_KEY', apiKey: draft.trim() });
|
||||
onClose();
|
||||
};
|
||||
|
||||
const clear = () => {
|
||||
dispatch({ type: 'SET_API_KEY', apiKey: '' });
|
||||
setDraft('');
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<div class={modalStyles.overlay} onMouseDown={e => { if (e.target === e.currentTarget) onClose(); }}>
|
||||
<div class={`${modalStyles.modal} ${styles.modal}`}>
|
||||
<div class={modalStyles.header}>
|
||||
<span class={modalStyles.title}>Options</span>
|
||||
<button class={modalStyles.closeButton} onClick={onClose}><X size={16} /></button>
|
||||
</div>
|
||||
<div class={modalStyles.body}>
|
||||
<label class={styles.label}>
|
||||
<span>API Key</span>
|
||||
<input
|
||||
type="password"
|
||||
value={draft}
|
||||
onInput={e => setDraft((e.target as HTMLInputElement).value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') save(); }}
|
||||
placeholder="Enter your AI Horde API key"
|
||||
autoFocus
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div class={modalStyles.footer}>
|
||||
<button class={styles.saveBtn} onClick={save}>Save</button>
|
||||
{state.apiKey && <button onClick={clear}>Clear</button>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -20,4 +20,4 @@
|
|||
flex-direction: column;
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
|
|
@ -1,8 +1,10 @@
|
|||
.modal {
|
||||
width: 480px;
|
||||
max-width: 480px;
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
.loading, .error {
|
||||
.loading,
|
||||
.error {
|
||||
color: var(--text-muted);
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
|
|
@ -18,7 +20,8 @@
|
|||
border-collapse: collapse;
|
||||
font-size: 13px;
|
||||
|
||||
th, td {
|
||||
th,
|
||||
td {
|
||||
padding: 7px 10px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid var(--border);
|
||||
|
|
@ -71,4 +74,4 @@
|
|||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
.modal {
|
||||
width: 480px;
|
||||
max-width: 480px;
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
.loading {
|
||||
|
|
@ -57,11 +58,10 @@
|
|||
gap: 8px;
|
||||
}
|
||||
|
||||
.saveBtn {
|
||||
color: var(--accent-alt) !important;
|
||||
.saveBtn {
|
||||
composes: buttonSecondary from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.deleteBtn {
|
||||
color: var(--accent) !important;
|
||||
margin-left: auto;
|
||||
}
|
||||
.deleteBtn {
|
||||
composes: buttonDanger from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
|
@ -20,4 +20,4 @@
|
|||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 4px;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
.modal {
|
||||
max-width: 380px;
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.saveBtn {
|
||||
composes: buttonSecondary from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.clearBtn {
|
||||
composes: buttonSecondary from '@common/assets/ui.module.css';
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
|
|
@ -59,7 +59,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
.userStats, .networkStats {
|
||||
.userStats,
|
||||
.networkStats {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
|
@ -83,7 +84,8 @@
|
|||
border-collapse: collapse;
|
||||
font-size: 12px;
|
||||
|
||||
th, td {
|
||||
th,
|
||||
td {
|
||||
padding: 5px 6px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid var(--border);
|
||||
|
|
@ -122,4 +124,4 @@
|
|||
width: 52px;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
}
|
||||
|
||||
.own {
|
||||
border-color: var(--accent) !important;
|
||||
border-color: var(--accent-alt) !important;
|
||||
}
|
||||
|
||||
.offline {
|
||||
|
|
@ -130,4 +130,4 @@
|
|||
font-size: 12px;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -44,4 +44,4 @@
|
|||
align-content: start;
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
import { useEffect, useState } from "preact/hooks";
|
||||
import { X } from "lucide-preact";
|
||||
import { useHordeState } from "../../contexts/state";
|
||||
import { fetchLeaderboard, type LeaderboardEntry } from "../../utils/api";
|
||||
import { formatNumber, formatTime } from "@common/utils";
|
||||
import modalStyles from "../../assets/modal.module.css";
|
||||
import { Modal } from "@common/components/Modal";
|
||||
import styles from "../../assets/leaderboard-modal.module.css";
|
||||
|
||||
interface Props {
|
||||
|
|
@ -93,67 +92,49 @@ export const LeaderboardModal = ({ open, onClose }: Props) => {
|
|||
return () => { cancelled = true; };
|
||||
}, [open, user?.username]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); };
|
||||
window.addEventListener('keydown', handler);
|
||||
return () => window.removeEventListener('keydown', handler);
|
||||
}, [open]);
|
||||
|
||||
if (!open) return null;
|
||||
const nextRow = rows.length >= 2 ? rows[rows.length - 2] : null;
|
||||
const footer = user && nextRow?.diff && nextRow.diff > 0 && kudosPerHour > 0
|
||||
? (() => {
|
||||
const secs = Math.ceil((nextRow.diff / kudosPerHour) * 3600);
|
||||
return (
|
||||
<span class={styles.nextPlace}>
|
||||
Time to #{nextRow.rank}: <strong>{formatTime(secs)}</strong>
|
||||
<span class={styles.nextPlaceMeta}> ({formatNumber(Math.round(kudosPerHour))} kudos/h)</span>
|
||||
</span>
|
||||
);
|
||||
})()
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<div class={modalStyles.overlay} onMouseDown={e => { if (e.target === e.currentTarget) onClose(); }}>
|
||||
<div class={`${modalStyles.modal} ${styles.modal}`}>
|
||||
<div class={modalStyles.header}>
|
||||
<span class={modalStyles.title}>Leaderboard</span>
|
||||
<button class={modalStyles.closeButton} onClick={onClose}><X size={16} /></button>
|
||||
</div>
|
||||
<div class={modalStyles.body}>
|
||||
{loading && <p class={styles.loading}>Loading…</p>}
|
||||
{error && <p class={styles.error}>{error}</p>}
|
||||
{!loading && !error && rows.length > 0 && (
|
||||
<table class={styles.table}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Username</th>
|
||||
<th>Kudos</th>
|
||||
{user && <th>Diff</th>}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map(r => (
|
||||
<tr key={r.rank} class={r.username === user?.username ? styles.selfRow : undefined}>
|
||||
<td>{r.rank}</td>
|
||||
<td>{r.username}</td>
|
||||
<td>{formatNumber(r.kudos)}</td>
|
||||
{user && (
|
||||
<td class={r.diff !== undefined ? (r.diff > 0 ? styles.above : styles.below) : undefined}>
|
||||
{r.diff !== undefined ? `+${formatNumber(r.diff)}` : '—'}
|
||||
</td>
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</div>
|
||||
{(() => {
|
||||
if (!user || rows.length < 2 || kudosPerHour <= 0) return null;
|
||||
const nextRow = rows[rows.length - 2];
|
||||
if (!nextRow.diff || nextRow.diff <= 0) return null;
|
||||
const secs = Math.ceil((nextRow.diff / kudosPerHour) * 3600);
|
||||
return (
|
||||
<div class={modalStyles.footer}>
|
||||
<span class={styles.nextPlace}>
|
||||
Time to #{nextRow.rank}: <strong>{formatTime(secs)}</strong>
|
||||
<span class={styles.nextPlaceMeta}> ({formatNumber(Math.round(kudosPerHour))} kudos/h)</span>
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
</div>
|
||||
<Modal open={open} onClose={onClose} title="Leaderboard" class={styles.modal} footer={footer}>
|
||||
{loading && <p class={styles.loading}>Loading…</p>}
|
||||
{error && <p class={styles.error}>{error}</p>}
|
||||
{!loading && !error && rows.length > 0 && (
|
||||
<table class={styles.table}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Username</th>
|
||||
<th>Kudos</th>
|
||||
{user && <th>Diff</th>}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map(r => (
|
||||
<tr key={r.rank} class={r.username === user?.username ? styles.selfRow : undefined}>
|
||||
<td>{r.rank}</td>
|
||||
<td>{r.username}</td>
|
||||
<td>{formatNumber(r.kudos)}</td>
|
||||
{user && (
|
||||
<td class={r.diff !== undefined ? (r.diff > 0 ? styles.above : styles.below) : undefined}>
|
||||
{r.diff !== undefined ? `+${formatNumber(r.diff)}` : '—'}
|
||||
</td>
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
import { useEffect, useState } from "preact/hooks";
|
||||
import { useHordeState } from "../../contexts/state";
|
||||
import { fetchWorker, updateWorker, deleteWorker, type WorkerData } from "../../utils/api";
|
||||
import { Modal } from "@common/components/Modal";
|
||||
import styles from "../../assets/manage-workers-modal.module.css";
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
interface WorkerEdit {
|
||||
name: string;
|
||||
info: string;
|
||||
maintenance_mode: boolean;
|
||||
}
|
||||
|
||||
export const ManageWorkersModal = ({ open, onClose }: Props) => {
|
||||
const { state, dispatch } = useHordeState();
|
||||
const { user, apiKey } = state;
|
||||
|
||||
const [workerDetails, setWorkerDetails] = useState<WorkerData[]>([]);
|
||||
const [edits, setEdits] = useState<Record<string, WorkerEdit>>({});
|
||||
const [saving, setSaving] = useState<Record<string, boolean>>({});
|
||||
const [deleting, setDeleting] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open || !user || !apiKey) return;
|
||||
let cancelled = false;
|
||||
|
||||
setLoading(true);
|
||||
Promise.all(user.worker_ids.map(id => fetchWorker(id, apiKey)))
|
||||
.then(details => {
|
||||
if (cancelled) return;
|
||||
setWorkerDetails(details);
|
||||
const initialEdits: Record<string, WorkerEdit> = {};
|
||||
for (const w of details) {
|
||||
initialEdits[w.id] = { name: w.name, info: w.info ?? '', maintenance_mode: w.maintenance_mode };
|
||||
}
|
||||
setEdits(initialEdits);
|
||||
})
|
||||
.catch(console.error)
|
||||
.finally(() => { if (!cancelled) setLoading(false); });
|
||||
|
||||
return () => { cancelled = true; };
|
||||
}, [open, user?.worker_ids.join(',')]);
|
||||
|
||||
const setEdit = (id: string, patch: Partial<WorkerEdit>) => {
|
||||
setEdits(prev => ({ ...prev, [id]: { ...prev[id], ...patch } }));
|
||||
};
|
||||
|
||||
const save = async (id: string) => {
|
||||
if (!apiKey) return;
|
||||
setSaving(prev => ({ ...prev, [id]: true }));
|
||||
try {
|
||||
const updated = await updateWorker(id, apiKey, edits[id]);
|
||||
setWorkerDetails(prev => prev.map(w => w.id === id ? updated : w));
|
||||
} catch (e) {
|
||||
console.error('[horde] save worker error:', e);
|
||||
} finally {
|
||||
setSaving(prev => ({ ...prev, [id]: false }));
|
||||
}
|
||||
};
|
||||
|
||||
const confirmDelete = async (id: string) => {
|
||||
if (!apiKey || !confirm('Delete this worker? This cannot be undone.')) return;
|
||||
setDeleting(id);
|
||||
try {
|
||||
await deleteWorker(id, apiKey);
|
||||
setWorkerDetails(prev => prev.filter(w => w.id !== id));
|
||||
dispatch({ type: 'SET_USER', user: { ...user!, worker_ids: user!.worker_ids.filter(i => i !== id) } });
|
||||
} catch (e) {
|
||||
console.error('[horde] delete worker error:', e);
|
||||
} finally {
|
||||
setDeleting(null);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal open={open && Boolean(user)} onClose={onClose} title="Manage Workers" class={styles.modal}>
|
||||
{loading && <p class={styles.loading}>Loading…</p>}
|
||||
{!loading && user && workerDetails.map(w => {
|
||||
const edit = edits[w.id] ?? { name: w.name, info: w.info ?? '', maintenance_mode: w.maintenance_mode };
|
||||
return (
|
||||
<div key={w.id} class={styles.workerForm}>
|
||||
<div class={styles.workerName}>{w.name}</div>
|
||||
<label class={styles.label}>
|
||||
<span>Name</span>
|
||||
<input
|
||||
value={edit.name}
|
||||
onInput={e => setEdit(w.id, { name: (e.target as HTMLInputElement).value })}
|
||||
/>
|
||||
</label>
|
||||
<label class={styles.label}>
|
||||
<span>Info</span>
|
||||
<textarea
|
||||
class={styles.textarea}
|
||||
value={edit.info}
|
||||
onInput={e => setEdit(w.id, { info: (e.target as HTMLTextAreaElement).value })}
|
||||
rows={3}
|
||||
/>
|
||||
</label>
|
||||
<label class={styles.checkboxLabel}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={edit.maintenance_mode}
|
||||
onChange={e => setEdit(w.id, { maintenance_mode: (e.target as HTMLInputElement).checked })}
|
||||
/>
|
||||
<span>Maintenance mode</span>
|
||||
</label>
|
||||
<div class={styles.formActions}>
|
||||
<button class={styles.saveBtn} onClick={() => save(w.id)} disabled={saving[w.id]}>
|
||||
{saving[w.id] ? 'Saving…' : 'Save'}
|
||||
</button>
|
||||
<button class={styles.deleteBtn} onClick={() => confirmDelete(w.id)} disabled={deleting === w.id}>
|
||||
{deleting === w.id ? 'Deleting…' : 'Delete'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
import { useEffect } from "preact/hooks";
|
||||
import { useHordeState } from "../../contexts/state";
|
||||
import { useInputState } from "@common/hooks/useInputState";
|
||||
import { Modal } from "@common/components/Modal";
|
||||
import styles from "../../assets/options-modal.module.css";
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const OptionsModal = ({ open, onClose }: Props) => {
|
||||
const { state, dispatch } = useHordeState();
|
||||
const [draft, setDraft] = useInputState(state.apiKey);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) setDraft(state.apiKey);
|
||||
}, [open]);
|
||||
|
||||
const save = () => {
|
||||
dispatch({ type: 'SET_API_KEY', apiKey: draft.trim() });
|
||||
onClose();
|
||||
};
|
||||
|
||||
const clear = () => {
|
||||
dispatch({ type: 'SET_API_KEY', apiKey: '' });
|
||||
setDraft('');
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
title="Options"
|
||||
class={styles.modal}
|
||||
footer={<>
|
||||
<button class={styles.saveBtn} onClick={save}>Save</button>
|
||||
{state.apiKey && <button class={styles.clearBtn} onClick={clear}>Clear</button>}
|
||||
</>}
|
||||
>
|
||||
<label class={styles.label}>
|
||||
<span>API Key</span>
|
||||
<input
|
||||
type="password"
|
||||
value={draft}
|
||||
onInput={setDraft}
|
||||
onKeyDown={e => { if (e.key === 'Enter') save(); }}
|
||||
placeholder="Enter your AI Horde API key"
|
||||
autoFocus
|
||||
/>
|
||||
</label>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
|
@ -59,7 +59,7 @@ export const StatsPanel = () => {
|
|||
</div>
|
||||
<div class={styles.stat}>
|
||||
<dt>Workers</dt>
|
||||
<dd>{user.worker_count}</dd>
|
||||
<dd>{ownWorkers.length}/{user.worker_count}</dd>
|
||||
</div>
|
||||
<div class={styles.stat}>
|
||||
<dt>Tokens generated</dt>
|
||||
|
|
@ -2,8 +2,6 @@ import { render } from "preact";
|
|||
import { App } from "./components/app";
|
||||
import { HordeStateProvider } from "./contexts/state";
|
||||
|
||||
import './assets/style.css';
|
||||
|
||||
export default function main() {
|
||||
render(
|
||||
<HordeStateProvider>
|
||||
|
|
@ -7,18 +7,11 @@
|
|||
}
|
||||
|
||||
.empty {
|
||||
color: var(--text-muted);
|
||||
font-style: italic;
|
||||
font-size: 14px;
|
||||
composes: empty from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.chapterCard {
|
||||
background: var(--bg-secondary);
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
composes: card from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.chapterTitle {
|
||||
|
|
@ -59,24 +52,9 @@
|
|||
}
|
||||
|
||||
.summaryEditable {
|
||||
width: 100%;
|
||||
composes: textarea from '@common/assets/ui.module.css';
|
||||
padding: 10px 12px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
font-family: inherit;
|
||||
box-sizing: border-box;
|
||||
min-height: 80px;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
resize: vertical;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,7 @@
|
|||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
composes: editorHeader from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.header h2 {
|
||||
|
|
@ -22,19 +18,8 @@
|
|||
}
|
||||
|
||||
.addButton {
|
||||
padding: 8px 16px;
|
||||
background: var(--accent);
|
||||
color: var(--bg);
|
||||
border: none;
|
||||
composes: buttonPrimary from '@common/assets/ui.module.css';
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: var(--accent-alt);
|
||||
}
|
||||
}
|
||||
|
||||
.deleteConfirm {
|
||||
|
|
@ -53,37 +38,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
.confirmButton,
|
||||
.cancelButton {
|
||||
padding: 4px 10px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--radius);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all var(--transition);
|
||||
}
|
||||
|
||||
.confirmButton {
|
||||
background: var(--accent);
|
||||
color: var(--bg);
|
||||
border-color: var(--accent);
|
||||
|
||||
&:hover {
|
||||
background: var(--bg);
|
||||
color: var(--accent);
|
||||
}
|
||||
composes: confirmButton from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.cancelButton {
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
border-color: var(--border);
|
||||
|
||||
&:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text);
|
||||
}
|
||||
composes: cancelButton from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.list {
|
||||
|
|
@ -95,24 +55,15 @@
|
|||
}
|
||||
|
||||
.empty {
|
||||
color: var(--text-muted);
|
||||
font-style: italic;
|
||||
font-size: 14px;
|
||||
composes: empty from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.characterCard {
|
||||
background: var(--bg-secondary);
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
composes: card from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.cardHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
composes: cardHeader from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.nameInput {
|
||||
|
|
@ -133,29 +84,15 @@
|
|||
}
|
||||
|
||||
.deleteButton {
|
||||
composes: deleteButton from '@common/assets/ui.module.css';
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: transparent;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
color: var(--text-muted);
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
transition: all var(--transition);
|
||||
|
||||
&:hover {
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
color: var(--bg);
|
||||
}
|
||||
}
|
||||
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
composes: formGroup from '@common/assets/ui.module.css';
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
|
|
@ -224,70 +161,23 @@
|
|||
}
|
||||
|
||||
.generateButton {
|
||||
padding: 4px 10px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
transition: all var(--transition);
|
||||
|
||||
&:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
composes: buttonSmall from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.textarea {
|
||||
width: 100%;
|
||||
composes: textarea from '@common/assets/ui.module.css';
|
||||
padding: 10px 12px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
font-family: inherit;
|
||||
resize: vertical;
|
||||
box-sizing: border-box;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
}
|
||||
|
||||
.select {
|
||||
width: 100%;
|
||||
composes: select from '@common/assets/ui.module.css';
|
||||
padding: 10px 12px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
}
|
||||
|
||||
.smallButton {
|
||||
padding: 4px 10px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
composes: buttonSmall from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.nicknames {
|
||||
|
|
@ -303,35 +193,11 @@
|
|||
}
|
||||
|
||||
.badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 4px 10px;
|
||||
background: var(--bg-active);
|
||||
border-radius: 16px;
|
||||
font-size: 13px;
|
||||
color: var(--text);
|
||||
composes: badge from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.badgeRemove {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
|
||||
&:hover {
|
||||
background: var(--danger);
|
||||
color: var(--bg);
|
||||
}
|
||||
composes: badgeRemove from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.relations {
|
||||
|
|
|
|||
|
|
@ -7,11 +7,7 @@
|
|||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
composes: editorHeader from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.header h2 {
|
||||
|
|
@ -22,19 +18,8 @@
|
|||
}
|
||||
|
||||
.addButton {
|
||||
padding: 8px 16px;
|
||||
background: var(--accent);
|
||||
color: var(--bg);
|
||||
border: none;
|
||||
composes: buttonPrimary from '@common/assets/ui.module.css';
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: var(--accent-alt);
|
||||
}
|
||||
}
|
||||
|
||||
.deleteConfirm {
|
||||
|
|
@ -53,37 +38,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
.confirmButton,
|
||||
.cancelButton {
|
||||
padding: 4px 10px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--radius);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all var(--transition);
|
||||
}
|
||||
|
||||
.confirmButton {
|
||||
background: var(--accent);
|
||||
color: var(--bg);
|
||||
border-color: var(--accent);
|
||||
|
||||
&:hover {
|
||||
background: var(--bg);
|
||||
color: var(--accent);
|
||||
}
|
||||
composes: confirmButton from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.cancelButton {
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
border-color: var(--border);
|
||||
|
||||
&:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text);
|
||||
}
|
||||
composes: cancelButton from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.list {
|
||||
|
|
@ -95,24 +55,15 @@
|
|||
}
|
||||
|
||||
.empty {
|
||||
color: var(--text-muted);
|
||||
font-style: italic;
|
||||
font-size: 14px;
|
||||
composes: empty from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.locationCard {
|
||||
background: var(--bg-secondary);
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
composes: card from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.cardHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
composes: cardHeader from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.nameInput {
|
||||
|
|
@ -133,29 +84,15 @@
|
|||
}
|
||||
|
||||
.deleteButton {
|
||||
composes: deleteButton from '@common/assets/ui.module.css';
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: transparent;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
color: var(--text-muted);
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
transition: all var(--transition);
|
||||
|
||||
&:hover {
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
color: var(--bg);
|
||||
}
|
||||
}
|
||||
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
composes: formGroup from '@common/assets/ui.module.css';
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
|
|
@ -174,52 +111,17 @@
|
|||
}
|
||||
|
||||
.select {
|
||||
width: 100%;
|
||||
composes: select from '@common/assets/ui.module.css';
|
||||
padding: 10px 12px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
}
|
||||
|
||||
.generateButton {
|
||||
padding: 4px 10px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
transition: all var(--transition);
|
||||
|
||||
&:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
composes: buttonSmall from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.textarea {
|
||||
width: 100%;
|
||||
composes: textarea from '@common/assets/ui.module.css';
|
||||
padding: 10px 12px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
font-family: inherit;
|
||||
resize: vertical;
|
||||
box-sizing: border-box;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,7 @@
|
|||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
composes: editorHeader from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.header h2 {
|
||||
|
|
@ -44,19 +40,8 @@
|
|||
}
|
||||
|
||||
.addButton {
|
||||
padding: 8px 16px;
|
||||
background: var(--accent);
|
||||
color: var(--bg);
|
||||
border: none;
|
||||
composes: buttonPrimary from '@common/assets/ui.module.css';
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: var(--accent-alt);
|
||||
}
|
||||
}
|
||||
|
||||
.list {
|
||||
|
|
@ -68,25 +53,17 @@
|
|||
}
|
||||
|
||||
.empty {
|
||||
color: var(--text-muted);
|
||||
font-style: italic;
|
||||
font-size: 14px;
|
||||
composes: empty from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.entryCard {
|
||||
background: var(--bg-secondary);
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
composes: card from '@common/assets/ui.module.css';
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.cardHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
composes: cardHeader from '@common/assets/ui.module.css';
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.titleRow {
|
||||
|
|
@ -131,49 +108,15 @@
|
|||
}
|
||||
|
||||
.moveButton {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
composes: iconButton from '@common/assets/ui.module.css';
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
color: var(--text);
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
transition: all var(--transition);
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.3;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.deleteButton {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: transparent;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
color: var(--text-muted);
|
||||
composes: deleteButton from '@common/assets/ui.module.css';
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
transition: all var(--transition);
|
||||
|
||||
&:hover {
|
||||
background: var(--danger);
|
||||
border-color: var(--danger);
|
||||
color: var(--bg);
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
|
|
@ -181,20 +124,7 @@
|
|||
}
|
||||
|
||||
.textarea {
|
||||
width: 100%;
|
||||
composes: textarea from '@common/assets/ui.module.css';
|
||||
padding: 10px 12px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
font-family: inherit;
|
||||
resize: vertical;
|
||||
min-height: 80px;
|
||||
box-sizing: border-box;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,77 +1,3 @@
|
|||
.overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.modal {
|
||||
background: var(--bg);
|
||||
border-radius: 8px;
|
||||
width: 90%;
|
||||
max-width: 960px;
|
||||
height: 80vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: var(--text);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.closeButton {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
font-size: 20px;
|
||||
color: var(--text-muted);
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
color: var(--text);
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
}
|
||||
|
||||
.body {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 160px;
|
||||
flex-shrink: 0;
|
||||
border-right: 1px solid var(--border);
|
||||
padding: 8px;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.menuItem {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
@ -98,25 +24,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
flex: 1;
|
||||
composes: form from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.formGroup {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
composes: formGroup from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.formGroupFill {
|
||||
|
|
@ -124,9 +37,7 @@
|
|||
}
|
||||
|
||||
.label {
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
font-weight: bold;
|
||||
composes: label from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.selectMultiline {
|
||||
|
|
@ -143,54 +54,38 @@
|
|||
padding-inline-start: 16px;
|
||||
}
|
||||
|
||||
.input,
|
||||
.select,
|
||||
.textarea {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
.input {
|
||||
composes: input from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.select {
|
||||
composes: select from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.textarea {
|
||||
composes: textarea from '@common/assets/ui.module.css';
|
||||
resize: none;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
line-height: 1.5;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.footer {
|
||||
padding: 16px 20px;
|
||||
border-top: 1px solid var(--border);
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
min-height: unset;
|
||||
}
|
||||
|
||||
.button {
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
composes: button from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.buttonSecondary {
|
||||
border: 1px solid var(--border);
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
composes: buttonSecondary from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.buttonPrimary {
|
||||
border: none;
|
||||
background: var(--accent);
|
||||
composes: buttonPrimary from '@common/assets/ui.module.css';
|
||||
color: var(--accent-text);
|
||||
}
|
||||
|
||||
.inputRow {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
composes: inputRow from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.inputRow .input {
|
||||
|
|
@ -203,7 +98,7 @@
|
|||
justify-content: center;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
border-radius: var(--radius);
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
|
|
@ -216,9 +111,7 @@
|
|||
}
|
||||
|
||||
.divider {
|
||||
height: 1px;
|
||||
background: var(--border);
|
||||
margin: 16px 0;
|
||||
composes: divider from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
.tokenList {
|
||||
|
|
@ -229,49 +122,21 @@
|
|||
}
|
||||
|
||||
.tokenItem {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 4px 8px;
|
||||
background: var(--bg-active);
|
||||
composes: badge from '@common/assets/ui.module.css';
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
color: var(--text);
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
|
||||
.tokenRemoveButton {
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
composes: badgeRemove from '@common/assets/ui.module.css';
|
||||
padding: 0 2px;
|
||||
font-size: 14px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.emptyText {
|
||||
color: var(--text-muted);
|
||||
composes: empty from '@common/assets/ui.module.css';
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.body {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
border-right: none;
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 4px 8px;
|
||||
flex-shrink: 0;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.sidebar::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.menuItem {
|
||||
flex: 1;
|
||||
justify-content: center;
|
||||
|
|
@ -280,8 +145,4 @@
|
|||
padding: 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
padding: 12px 16px;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -322,9 +322,8 @@ export const Menu = ({ visible }: { visible: boolean }) => {
|
|||
<Settings size={16} /> Settings
|
||||
</button>
|
||||
</div>
|
||||
{isSettingsOpen.value && (
|
||||
<SettingsModal onClose={isSettingsOpen.toggle} />
|
||||
)}
|
||||
|
||||
<SettingsModal open={isSettingsOpen.value} onClose={isSettingsOpen.setFalse} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import clsx from "clsx";
|
||||
import { X } from "lucide-preact";
|
||||
import { useState } from "preact/hooks";
|
||||
import { Modal } from "@common/components/Modal";
|
||||
import styles from "../assets/settings-modal.module.css";
|
||||
import { BannedTokensSettings } from "./settings/banned-tokens";
|
||||
import { ChatSystemInstructionSettings } from "./settings/chat-system-instruction";
|
||||
|
|
@ -10,77 +10,50 @@ import { SystemInstructionSettings } from "./settings/system-instruction";
|
|||
import { UserSettings } from "./settings/user";
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
type Tab = "banned-tokens" | "system-instruction" | "chat-system-instruction" | "continue-prompt" | "connection" | "user";
|
||||
|
||||
export const SettingsModal = ({ onClose }: Props) => {
|
||||
const TABS: { id: Tab; label: string }[] = [
|
||||
{ id: "connection", label: "Connection" },
|
||||
{ id: "user", label: "User" },
|
||||
{ id: "system-instruction", label: "System Instruction" },
|
||||
{ id: "continue-prompt", label: "Continue Prompt" },
|
||||
{ id: "chat-system-instruction", label: "Chat System Instruction" },
|
||||
{ id: "banned-tokens", label: "Banned Tokens" },
|
||||
];
|
||||
|
||||
export const SettingsModal = ({ open, onClose }: Props) => {
|
||||
const [activeTab, setActiveTab] = useState<Tab>("connection");
|
||||
|
||||
return (
|
||||
<div class={styles.overlay} onClick={onClose}>
|
||||
<div class={styles.modal} onClick={(e) => e.stopPropagation()}>
|
||||
<div class={styles.header}>
|
||||
<h2 class={styles.title}>Settings</h2>
|
||||
<button class={styles.closeButton} onClick={onClose}>
|
||||
<X size={20} />
|
||||
</button>
|
||||
</div>
|
||||
<div class={styles.body}>
|
||||
<nav class={styles.sidebar}>
|
||||
<button
|
||||
class={clsx(styles.menuItem, activeTab === "connection" && styles.active)}
|
||||
onClick={() => setActiveTab("connection")}
|
||||
>
|
||||
Connection
|
||||
</button>
|
||||
<button
|
||||
class={clsx(styles.menuItem, activeTab === "user" && styles.active)}
|
||||
onClick={() => setActiveTab("user")}
|
||||
>
|
||||
User
|
||||
</button>
|
||||
<button
|
||||
class={clsx(styles.menuItem, activeTab === "system-instruction" && styles.active)}
|
||||
onClick={() => setActiveTab("system-instruction")}
|
||||
>
|
||||
System Instruction
|
||||
</button>
|
||||
<button
|
||||
class={clsx(styles.menuItem, activeTab === "continue-prompt" && styles.active)}
|
||||
onClick={() => setActiveTab("continue-prompt")}
|
||||
>
|
||||
Continue Prompt
|
||||
</button>
|
||||
<button
|
||||
class={clsx(styles.menuItem, activeTab === "chat-system-instruction" && styles.active)}
|
||||
onClick={() => setActiveTab("chat-system-instruction")}
|
||||
>
|
||||
Chat System Instruction
|
||||
</button>
|
||||
<button
|
||||
class={clsx(styles.menuItem, activeTab === "banned-tokens" && styles.active)}
|
||||
onClick={() => setActiveTab("banned-tokens")}
|
||||
>
|
||||
Banned Tokens
|
||||
</button>
|
||||
</nav>
|
||||
<div class={styles.content}>
|
||||
{activeTab === "user" && <UserSettings />}
|
||||
{activeTab === "banned-tokens" && <BannedTokensSettings />}
|
||||
{activeTab === "system-instruction" && <SystemInstructionSettings />}
|
||||
{activeTab === "chat-system-instruction" && <ChatSystemInstructionSettings />}
|
||||
{activeTab === "continue-prompt" && <ContinuePromptSettings />}
|
||||
{activeTab === "connection" && <ConnectionSettings />}
|
||||
</div>
|
||||
</div>
|
||||
<div class={styles.footer}>
|
||||
<button onClick={onClose} class={clsx(styles.button, styles.buttonSecondary)}>
|
||||
Done
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Modal
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
title="Settings"
|
||||
sidebar={TABS.map(({ id, label }) => (
|
||||
<button
|
||||
key={id}
|
||||
class={clsx(styles.menuItem, activeTab === id && styles.active)}
|
||||
onClick={() => setActiveTab(id)}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
footer={
|
||||
<button onClick={onClose} class={clsx(styles.button, styles.buttonSecondary)}>
|
||||
Done
|
||||
</button>
|
||||
}
|
||||
>
|
||||
{activeTab === "user" && <UserSettings />}
|
||||
{activeTab === "banned-tokens" && <BannedTokensSettings />}
|
||||
{activeTab === "system-instruction" && <SystemInstructionSettings />}
|
||||
{activeTab === "chat-system-instruction" && <ChatSystemInstructionSettings />}
|
||||
{activeTab === "continue-prompt" && <ContinuePromptSettings />}
|
||||
{activeTab === "connection" && <ConnectionSettings />}
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue