Skip to content

Item-level style example; fixes disappearing styles for nested #203

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

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions examples/checkable-item.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use PhpSchool\CliMenu\CliMenu;
use PhpSchool\CliMenu\Builder\CliMenuBuilder;
use PhpSchool\CliMenu\Style\CheckableStyle;

require_once(__DIR__ . '/../vendor/autoload.php');

Expand All @@ -22,8 +23,10 @@
})
->addSubMenu('Interpreted', function (CliMenuBuilder $b) use ($itemCallable) {
$b->setTitle('Interpreted Languages')
->setUncheckedMarker('[○] ')
->setCheckedMarker('[●] ')
->setCheckableStyle(function (CheckableStyle $style) {
Copy link
Member

@AydinHassan AydinHassan Dec 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is irking me a little. Can we change CheckableItem to CheckboxItem to match RadioItem please, then possibly change this to CheckboxStyle and ->setCheckboxStyle. Can we rename the checkbox as a separate PR though. This one in a bit unruly!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, removing the able from items makes sense and it was bothering me as well.

As for this being unruly - I can yank out the bits with Closure that fixes nested styles not being applied, and put it into a separate PR. Anything else you think isn't clear, though?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be very helpful, I'll try pick out and comment on things I think can be separated. Appreciate all the work though!

$style->setMarkerOff('[○] ')
->setMarkerOn('[●] ');
})
->addCheckableItem('PHP', $itemCallable)
->addCheckableItem('Javascript', $itemCallable)
->addCheckableItem('Ruby', $itemCallable)
Expand Down
11 changes: 9 additions & 2 deletions examples/radio-item.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

use PhpSchool\CliMenu\CliMenu;
use PhpSchool\CliMenu\Builder\CliMenuBuilder;
use PhpSchool\CliMenu\Style\RadioStyle;

require_once(__DIR__ . '/../vendor/autoload.php');

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$itemCallable = function (CliMenu $menu) {
echo $menu->getSelectedItem()->getText();
};
Expand All @@ -22,8 +27,10 @@
})
->addSubMenu('Interpreted', function (CliMenuBuilder $b) use ($itemCallable) {
$b->setTitle('Interpreted Languages')
->setUnradioMarker('[ ] ')
->setRadioMarker('[✔] ')
->setRadioStyle(function (RadioStyle $style) {
$style->setMarkerOff('[ ] ')
->setMarkerOn('[✔] ');
})
->addRadioItem('PHP', $itemCallable)
->addRadioItem('Javascript', $itemCallable)
->addRadioItem('Ruby', $itemCallable)
Expand Down
Loading