-
Notifications
You must be signed in to change notification settings - Fork 106
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
Conversation
Basically what I've changed is created three new style objects:
Each So an example CheckableItem would be:
The style classes only care about styles related to their item type. Right now they're identical, only difference are the marker texts. You'll be able to deprecate the following in
since these are item-level styles. Note that not all item types have moved off of Since the style classes all share the same interface, we're able to get rid of Aside from this, I was able to fix the #201 issue.
This helps avoid creating the menu code ahead of time, and uses style values that are set after all PHP code has been read. |
Codecov Report
@@ Coverage Diff @@
## master #203 +/- ##
============================================
- Coverage 93.91% 91.85% -2.06%
- Complexity 516 554 +38
============================================
Files 29 35 +6
Lines 1561 1744 +183
============================================
+ Hits 1466 1602 +136
- Misses 95 142 +47
Continue to review full report at Codecov.
|
|
This PR provides item-level styles, and completely removes these same styles from To run a quick test:
|
@@ -22,8 +23,10 @@ | |||
}) | |||
->addSubMenu('Interpreted', function (CliMenuBuilder $b) use ($itemCallable) { | |||
$b->setTitle('Interpreted Languages') | |||
->setUncheckedMarker('[○] ') | |||
->setCheckedMarker('[●] ') | |||
->setCheckableStyle(function (CheckableStyle $style) { |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
|
||
use PhpSchool\CliMenu\Style; | ||
|
||
interface ItemStyleInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this StyleableItem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StyleableItem
or StyleableItemInterface
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just go with StyleableItem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it again, we also don't need this. I think we can drop it. Each item can still implement getStyle
and setStyle
but should type hint on the concrete style they need. If it turns out that a few different types of item use basically the same styles then we can introduce an interface but I think until then there is no benefit.
|
||
namespace PhpSchool\CliMenu\Style; | ||
|
||
interface ItemStyleInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd rather get rid of the interfaces for each item style type. Each item renders itself so therefore can just hint on the concrete. I don't think we need interfaces for that.
What I'd like to see here (after changing the checkableitem to checkbox item) a PR just changing checkbox item to this new individual style design. And then we can PR each item type one by one making it easier to review. I think it makes it easier to discuss the design that way. What do you think? |
I'll redo the PR to slim it down in scope, but doing only Checkbox styling and leaving Radio and Selectable will be ugly as will need to do a bunch if I'll create the minimum for the Selectable and Radio styles and include in PR. |
Not ready for merge. Needs feedback, unit tests and general cleanup.