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

Allow passing custom MenuStyle to dialog functions #99

Merged
merged 1 commit into from
May 7, 2018

Conversation

Lynesth
Copy link
Collaborator

@Lynesth Lynesth commented May 3, 2018

No description provided.

@codecov-io
Copy link

codecov-io commented May 3, 2018

Codecov Report

Merging #99 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #99   +/-   ##
=========================================
  Coverage     96.68%   96.68%           
  Complexity      293      293           
=========================================
  Files            22       22           
  Lines           905      905           
=========================================
  Hits            875      875           
  Misses           30       30
Impacted Files Coverage Δ Complexity Δ
src/CliMenu.php 91.62% <100%> (ø) 71 <5> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc3a2b7...32e4894. Read the comment docs.

@AydinHassan
Copy link
Member

AydinHassan commented May 3, 2018

I'm not really sold on this - I'm not a fan of keep tacking on extra parameters, it looks a bit wonky - although I can't think of another way to achieve it. Functionality seems fine - I'm guessing its because you would rather set a theme once for all dialogues and pass it around? Maybe you have an idea @mikeymike or thoughts in general?

Maybe there could be a separate dialogue style property on cli menu that can be set and that is used for dialogues instead?

@Lynesth
Copy link
Collaborator Author

Lynesth commented May 4, 2018

The first reason for this PR was that we cannot currently modify the style of those dialogues. At the very least, being able to do something like this seems necessary:

$result = $menu->askText()
    ->setPlaceholderText('Enter something')
    ->setForegroundColour('white')
    ->setBackgroundColour('black')
    ->ask();

But yeah, being able to pass only one MenuStyle to every dialogues prevents would be nice (only one object, the same colours everywhere wihtout having to redefine them each time).

It's something currently achievable doing this:

// Let's say we already have a $menu
$diagStyle = (new MenuStyle)
    ->setBg('black')
    ->setFg('white');

$result = (new Text(new InputIO($menu, $menu->getTerminal(), $diagStyle)))
    ->ask();

But it isn't really nice...

@AydinHassan
Copy link
Member

AydinHassan commented May 4, 2018

It is possible to modify the styles, both the dialogues and inputs expose a getStyle method which allows you to customise.

However, if thats still not enough I be happy with either a withStyle method on the inputs and dialogues or a secondary style object stored on CliMenu which is used for all dialogues and inputs.

@mikeymike
Copy link
Member

My .2c

I think having the methods globally on the MenuStyle makes the most sense, you don't want to have to pass around the object or have to define the style for every dialog.

However I like the option to have a withStyle or getStyle which would allow someone to override those for other use cases such as big alerts, warning alerts etc etc

I think I've spoken to @AydinHassan about this before but one thing I'd really think would be awesome is having a CSS like approach to the styles, we'd need to classify stylable areas etc but it would make it easier for the end user

@AydinHassan AydinHassan added this to the 3.0 milestone May 4, 2018
@Lynesth
Copy link
Collaborator Author

Lynesth commented May 4, 2018

I totally overlooked the getStyle() function. Yeah so that allows for customization.

@AydinHassan
Copy link
Member

@Lynesth you think getStyle is enough or would withStyle be a nice addition?

@AydinHassan AydinHassan merged commit 5faa5c2 into php-school:master May 7, 2018
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.

4 participants