mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 13:05:14 +03:00
refactor(tui): replace dialog inset flag with a cell count (#55582)
This commit is contained in:
committed by
GitHub
Unverified
parent
6c706f2021
commit
6d570f1d92
@@ -703,7 +703,7 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
|
||||
</Show>
|
||||
</box>
|
||||
<Show when={props.footer || visibleActions().length} fallback={<box flexShrink={0} />}>
|
||||
<DialogFooter newInset={DIALOG_LIST_INSET} actions={footerActions()}>
|
||||
<DialogFooter inset={DIALOG_LIST_INSET} actions={footerActions()}>
|
||||
{props.footer}
|
||||
</DialogFooter>
|
||||
</Show>
|
||||
|
||||
@@ -21,8 +21,6 @@ import { copy, copyOnSelectRelease } from "../util/selection"
|
||||
|
||||
export type DialogSize = "medium" | "large" | "xlarge"
|
||||
|
||||
export const DIALOG_PADDING_X = 4
|
||||
|
||||
export const DIALOG_INSET = 3
|
||||
// List rows reserve a 1-cell gutter for the ▌ bar / ● marker.
|
||||
export const DIALOG_LIST_INSET = DIALOG_INSET + 1
|
||||
@@ -96,20 +94,12 @@ export function DialogHeader(
|
||||
closeLabel?: string
|
||||
onClose?: () => void
|
||||
gap?: number
|
||||
inset?: boolean
|
||||
newInset?: number
|
||||
}>,
|
||||
) {
|
||||
const dialog = useDialog()
|
||||
const theme = useTheme().surface("dialog")
|
||||
return (
|
||||
<box
|
||||
flexDirection="row"
|
||||
justifyContent="space-between"
|
||||
gap={props.gap}
|
||||
paddingLeft={props.newInset ?? (props.inset ? DIALOG_PADDING_X : undefined)}
|
||||
paddingRight={props.newInset ?? (props.inset ? DIALOG_PADDING_X : undefined)}
|
||||
>
|
||||
<box flexDirection="row" justifyContent="space-between" gap={props.gap}>
|
||||
{props.titleView ?? (
|
||||
<text attributes={TextAttributes.BOLD} fg={theme.text.base}>
|
||||
{props.title}
|
||||
@@ -170,8 +160,8 @@ export type DialogFooterAction = {
|
||||
export function DialogFooter(
|
||||
props: ParentProps<{
|
||||
actions?: DialogFooterAction[]
|
||||
inset?: boolean
|
||||
newInset?: number
|
||||
/** Side padding in cells, e.g. DIALOG_INSET or DIALOG_LIST_INSET. Omit when the parent already pads. */
|
||||
inset?: number
|
||||
}>,
|
||||
) {
|
||||
const dimensions = useTerminalDimensions()
|
||||
@@ -187,8 +177,8 @@ export function DialogFooter(
|
||||
const right = () => actions().filter((action) => action.side === "right")
|
||||
return (
|
||||
<box
|
||||
paddingLeft={props.newInset ?? (props.inset ? DIALOG_PADDING_X : undefined)}
|
||||
paddingRight={props.newInset ?? (props.inset ? DIALOG_PADDING_X : undefined)}
|
||||
paddingLeft={props.inset}
|
||||
paddingRight={props.inset}
|
||||
flexDirection="row"
|
||||
justifyContent="space-between"
|
||||
flexShrink={0}
|
||||
|
||||
Reference in New Issue
Block a user