prompts
prompts copied to clipboard
Add DrawsTabs trait with tests
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:
https://github.com/laravel/prompts/assets/1688608/46451de2-e866-4372-b2cb-c570aa35b89e
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?
@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.
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.