Compare commits
No commits in common. "7f2987041e1eb20512b4065c3d8ab4c15c8521e9" and "23bc808ccad9b2dc8d0eef3685569d3c80e680de" have entirely different histories.
7f2987041e
...
23bc808cca
2
bun.lock
2
bun.lock
|
|
@ -18,7 +18,7 @@
|
||||||
"preact": "10.22.0",
|
"preact": "10.22.0",
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bun": "^1.3.11",
|
"@types/bun": "latest",
|
||||||
"@types/html-minifier": "4.0.5",
|
"@types/html-minifier": "4.0.5",
|
||||||
"@types/inquirer": "9.0.7",
|
"@types/inquirer": "9.0.7",
|
||||||
"@types/web-bluetooth": "0.0.21",
|
"@types/web-bluetooth": "0.0.21",
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
"preact": "10.22.0"
|
"preact": "10.22.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bun": "^1.3.11",
|
"@types/bun": "latest",
|
||||||
"@types/html-minifier": "4.0.5",
|
"@types/html-minifier": "4.0.5",
|
||||||
"@types/inquirer": "9.0.7",
|
"@types/inquirer": "9.0.7",
|
||||||
"@types/web-bluetooth": "0.0.21",
|
"@types/web-bluetooth": "0.0.21",
|
||||||
|
|
|
||||||
|
|
@ -26,19 +26,3 @@
|
||||||
scrollbar-width: thin;
|
scrollbar-width: thin;
|
||||||
scrollbar-color: var(--bg-active) transparent;
|
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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,131 +0,0 @@
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,267 +0,0 @@
|
||||||
@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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
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>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
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,10 +1,8 @@
|
||||||
.modal {
|
.modal {
|
||||||
max-width: 480px;
|
width: 480px;
|
||||||
height: fit-content;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading,
|
.loading, .error {
|
||||||
.error {
|
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
@ -20,8 +18,7 @@
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
|
||||||
th,
|
th, td {
|
||||||
td {
|
|
||||||
padding: 7px 10px;
|
padding: 7px 10px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid var(--border);
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
.modal {
|
.modal {
|
||||||
max-width: 480px;
|
width: 480px;
|
||||||
height: fit-content;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading {
|
.loading {
|
||||||
|
|
@ -59,9 +58,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.saveBtn {
|
.saveBtn {
|
||||||
composes: buttonSecondary from '@common/assets/ui.module.css';
|
color: var(--accent-alt) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.deleteBtn {
|
.deleteBtn {
|
||||||
composes: buttonDanger from '@common/assets/ui.module.css';
|
color: var(--accent) !important;
|
||||||
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
@ -59,8 +59,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.userStats,
|
.userStats, .networkStats {
|
||||||
.networkStats {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
@ -84,8 +83,7 @@
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
|
||||||
th,
|
th, td {
|
||||||
td {
|
|
||||||
padding: 5px 6px;
|
padding: 5px 6px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid var(--border);
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.own {
|
.own {
|
||||||
border-color: var(--accent-alt) !important;
|
border-color: var(--accent) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.offline {
|
.offline {
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
import { useEffect, useState } from "preact/hooks";
|
import { useEffect, useState } from "preact/hooks";
|
||||||
|
import { X } from "lucide-preact";
|
||||||
import { useHordeState } from "../../contexts/state";
|
import { useHordeState } from "../../contexts/state";
|
||||||
import { fetchLeaderboard, type LeaderboardEntry } from "../../utils/api";
|
import { fetchLeaderboard, type LeaderboardEntry } from "../../utils/api";
|
||||||
import { formatNumber, formatTime } from "@common/utils";
|
import { formatNumber, formatTime } from "@common/utils";
|
||||||
import { Modal } from "@common/components/Modal";
|
import modalStyles from "../../assets/modal.module.css";
|
||||||
import styles from "../../assets/leaderboard-modal.module.css";
|
import styles from "../../assets/leaderboard-modal.module.css";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
@ -92,49 +93,67 @@ export const LeaderboardModal = ({ open, onClose }: Props) => {
|
||||||
return () => { cancelled = true; };
|
return () => { cancelled = true; };
|
||||||
}, [open, user?.username]);
|
}, [open, user?.username]);
|
||||||
|
|
||||||
const nextRow = rows.length >= 2 ? rows[rows.length - 2] : null;
|
useEffect(() => {
|
||||||
const footer = user && nextRow?.diff && nextRow.diff > 0 && kudosPerHour > 0
|
if (!open) return;
|
||||||
? (() => {
|
const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); };
|
||||||
const secs = Math.ceil((nextRow.diff / kudosPerHour) * 3600);
|
window.addEventListener('keydown', handler);
|
||||||
return (
|
return () => window.removeEventListener('keydown', handler);
|
||||||
<span class={styles.nextPlace}>
|
}, [open]);
|
||||||
Time to #{nextRow.rank}: <strong>{formatTime(secs)}</strong>
|
|
||||||
<span class={styles.nextPlaceMeta}> ({formatNumber(Math.round(kudosPerHour))} kudos/h)</span>
|
if (!open) return null;
|
||||||
</span>
|
|
||||||
);
|
|
||||||
})()
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal open={open} onClose={onClose} title="Leaderboard" class={styles.modal} footer={footer}>
|
<div class={modalStyles.overlay} onMouseDown={e => { if (e.target === e.currentTarget) onClose(); }}>
|
||||||
{loading && <p class={styles.loading}>Loading…</p>}
|
<div class={`${modalStyles.modal} ${styles.modal}`}>
|
||||||
{error && <p class={styles.error}>{error}</p>}
|
<div class={modalStyles.header}>
|
||||||
{!loading && !error && rows.length > 0 && (
|
<span class={modalStyles.title}>Leaderboard</span>
|
||||||
<table class={styles.table}>
|
<button class={modalStyles.closeButton} onClick={onClose}><X size={16} /></button>
|
||||||
<thead>
|
</div>
|
||||||
<tr>
|
<div class={modalStyles.body}>
|
||||||
<th>#</th>
|
{loading && <p class={styles.loading}>Loading…</p>}
|
||||||
<th>Username</th>
|
{error && <p class={styles.error}>{error}</p>}
|
||||||
<th>Kudos</th>
|
{!loading && !error && rows.length > 0 && (
|
||||||
{user && <th>Diff</th>}
|
<table class={styles.table}>
|
||||||
</tr>
|
<thead>
|
||||||
</thead>
|
<tr>
|
||||||
<tbody>
|
<th>#</th>
|
||||||
{rows.map(r => (
|
<th>Username</th>
|
||||||
<tr key={r.rank} class={r.username === user?.username ? styles.selfRow : undefined}>
|
<th>Kudos</th>
|
||||||
<td>{r.rank}</td>
|
{user && <th>Diff</th>}
|
||||||
<td>{r.username}</td>
|
</tr>
|
||||||
<td>{formatNumber(r.kudos)}</td>
|
</thead>
|
||||||
{user && (
|
<tbody>
|
||||||
<td class={r.diff !== undefined ? (r.diff > 0 ? styles.above : styles.below) : undefined}>
|
{rows.map(r => (
|
||||||
{r.diff !== undefined ? `+${formatNumber(r.diff)}` : '—'}
|
<tr key={r.rank} class={r.username === user?.username ? styles.selfRow : undefined}>
|
||||||
</td>
|
<td>{r.rank}</td>
|
||||||
)}
|
<td>{r.username}</td>
|
||||||
</tr>
|
<td>{formatNumber(r.kudos)}</td>
|
||||||
))}
|
{user && (
|
||||||
</tbody>
|
<td class={r.diff !== undefined ? (r.diff > 0 ? styles.above : styles.below) : undefined}>
|
||||||
</table>
|
{r.diff !== undefined ? `+${formatNumber(r.diff)}` : '—'}
|
||||||
)}
|
</td>
|
||||||
</Modal>
|
)}
|
||||||
|
</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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
@ -0,0 +1,143 @@
|
||||||
|
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>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
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>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
@ -59,7 +59,7 @@ export const StatsPanel = () => {
|
||||||
</div>
|
</div>
|
||||||
<div class={styles.stat}>
|
<div class={styles.stat}>
|
||||||
<dt>Workers</dt>
|
<dt>Workers</dt>
|
||||||
<dd>{ownWorkers.length}/{user.worker_count}</dd>
|
<dd>{user.worker_count}</dd>
|
||||||
</div>
|
</div>
|
||||||
<div class={styles.stat}>
|
<div class={styles.stat}>
|
||||||
<dt>Tokens generated</dt>
|
<dt>Tokens generated</dt>
|
||||||
|
|
@ -2,6 +2,8 @@ import { render } from "preact";
|
||||||
import { App } from "./components/app";
|
import { App } from "./components/app";
|
||||||
import { HordeStateProvider } from "./contexts/state";
|
import { HordeStateProvider } from "./contexts/state";
|
||||||
|
|
||||||
|
import './assets/style.css';
|
||||||
|
|
||||||
export default function main() {
|
export default function main() {
|
||||||
render(
|
render(
|
||||||
<HordeStateProvider>
|
<HordeStateProvider>
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB |
|
|
@ -1,24 +0,0 @@
|
||||||
.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.
|
Before Width: | Height: | Size: 50 KiB |
|
|
@ -1,125 +0,0 @@
|
||||||
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>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
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>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
@ -7,11 +7,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty {
|
.empty {
|
||||||
composes: empty from '@common/assets/ui.module.css';
|
color: var(--text-muted);
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chapterCard {
|
.chapterCard {
|
||||||
composes: card from '@common/assets/ui.module.css';
|
background: var(--bg-secondary);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chapterTitle {
|
.chapterTitle {
|
||||||
|
|
@ -52,9 +59,24 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.summaryEditable {
|
.summaryEditable {
|
||||||
composes: textarea from '@common/assets/ui.module.css';
|
width: 100%;
|
||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
|
background: var(--bg);
|
||||||
|
border: 1px solid var(--border);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--text);
|
||||||
|
font-family: inherit;
|
||||||
|
box-sizing: border-box;
|
||||||
|
min-height: 80px;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
resize: vertical;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
composes: editorHeader from '@common/assets/ui.module.css';
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding-bottom: 16px;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
|
|
||||||
.header h2 {
|
.header h2 {
|
||||||
|
|
@ -18,8 +22,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.addButton {
|
.addButton {
|
||||||
composes: buttonPrimary from '@common/assets/ui.module.css';
|
padding: 8px 16px;
|
||||||
|
background: var(--accent);
|
||||||
|
color: var(--bg);
|
||||||
|
border: none;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: opacity 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--accent-alt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.deleteConfirm {
|
.deleteConfirm {
|
||||||
|
|
@ -38,12 +53,37 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.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 {
|
.confirmButton {
|
||||||
composes: confirmButton from '@common/assets/ui.module.css';
|
background: var(--accent);
|
||||||
|
color: var(--bg);
|
||||||
|
border-color: var(--accent);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.cancelButton {
|
.cancelButton {
|
||||||
composes: cancelButton from '@common/assets/ui.module.css';
|
background: transparent;
|
||||||
|
color: var(--text-muted);
|
||||||
|
border-color: var(--border);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--bg-hover);
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.list {
|
.list {
|
||||||
|
|
@ -55,15 +95,24 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty {
|
.empty {
|
||||||
composes: empty from '@common/assets/ui.module.css';
|
color: var(--text-muted);
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.characterCard {
|
.characterCard {
|
||||||
composes: card from '@common/assets/ui.module.css';
|
background: var(--bg-secondary);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cardHeader {
|
.cardHeader {
|
||||||
composes: cardHeader from '@common/assets/ui.module.css';
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nameInput {
|
.nameInput {
|
||||||
|
|
@ -84,15 +133,29 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.deleteButton {
|
.deleteButton {
|
||||||
composes: deleteButton from '@common/assets/ui.module.css';
|
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid var(--border);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
color: var(--text-muted);
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all var(--transition);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--accent);
|
||||||
|
border-color: var(--accent);
|
||||||
|
color: var(--bg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.field {
|
.field {
|
||||||
composes: formGroup from '@common/assets/ui.module.css';
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,23 +224,70 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.generateButton {
|
.generateButton {
|
||||||
composes: buttonSmall from '@common/assets/ui.module.css';
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.textarea {
|
.textarea {
|
||||||
composes: textarea from '@common/assets/ui.module.css';
|
width: 100%;
|
||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
|
background: var(--bg);
|
||||||
|
border: 1px solid var(--border);
|
||||||
border-radius: 6px;
|
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 {
|
.select {
|
||||||
composes: select from '@common/assets/ui.module.css';
|
width: 100%;
|
||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
|
background: var(--bg);
|
||||||
|
border: 1px solid var(--border);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--text);
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--accent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.smallButton {
|
.smallButton {
|
||||||
composes: buttonSmall from '@common/assets/ui.module.css';
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.nicknames {
|
.nicknames {
|
||||||
|
|
@ -193,11 +303,35 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge {
|
.badge {
|
||||||
composes: badge from '@common/assets/ui.module.css';
|
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 {
|
.badgeRemove {
|
||||||
composes: badgeRemove from '@common/assets/ui.module.css';
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.relations {
|
.relations {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
composes: editorHeader from '@common/assets/ui.module.css';
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding-bottom: 16px;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
|
|
||||||
.header h2 {
|
.header h2 {
|
||||||
|
|
@ -18,8 +22,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.addButton {
|
.addButton {
|
||||||
composes: buttonPrimary from '@common/assets/ui.module.css';
|
padding: 8px 16px;
|
||||||
|
background: var(--accent);
|
||||||
|
color: var(--bg);
|
||||||
|
border: none;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: opacity 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--accent-alt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.deleteConfirm {
|
.deleteConfirm {
|
||||||
|
|
@ -38,12 +53,37 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.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 {
|
.confirmButton {
|
||||||
composes: confirmButton from '@common/assets/ui.module.css';
|
background: var(--accent);
|
||||||
|
color: var(--bg);
|
||||||
|
border-color: var(--accent);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.cancelButton {
|
.cancelButton {
|
||||||
composes: cancelButton from '@common/assets/ui.module.css';
|
background: transparent;
|
||||||
|
color: var(--text-muted);
|
||||||
|
border-color: var(--border);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--bg-hover);
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.list {
|
.list {
|
||||||
|
|
@ -55,15 +95,24 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty {
|
.empty {
|
||||||
composes: empty from '@common/assets/ui.module.css';
|
color: var(--text-muted);
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.locationCard {
|
.locationCard {
|
||||||
composes: card from '@common/assets/ui.module.css';
|
background: var(--bg-secondary);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cardHeader {
|
.cardHeader {
|
||||||
composes: cardHeader from '@common/assets/ui.module.css';
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nameInput {
|
.nameInput {
|
||||||
|
|
@ -84,15 +133,29 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.deleteButton {
|
.deleteButton {
|
||||||
composes: deleteButton from '@common/assets/ui.module.css';
|
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid var(--border);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
color: var(--text-muted);
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all var(--transition);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--accent);
|
||||||
|
border-color: var(--accent);
|
||||||
|
color: var(--bg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.field {
|
.field {
|
||||||
composes: formGroup from '@common/assets/ui.module.css';
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,17 +174,52 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.select {
|
.select {
|
||||||
composes: select from '@common/assets/ui.module.css';
|
width: 100%;
|
||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
|
background: var(--bg);
|
||||||
|
border: 1px solid var(--border);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--text);
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--accent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.generateButton {
|
.generateButton {
|
||||||
composes: buttonSmall from '@common/assets/ui.module.css';
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.textarea {
|
.textarea {
|
||||||
composes: textarea from '@common/assets/ui.module.css';
|
width: 100%;
|
||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
|
background: var(--bg);
|
||||||
|
border: 1px solid var(--border);
|
||||||
border-radius: 6px;
|
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,7 +7,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
composes: editorHeader from '@common/assets/ui.module.css';
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding-bottom: 16px;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
|
|
||||||
.header h2 {
|
.header h2 {
|
||||||
|
|
@ -40,8 +44,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.addButton {
|
.addButton {
|
||||||
composes: buttonPrimary from '@common/assets/ui.module.css';
|
padding: 8px 16px;
|
||||||
|
background: var(--accent);
|
||||||
|
color: var(--bg);
|
||||||
|
border: none;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: opacity 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--accent-alt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.list {
|
.list {
|
||||||
|
|
@ -53,17 +68,25 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty {
|
.empty {
|
||||||
composes: empty from '@common/assets/ui.module.css';
|
color: var(--text-muted);
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.entryCard {
|
.entryCard {
|
||||||
composes: card from '@common/assets/ui.module.css';
|
background: var(--bg-secondary);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cardHeader {
|
.cardHeader {
|
||||||
composes: cardHeader from '@common/assets/ui.module.css';
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.titleRow {
|
.titleRow {
|
||||||
|
|
@ -108,15 +131,49 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.moveButton {
|
.moveButton {
|
||||||
composes: iconButton from '@common/assets/ui.module.css';
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 4px;
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
font-size: 14px;
|
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 {
|
.deleteButton {
|
||||||
composes: deleteButton from '@common/assets/ui.module.css';
|
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);
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all var(--transition);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--danger);
|
||||||
|
border-color: var(--danger);
|
||||||
|
color: var(--bg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
|
|
@ -124,7 +181,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.textarea {
|
.textarea {
|
||||||
composes: textarea from '@common/assets/ui.module.css';
|
width: 100%;
|
||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
|
background: var(--bg);
|
||||||
|
border: 1px solid var(--border);
|
||||||
border-radius: 6px;
|
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,3 +1,77 @@
|
||||||
|
.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 {
|
.menuItem {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
@ -24,12 +98,25 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
.form {
|
.form {
|
||||||
composes: form from '@common/assets/ui.module.css';
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.formGroup {
|
.formGroup {
|
||||||
composes: formGroup from '@common/assets/ui.module.css';
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.formGroupFill {
|
.formGroupFill {
|
||||||
|
|
@ -37,7 +124,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
composes: label from '@common/assets/ui.module.css';
|
display: block;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.selectMultiline {
|
.selectMultiline {
|
||||||
|
|
@ -54,38 +143,54 @@
|
||||||
padding-inline-start: 16px;
|
padding-inline-start: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input {
|
.input,
|
||||||
composes: input from '@common/assets/ui.module.css';
|
.select,
|
||||||
}
|
.textarea {
|
||||||
|
width: 100%;
|
||||||
.select {
|
padding: 8px;
|
||||||
composes: select from '@common/assets/ui.module.css';
|
border-radius: 4px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
.textarea {
|
.textarea {
|
||||||
composes: textarea from '@common/assets/ui.module.css';
|
|
||||||
resize: none;
|
resize: none;
|
||||||
|
font-family: inherit;
|
||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: unset;
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
padding: 16px 20px;
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
composes: button from '@common/assets/ui.module.css';
|
padding: 8px 16px;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttonSecondary {
|
.buttonSecondary {
|
||||||
composes: buttonSecondary from '@common/assets/ui.module.css';
|
border: 1px solid var(--border);
|
||||||
|
background: transparent;
|
||||||
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttonPrimary {
|
.buttonPrimary {
|
||||||
composes: buttonPrimary from '@common/assets/ui.module.css';
|
border: none;
|
||||||
|
background: var(--accent);
|
||||||
color: var(--accent-text);
|
color: var(--accent-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
.inputRow {
|
.inputRow {
|
||||||
composes: inputRow from '@common/assets/ui.module.css';
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.inputRow .input {
|
.inputRow .input {
|
||||||
|
|
@ -98,7 +203,7 @@
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
border-radius: var(--radius);
|
border-radius: 4px;
|
||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
@ -111,7 +216,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.divider {
|
.divider {
|
||||||
composes: divider from '@common/assets/ui.module.css';
|
height: 1px;
|
||||||
|
background: var(--border);
|
||||||
|
margin: 16px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tokenList {
|
.tokenList {
|
||||||
|
|
@ -122,21 +229,49 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.tokenItem {
|
.tokenItem {
|
||||||
composes: badge from '@common/assets/ui.module.css';
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
background: var(--bg-active);
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
border-radius: var(--radius);
|
border-radius: 4px;
|
||||||
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tokenRemoveButton {
|
.tokenRemoveButton {
|
||||||
composes: badgeRemove from '@common/assets/ui.module.css';
|
background: none;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
padding: 0 2px;
|
padding: 0 2px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
.emptyText {
|
.emptyText {
|
||||||
composes: empty from '@common/assets/ui.module.css';
|
color: var(--text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
@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 {
|
.menuItem {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
@ -145,4 +280,8 @@
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
padding: 12px 16px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -322,8 +322,9 @@ export const Menu = ({ visible }: { visible: boolean }) => {
|
||||||
<Settings size={16} /> Settings
|
<Settings size={16} /> Settings
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
{isSettingsOpen.value && (
|
||||||
<SettingsModal open={isSettingsOpen.value} onClose={isSettingsOpen.setFalse} />
|
<SettingsModal onClose={isSettingsOpen.toggle} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
import { X } from "lucide-preact";
|
||||||
import { useState } from "preact/hooks";
|
import { useState } from "preact/hooks";
|
||||||
import { Modal } from "@common/components/Modal";
|
|
||||||
import styles from "../assets/settings-modal.module.css";
|
import styles from "../assets/settings-modal.module.css";
|
||||||
import { BannedTokensSettings } from "./settings/banned-tokens";
|
import { BannedTokensSettings } from "./settings/banned-tokens";
|
||||||
import { ChatSystemInstructionSettings } from "./settings/chat-system-instruction";
|
import { ChatSystemInstructionSettings } from "./settings/chat-system-instruction";
|
||||||
|
|
@ -10,50 +10,77 @@ import { SystemInstructionSettings } from "./settings/system-instruction";
|
||||||
import { UserSettings } from "./settings/user";
|
import { UserSettings } from "./settings/user";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean;
|
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Tab = "banned-tokens" | "system-instruction" | "chat-system-instruction" | "continue-prompt" | "connection" | "user";
|
type Tab = "banned-tokens" | "system-instruction" | "chat-system-instruction" | "continue-prompt" | "connection" | "user";
|
||||||
|
|
||||||
const TABS: { id: Tab; label: string }[] = [
|
export const SettingsModal = ({ onClose }: Props) => {
|
||||||
{ 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");
|
const [activeTab, setActiveTab] = useState<Tab>("connection");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<div class={styles.overlay} onClick={onClose}>
|
||||||
open={open}
|
<div class={styles.modal} onClick={(e) => e.stopPropagation()}>
|
||||||
onClose={onClose}
|
<div class={styles.header}>
|
||||||
title="Settings"
|
<h2 class={styles.title}>Settings</h2>
|
||||||
sidebar={TABS.map(({ id, label }) => (
|
<button class={styles.closeButton} onClick={onClose}>
|
||||||
<button
|
<X size={20} />
|
||||||
key={id}
|
</button>
|
||||||
class={clsx(styles.menuItem, activeTab === id && styles.active)}
|
</div>
|
||||||
onClick={() => setActiveTab(id)}
|
<div class={styles.body}>
|
||||||
>
|
<nav class={styles.sidebar}>
|
||||||
{label}
|
<button
|
||||||
</button>
|
class={clsx(styles.menuItem, activeTab === "connection" && styles.active)}
|
||||||
))}
|
onClick={() => setActiveTab("connection")}
|
||||||
footer={
|
>
|
||||||
<button onClick={onClose} class={clsx(styles.button, styles.buttonSecondary)}>
|
Connection
|
||||||
Done
|
</button>
|
||||||
</button>
|
<button
|
||||||
}
|
class={clsx(styles.menuItem, activeTab === "user" && styles.active)}
|
||||||
>
|
onClick={() => setActiveTab("user")}
|
||||||
{activeTab === "user" && <UserSettings />}
|
>
|
||||||
{activeTab === "banned-tokens" && <BannedTokensSettings />}
|
User
|
||||||
{activeTab === "system-instruction" && <SystemInstructionSettings />}
|
</button>
|
||||||
{activeTab === "chat-system-instruction" && <ChatSystemInstructionSettings />}
|
<button
|
||||||
{activeTab === "continue-prompt" && <ContinuePromptSettings />}
|
class={clsx(styles.menuItem, activeTab === "system-instruction" && styles.active)}
|
||||||
{activeTab === "connection" && <ConnectionSettings />}
|
onClick={() => setActiveTab("system-instruction")}
|
||||||
</Modal>
|
>
|
||||||
|
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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue