@diskette/palette 0.24.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/types.d.ts +5 -1
- package/dist/utils.d.ts +52 -1
- package/dist/utils.js +54 -0
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -26,7 +26,7 @@ const grayOptions = grayOptionsList.map((c) => {
|
|
|
26
26
|
return { value: c, label: `${swatch}${capitalize(c)}` };
|
|
27
27
|
});
|
|
28
28
|
async function main() {
|
|
29
|
-
p.intro(`palette v0.
|
|
29
|
+
p.intro(`palette v0.25.0`);
|
|
30
30
|
const results = await p.group({
|
|
31
31
|
colors: () => p.groupMultiselect({
|
|
32
32
|
message: 'Select accent colors',
|
package/dist/index.d.ts
CHANGED
|
@@ -1118,6 +1118,6 @@ export declare const colors: {
|
|
|
1118
1118
|
};
|
|
1119
1119
|
export default colors;
|
|
1120
1120
|
export { accentColors, grayColors } from './types.ts';
|
|
1121
|
-
export type { AccentColor, AlphaConfig, AlphaScale, Color, ColorScale, GrayColor, PaletteColor, ScaleSteps, } from './types.ts';
|
|
1121
|
+
export type { AccentColor, AlphaConfig, AlphaScale, Color, ColorScale, ColorSteps, GrayColor, PaletteColor, ScaleSteps, } from './types.ts';
|
|
1122
1122
|
export { applyColorVars, css } from './css.ts';
|
|
1123
|
-
export { getMatchingGrayColor, toVarName } from './utils.ts';
|
|
1123
|
+
export { getColor, getColorModes, getMatchingGrayColor, toVarName, } from './utils.ts';
|
package/dist/index.js
CHANGED
|
@@ -65,4 +65,4 @@ export const colors = {
|
|
|
65
65
|
export default colors;
|
|
66
66
|
export { accentColors, grayColors } from "./types.js";
|
|
67
67
|
export { applyColorVars, css } from "./css.js";
|
|
68
|
-
export { getMatchingGrayColor, toVarName } from "./utils.js";
|
|
68
|
+
export { getColor, getColorModes, getMatchingGrayColor, toVarName, } from "./utils.js";
|
package/dist/types.d.ts
CHANGED
|
@@ -33,8 +33,12 @@ export interface PaletteColor<C extends Color> {
|
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
export type Steps = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
37
|
+
export type ColorSteps = {
|
|
38
|
+
[K in `step${Steps}`]: string;
|
|
39
|
+
};
|
|
36
40
|
export type AlphaScale<C extends 'white' | 'back'> = {
|
|
37
|
-
[K in `${C}A${
|
|
41
|
+
[K in `${C}A${Steps}`]: string;
|
|
38
42
|
};
|
|
39
43
|
export type AlphaConfig<C extends 'white' | 'back'> = {
|
|
40
44
|
name: C;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AccentColor, GrayColor } from './types.ts';
|
|
1
|
+
import type { AccentColor, Color, ColorSteps, GrayColor } from './types.ts';
|
|
2
2
|
export declare const LIGHT_SELECTOR = ":root, .light, .light-theme";
|
|
3
3
|
export declare const DARK_SELECTOR = ".dark, .dark-theme";
|
|
4
4
|
export declare const schemeSelector: (scheme: "light" | "dark") => string;
|
|
@@ -8,3 +8,54 @@ export declare const formatRule: (selector: string, vars: string[]) => string;
|
|
|
8
8
|
export declare const formatP3: (selector: string, vars: string[]) => string;
|
|
9
9
|
export declare const formatNestedBlock: (selector: string, vars: string[]) => string;
|
|
10
10
|
export declare function getMatchingGrayColor(accentColor: AccentColor): GrayColor;
|
|
11
|
+
/**
|
|
12
|
+
* Steps `1` and `2` are designed for app backgrounds and subtle component backgrounds.
|
|
13
|
+
* Appropriate applications include:
|
|
14
|
+
* - Main app background
|
|
15
|
+
* - Striped table background
|
|
16
|
+
* - Code block background
|
|
17
|
+
* - Card background
|
|
18
|
+
* - Sidebar background
|
|
19
|
+
* - Canvas area background
|
|
20
|
+
*
|
|
21
|
+
* Steps `3`, `4`, and `5` are designed for UI component backgrounds.
|
|
22
|
+
* - Step `3` is for normal states.
|
|
23
|
+
* - Step `4` is for hover states.
|
|
24
|
+
* - Step `5` is for pressed or selected states.
|
|
25
|
+
* Steps `11` and `12`—which are designed for text
|
|
26
|
+
*
|
|
27
|
+
* Steps `6`, `7`, and `8` are designed for borders.
|
|
28
|
+
* - Step `6` is designed for subtle borders on components which are not interactive. For example sidebars, headers, cards, alerts, and separators.
|
|
29
|
+
* - Step `7` is designed for subtle borders on interactive components.
|
|
30
|
+
* - Step `8` is designed for stronger borders on interactive components and focus rings. Most of the components use --focus-8 for the focus outline color.
|
|
31
|
+
*
|
|
32
|
+
* Step `9` has the highest chroma of all steps in the scale. In other words, it's the purest step, the step mixed with the least amount of white or black. Because `9` is the purest step, it has a wide range of applications:
|
|
33
|
+
* - Website/App backgrounds
|
|
34
|
+
* - Website section backgrounds
|
|
35
|
+
* - Header backgrounds
|
|
36
|
+
* - Component backgrounds
|
|
37
|
+
* - Graphics/Logos
|
|
38
|
+
* - Overlays
|
|
39
|
+
* - Coloured shadows
|
|
40
|
+
* - Accent borders
|
|
41
|
+
*
|
|
42
|
+
* Step `10` is designed for component hover states, where step `9` is the component's normal state background.
|
|
43
|
+
*
|
|
44
|
+
* Most step 9 colors are designed for white foreground text. `Sky`, `Mint`, `Lime`, `Yellow`, and `Amber` are designed for dark foreground text and steps `9` and `10`.
|
|
45
|
+
*
|
|
46
|
+
* Steps `11` and `12` are designed for text.
|
|
47
|
+
* - Step `11` is designed for low-contrast text.
|
|
48
|
+
* - Step `12` is designed for high-contrast text.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getColor(color: Color, opts?: {
|
|
51
|
+
mode?: 'light' | 'dark';
|
|
52
|
+
variant?: 'alpha' | 'solid';
|
|
53
|
+
type?: 'p3' | 'srgb';
|
|
54
|
+
}): ColorSteps;
|
|
55
|
+
export declare function getColorModes(color: Color, opts?: {
|
|
56
|
+
variant?: 'alpha' | 'solid';
|
|
57
|
+
type?: 'p3' | 'srgb';
|
|
58
|
+
}): {
|
|
59
|
+
light: ColorSteps;
|
|
60
|
+
dark: ColorSteps;
|
|
61
|
+
};
|
package/dist/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import colors from "./index.js";
|
|
1
2
|
export const LIGHT_SELECTOR = ':root, .light, .light-theme';
|
|
2
3
|
export const DARK_SELECTOR = '.dark, .dark-theme';
|
|
3
4
|
export const schemeSelector = (scheme) => scheme === 'light' ? LIGHT_SELECTOR : DARK_SELECTOR;
|
|
@@ -43,3 +44,56 @@ export function getMatchingGrayColor(accentColor) {
|
|
|
43
44
|
return 'gray';
|
|
44
45
|
}
|
|
45
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Steps `1` and `2` are designed for app backgrounds and subtle component backgrounds.
|
|
49
|
+
* Appropriate applications include:
|
|
50
|
+
* - Main app background
|
|
51
|
+
* - Striped table background
|
|
52
|
+
* - Code block background
|
|
53
|
+
* - Card background
|
|
54
|
+
* - Sidebar background
|
|
55
|
+
* - Canvas area background
|
|
56
|
+
*
|
|
57
|
+
* Steps `3`, `4`, and `5` are designed for UI component backgrounds.
|
|
58
|
+
* - Step `3` is for normal states.
|
|
59
|
+
* - Step `4` is for hover states.
|
|
60
|
+
* - Step `5` is for pressed or selected states.
|
|
61
|
+
* Steps `11` and `12`—which are designed for text
|
|
62
|
+
*
|
|
63
|
+
* Steps `6`, `7`, and `8` are designed for borders.
|
|
64
|
+
* - Step `6` is designed for subtle borders on components which are not interactive. For example sidebars, headers, cards, alerts, and separators.
|
|
65
|
+
* - Step `7` is designed for subtle borders on interactive components.
|
|
66
|
+
* - Step `8` is designed for stronger borders on interactive components and focus rings. Most of the components use --focus-8 for the focus outline color.
|
|
67
|
+
*
|
|
68
|
+
* Step `9` has the highest chroma of all steps in the scale. In other words, it's the purest step, the step mixed with the least amount of white or black. Because `9` is the purest step, it has a wide range of applications:
|
|
69
|
+
* - Website/App backgrounds
|
|
70
|
+
* - Website section backgrounds
|
|
71
|
+
* - Header backgrounds
|
|
72
|
+
* - Component backgrounds
|
|
73
|
+
* - Graphics/Logos
|
|
74
|
+
* - Overlays
|
|
75
|
+
* - Coloured shadows
|
|
76
|
+
* - Accent borders
|
|
77
|
+
*
|
|
78
|
+
* Step `10` is designed for component hover states, where step `9` is the component's normal state background.
|
|
79
|
+
*
|
|
80
|
+
* Most step 9 colors are designed for white foreground text. `Sky`, `Mint`, `Lime`, `Yellow`, and `Amber` are designed for dark foreground text and steps `9` and `10`.
|
|
81
|
+
*
|
|
82
|
+
* Steps `11` and `12` are designed for text.
|
|
83
|
+
* - Step `11` is designed for low-contrast text.
|
|
84
|
+
* - Step `12` is designed for high-contrast text.
|
|
85
|
+
*/
|
|
86
|
+
export function getColor(color, opts) {
|
|
87
|
+
const { variant = 'solid', type = 'p3', mode = 'dark' } = opts ?? {};
|
|
88
|
+
const scales = colors[color][mode][type][variant];
|
|
89
|
+
return scales.reduce((acc, current, index) => {
|
|
90
|
+
const key = `step${index + 1}`;
|
|
91
|
+
acc[key] = current;
|
|
92
|
+
return acc;
|
|
93
|
+
}, {});
|
|
94
|
+
}
|
|
95
|
+
export function getColorModes(color, opts) {
|
|
96
|
+
const light = getColor(color, opts);
|
|
97
|
+
const dark = getColor(color, opts);
|
|
98
|
+
return { light, dark };
|
|
99
|
+
}
|