Giter VIP home page Giter VIP logo

Comments (4)

pi0 avatar pi0 commented on May 28, 2024 1

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.

natemoo-re avatar natemoo-re commented on May 28, 2024

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.

cpreston321 avatar cpreston321 commented on May 28, 2024

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.

kevinwolfcr avatar kevinwolfcr commented on May 28, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.