Comments (4)
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.
from clack.
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!
from clack.
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.
from clack.
@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 })
from clack.
Related Issues (20)
- [Bug] Bun Incompatibility HOT 1
- [Request] Add `Error` support for `prompt.validate`
- [Bug] multiselect doesn't have `validate` option.
- [Request] prompt override
- [Request] Disable continuous terminal rewriting in CI HOT 1
- [Bug] Has anyone been able to get the @clack/prompts example working with Bun? HOT 4
- To allow the possibility of adding a JavaScript object as a value in a select value
- Spinner not showing on using silent exec HOT 2
- [Bug] Long select list glitches HOT 1
- [Request] May you give a release to take the feature [clear process listener in spinner](https://github.com/natemoo-re/clack/commit/8a6315eb39e83951676e3e61e32b6acec784f30c)
- [Bug] Keyboard input not working after await in spinner HOT 7
- [Request] p.info HOT 2
- [Bug] Typescript Select option value warning HOT 2
- Release new version
- [Request] Setting up Elm projects as well
- [Request] `Select` or `Multi-Select` provide `disable` option in `@clack/prompts`
- [Request] release version need tasks api HOT 3
- [Request] use clack text to develop a cli supporting command history
- Dynamic message
- [Bug] group HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clack.