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

Expose styles as variables #566

Merged
merged 6 commits into from Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions readme.md
Expand Up @@ -201,6 +201,10 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=

`chalkStderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `supportsColor` apply to this too. `supportsColorStderr` is exposed for convenience.

### modifiers, foregroundColors, backgroundColors, and colors

All supported style strings are exposed for convenience. `colors` is the combination of `foregroundColors` and `backgroundColors`.

LitoMore marked this conversation as resolved.
Show resolved Hide resolved
## Styles

### Modifiers
Expand Down
5 changes: 5 additions & 0 deletions source/index.d.ts
Expand Up @@ -284,4 +284,9 @@ export {
// } from '#supports-color';
} from './vendor/supports-color/index.js';

export const modifiers: readonly Modifiers[];
export const foregroundColors: readonly ForegroundColor[];
export const backgroundColors: readonly BackgroundColor[];
export const colors: readonly Color[];

export default chalk;
5 changes: 5 additions & 0 deletions source/index.js
Expand Up @@ -209,4 +209,9 @@ export {
stderrColor as supportsColorStderr,
};

export const modifiers = Object.keys(ansiStyles.modifier);
export const foregroundColors = Object.keys(ansiStyles.color);
export const backgroundColors = Object.keys(ansiStyles.bgColor);
LitoMore marked this conversation as resolved.
Show resolved Hide resolved
LitoMore marked this conversation as resolved.
Show resolved Hide resolved
export const colors = [...foregroundColors, ...backgroundColors];

export default chalk;