mirror of
https://github.com/bitbaum/chatkit.git
synced 2026-12-04 05:47:38 +01:00
The pieces of the ChatGPT app the owner put beside ours (2026-10-21), done once here so Loki, OrangeCat and every chat in the fleet get them: - `AnswerActions`: the row under an answer. Copy; Listen, reading the answer as prose (`plainTextForSpeech`, from loki) with the browser's voice or the `speaker` an app passes (loki's studio voice), with a small player — Stop and the time so far — while it reads; Share through the system sheet where one exists. `ChatThread` renders it under every answer. - Sources on a touch screen are ONE "Sources · n" button that opens a sheet with every record (label, detail, link); chips stay on a mouse. `Sheet` (the attach sheet's <dialog>, extracted) and `SourcesRow` are exported. - `AttachMenu` takes `extra` rows under Camera · Photos · Files, and then opens the sheet on a mouse too — an app's "one of my things" has no file dialog to live in. - The replies instruction makes the model lead: 2–4 replies on every answer, the recommended next step first, drawn as the lead (`ck-reply-lead`). - An empty box is one row on the narrowest phone: the placeholder is cut at the edge, never wrapped into a clipped second line. Browser checks cover the player, the sources sheet on a touch screen and chips on a mouse, and the one-row placeholder at 320px. Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE Co-authored-by: Claude <noreply@anthropic.com>
37 lines
1.9 KiB
JavaScript
37 lines
1.9 KiB
JavaScript
"use client";
|
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
import { useEffect, useRef } from "react";
|
|
import { IconX } from "./icons.js";
|
|
/**
|
|
* A sheet from the bottom edge on a phone, a centred panel on a desktop: the
|
|
* attach menu, the sources of an answer, anything a tap opens that is more
|
|
* than a menu. A native `<dialog>` opened with `showModal()`: it renders in
|
|
* the browser's top layer, so a composer inside a transformed or
|
|
* overflow-clipped panel still gets a full sheet, and the browser supplies
|
|
* Escape, the focus trap and focus restore.
|
|
*/
|
|
export function Sheet({ open, onClose, title, closeLabel = "Close", children, }) {
|
|
const ref = useRef(null);
|
|
useEffect(() => {
|
|
const d = ref.current;
|
|
if (!d)
|
|
return;
|
|
if (open && !d.open && typeof d.showModal === "function")
|
|
d.showModal();
|
|
else if (!open && d.open)
|
|
d.close();
|
|
}, [open]);
|
|
return (_jsx("dialog", { ref: ref, className: "ck-sheet", "aria-label": title, onClose: onClose,
|
|
// A tap on the backdrop lands on the <dialog> itself, never on the
|
|
// panel inside it: that is the scrim.
|
|
onClick: (e) => {
|
|
if (e.target === e.currentTarget)
|
|
onClose();
|
|
}, children: _jsxs("div", { className: "ck-sheet-panel", children: [_jsxs("div", { className: "ck-sheet-head", children: [_jsx("span", { className: "ck-sheet-title", children: title }), _jsx("button", { type: "button", className: "ck-icon-btn ck-sheet-close", onClick: onClose, "aria-label": closeLabel, title: closeLabel, children: _jsx(IconX, {}) })] }), children] }) }));
|
|
}
|
|
/** A touch screen gets the sheet; a mouse gets the plainer thing (a file
|
|
* dialog, a row of chips) in one click. */
|
|
export function prefersSheet() {
|
|
return typeof window !== "undefined" && window.matchMedia?.("(pointer: coarse)").matches;
|
|
}
|
|
//# sourceMappingURL=Sheet.js.map
|