@ankhorage/color-theory 0.0.1 → 0.0.3

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.
@@ -1,77 +0,0 @@
1
- import { type GeneratedHarmonyRoleColors, generateHarmonyRoleColors } from './harmony';
2
- import type { HexColor } from './hex';
3
- import { parseHexColorOrThrow } from './hex';
4
- import { type GeneratedNeutralMetadata, generateNeutralSwatch } from './neutral';
5
- import { type ColorSwatch, generateColorSwatch } from './swatches';
6
-
7
- export interface ThemeModeColorInput {
8
- primaryColor: string;
9
- harmony: GeneratedHarmonyRoleColors['harmony'];
10
- }
11
-
12
- export interface ThemeColorInput {
13
- light: ThemeModeColorInput;
14
- dark: ThemeModeColorInput;
15
- }
16
-
17
- export interface GeneratedThemeSwatches {
18
- primary: ColorSwatch;
19
- secondary?: ColorSwatch;
20
- tertiary?: ColorSwatch;
21
- quaternary?: ColorSwatch;
22
- neutral: ColorSwatch;
23
- }
24
-
25
- export interface GeneratedThemeModeColors {
26
- harmonyRoleColors: GeneratedHarmonyRoleColors;
27
- swatches: GeneratedThemeSwatches;
28
- neutral: GeneratedNeutralMetadata;
29
- }
30
-
31
- export function getThemeModePrimaryHex(mode: ThemeModeColorInput): HexColor {
32
- return parseHexColorOrThrow(mode.primaryColor);
33
- }
34
-
35
- export function generateThemeModeColors(mode: ThemeModeColorInput): GeneratedThemeModeColors {
36
- const primaryHex = getThemeModePrimaryHex(mode);
37
- const harmonyRoleColors = generateHarmonyRoleColors(primaryHex, mode.harmony);
38
-
39
- const primarySwatch = generateColorSwatch(harmonyRoleColors.primary.hex).swatch;
40
- const secondarySwatch = harmonyRoleColors.secondary
41
- ? generateColorSwatch(harmonyRoleColors.secondary.hex).swatch
42
- : undefined;
43
- const tertiarySwatch = harmonyRoleColors.tertiary
44
- ? generateColorSwatch(harmonyRoleColors.tertiary.hex).swatch
45
- : undefined;
46
- const quaternarySwatch = harmonyRoleColors.quaternary
47
- ? generateColorSwatch(harmonyRoleColors.quaternary.hex).swatch
48
- : undefined;
49
-
50
- const neutral = generateNeutralSwatch(harmonyRoleColors);
51
- const swatches: GeneratedThemeSwatches = {
52
- primary: primarySwatch,
53
- neutral: neutral.neutral,
54
- ...(secondarySwatch ? { secondary: secondarySwatch } : {}),
55
- ...(tertiarySwatch ? { tertiary: tertiarySwatch } : {}),
56
- ...(quaternarySwatch ? { quaternary: quaternarySwatch } : {}),
57
- };
58
-
59
- return {
60
- harmonyRoleColors,
61
- swatches,
62
- neutral: {
63
- neutralKeyColor: neutral.neutralKeyColor,
64
- diagnostics: neutral.diagnostics,
65
- },
66
- };
67
- }
68
-
69
- export function generateThemeColors(theme: ThemeColorInput): {
70
- light: GeneratedThemeModeColors;
71
- dark: GeneratedThemeModeColors;
72
- } {
73
- return {
74
- light: generateThemeModeColors(theme.light),
75
- dark: generateThemeModeColors(theme.dark),
76
- };
77
- }