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

feat(@clack/prompts): configurable colors #212

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hazycora
Copy link

@hazycora hazycora commented Dec 2, 2024

A partial implementation of #36.

I'm sure the maintainers likely have their own ideas for how this could work instead. I've made this for my own use until #36 is resolved, but just on the off-chance my approach is okay with the maintainers here I thought I'd try submitting it as a PR. Fully understand if this approach isn't preferred :) It's highly customisable to an extent that could be seen as unnecessary, lol.

Colors for specific contexts are defined in a config.colors exported object, which users of the library can edit. If, for instance, you wanted to replace all uses of green in the default theme with magenta, you could do this:

import * as p from '@clack/prompts'

p.config.colors.symbol.submit = 'magenta'
p.config.colors.log.success = 'magenta'
p.config.colors.log.step = 'magenta'
p.config.colors.radio.active = 'magenta'
p.config.colors.checkbox.selected = 'magenta'
p.config.colors.key.active = ['inverse', 'bgMagenta', 'gray']

I've used a config object instead of just having an object for the colors themselves, in case more was configurable in the future, like the symbols used for various things.

Copy link

changeset-bot bot commented Dec 2, 2024

⚠️ No Changeset found

Latest commit: 7150a68

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

1 participant