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

Style customization #822

Closed
medikoo opened this issue Jul 8, 2019 · 6 comments
Closed

Style customization #822

medikoo opened this issue Jul 8, 2019 · 6 comments

Comments

@medikoo
Copy link

medikoo commented Jul 8, 2019

It'll be nice to be able to style the output, e.g. at serverless we'd love to resemble style to which we already accustomed our users, as e.g.:

Screenshot 2019-07-08 at 17 32 53

Currently, it appears that without hacking of inquirer internals it's not possible to achieve.

@SBoudrias
Copy link
Owner

I'm open to extend the API to support something like this. Maybe you could suggest how the API could look like?

@medikoo
Copy link
Author

medikoo commented Jul 11, 2019

Maybe you could suggest how the API could look like?

As inquirer is singleton, it could work as:

inquirer.registerStyle({
  // Assign on top of default style (not changed remain as default)
  question: chalk.bold.yellow,
  answer: chalk.bold,
   ..
})
// All further prompts rely on that

Internally, probably @inquirer/style should be introduced to serve as a style information source for all prompts.

What do you think?

@SBoudrias
Copy link
Owner

Yeah I think I like that. Then we'd need to update our prompts to use styles.question(prefix + question) instead of raw chalk.

I don't think an extra module is necessary? What would this module do? Encapsulate default styles and the way to extend it?

Might be good to also unify everything like:

{
	colors: {
		question: chalk.bold.yellow,
		...
	},
	glyphs: {
		questionPrefix: { default: '? ', windows: '? ' },
	}
}

There's been request to update the way we modify glyphs quite often too, so this might be a good occasion to unify everything under a styling interface.

@medikoo
Copy link
Author

medikoo commented Jul 16, 2019

Yeah I think I like that. Then we'd need to update our prompts to use styles.question(prefix + question)

It might be more composable if a prefix (which may already have a custom styles applied by user) is kept out of enforced styling, e.g. in my case I want prefix to be in different style than question body, so if question style would be applied to it, I would need to add hack so it doesn't really apply.

I don't think an extra module is necessary? What would this module do? Encapsulate default styles and the way to extend it?

I thought it'll be good if given prompts can just access given styles setup (without a need of injecting them as argument for every prompt creation). So my first thought was that e.g. here it can be:

const style = require('@inquirer/style');

but technically we could also do:

const { style } = require('@inquirer/core')

There's been request to update the way we modify glyphs quite often too, so this might be a good occasion to unify everything under a styling interface.

Currently, if I see correctly ? is a default value for a prefix, which is already fully customizable.
I'm not sure if it really applies for that. Are there any other characters in other places you're referring to?

@SBoudrias
Copy link
Owner

All the requests were about the question prefix specifically. But we could extend to things like lists characters, etc.

@SBoudrias
Copy link
Owner

Closing this old issue, there's a theme today configuration supported by all prompts.

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

No branches or pull requests

2 participants