Skip to content
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

Add DrawsTabs trait with tests #143

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ProjektGopher
Copy link
Contributor

@ProjektGopher ProjektGopher commented May 1, 2024

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
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
Copy link
Contributor Author

ProjektGopher commented May 2, 2024

@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
Copy link
Contributor Author

ProjektGopher commented May 3, 2024

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.

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.

2 participants