-
Notifications
You must be signed in to change notification settings - Fork 95
feat(wizard): shared wizard shell, used by project create and add runtime #2284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
notgitika
wants to merge
5
commits into
aws:refactor
Choose a base branch
from
notgitika:feat/wizard-shell
base: refactor
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b85a06f
feat(wizard): shared wizard shell, used by project create and add run…
4fb735c
fix(wizard): dispatch bare add runtime to the wizard, tighten name va…
022bd11
refactor(wizard): drop the description step from add runtime
5067cc7
feat(wizard): enter returns to the add menu after adding a runtime
ea56301
fix(wizard): hand the form back when an add fails
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { isValidElement, type ReactElement, type ReactNode } from "react"; | ||
| import { Box, Text } from "ink"; | ||
| import { darkTheme } from "../ui/_core.js"; | ||
|
|
||
| const theme = darkTheme; | ||
|
|
||
| export interface StepProps { | ||
| // name is the step's stable key. Position is tracked by key rather than by | ||
| // index because branches have different lengths: a conditional step that | ||
| // appears or disappears must not shift the user to a different question. | ||
| name: string; | ||
| // title labels the step in the Stepper; defaults to `name`. | ||
| title?: string; | ||
| // question is the one-line prompt shown under the Stepper. The Stepper | ||
| // already names the step, so the body opens with the question itself. | ||
| question?: string; | ||
| children: ReactNode; | ||
| } | ||
|
|
||
| // Step is one page of a <Wizard>: the stepper entry, the question line, and the | ||
| // field that collects the answer. | ||
| // | ||
| // One field per step. Every field registers its own useInput and answers enter, | ||
| // esc and the arrows itself; two fields mounted at once would both react to the | ||
| // same keystroke. The shell has no notion of focus and is not meant to grow | ||
| // one — a step that genuinely needs two related inputs should get a single | ||
| // compound field that owns one useInput and manages focus internally. | ||
| export function Step({ question, children }: StepProps) { | ||
| return ( | ||
| <Box flexDirection="column" paddingX={1}> | ||
| {question !== undefined && <Text color={theme.colors.muted}>{question}</Text>} | ||
| {children} | ||
| </Box> | ||
| ); | ||
| } | ||
|
|
||
| // isStepElement narrows a child to a <Step>. Children.toArray already | ||
| // drops the `false`/`null` that a `{condition && <Step/>}` branch produces, so | ||
| // filtering with this yields exactly the steps that apply to the current | ||
| // answers — which is how a wizard branches without a step-list useMemo. | ||
| export function isStepElement(child: ReactNode): child is ReactElement<StepProps> { | ||
| return isValidElement(child) && child.type === Step; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flexGrow here makes the table take all free height in any growing column parent. The gateway policy generate screen now has 14 blank lines between the table and the input. Put flexDirection="column" on the two bordered wrapper Boxes instead and leave the shared table alone.