@diagrammo/dgmo 0.0.1
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/LICENSE +21 -0
- package/README.md +335 -0
- package/dist/index.cjs +6698 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +685 -0
- package/dist/index.d.ts +685 -0
- package/dist/index.js +6611 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
- package/src/chartjs.ts +784 -0
- package/src/colors.ts +75 -0
- package/src/d3.ts +5021 -0
- package/src/dgmo-mermaid.ts +247 -0
- package/src/dgmo-router.ts +77 -0
- package/src/echarts.ts +1207 -0
- package/src/index.ts +126 -0
- package/src/palettes/bold.ts +59 -0
- package/src/palettes/catppuccin.ts +76 -0
- package/src/palettes/color-utils.ts +191 -0
- package/src/palettes/gruvbox.ts +77 -0
- package/src/palettes/index.ts +35 -0
- package/src/palettes/mermaid-bridge.ts +220 -0
- package/src/palettes/nord.ts +59 -0
- package/src/palettes/one-dark.ts +62 -0
- package/src/palettes/registry.ts +92 -0
- package/src/palettes/rose-pine.ts +76 -0
- package/src/palettes/solarized.ts +69 -0
- package/src/palettes/tokyo-night.ts +78 -0
- package/src/palettes/types.ts +67 -0
- package/src/sequence/parser.ts +531 -0
- package/src/sequence/participant-inference.ts +178 -0
- package/src/sequence/renderer.ts +1487 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Router
|
|
3
|
+
// ============================================================
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
parseDgmoChartType,
|
|
7
|
+
getDgmoFramework,
|
|
8
|
+
DGMO_CHART_TYPE_MAP,
|
|
9
|
+
} from './dgmo-router';
|
|
10
|
+
export type { DgmoFramework } from './dgmo-router';
|
|
11
|
+
|
|
12
|
+
// ============================================================
|
|
13
|
+
// Parsers
|
|
14
|
+
// ============================================================
|
|
15
|
+
|
|
16
|
+
export { parseChartJs } from './chartjs';
|
|
17
|
+
export type {
|
|
18
|
+
ParsedChartJs,
|
|
19
|
+
ChartJsChartType,
|
|
20
|
+
ChartJsDataPoint,
|
|
21
|
+
} from './chartjs';
|
|
22
|
+
|
|
23
|
+
export { parseEChart } from './echarts';
|
|
24
|
+
export type { ParsedEChart, EChartsChartType } from './echarts';
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
parseD3,
|
|
28
|
+
orderArcNodes,
|
|
29
|
+
parseTimelineDate,
|
|
30
|
+
addDurationToDate,
|
|
31
|
+
computeTimeTicks,
|
|
32
|
+
formatDateLabel,
|
|
33
|
+
} from './d3';
|
|
34
|
+
export type { ParsedD3, D3ChartType, ArcLink, ArcNodeGroup } from './d3';
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
parseSequenceDgmo,
|
|
38
|
+
looksLikeSequence,
|
|
39
|
+
isSequenceBlock,
|
|
40
|
+
} from './sequence/parser';
|
|
41
|
+
export type {
|
|
42
|
+
ParsedSequenceDgmo,
|
|
43
|
+
SequenceParticipant,
|
|
44
|
+
SequenceMessage,
|
|
45
|
+
SequenceBlock,
|
|
46
|
+
SequenceSection,
|
|
47
|
+
SequenceElement,
|
|
48
|
+
SequenceGroup,
|
|
49
|
+
ParticipantType,
|
|
50
|
+
} from './sequence/parser';
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
inferParticipantType,
|
|
54
|
+
RULE_COUNT,
|
|
55
|
+
} from './sequence/participant-inference';
|
|
56
|
+
|
|
57
|
+
export { parseQuadrant } from './dgmo-mermaid';
|
|
58
|
+
export type { ParsedQuadrant } from './dgmo-mermaid';
|
|
59
|
+
|
|
60
|
+
// ============================================================
|
|
61
|
+
// Config Builders (produce framework-specific config objects)
|
|
62
|
+
// ============================================================
|
|
63
|
+
|
|
64
|
+
export { buildChartJsConfig } from './chartjs';
|
|
65
|
+
export { buildEChartsOption } from './echarts';
|
|
66
|
+
export { buildMermaidQuadrant } from './dgmo-mermaid';
|
|
67
|
+
|
|
68
|
+
// ============================================================
|
|
69
|
+
// Renderers (produce SVG output)
|
|
70
|
+
// ============================================================
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
renderSlopeChart,
|
|
74
|
+
renderArcDiagram,
|
|
75
|
+
renderTimeline,
|
|
76
|
+
renderWordCloud,
|
|
77
|
+
renderVenn,
|
|
78
|
+
renderQuadrant,
|
|
79
|
+
renderD3ForExport,
|
|
80
|
+
} from './d3';
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
renderSequenceDiagram,
|
|
84
|
+
buildRenderSequence,
|
|
85
|
+
computeActivations,
|
|
86
|
+
applyPositionOverrides,
|
|
87
|
+
applyGroupOrdering,
|
|
88
|
+
} from './sequence/renderer';
|
|
89
|
+
export type { RenderStep, Activation } from './sequence/renderer';
|
|
90
|
+
|
|
91
|
+
// ============================================================
|
|
92
|
+
// Colors & Palettes
|
|
93
|
+
// ============================================================
|
|
94
|
+
|
|
95
|
+
export { resolveColor, colorNames, nord, seriesColors } from './colors';
|
|
96
|
+
|
|
97
|
+
export {
|
|
98
|
+
// Registry
|
|
99
|
+
getPalette,
|
|
100
|
+
getAvailablePalettes,
|
|
101
|
+
registerPalette,
|
|
102
|
+
isValidHex,
|
|
103
|
+
// Utilities
|
|
104
|
+
hexToHSL,
|
|
105
|
+
hslToHex,
|
|
106
|
+
hexToHSLString,
|
|
107
|
+
mute,
|
|
108
|
+
tint,
|
|
109
|
+
shade,
|
|
110
|
+
getSeriesColors,
|
|
111
|
+
contrastText,
|
|
112
|
+
// Palette definitions
|
|
113
|
+
nordPalette,
|
|
114
|
+
solarizedPalette,
|
|
115
|
+
catppuccinPalette,
|
|
116
|
+
rosePinePalette,
|
|
117
|
+
gruvboxPalette,
|
|
118
|
+
tokyoNightPalette,
|
|
119
|
+
oneDarkPalette,
|
|
120
|
+
boldPalette,
|
|
121
|
+
// Mermaid bridge
|
|
122
|
+
buildMermaidThemeVars,
|
|
123
|
+
buildThemeCSS,
|
|
124
|
+
} from './palettes';
|
|
125
|
+
|
|
126
|
+
export type { PaletteConfig, PaletteColors } from './palettes';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { PaletteConfig } from './types';
|
|
2
|
+
import { registerPalette } from './registry';
|
|
3
|
+
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Bold Palette Definition
|
|
6
|
+
// ============================================================
|
|
7
|
+
|
|
8
|
+
export const boldPalette: PaletteConfig = {
|
|
9
|
+
id: 'bold',
|
|
10
|
+
name: 'Bold',
|
|
11
|
+
light: {
|
|
12
|
+
bg: '#ffffff',
|
|
13
|
+
surface: '#f0f0f0',
|
|
14
|
+
overlay: '#f0f0f0',
|
|
15
|
+
border: '#cccccc',
|
|
16
|
+
text: '#000000',
|
|
17
|
+
textMuted: '#666666',
|
|
18
|
+
primary: '#0000ff',
|
|
19
|
+
secondary: '#ff00ff',
|
|
20
|
+
accent: '#00cccc',
|
|
21
|
+
destructive: '#ff0000',
|
|
22
|
+
colors: {
|
|
23
|
+
red: '#ff0000',
|
|
24
|
+
orange: '#ff8000',
|
|
25
|
+
yellow: '#ffcc00',
|
|
26
|
+
green: '#00cc00',
|
|
27
|
+
blue: '#0000ff',
|
|
28
|
+
purple: '#cc00cc',
|
|
29
|
+
teal: '#008080',
|
|
30
|
+
cyan: '#00cccc',
|
|
31
|
+
gray: '#808080',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
dark: {
|
|
35
|
+
bg: '#000000',
|
|
36
|
+
surface: '#111111',
|
|
37
|
+
overlay: '#000000',
|
|
38
|
+
border: '#333333',
|
|
39
|
+
text: '#ffffff',
|
|
40
|
+
textMuted: '#aaaaaa',
|
|
41
|
+
primary: '#00ccff',
|
|
42
|
+
secondary: '#ff00ff',
|
|
43
|
+
accent: '#ffff00',
|
|
44
|
+
destructive: '#ff0000',
|
|
45
|
+
colors: {
|
|
46
|
+
red: '#ff0000',
|
|
47
|
+
orange: '#ff8000',
|
|
48
|
+
yellow: '#ffff00',
|
|
49
|
+
green: '#00ff00',
|
|
50
|
+
blue: '#0066ff',
|
|
51
|
+
purple: '#ff00ff',
|
|
52
|
+
teal: '#00cccc',
|
|
53
|
+
cyan: '#00ffff',
|
|
54
|
+
gray: '#808080',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
registerPalette(boldPalette);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { PaletteConfig } from './types';
|
|
2
|
+
import { registerPalette } from './registry';
|
|
3
|
+
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Catppuccin Palette Definition
|
|
6
|
+
// ============================================================
|
|
7
|
+
|
|
8
|
+
// Official Catppuccin colors: https://catppuccin.com/palette
|
|
9
|
+
//
|
|
10
|
+
// Latte (light):
|
|
11
|
+
// Base #eff1f5 | Mantle #e6e9ef | Crust #dce0e8
|
|
12
|
+
// Surface0 #ccd0da | Text #4c4f69 | Subtext1 #5c5f77 | Overlay0 #9ca0b0
|
|
13
|
+
//
|
|
14
|
+
// Mocha (dark):
|
|
15
|
+
// Base #1e1e2e | Mantle #181825 | Surface0 #313244
|
|
16
|
+
// Surface1 #45475a | Overlay0 #6c7086 | Text #cdd6f4 | Subtext1 #bac2de
|
|
17
|
+
//
|
|
18
|
+
// Accents (Latte / Mocha):
|
|
19
|
+
// Red #d20f39 / #f38ba8 | Peach #fe640b / #fab387
|
|
20
|
+
// Yellow #df8e1d / #f9e2af | Green #40a02b / #a6e3a1
|
|
21
|
+
// Blue #1e66f5 / #89b4fa | Mauve #8839ef / #cba6f7
|
|
22
|
+
// Teal #179299 / #94e2d5 | Sapphire #209fb5 / #74c7ec
|
|
23
|
+
// Lavender #7287fd / #b4befe
|
|
24
|
+
|
|
25
|
+
export const catppuccinPalette: PaletteConfig = {
|
|
26
|
+
id: 'catppuccin',
|
|
27
|
+
name: 'Catppuccin',
|
|
28
|
+
light: {
|
|
29
|
+
bg: '#eff1f5', // Latte Base
|
|
30
|
+
surface: '#e6e9ef', // Latte Mantle
|
|
31
|
+
overlay: '#ccd0da', // Latte Surface0
|
|
32
|
+
border: '#dce0e8', // Latte Crust
|
|
33
|
+
text: '#4c4f69', // Latte Text
|
|
34
|
+
textMuted: '#5c5f77', // Latte Subtext1
|
|
35
|
+
primary: '#1e66f5', // Latte Blue
|
|
36
|
+
secondary: '#7287fd', // Latte Lavender
|
|
37
|
+
accent: '#8839ef', // Latte Mauve
|
|
38
|
+
destructive: '#d20f39', // Latte Red
|
|
39
|
+
colors: {
|
|
40
|
+
red: '#d20f39',
|
|
41
|
+
orange: '#fe640b',
|
|
42
|
+
yellow: '#df8e1d',
|
|
43
|
+
green: '#40a02b',
|
|
44
|
+
blue: '#1e66f5',
|
|
45
|
+
purple: '#8839ef',
|
|
46
|
+
teal: '#179299',
|
|
47
|
+
cyan: '#209fb5',
|
|
48
|
+
gray: '#9ca0b0', // Latte Overlay0
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
dark: {
|
|
52
|
+
bg: '#1e1e2e', // Mocha Base
|
|
53
|
+
surface: '#313244', // Mocha Surface0
|
|
54
|
+
overlay: '#45475a', // Mocha Surface1
|
|
55
|
+
border: '#6c7086', // Mocha Overlay0
|
|
56
|
+
text: '#cdd6f4', // Mocha Text
|
|
57
|
+
textMuted: '#bac2de', // Mocha Subtext1
|
|
58
|
+
primary: '#89b4fa', // Mocha Blue
|
|
59
|
+
secondary: '#b4befe', // Mocha Lavender
|
|
60
|
+
accent: '#cba6f7', // Mocha Mauve
|
|
61
|
+
destructive: '#f38ba8', // Mocha Red
|
|
62
|
+
colors: {
|
|
63
|
+
red: '#f38ba8',
|
|
64
|
+
orange: '#fab387',
|
|
65
|
+
yellow: '#f9e2af',
|
|
66
|
+
green: '#a6e3a1',
|
|
67
|
+
blue: '#89b4fa',
|
|
68
|
+
purple: '#cba6f7',
|
|
69
|
+
teal: '#94e2d5',
|
|
70
|
+
cyan: '#74c7ec',
|
|
71
|
+
gray: '#6c7086', // Mocha Overlay0
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
registerPalette(catppuccinPalette);
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { PaletteColors } from './types';
|
|
2
|
+
|
|
3
|
+
// ============================================================
|
|
4
|
+
// HSL Conversion
|
|
5
|
+
// ============================================================
|
|
6
|
+
|
|
7
|
+
/** Convert hex (#RRGGBB or #RGB) to { h, s, l } with h in degrees, s/l as percentages. */
|
|
8
|
+
export function hexToHSL(hex: string): { h: number; s: number; l: number } {
|
|
9
|
+
const raw = hex.replace('#', '');
|
|
10
|
+
const full =
|
|
11
|
+
raw.length === 3
|
|
12
|
+
? raw[0] + raw[0] + raw[1] + raw[1] + raw[2] + raw[2]
|
|
13
|
+
: raw;
|
|
14
|
+
|
|
15
|
+
const r = parseInt(full.substring(0, 2), 16) / 255;
|
|
16
|
+
const g = parseInt(full.substring(2, 4), 16) / 255;
|
|
17
|
+
const b = parseInt(full.substring(4, 6), 16) / 255;
|
|
18
|
+
|
|
19
|
+
const max = Math.max(r, g, b);
|
|
20
|
+
const min = Math.min(r, g, b);
|
|
21
|
+
const l = (max + min) / 2;
|
|
22
|
+
|
|
23
|
+
if (max === min) {
|
|
24
|
+
return { h: 0, s: 0, l: Math.round(l * 100) };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const d = max - min;
|
|
28
|
+
const s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
29
|
+
|
|
30
|
+
let h: number;
|
|
31
|
+
if (max === r) {
|
|
32
|
+
h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
33
|
+
} else if (max === g) {
|
|
34
|
+
h = ((b - r) / d + 2) / 6;
|
|
35
|
+
} else {
|
|
36
|
+
h = ((r - g) / d + 4) / 6;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
h: Math.round(h * 360),
|
|
41
|
+
s: Math.round(s * 100),
|
|
42
|
+
l: Math.round(l * 100),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Convert { h (degrees), s (%), l (%) } back to #RRGGBB hex string. */
|
|
47
|
+
export function hslToHex(h: number, s: number, l: number): string {
|
|
48
|
+
const sNorm = s / 100;
|
|
49
|
+
const lNorm = l / 100;
|
|
50
|
+
|
|
51
|
+
if (sNorm === 0) {
|
|
52
|
+
const v = Math.round(lNorm * 255);
|
|
53
|
+
return `#${v.toString(16).padStart(2, '0')}${v.toString(16).padStart(2, '0')}${v.toString(16).padStart(2, '0')}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const hue2rgb = (p: number, q: number, t: number): number => {
|
|
57
|
+
let tNorm = t;
|
|
58
|
+
if (tNorm < 0) tNorm += 1;
|
|
59
|
+
if (tNorm > 1) tNorm -= 1;
|
|
60
|
+
if (tNorm < 1 / 6) return p + (q - p) * 6 * tNorm;
|
|
61
|
+
if (tNorm < 1 / 2) return q;
|
|
62
|
+
if (tNorm < 2 / 3) return p + (q - p) * (2 / 3 - tNorm) * 6;
|
|
63
|
+
return p;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const q = lNorm < 0.5 ? lNorm * (1 + sNorm) : lNorm + sNorm - lNorm * sNorm;
|
|
67
|
+
const p = 2 * lNorm - q;
|
|
68
|
+
const hNorm = h / 360;
|
|
69
|
+
|
|
70
|
+
const r = Math.round(hue2rgb(p, q, hNorm + 1 / 3) * 255);
|
|
71
|
+
const g = Math.round(hue2rgb(p, q, hNorm) * 255);
|
|
72
|
+
const b = Math.round(hue2rgb(p, q, hNorm - 1 / 3) * 255);
|
|
73
|
+
|
|
74
|
+
return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Convert hex to "H S% L%" string for CSS custom properties. */
|
|
78
|
+
export function hexToHSLString(hex: string): string {
|
|
79
|
+
const { h, s, l } = hexToHSL(hex);
|
|
80
|
+
return `${h} ${s}% ${l}%`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// ============================================================
|
|
84
|
+
// Color Manipulation
|
|
85
|
+
// ============================================================
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Derive a muted (desaturated, darkened) variant of a color.
|
|
89
|
+
* Used by the Mermaid theme generator for dark-mode fills.
|
|
90
|
+
*
|
|
91
|
+
* Algorithm: cap saturation at 35% and lightness at 36%.
|
|
92
|
+
*/
|
|
93
|
+
export function mute(hex: string): string {
|
|
94
|
+
const { h, s, l } = hexToHSL(hex);
|
|
95
|
+
return hslToHex(h, Math.min(s, 35), Math.min(l, 36));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Blend a color toward white (light mode quadrant fills).
|
|
100
|
+
* amount: 0 = original, 1 = white
|
|
101
|
+
*/
|
|
102
|
+
export function tint(hex: string, amount: number): string {
|
|
103
|
+
const raw = hex.replace('#', '');
|
|
104
|
+
const full =
|
|
105
|
+
raw.length === 3
|
|
106
|
+
? raw[0] + raw[0] + raw[1] + raw[1] + raw[2] + raw[2]
|
|
107
|
+
: raw;
|
|
108
|
+
|
|
109
|
+
const r = parseInt(full.substring(0, 2), 16);
|
|
110
|
+
const g = parseInt(full.substring(2, 4), 16);
|
|
111
|
+
const b = parseInt(full.substring(4, 6), 16);
|
|
112
|
+
|
|
113
|
+
const tr = Math.round(r + (255 - r) * amount);
|
|
114
|
+
const tg = Math.round(g + (255 - g) * amount);
|
|
115
|
+
const tb = Math.round(b + (255 - b) * amount);
|
|
116
|
+
|
|
117
|
+
return `#${tr.toString(16).padStart(2, '0')}${tg.toString(16).padStart(2, '0')}${tb.toString(16).padStart(2, '0')}`;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Blend a color toward a dark base (dark mode quadrant fills).
|
|
122
|
+
* amount: 0 = original, 1 = base
|
|
123
|
+
*/
|
|
124
|
+
export function shade(hex: string, base: string, amount: number): string {
|
|
125
|
+
const parse = (h: string): [number, number, number] => {
|
|
126
|
+
const raw = h.replace('#', '');
|
|
127
|
+
const full =
|
|
128
|
+
raw.length === 3
|
|
129
|
+
? raw[0] + raw[0] + raw[1] + raw[1] + raw[2] + raw[2]
|
|
130
|
+
: raw;
|
|
131
|
+
return [
|
|
132
|
+
parseInt(full.substring(0, 2), 16),
|
|
133
|
+
parseInt(full.substring(2, 4), 16),
|
|
134
|
+
parseInt(full.substring(4, 6), 16),
|
|
135
|
+
];
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const [r, g, b] = parse(hex);
|
|
139
|
+
const [br, bg, bb] = parse(base);
|
|
140
|
+
|
|
141
|
+
const sr = Math.round(r + (br - r) * amount);
|
|
142
|
+
const sg = Math.round(g + (bg - g) * amount);
|
|
143
|
+
const sb = Math.round(b + (bb - b) * amount);
|
|
144
|
+
|
|
145
|
+
return `#${sr.toString(16).padStart(2, '0')}${sg.toString(16).padStart(2, '0')}${sb.toString(16).padStart(2, '0')}`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ============================================================
|
|
149
|
+
// Contrast / Accessibility
|
|
150
|
+
// ============================================================
|
|
151
|
+
|
|
152
|
+
/** WCAG 2.1 relative luminance (0 = black, 1 = white). */
|
|
153
|
+
export function relativeLuminance(hex: string): number {
|
|
154
|
+
const raw = hex.replace('#', '');
|
|
155
|
+
const full =
|
|
156
|
+
raw.length === 3
|
|
157
|
+
? raw[0] + raw[0] + raw[1] + raw[1] + raw[2] + raw[2]
|
|
158
|
+
: raw;
|
|
159
|
+
|
|
160
|
+
const srgb = [
|
|
161
|
+
parseInt(full.substring(0, 2), 16) / 255,
|
|
162
|
+
parseInt(full.substring(2, 4), 16) / 255,
|
|
163
|
+
parseInt(full.substring(4, 6), 16) / 255,
|
|
164
|
+
].map((c) => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4));
|
|
165
|
+
|
|
166
|
+
return 0.2126 * srgb[0] + 0.7152 * srgb[1] + 0.0722 * srgb[2];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Pick a text color that contrasts against `bg`.
|
|
171
|
+
* Returns `darkText` when background is light (luminance > 0.179),
|
|
172
|
+
* `lightText` when background is dark.
|
|
173
|
+
* Threshold 0.179 is the standard WCAG midpoint for the contrast flip.
|
|
174
|
+
*/
|
|
175
|
+
export function contrastText(
|
|
176
|
+
bg: string,
|
|
177
|
+
lightText: string,
|
|
178
|
+
darkText: string
|
|
179
|
+
): string {
|
|
180
|
+
return relativeLuminance(bg) > 0.179 ? darkText : lightText;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// ============================================================
|
|
184
|
+
// Series Colors
|
|
185
|
+
// ============================================================
|
|
186
|
+
|
|
187
|
+
/** Derive the 8-color series rotation from a palette's named colors. */
|
|
188
|
+
export function getSeriesColors(palette: PaletteColors): string[] {
|
|
189
|
+
const c = palette.colors;
|
|
190
|
+
return [c.blue, c.green, c.yellow, c.orange, c.purple, c.red, c.teal, c.cyan];
|
|
191
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { PaletteConfig } from './types';
|
|
2
|
+
import { registerPalette } from './registry';
|
|
3
|
+
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Gruvbox Palette Definition
|
|
6
|
+
// ============================================================
|
|
7
|
+
|
|
8
|
+
// Official Gruvbox colors: https://github.com/morhetz/gruvbox
|
|
9
|
+
//
|
|
10
|
+
// Neutrals:
|
|
11
|
+
// dark0 #282828 | dark1 #3c3836 | dark2 #504945 | dark3 #665c54
|
|
12
|
+
// light0 #fbf1c7 | light1 #ebdbb2 | light2 #d5c4a1 | light3 #bdae93
|
|
13
|
+
// gray #928374
|
|
14
|
+
//
|
|
15
|
+
// Accents (bright / neutral / faded):
|
|
16
|
+
// Red #fb4934 / #cc241d / #9d0006
|
|
17
|
+
// Green #b8bb26 / #98971a / #79740e
|
|
18
|
+
// Yellow #fabd2f / #d79921 / #b57614
|
|
19
|
+
// Blue #83a598 / #458588 / #076678
|
|
20
|
+
// Purple #d3869b / #b16286 / #8f3f71
|
|
21
|
+
// Aqua #8ec07c / #689d6a / #427b58
|
|
22
|
+
// Orange #fe8019 / #d65d0e / #af3a03
|
|
23
|
+
//
|
|
24
|
+
// Light mode uses faded accents, dark mode uses bright accents.
|
|
25
|
+
|
|
26
|
+
export const gruvboxPalette: PaletteConfig = {
|
|
27
|
+
id: 'gruvbox',
|
|
28
|
+
name: 'Gruvbox',
|
|
29
|
+
light: {
|
|
30
|
+
bg: '#fbf1c7', // light0
|
|
31
|
+
surface: '#ebdbb2', // light1
|
|
32
|
+
overlay: '#d5c4a1', // light2
|
|
33
|
+
border: '#bdae93', // light3
|
|
34
|
+
text: '#3c3836', // dark1
|
|
35
|
+
textMuted: '#7c6f64', // dark4
|
|
36
|
+
primary: '#076678', // faded blue
|
|
37
|
+
secondary: '#427b58', // faded aqua
|
|
38
|
+
accent: '#8f3f71', // faded purple
|
|
39
|
+
destructive: '#9d0006', // faded red
|
|
40
|
+
colors: {
|
|
41
|
+
red: '#9d0006', // faded
|
|
42
|
+
orange: '#af3a03', // faded
|
|
43
|
+
yellow: '#b57614', // faded
|
|
44
|
+
green: '#79740e', // faded
|
|
45
|
+
blue: '#076678', // faded
|
|
46
|
+
purple: '#8f3f71', // faded
|
|
47
|
+
teal: '#427b58', // faded aqua
|
|
48
|
+
cyan: '#427b58', // faded aqua
|
|
49
|
+
gray: '#928374',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
dark: {
|
|
53
|
+
bg: '#282828', // dark0
|
|
54
|
+
surface: '#3c3836', // dark1
|
|
55
|
+
overlay: '#504945', // dark2
|
|
56
|
+
border: '#665c54', // dark3
|
|
57
|
+
text: '#ebdbb2', // light1
|
|
58
|
+
textMuted: '#a89984', // light4
|
|
59
|
+
primary: '#83a598', // bright blue
|
|
60
|
+
secondary: '#8ec07c', // bright aqua
|
|
61
|
+
accent: '#d3869b', // bright purple
|
|
62
|
+
destructive: '#fb4934', // bright red
|
|
63
|
+
colors: {
|
|
64
|
+
red: '#fb4934', // bright
|
|
65
|
+
orange: '#fe8019', // bright
|
|
66
|
+
yellow: '#fabd2f', // bright
|
|
67
|
+
green: '#b8bb26', // bright
|
|
68
|
+
blue: '#83a598', // bright
|
|
69
|
+
purple: '#d3869b', // bright
|
|
70
|
+
teal: '#8ec07c', // bright aqua
|
|
71
|
+
cyan: '#8ec07c', // bright aqua
|
|
72
|
+
gray: '#928374',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
registerPalette(gruvboxPalette);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Re-export types
|
|
2
|
+
export type { PaletteConfig, PaletteColors } from './types';
|
|
3
|
+
|
|
4
|
+
// Re-export registry
|
|
5
|
+
export {
|
|
6
|
+
getPalette,
|
|
7
|
+
getAvailablePalettes,
|
|
8
|
+
registerPalette,
|
|
9
|
+
isValidHex,
|
|
10
|
+
} from './registry';
|
|
11
|
+
|
|
12
|
+
// Re-export utilities
|
|
13
|
+
export {
|
|
14
|
+
hexToHSL,
|
|
15
|
+
hslToHex,
|
|
16
|
+
hexToHSLString,
|
|
17
|
+
mute,
|
|
18
|
+
tint,
|
|
19
|
+
shade,
|
|
20
|
+
getSeriesColors,
|
|
21
|
+
contrastText,
|
|
22
|
+
} from './color-utils';
|
|
23
|
+
|
|
24
|
+
// Re-export palette definitions
|
|
25
|
+
export { nordPalette } from './nord';
|
|
26
|
+
export { solarizedPalette } from './solarized';
|
|
27
|
+
export { catppuccinPalette } from './catppuccin';
|
|
28
|
+
export { rosePinePalette } from './rose-pine';
|
|
29
|
+
export { gruvboxPalette } from './gruvbox';
|
|
30
|
+
export { tokyoNightPalette } from './tokyo-night';
|
|
31
|
+
export { oneDarkPalette } from './one-dark';
|
|
32
|
+
export { boldPalette } from './bold';
|
|
33
|
+
|
|
34
|
+
// Re-export Mermaid bridge
|
|
35
|
+
export { buildMermaidThemeVars, buildThemeCSS } from './mermaid-bridge';
|