Skip to content

Add DrawsTabs trait with tests - #143

Draft
ProjektGopher wants to merge 4 commits into
laravel:mainfrom
ProjektGopher:feature/DrawsTabs
Draft

Add DrawsTabs trait with tests#143
ProjektGopher wants to merge 4 commits into
laravel:mainfrom
ProjektGopher:feature/DrawsTabs

Conversation

@ProjektGopher

@ProjektGopher ProjektGopher commented May 1, 2024

Copy link
Copy Markdown
Contributor

This PR adds a trait that can be used in the same way as the DrawsScrollbars or DrawsBoxes traits to draw a series of tabs in a prompt. The selected index will be highlighted, and the tabs scroll horizontally automatically to make sure that the highlighted tab is always fully visible.

Example Usage:

$this->tabs(
    tabs: collect(['One', 'Two', 'Three', 'Four', 'Five', 'Six']),
    selected: 0,
    width: 60,
);

Example Output:

    ╭─────╮                                       
    │ One │  Two    Three    Four    Five    Six  
    ┴─────┴─────────────────────────────────────────────────────

This could potentially be used at the top of a box for tabbed navigation in order to give extra context. Here's an example of this trait being used for exactly that purpose in a component I've built:

TabbedScrollableSelectPrompt-edit.mov

@taylorotwell
taylorotwell marked this pull request as draft May 2, 2024 15:07
@taylorotwell

Copy link
Copy Markdown
Member

Not sure we have the bandwidth to take this on at the moment 😅 I wonder if there is a world where Prompts could maybe support stuff like this via packages / extensions?

@ProjektGopher

ProjektGopher commented May 2, 2024

Copy link
Copy Markdown
Contributor Author

@taylorotwell technically with my three other PRs that you've merged this week, I could now package my trait and prompt separately and it would be compatible.

My ultimate goal here is to get this prompt of mine into the laravel installer so that we can provide some detailed context on our various front end stack options to newcomers directly within the installer.

If I were to package my prompt up instead, would you be okay with me adding a new dependency on it in the installer?

I've tried to limit the maintenance burden as much as possible by including plenty of tests and documentation, but I understand the apprehension.

@ProjektGopher

ProjektGopher commented May 3, 2024

Copy link
Copy Markdown
Contributor Author

I've released this trait (along with the prompt that it enables) in my Community Prompts Package so that others can use it. I'll leave this PR open though until it's either merged or closed by you folks since I'd still love it to become first party and available to everyone.

@weitzman

weitzman commented Nov 15, 2025

Copy link
Copy Markdown
Contributor

I came looking to use this exact feature in Drush (the CLI for Drupal - a happy Prompts adopter). Below is the /permissions UX from Claude Code. The 'Allow' tab is currently selected - other tabs are 'Ask', 'Deny', 'Workspace'. They have lists of their own.

image

P.S I also like the down arrow at the bottom indicating more available choices. I dont think Prompts has it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants