import { Fragment } from "preact" import { useState } from "preact/hooks" import { html, useInkHookState } from "./bootstrap" import { LineViewer } from "./line-viewer" import { SectionView } from "./section-view" export const InkStoryView = () => { const [showLog, setShowLog] = useState(false) const inkState = useInkHookState() const lines = inkState.getVisibleLines({ showHidden: showLog, showCommands: false, }) const renderStory = () => { return html`
${lines.map((line) => { if (line.type === "command") { return html`
>> ${line.command}
` } return html`<${LineViewer} line=${line} />` })}
` } const renderAdvanceButton = () => { if (inkState.getCanAdvance()) { return html`` } return null } const renderChoices = () => { if (!inkState.shouldShowChoices()) { return null } return html`
${inkState.getChoices().map((choice) => { return html`` })}
` } const renderLogButton = () => { const logButtonText = showLog ? "Hide Log" : "Show Log" return html`` } const renderHideButton = () => { return html`` } const renderHideOldButton = () => { return html`` } const renderResetButton = () => { return html`` } return html`
${renderStory()} ${renderAdvanceButton()} ${renderChoices()}
${renderLogButton()} ${renderHideButton()} ${renderHideOldButton()} ${renderResetButton()}
<${SectionView} />
` }