@diskette/palette 0.23.0 → 0.23.2

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 CHANGED
@@ -25,7 +25,7 @@ const grayOptions = grayColors.map((c) => {
25
25
  return { value: c, label: `${swatch}${capitalize(c)}` };
26
26
  });
27
27
  async function main() {
28
- p.intro(`palette v0.23.0`);
28
+ p.intro(`palette v0.23.2`);
29
29
  const results = await p.group({
30
30
  colors: () => p.groupMultiselect({
31
31
  message: 'Select accent colors',
@@ -77,6 +77,7 @@ async function main() {
77
77
  // Build file list, confirm overwrites, and write
78
78
  const allFiles = buildOutputFiles({
79
79
  colors: allColors,
80
+ grays: selectedGrays,
80
81
  outputPath,
81
82
  accents: results.accents,
82
83
  tailwind: results.tailwind,
@@ -2,7 +2,6 @@ export type OutputFile = {
2
2
  path: string;
3
3
  displayName: string;
4
4
  content: () => string;
5
- skipIfExists?: boolean;
6
5
  };
7
6
  export type WriteResult = {
8
7
  path: string;
@@ -11,6 +10,7 @@ export type WriteResult = {
11
10
  };
12
11
  export declare function buildOutputFiles(config: {
13
12
  colors: string[];
13
+ grays: string[];
14
14
  outputPath: string;
15
15
  accents?: boolean;
16
16
  tailwind?: boolean;
@@ -10,11 +10,15 @@ function isAlphaColor(name) {
10
10
  }
11
11
  function alphaColorFile(name, outputPath) {
12
12
  const fileName = name === 'blackAlpha' ? 'black-alpha' : 'white-alpha';
13
+ const path = `${outputPath}/${fileName}.css`;
14
+ // Alpha files are silently skipped if they exist
15
+ if (existsSync(path)) {
16
+ return null;
17
+ }
13
18
  return {
14
- path: `${outputPath}/${fileName}.css`,
19
+ path,
15
20
  displayName: capitalize(fileName.replace('-', ' ')),
16
21
  content: () => css.alpha(palette[name]),
17
- skipIfExists: true,
18
22
  };
19
23
  }
20
24
  function paletteColorFiles(name, outputPath) {
@@ -32,11 +36,17 @@ function paletteColorFiles(name, outputPath) {
32
36
  },
33
37
  ];
34
38
  }
35
- function accentsFile(colorNames, outputPath) {
39
+ function accentsFile(colorNames, grayNames, outputPath) {
36
40
  return {
37
41
  path: `${outputPath}/accents.css`,
38
42
  displayName: 'Accents',
39
- content: () => css.accents(colorNames),
43
+ content: () => {
44
+ const parts = [css.accents(colorNames)];
45
+ if (grayNames.length > 0) {
46
+ parts.push(css.grays(grayNames));
47
+ }
48
+ return parts.join('\n');
49
+ },
40
50
  };
41
51
  }
42
52
  function tailwindFile(names, outputPath, accents) {
@@ -47,11 +57,13 @@ function tailwindFile(names, outputPath, accents) {
47
57
  };
48
58
  }
49
59
  export function buildOutputFiles(config) {
50
- const { colors, outputPath, accents, tailwind } = config;
60
+ const { colors, grays, outputPath, accents, tailwind } = config;
51
61
  const files = [];
52
62
  for (const name of colors) {
53
63
  if (isAlphaColor(name)) {
54
- files.push(alphaColorFile(name, outputPath));
64
+ const file = alphaColorFile(name, outputPath);
65
+ if (file)
66
+ files.push(file);
55
67
  }
56
68
  else {
57
69
  files.push(...paletteColorFiles(name, outputPath));
@@ -59,7 +71,7 @@ export function buildOutputFiles(config) {
59
71
  }
60
72
  if (accents) {
61
73
  const colorNames = colors.filter((c) => !isAlphaColor(c));
62
- files.push(accentsFile(colorNames, outputPath));
74
+ files.push(accentsFile(colorNames, grays, outputPath));
63
75
  }
64
76
  if (tailwind) {
65
77
  const tailwindNames = colors.map((c) => c === 'blackAlpha' ? 'black' : c === 'whiteAlpha' ? 'white' : c);
@@ -71,14 +83,12 @@ export async function confirmOverwrites(files) {
71
83
  const cwd = process.cwd();
72
84
  const newFiles = files.filter((f) => !existsSync(f.path));
73
85
  const existing = files.filter((f) => existsSync(f.path));
74
- // Files that should prompt for overwrite confirmation
75
- const promptable = existing.filter((f) => !f.skipIfExists);
76
- if (promptable.length === 0) {
86
+ if (existing.length === 0) {
77
87
  return newFiles;
78
88
  }
79
89
  const selected = await p.multiselect({
80
90
  message: 'These files already exist. Select to overwrite:',
81
- options: promptable.map((f) => ({
91
+ options: existing.map((f) => ({
82
92
  value: f.path,
83
93
  label: f.displayName,
84
94
  hint: relative(cwd, f.path),
@@ -90,7 +100,7 @@ export async function confirmOverwrites(files) {
90
100
  process.exit(0);
91
101
  }
92
102
  const selectedSet = new Set(selected);
93
- const toOverwrite = promptable.filter((f) => selectedSet.has(f.path));
103
+ const toOverwrite = existing.filter((f) => selectedSet.has(f.path));
94
104
  return [...newFiles, ...toOverwrite];
95
105
  }
96
106
  export function writeOutputFiles(files) {
package/dist/css.d.ts CHANGED
@@ -12,7 +12,7 @@ type PaletteOptions = {
12
12
  declare function palette<C extends Color>(config: PaletteColor<C>, options?: PaletteOptions): string;
13
13
  declare function alpha(config: AlphaConfig): string;
14
14
  declare function accents(colorNames: string[]): string;
15
- declare function grays(names: readonly string[], className: string): string;
15
+ declare function grays(names: readonly string[], className?: string): string;
16
16
  type TailwindOptions = {
17
17
  /** Include @import for accents.css. Defaults to false */
18
18
  accents?: boolean;
package/dist/css.js CHANGED
@@ -80,7 +80,7 @@ function accents(colorNames) {
80
80
  output.push(formatRule(`[data-accent-color]:where(:not([data-accent-color=''], [data-accent-color='gray']))`, [...focus, ...focusAlpha]));
81
81
  return output.join('\n\n') + '\n';
82
82
  }
83
- function grays(names, className) {
83
+ function grays(names, className = 'diskette-theme') {
84
84
  const grays = names.filter((n) => n !== 'gray');
85
85
  const blocks = grays.map((colorName) => {
86
86
  const srgb = [];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@diskette/palette",
3
3
  "type": "module",
4
- "version": "0.23.0",
4
+ "version": "0.23.2",
5
5
  "bin": {
6
6
  "palette": "./dist/cli/cli.js"
7
7
  },