@ankhorage/color-theory 0.0.3 → 0.0.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ankhorage/color-theory
2
2
 
3
+ ## 0.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - c15063e: Add semantic status color seeds and deterministic status swatch generation helpers.
8
+
3
9
  ## 0.0.3
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -1,3 +1,27 @@
1
1
  # @ankhorage/color-theory
2
2
 
3
3
  Standalone color theory, harmony, swatch, contrast, and theme color generation utilities.
4
+
5
+ ## Semantic status colors
6
+
7
+ Generate deterministic swatches for semantic status roles like `danger`, `success`, and `warning`.
8
+
9
+ ```ts
10
+ import { createDefaultSemanticStatusSwatches } from '@ankhorage/color-theory';
11
+
12
+ const status = createDefaultSemanticStatusSwatches();
13
+ status.seeds.danger; // "#ef4444"
14
+ status.swatches.danger[500]; // "#ef4444"
15
+ ```
16
+
17
+ Override defaults by passing your own seeds (throws on invalid hex input):
18
+
19
+ ```ts
20
+ import { createSemanticStatusSwatches } from '@ankhorage/color-theory';
21
+
22
+ const status = createSemanticStatusSwatches({
23
+ danger: '#ef4444',
24
+ success: '#22c55e',
25
+ warning: '#f59e0b',
26
+ });
27
+ ```
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from './contrast';
2
2
  export * from './harmony';
3
3
  export * from './hex';
4
4
  export * from './neutral';
5
+ export * from './semantic-status';
5
6
  export * from './semantics';
6
7
  export * from './swatches';
7
8
  export * from './theme-colors';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ export * from './contrast';
2
2
  export * from './harmony';
3
3
  export * from './hex';
4
4
  export * from './neutral';
5
+ export * from './semantic-status';
5
6
  export * from './semantics';
6
7
  export * from './swatches';
7
8
  export * from './theme-colors';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './contrast';\nexport * from './harmony';\nexport * from './hex';\nexport * from './neutral';\nexport * from './semantics';\nexport * from './swatches';\nexport * from './theme-colors';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './contrast';\nexport * from './harmony';\nexport * from './hex';\nexport * from './neutral';\nexport * from './semantic-status';\nexport * from './semantics';\nexport * from './swatches';\nexport * from './theme-colors';\n"]}
@@ -0,0 +1,17 @@
1
+ import type { HexColor } from './hex';
2
+ import type { ColorSwatch, ColorSwatchDiagnostics } from './swatches';
3
+ export declare const DEFAULT_SEMANTIC_STATUS_COLOR_SEEDS: {
4
+ readonly danger: "#ef4444";
5
+ readonly success: "#22c55e";
6
+ readonly warning: "#f59e0b";
7
+ };
8
+ export type DefaultSemanticStatusRole = keyof typeof DEFAULT_SEMANTIC_STATUS_COLOR_SEEDS;
9
+ export type SemanticStatusSeedInput = string | HexColor;
10
+ export interface SemanticStatusSwatches<Role extends string> {
11
+ seeds: Record<Role, HexColor>;
12
+ swatches: Record<Role, ColorSwatch>;
13
+ diagnostics: Record<Role, ColorSwatchDiagnostics>;
14
+ }
15
+ export declare function createSemanticStatusSwatches<Role extends string>(seeds: Record<Role, SemanticStatusSeedInput>): SemanticStatusSwatches<Role>;
16
+ export declare function createDefaultSemanticStatusSwatches(): SemanticStatusSwatches<DefaultSemanticStatusRole>;
17
+ //# sourceMappingURL=semantic-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-status.d.ts","sourceRoot":"","sources":["../src/semantic-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAGtE,eAAO,MAAM,mCAAmC;;;;CAIL,CAAC;AAE5C,MAAM,MAAM,yBAAyB,GAAG,MAAM,OAAO,mCAAmC,CAAC;AAEzF,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAExD,MAAM,WAAW,sBAAsB,CAAC,IAAI,SAAS,MAAM;IACzD,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;CACnD;AAED,wBAAgB,4BAA4B,CAAC,IAAI,SAAS,MAAM,EAC9D,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,uBAAuB,CAAC,GAC3C,sBAAsB,CAAC,IAAI,CAAC,CAkB9B;AAED,wBAAgB,mCAAmC,IAAI,sBAAsB,CAAC,yBAAyB,CAAC,CAEvG"}
@@ -0,0 +1,26 @@
1
+ import { parseHexColorOrThrow } from './hex';
2
+ import { generateColorSwatch } from './swatches';
3
+ export const DEFAULT_SEMANTIC_STATUS_COLOR_SEEDS = {
4
+ danger: '#ef4444',
5
+ success: '#22c55e',
6
+ warning: '#f59e0b',
7
+ };
8
+ export function createSemanticStatusSwatches(seeds) {
9
+ const roles = Object.keys(seeds);
10
+ const normalizedSeeds = {};
11
+ const swatches = {};
12
+ const diagnostics = {};
13
+ for (const role of roles) {
14
+ const seed = seeds[role];
15
+ const seedHex = typeof seed === 'string' ? parseHexColorOrThrow(seed) : seed;
16
+ normalizedSeeds[role] = seedHex;
17
+ const generated = generateColorSwatch(seedHex);
18
+ swatches[role] = generated.swatch;
19
+ diagnostics[role] = generated.diagnostics;
20
+ }
21
+ return { seeds: normalizedSeeds, swatches, diagnostics };
22
+ }
23
+ export function createDefaultSemanticStatusSwatches() {
24
+ return createSemanticStatusSwatches(DEFAULT_SEMANTIC_STATUS_COLOR_SEEDS);
25
+ }
26
+ //# sourceMappingURL=semantic-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-status.js","sourceRoot":"","sources":["../src/semantic-status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,mCAAmC,GAAG;IACjD,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;CACuB,CAAC;AAY5C,MAAM,UAAU,4BAA4B,CAC1C,KAA4C;IAE5C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAW,CAAC;IAE3C,MAAM,eAAe,GAAG,EAA4B,CAAC;IACrD,MAAM,QAAQ,GAAG,EAA+B,CAAC;IACjD,MAAM,WAAW,GAAG,EAA0C,CAAC;IAE/D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QACzB,MAAM,OAAO,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC7E,eAAe,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;QAEhC,MAAM,SAAS,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAC/C,QAAQ,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC;QAClC,WAAW,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,WAAW,CAAC;IAC5C,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,mCAAmC;IACjD,OAAO,4BAA4B,CAAC,mCAAmC,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["import type { HexColor } from './hex';\nimport { parseHexColorOrThrow } from './hex';\nimport type { ColorSwatch, ColorSwatchDiagnostics } from './swatches';\nimport { generateColorSwatch } from './swatches';\n\nexport const DEFAULT_SEMANTIC_STATUS_COLOR_SEEDS = {\n danger: '#ef4444',\n success: '#22c55e',\n warning: '#f59e0b',\n} as const satisfies Record<string, string>;\n\nexport type DefaultSemanticStatusRole = keyof typeof DEFAULT_SEMANTIC_STATUS_COLOR_SEEDS;\n\nexport type SemanticStatusSeedInput = string | HexColor;\n\nexport interface SemanticStatusSwatches<Role extends string> {\n seeds: Record<Role, HexColor>;\n swatches: Record<Role, ColorSwatch>;\n diagnostics: Record<Role, ColorSwatchDiagnostics>;\n}\n\nexport function createSemanticStatusSwatches<Role extends string>(\n seeds: Record<Role, SemanticStatusSeedInput>,\n): SemanticStatusSwatches<Role> {\n const roles = Object.keys(seeds) as Role[];\n\n const normalizedSeeds = {} as Record<Role, HexColor>;\n const swatches = {} as Record<Role, ColorSwatch>;\n const diagnostics = {} as Record<Role, ColorSwatchDiagnostics>;\n\n for (const role of roles) {\n const seed = seeds[role];\n const seedHex = typeof seed === 'string' ? parseHexColorOrThrow(seed) : seed;\n normalizedSeeds[role] = seedHex;\n\n const generated = generateColorSwatch(seedHex);\n swatches[role] = generated.swatch;\n diagnostics[role] = generated.diagnostics;\n }\n\n return { seeds: normalizedSeeds, swatches, diagnostics };\n}\n\nexport function createDefaultSemanticStatusSwatches(): SemanticStatusSwatches<DefaultSemanticStatusRole> {\n return createSemanticStatusSwatches(DEFAULT_SEMANTIC_STATUS_COLOR_SEEDS);\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ankhorage/color-theory",
3
3
  "type": "module",
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "description": "Standalone color theory, harmony, swatch, contrast, and theme color generation utilities.",
6
6
  "homepage": "https://github.com/ankhorage/color-theory#readme",
7
7
  "bugs": {