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

[feature idea]: @clack/prompts support for many different themes, variants, and colors #36

Open
cpreston321 opened this issue Feb 14, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@cpreston321
Copy link
Collaborator

cpreston321 commented Feb 14, 2023

Is your feature request related to a problem? Please describe.

No

Describe the solution you'd like

Since prompts is super nice it would be since to see a way to either change the theme of the prompts either containing theme within another repo that has those themes, but since prompts is one color and has default set of icons. You could possibly create a way to customize the colors through config or maybe some type of system that can define these as a variant or theme. Since prompts is more a granular term but could be perceived as an all in one alternative solution for CLI prompts.

Describe alternatives you've considered

N/A

Additional context

I would like to discuss more here but it's an idea. Even though @clack/prompts is a wrapper for core I foresee it being bigger package that is built off of core that can include many handy utils, functions, and prompts. Maybe it's the wrong package for it. I am kinda thinking of variants like astro-theme, clack-theme and these will drive icons, styles etc.

@cpreston321 cpreston321 added the enhancement New feature or request label Feb 14, 2023
@cpreston321 cpreston321 changed the title [feature]: @clack/prompts support for many different themes, variants, and colors [feature idea]: @clack/prompts support for many different themes, variants, and colors Feb 14, 2023
@natemoo-re
Copy link
Member

I like this idea a lot and have similar thoughts. I haven't really sketched it out yet, but totally agree that theming would be a really powerful feature.

If you have any API ideas I'm all ears!

@cpreston321
Copy link
Collaborator Author

I think theming can go many ways like if you want the theme layer to be at the core package and have a class that can drive themes. The could potentially be the base point that then, you can extend it within prompts that will create a bigger theme for prompts and then add custom variants/themes to inputs that was wrapped within prompts.

The only problem with injecting a theme within core is that you will have multiple prompts with the same config. So goes back to whats the best way to apply global settings that will look at the applied settings. You could possibly use unjs/c12 smart configuration loader from the root of the directory. To then load a config file of your choice to then drive global configuration. Or it could be at the core level but since this is a CLI root doesn't seem bad to have something at the root level config that can drive settings.

@kevinwolfcr
Copy link

@natemoo-re I think you could benefit from the NodeJS's AsyncLocalStorage class, and use something like React Context to propagate the user-defined theme through all the prompts. So the API could be something like this:

import { run } from `@clack/prompts`

run(async () => {
  // your cli code here...
}, { theme: someThemeConfig, onCancel: someCustomCancelHandling })

@pi0
Copy link

pi0 commented Mar 31, 2023

I just started experimenting (amazing) clack with unjs/consola (unjs/consola#170, unjs/consola#169).

Currently had to make an inline copy/paste of @clack/prompts in order to customize symbols for CLI consistency. It would be amazing if exposed utils, can accept an optional styles or theme object (defaulting to currently static consts) and use this styles internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants