refactor(ask): reorganize ask flow internals

This commit is contained in:
Erik Kotsiuba
2026-04-17 19:58:58 +02:00
parent c1ac241655
commit 87cbfa546e
25 changed files with 2448 additions and 1639 deletions
+43
View File
@@ -0,0 +1,43 @@
import {
getCurrentQuestion,
getRenderableOptions,
isSubmitTab,
} from "../state.ts";
import type { AskState } from "../types.ts";
import { renderFrameFooter, renderFrameHeader } from "./render-frame.ts";
import { renderQuestionScreen } from "./render-question.ts";
import { renderSubmitScreen } from "./render-submit.ts";
import type { QuestionRenderContext, Theme } from "./render-types.ts";
export function renderAskScreen(args: {
state: AskState;
theme: Theme;
width: number;
editor: QuestionRenderContext["editor"];
newLineHint: string;
}): string[] {
const { state, theme, width, editor, newLineHint } = args;
const lines: string[] = [];
const question = getCurrentQuestion(state);
const options = getRenderableOptions(question);
renderFrameHeader({ lines, state, theme, width });
if (isSubmitTab(state)) {
renderSubmitScreen(lines, state, theme, width);
} else if (question) {
renderQuestionScreen({
lines,
state,
question,
options,
theme,
width,
editor,
newLineHint,
});
}
renderFrameFooter({ lines, state, theme, width });
return lines;
}