php-school / cli-menu

🖥 Build beautiful PHP CLI menus. Simple yet Powerful. Expressive DSL.
http://www.phpschool.io
MIT License
1.94k stars 106 forks source link

Renaming some Items, layout idea #190

Closed jtreminio closed 4 years ago

jtreminio commented 4 years ago

Seems like the naming of items is a bit weird. I'm new to the project so maybe I simply need to become acquainted a bit more to understand.

I will be talking specifically about these items: https://github.com/php-school/cli-menu#items

These two are pretty simple, but they're more structure type elements. I feel having everything named "* Item" can be confusing to a developer.


Sub Menu Item - Why not rename this to simply Menu Item? This makes it clear that a menu is completely made up of menus. Instead of CliMenuBuilder::addSubMenu() it seems clearer when it is called CliMenuBuilder::addMenu().

While I'm on the subject, CliMenuBuilder should be renamed MenuBuilder. The whole project is CLI-based, calling it a CliMenuBuilder adds confusion.


Split Item - This one is the toughest to wrap your mind around. You have both a SplitItemBuilder and SplitItem. Why not make it so SplitItem creates a horizontal-style menu. Any items added are displayed on a horizontal line, vs vertical.

Right now you've blacklisted the following:

But making it so SplitItem is simply a direction directive (display the contained items horizontally vs vertically) there'd be no reason you couldn't add any other type of item that the normal CliMenu can contain. LineBreakItem could be made to repeat vertically vs horizontally.


I think that SplitItem's responsibilities should also be ... split up, or a new element type created to allow creating new side-by-side blocks.

The way the menu works is very much in a vertical manner:

    Awesome Vertical Menu
    ==========================================  
    ● Item #1
    ○ Item #2
    ○ Item #3
    ○ Go Back
    ○ Exit

This makes sense. CLI tools go up and down.

When you add a SplitItem it changes it to be completely horizontal:

   Awesome Horizontal Menu
   ===========================================
   Sub Item
   [ ] #1     [ ] #2     [ ] #3     [ ] #4
   ○ Go Back
   ○ Exit

So instead of having an either/or horizontal/vertical, you can actually start defining blocks of menus:

   Awesome Mixed Menu
   ==================================================
   Section 1     Section 2     Section 3
   ● Item #1     [ ] #1        [ ] #1        _ __ _
   ○ Item #2     [ ] #2        [✔] #2       / |..| \
   ○ Item #3     [✔] #3        [ ] #3       \/ || \/
                 [ ] #4        [ ] #4        |_''_|

   ○ Go Back
   ○ Exit

I've not tried implementing this last feature, but reading through your Terminal and SplitItem classes it seems you've got at least most of the groundwork down. You'd basically create side-by-side blocks that contain vertical elements.

Thoughts?

AydinHassan commented 4 years ago

Whilst I agree on the naming of things I don't really want to go about changing the names due to BC concerns. We've already renamed a bunch of stuff and it was quite annoying. The documentation and examples are very thorough so I don't really agree on the confusion aspect. The library is quite well established so I'd rather not chuck in a bunch of BC breaks for purity. Hope you understand.

Your proposed ideas look very interesting though so maybe you could introduce the new horizontal type and maybe in the future we can deprecate the split item as long as all the features are covered in the horizontal item?