Panels above the composer: background blocks with a left bar
This commit is contained in:
1 parent
fc42f2b170
commit
d6bd91872c
4 files changed
+11
-7
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import type { ComposerItem } from "../model/composerMenu.ts";
|
||||
import { ClickRow } from "./Button.tsx";
|
||||
import { BAR } from "./edges.ts";
|
||||
import { truncate } from "./text.ts";
|
||||
import { colors } from "./theme.ts";
|
||||
|
||||
@@ -12,9 +13,9 @@ const MAX_ROWS = 8;
|
||||
export function ComposerMenu(props: { readonly items: readonly ComposerItem[]; readonly selected: number; readonly empty: string; readonly width: number; readonly onPick: (index: number) => void }) {
|
||||
const { items, selected } = props;
|
||||
const start = Math.max(0, Math.min(selected - Math.floor(MAX_ROWS / 2), items.length - MAX_ROWS));
|
||||
const inner = Math.max(10, props.width - 4);
|
||||
const inner = Math.max(10, props.width - 3);
|
||||
return (
|
||||
<box border borderStyle="rounded" borderColor={colors.border} flexDirection="column" flexShrink={0} marginLeft={1} marginRight={1} backgroundColor={colors.panel}>
|
||||
<box border={["left"]} customBorderChars={BAR} borderColor={colors.accent} flexDirection="column" flexShrink={0} marginLeft={1} marginRight={1} backgroundColor={colors.panel}>
|
||||
{items.length === 0 ? (
|
||||
<text fg={colors.muted} paddingLeft={1}>
|
||||
{props.empty}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Button, Buttons } from "./Button.tsx";
|
||||
import { BAR } from "./edges.ts";
|
||||
import { colors } from "./theme.ts";
|
||||
|
||||
/** An action that waits for you to say yes: git actions, stopping a server, running an automation. */
|
||||
@@ -15,7 +16,7 @@ export interface Confirmation {
|
||||
export function ConfirmBar(props: { readonly confirmation: Confirmation; readonly message: string; readonly onMessage: (value: string) => void; readonly onSubmit: () => void; readonly onCancel: () => void }) {
|
||||
const { confirmation } = props;
|
||||
return (
|
||||
<box border borderStyle="rounded" borderColor={colors.warn} flexDirection="column" flexShrink={0} marginLeft={1} marginRight={1} paddingLeft={1} paddingRight={1}>
|
||||
<box border={["left"]} customBorderChars={BAR} borderColor={colors.warn} backgroundColor={colors.panel} flexDirection="column" flexShrink={0} marginLeft={1} marginRight={1} paddingLeft={2} paddingRight={1}>
|
||||
<text fg={colors.warn}>
|
||||
<strong>{confirmation.title}</strong>
|
||||
</text>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { isPendingUserInputOptionSelected, type PendingUserInputDraftAnswer } fr
|
||||
import type { MouseEvent } from "@opentui/core";
|
||||
|
||||
import { Button, Buttons, isLeftClick, useHover } from "./Button.tsx";
|
||||
import { BAR } from "./edges.ts";
|
||||
import { colors } from "./theme.ts";
|
||||
|
||||
/**
|
||||
@@ -24,7 +25,7 @@ export function QuestionPanel(props: {
|
||||
if (!question) return null;
|
||||
const total = request.questions.length;
|
||||
return (
|
||||
<box border borderStyle="rounded" borderColor={colors.input} flexDirection="column" flexShrink={0} marginLeft={1} marginRight={1} paddingLeft={1} paddingRight={1}>
|
||||
<box border={["left"]} customBorderChars={BAR} borderColor={colors.accent} backgroundColor={colors.panel} flexDirection="column" flexShrink={0} marginLeft={1} marginRight={1} paddingLeft={2} paddingRight={1}>
|
||||
<box flexDirection="row">
|
||||
<text fg={colors.input}>
|
||||
<strong>{question.header}</strong>
|
||||
@@ -51,7 +52,7 @@ export function QuestionPanel(props: {
|
||||
function Option(props: { readonly label: string; readonly description?: string | undefined; readonly prefix: string; readonly selected: boolean; readonly onPick: () => void }) {
|
||||
const [hover, hoverProps] = useHover();
|
||||
return (
|
||||
<box flexDirection="row" backgroundColor={hover ? colors.hoverBg : "transparent"} {...hoverProps} onMouseDown={(event: MouseEvent) => isLeftClick(event) && props.onPick()}>
|
||||
<box flexDirection="row" backgroundColor={props.selected ? colors.selectedBg : hover ? colors.hoverBg : "transparent"} {...hoverProps} onMouseDown={(event: MouseEvent) => isLeftClick(event) && props.onPick()}>
|
||||
<text fg={props.selected ? colors.input : colors.faint} selectable={false}>{props.prefix}</text>
|
||||
<text fg={props.selected ? colors.text : colors.muted} selectable={false}>{props.label}</text>
|
||||
<text fg={colors.faint} selectable={false}>{props.description ? ` ${props.description}` : ""}</text>
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { MouseEvent } from "@opentui/core";
|
||||
|
||||
import type { QueuedMessage } from "../model/queue.ts";
|
||||
import { Button, Buttons, isLeftClick, useHover } from "./Button.tsx";
|
||||
import { BAR } from "./edges.ts";
|
||||
import { truncate } from "./text.ts";
|
||||
import { colors } from "./theme.ts";
|
||||
|
||||
@@ -26,9 +27,9 @@ export function QueuePanel(props: { readonly queued: readonly QueuedMessage[]; r
|
||||
const { queued, focus } = props;
|
||||
const start = focus === null ? 0 : Math.max(0, Math.min(focus - 1, queued.length - VISIBLE_ROWS));
|
||||
const shown = queued.slice(start, start + VISIBLE_ROWS);
|
||||
const inner = Math.max(10, props.width - 8);
|
||||
const inner = Math.max(10, props.width - 7);
|
||||
return (
|
||||
<box border borderStyle="rounded" borderColor={focus === null ? colors.border : colors.borderFocused} flexDirection="column" flexShrink={0} marginLeft={1} marginRight={1} paddingLeft={1} paddingRight={1}>
|
||||
<box border={["left"]} customBorderChars={BAR} borderColor={focus === null ? colors.border : colors.accent} backgroundColor={colors.panel} flexDirection="column" flexShrink={0} marginLeft={1} marginRight={1} paddingLeft={2} paddingRight={1}>
|
||||
<box flexDirection="row" columnGap={1}>
|
||||
<text fg={colors.muted}>{`${queued.length} queued${props.held ? " · held after the interrupt" : ""}`}</text>
|
||||
{props.held && actions.resume ? <Button label="Send them now" shortcut="enter" color={colors.accent} onPress={actions.resume} /> : null}
|
||||
|
||||
Reference in new issue
Block a user