@snagtag/design-system 0.2.2 → 0.2.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.
- package/dist/index.cjs +20 -2
- package/dist/index.d.cts +29 -3
- package/dist/index.d.ts +29 -3
- package/dist/index.js +19 -2
- package/dist/manifest.json +3 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -61,6 +61,7 @@ __export(index_exports, {
|
|
|
61
61
|
createOverlay: () => createOverlay,
|
|
62
62
|
createReassignmentState: () => createReassignmentState,
|
|
63
63
|
createThemeEditorState: () => createThemeEditorState,
|
|
64
|
+
customTokenDefaults: () => customTokenDefaults,
|
|
64
65
|
darken: () => darken,
|
|
65
66
|
downloadAuditReport: () => downloadAuditReport,
|
|
66
67
|
downloadStyleGuide: () => downloadStyleGuide,
|
|
@@ -327,6 +328,11 @@ function suggestPalettes(primaryHex) {
|
|
|
327
328
|
}
|
|
328
329
|
|
|
329
330
|
// src/theme-defaults.ts
|
|
331
|
+
function customTokenDefaults(tokens = []) {
|
|
332
|
+
const out = {};
|
|
333
|
+
for (const t of tokens) out[t.key] = t.defaultValue;
|
|
334
|
+
return out;
|
|
335
|
+
}
|
|
330
336
|
var THEME_DEFAULTS = {
|
|
331
337
|
// Primitives
|
|
332
338
|
primaryColor: "#2563eb",
|
|
@@ -2787,7 +2793,7 @@ function downloadAuditReport(report) {
|
|
|
2787
2793
|
}
|
|
2788
2794
|
|
|
2789
2795
|
// src/dom.ts
|
|
2790
|
-
function applyThemeToDOM(merged) {
|
|
2796
|
+
function applyThemeToDOM(merged, customTokens = []) {
|
|
2791
2797
|
const root = document.documentElement;
|
|
2792
2798
|
if (merged.primaryColor) {
|
|
2793
2799
|
merged.primaryColor = ensureContrastOnWhite(merged.primaryColor);
|
|
@@ -2824,12 +2830,23 @@ function applyThemeToDOM(merged) {
|
|
|
2824
2830
|
const accent = merged.accentColor || THEME_DEFAULTS.accentColor;
|
|
2825
2831
|
root.style.setProperty("--color-accent-light", lighten(accent, 0.85));
|
|
2826
2832
|
root.style.setProperty("--color-accent-hover", darken(accent, 0.15));
|
|
2833
|
+
for (const token of customTokens) {
|
|
2834
|
+
const value = merged[token.key] ?? token.defaultValue;
|
|
2835
|
+
if (value) {
|
|
2836
|
+
root.style.setProperty(token.cssVar, value);
|
|
2837
|
+
} else {
|
|
2838
|
+
root.style.removeProperty(token.cssVar);
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2827
2841
|
}
|
|
2828
|
-
function clearThemeFromDOM() {
|
|
2842
|
+
function clearThemeFromDOM(customTokens = []) {
|
|
2829
2843
|
const root = document.documentElement;
|
|
2830
2844
|
for (const cssVar of Object.values(THEME_KEY_TO_CSS)) {
|
|
2831
2845
|
root.style.removeProperty(cssVar);
|
|
2832
2846
|
}
|
|
2847
|
+
for (const token of customTokens) {
|
|
2848
|
+
root.style.removeProperty(token.cssVar);
|
|
2849
|
+
}
|
|
2833
2850
|
for (const v of [
|
|
2834
2851
|
"--color-sidebar-border",
|
|
2835
2852
|
"--color-sidebar-hover",
|
|
@@ -3195,6 +3212,7 @@ function calculateQualityScore2(overrides) {
|
|
|
3195
3212
|
createOverlay,
|
|
3196
3213
|
createReassignmentState,
|
|
3197
3214
|
createThemeEditorState,
|
|
3215
|
+
customTokenDefaults,
|
|
3198
3216
|
darken,
|
|
3199
3217
|
downloadAuditReport,
|
|
3200
3218
|
downloadStyleGuide,
|
package/dist/index.d.cts
CHANGED
|
@@ -140,6 +140,27 @@ declare function suggestPalettes(primaryHex: string): ColourSuggestion[];
|
|
|
140
140
|
* These are the canonical defaults for the design system package.
|
|
141
141
|
*/
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* A host-defined theme token, declared by a consuming app so its own bespoke
|
|
145
|
+
* tokens flow through the SnagTag editor + DOM pipeline without forking the
|
|
146
|
+
* built-in maps. See docs/LAYER2-HOST-EXTENSIBLE-TOKENS-PROPOSAL.md.
|
|
147
|
+
*/
|
|
148
|
+
interface CustomTokenDef {
|
|
149
|
+
/** Theme key used in the persisted overrides map + editor state (e.g. 'statusWatching'). */
|
|
150
|
+
key: string;
|
|
151
|
+
/** CSS custom property written to :root (e.g. '--status-watching'). */
|
|
152
|
+
cssVar: string;
|
|
153
|
+
/** Default colour value, used until the user overrides it. */
|
|
154
|
+
defaultValue: string;
|
|
155
|
+
/** Editor category to group the swatch under. Defaults to 'Custom'. */
|
|
156
|
+
category?: string;
|
|
157
|
+
/** Optional human label (the colour editor otherwise derives one from `key`). */
|
|
158
|
+
label?: string;
|
|
159
|
+
/** Optional CSS var this token references, for inspector chain tracing. */
|
|
160
|
+
references?: string;
|
|
161
|
+
}
|
|
162
|
+
/** Build a { key: defaultValue } map from custom token definitions. */
|
|
163
|
+
declare function customTokenDefaults(tokens?: CustomTokenDef[]): Record<string, string>;
|
|
143
164
|
/**
|
|
144
165
|
* The hardcoded defaults matching a standard design system theme.
|
|
145
166
|
* These are the "factory" values used when no overrides are set.
|
|
@@ -803,13 +824,18 @@ declare function downloadAuditReport(report: AuditReport): void;
|
|
|
803
824
|
* DOM utilities for applying and clearing theme values on the document root.
|
|
804
825
|
* These functions set/remove CSS custom properties on document.documentElement.
|
|
805
826
|
*/
|
|
827
|
+
|
|
806
828
|
/**
|
|
807
829
|
* Apply a merged theme to the DOM by setting CSS custom properties on :root.
|
|
808
830
|
* Derives sidebar states and accent variants automatically.
|
|
831
|
+
*
|
|
832
|
+
* Pass `customTokens` to also write host-defined tokens (each `cssVar` is set
|
|
833
|
+
* from `merged[key]`, falling back to the token's `defaultValue`). Omitting it
|
|
834
|
+
* leaves behaviour identical to before.
|
|
809
835
|
*/
|
|
810
|
-
declare function applyThemeToDOM(merged: Record<string, string
|
|
836
|
+
declare function applyThemeToDOM(merged: Record<string, string>, customTokens?: CustomTokenDef[]): void;
|
|
811
837
|
/** Remove all theme overrides from :root, restoring CSS defaults. */
|
|
812
|
-
declare function clearThemeFromDOM(): void;
|
|
838
|
+
declare function clearThemeFromDOM(customTokens?: CustomTokenDef[]): void;
|
|
813
839
|
|
|
814
840
|
/**
|
|
815
841
|
* Contrast Fix Engine - scans colour token pairs for WCAG AA failures
|
|
@@ -881,4 +907,4 @@ interface QualityBreakdown {
|
|
|
881
907
|
*/
|
|
882
908
|
declare function calculateQualityScore(overrides?: Record<string, string>): QualityBreakdown;
|
|
883
909
|
|
|
884
|
-
export { type ConsistencyIssue$1 as AuditConsistencyIssue, type ContrastIssue$1 as AuditContrastIssue, type QualityBreakdown$1 as AuditQualityBreakdown, type AuditReport, BUILT_IN_PRESETS, COLOUR_BLINDNESS_TYPES, type ColourBlindnessInfo, type ColourBlindnessType, type ColourSuggestion, type ConsistencyIssue, type ContrastIssue$2 as ContrastIssue, type CustomPreset, DENSITY_CONFIGS, type DarkModeConfig, type DensityConfig, type DensityMode, type DesignSystemAdapter, type ThemePreset as DesignThemePreset, EASING_PRESETS, type EasingPreset, type ExtractedTokenDef, FONT_PAIRINGS, type FontPairing, type HSL, type HarmonyType, type QualityBreakdown$2 as QualityBreakdown, type ReassignmentAction, type ReassignmentState, type RegistryOverlay, SCALE_RATIOS, SURFACE_DEFINITIONS, type ScaleRatio, type SurfaceDefinition, type SurfaceType, THEME_CATEGORIES, THEME_DEFAULTS, THEME_KEY_TO_CSS, TOKEN_REGISTRY, type ThemeEditorState, type ThemeExport, type ThemeExportPayload, type ThemePreset$1 as ThemePreset, type ThemeSnapshot, type ThemeVersion, type TokenCategory, type TokenDefinition, type TokenUsageResult, type TypeScale, type TypeScaleLevel, type UnusedTokenResult, addCustomCategory, addExtractedToken, adjustSemanticForDark, applyAddCategory, applyBulkChange, applyBulkMove, applyChange, applyDarkModeToDOM, applyDensity, applyDensityToDOM, applyExtract, applyMove, applySurface, applySurfaceToDOM, applyThemeToDOM, auditReportToMarkdown, bulkMoveTokens, calculateQualityScore, captureSnapshot, checkConsistency, clampControlPoint, clearSnapshots, clearSurface, clearThemeFromDOM, clearUsageCache, contrastRatio, countTokenUsage, createOverlay, createReassignmentState, createThemeEditorState, darken, downloadAuditReport, downloadStyleGuide, downloadThemeAsJSON, downloadW3CTokens, ensureContrastOnWhite, exportTheme, exportToW3CFormat, extractToken, findContrastIssues, findPreset, findPresetByValue, findToken, findUnusedTokens, formatCubicBezier, generateAuditReport, generateDarkTheme, generateScale, generateStyleGuide, generateTypeScale, getActiveDensity, getActiveSurface, getAllCategoryLabels, getDensityCSS, getDependents, getEffectiveCategories, getOpeningSnapshot, getPresetsByCategory, getSnapshot, getSurfaceDefinition, getSurfaceOverrides, getTokenCategory, getTokenChain, getTokenUsageCount, getTokenUsageStats, hasExtractedToken, hexToHSL, hexToHsl, hslToHex$1 as hslToHex, hslToHex as hslToHexDark, invertLightness, isDark, isDarkMode, lighten, luminance, makePreset, markSaved, moveToken, parseCubicBezier, readSnapshots, readThemeFromFile, redo, redoReassignment, resetToDefaults, resolveMode, rotateHue, sampleBezierCurve, setDarkMode, simulateColourBlindness, simulateThemeColourBlindness, snapToGrid, suggestFix, suggestPairings, suggestPalettes, suggestTokenName, systemPrefersDark, themesAreEqual, typeScaleToCSSVars, undo, undoReassignment, validateImport, validateTokenName };
|
|
910
|
+
export { type ConsistencyIssue$1 as AuditConsistencyIssue, type ContrastIssue$1 as AuditContrastIssue, type QualityBreakdown$1 as AuditQualityBreakdown, type AuditReport, BUILT_IN_PRESETS, COLOUR_BLINDNESS_TYPES, type ColourBlindnessInfo, type ColourBlindnessType, type ColourSuggestion, type ConsistencyIssue, type ContrastIssue$2 as ContrastIssue, type CustomPreset, type CustomTokenDef, DENSITY_CONFIGS, type DarkModeConfig, type DensityConfig, type DensityMode, type DesignSystemAdapter, type ThemePreset as DesignThemePreset, EASING_PRESETS, type EasingPreset, type ExtractedTokenDef, FONT_PAIRINGS, type FontPairing, type HSL, type HarmonyType, type QualityBreakdown$2 as QualityBreakdown, type ReassignmentAction, type ReassignmentState, type RegistryOverlay, SCALE_RATIOS, SURFACE_DEFINITIONS, type ScaleRatio, type SurfaceDefinition, type SurfaceType, THEME_CATEGORIES, THEME_DEFAULTS, THEME_KEY_TO_CSS, TOKEN_REGISTRY, type ThemeEditorState, type ThemeExport, type ThemeExportPayload, type ThemePreset$1 as ThemePreset, type ThemeSnapshot, type ThemeVersion, type TokenCategory, type TokenDefinition, type TokenUsageResult, type TypeScale, type TypeScaleLevel, type UnusedTokenResult, addCustomCategory, addExtractedToken, adjustSemanticForDark, applyAddCategory, applyBulkChange, applyBulkMove, applyChange, applyDarkModeToDOM, applyDensity, applyDensityToDOM, applyExtract, applyMove, applySurface, applySurfaceToDOM, applyThemeToDOM, auditReportToMarkdown, bulkMoveTokens, calculateQualityScore, captureSnapshot, checkConsistency, clampControlPoint, clearSnapshots, clearSurface, clearThemeFromDOM, clearUsageCache, contrastRatio, countTokenUsage, createOverlay, createReassignmentState, createThemeEditorState, customTokenDefaults, darken, downloadAuditReport, downloadStyleGuide, downloadThemeAsJSON, downloadW3CTokens, ensureContrastOnWhite, exportTheme, exportToW3CFormat, extractToken, findContrastIssues, findPreset, findPresetByValue, findToken, findUnusedTokens, formatCubicBezier, generateAuditReport, generateDarkTheme, generateScale, generateStyleGuide, generateTypeScale, getActiveDensity, getActiveSurface, getAllCategoryLabels, getDensityCSS, getDependents, getEffectiveCategories, getOpeningSnapshot, getPresetsByCategory, getSnapshot, getSurfaceDefinition, getSurfaceOverrides, getTokenCategory, getTokenChain, getTokenUsageCount, getTokenUsageStats, hasExtractedToken, hexToHSL, hexToHsl, hslToHex$1 as hslToHex, hslToHex as hslToHexDark, invertLightness, isDark, isDarkMode, lighten, luminance, makePreset, markSaved, moveToken, parseCubicBezier, readSnapshots, readThemeFromFile, redo, redoReassignment, resetToDefaults, resolveMode, rotateHue, sampleBezierCurve, setDarkMode, simulateColourBlindness, simulateThemeColourBlindness, snapToGrid, suggestFix, suggestPairings, suggestPalettes, suggestTokenName, systemPrefersDark, themesAreEqual, typeScaleToCSSVars, undo, undoReassignment, validateImport, validateTokenName };
|
package/dist/index.d.ts
CHANGED
|
@@ -140,6 +140,27 @@ declare function suggestPalettes(primaryHex: string): ColourSuggestion[];
|
|
|
140
140
|
* These are the canonical defaults for the design system package.
|
|
141
141
|
*/
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* A host-defined theme token, declared by a consuming app so its own bespoke
|
|
145
|
+
* tokens flow through the SnagTag editor + DOM pipeline without forking the
|
|
146
|
+
* built-in maps. See docs/LAYER2-HOST-EXTENSIBLE-TOKENS-PROPOSAL.md.
|
|
147
|
+
*/
|
|
148
|
+
interface CustomTokenDef {
|
|
149
|
+
/** Theme key used in the persisted overrides map + editor state (e.g. 'statusWatching'). */
|
|
150
|
+
key: string;
|
|
151
|
+
/** CSS custom property written to :root (e.g. '--status-watching'). */
|
|
152
|
+
cssVar: string;
|
|
153
|
+
/** Default colour value, used until the user overrides it. */
|
|
154
|
+
defaultValue: string;
|
|
155
|
+
/** Editor category to group the swatch under. Defaults to 'Custom'. */
|
|
156
|
+
category?: string;
|
|
157
|
+
/** Optional human label (the colour editor otherwise derives one from `key`). */
|
|
158
|
+
label?: string;
|
|
159
|
+
/** Optional CSS var this token references, for inspector chain tracing. */
|
|
160
|
+
references?: string;
|
|
161
|
+
}
|
|
162
|
+
/** Build a { key: defaultValue } map from custom token definitions. */
|
|
163
|
+
declare function customTokenDefaults(tokens?: CustomTokenDef[]): Record<string, string>;
|
|
143
164
|
/**
|
|
144
165
|
* The hardcoded defaults matching a standard design system theme.
|
|
145
166
|
* These are the "factory" values used when no overrides are set.
|
|
@@ -803,13 +824,18 @@ declare function downloadAuditReport(report: AuditReport): void;
|
|
|
803
824
|
* DOM utilities for applying and clearing theme values on the document root.
|
|
804
825
|
* These functions set/remove CSS custom properties on document.documentElement.
|
|
805
826
|
*/
|
|
827
|
+
|
|
806
828
|
/**
|
|
807
829
|
* Apply a merged theme to the DOM by setting CSS custom properties on :root.
|
|
808
830
|
* Derives sidebar states and accent variants automatically.
|
|
831
|
+
*
|
|
832
|
+
* Pass `customTokens` to also write host-defined tokens (each `cssVar` is set
|
|
833
|
+
* from `merged[key]`, falling back to the token's `defaultValue`). Omitting it
|
|
834
|
+
* leaves behaviour identical to before.
|
|
809
835
|
*/
|
|
810
|
-
declare function applyThemeToDOM(merged: Record<string, string
|
|
836
|
+
declare function applyThemeToDOM(merged: Record<string, string>, customTokens?: CustomTokenDef[]): void;
|
|
811
837
|
/** Remove all theme overrides from :root, restoring CSS defaults. */
|
|
812
|
-
declare function clearThemeFromDOM(): void;
|
|
838
|
+
declare function clearThemeFromDOM(customTokens?: CustomTokenDef[]): void;
|
|
813
839
|
|
|
814
840
|
/**
|
|
815
841
|
* Contrast Fix Engine - scans colour token pairs for WCAG AA failures
|
|
@@ -881,4 +907,4 @@ interface QualityBreakdown {
|
|
|
881
907
|
*/
|
|
882
908
|
declare function calculateQualityScore(overrides?: Record<string, string>): QualityBreakdown;
|
|
883
909
|
|
|
884
|
-
export { type ConsistencyIssue$1 as AuditConsistencyIssue, type ContrastIssue$1 as AuditContrastIssue, type QualityBreakdown$1 as AuditQualityBreakdown, type AuditReport, BUILT_IN_PRESETS, COLOUR_BLINDNESS_TYPES, type ColourBlindnessInfo, type ColourBlindnessType, type ColourSuggestion, type ConsistencyIssue, type ContrastIssue$2 as ContrastIssue, type CustomPreset, DENSITY_CONFIGS, type DarkModeConfig, type DensityConfig, type DensityMode, type DesignSystemAdapter, type ThemePreset as DesignThemePreset, EASING_PRESETS, type EasingPreset, type ExtractedTokenDef, FONT_PAIRINGS, type FontPairing, type HSL, type HarmonyType, type QualityBreakdown$2 as QualityBreakdown, type ReassignmentAction, type ReassignmentState, type RegistryOverlay, SCALE_RATIOS, SURFACE_DEFINITIONS, type ScaleRatio, type SurfaceDefinition, type SurfaceType, THEME_CATEGORIES, THEME_DEFAULTS, THEME_KEY_TO_CSS, TOKEN_REGISTRY, type ThemeEditorState, type ThemeExport, type ThemeExportPayload, type ThemePreset$1 as ThemePreset, type ThemeSnapshot, type ThemeVersion, type TokenCategory, type TokenDefinition, type TokenUsageResult, type TypeScale, type TypeScaleLevel, type UnusedTokenResult, addCustomCategory, addExtractedToken, adjustSemanticForDark, applyAddCategory, applyBulkChange, applyBulkMove, applyChange, applyDarkModeToDOM, applyDensity, applyDensityToDOM, applyExtract, applyMove, applySurface, applySurfaceToDOM, applyThemeToDOM, auditReportToMarkdown, bulkMoveTokens, calculateQualityScore, captureSnapshot, checkConsistency, clampControlPoint, clearSnapshots, clearSurface, clearThemeFromDOM, clearUsageCache, contrastRatio, countTokenUsage, createOverlay, createReassignmentState, createThemeEditorState, darken, downloadAuditReport, downloadStyleGuide, downloadThemeAsJSON, downloadW3CTokens, ensureContrastOnWhite, exportTheme, exportToW3CFormat, extractToken, findContrastIssues, findPreset, findPresetByValue, findToken, findUnusedTokens, formatCubicBezier, generateAuditReport, generateDarkTheme, generateScale, generateStyleGuide, generateTypeScale, getActiveDensity, getActiveSurface, getAllCategoryLabels, getDensityCSS, getDependents, getEffectiveCategories, getOpeningSnapshot, getPresetsByCategory, getSnapshot, getSurfaceDefinition, getSurfaceOverrides, getTokenCategory, getTokenChain, getTokenUsageCount, getTokenUsageStats, hasExtractedToken, hexToHSL, hexToHsl, hslToHex$1 as hslToHex, hslToHex as hslToHexDark, invertLightness, isDark, isDarkMode, lighten, luminance, makePreset, markSaved, moveToken, parseCubicBezier, readSnapshots, readThemeFromFile, redo, redoReassignment, resetToDefaults, resolveMode, rotateHue, sampleBezierCurve, setDarkMode, simulateColourBlindness, simulateThemeColourBlindness, snapToGrid, suggestFix, suggestPairings, suggestPalettes, suggestTokenName, systemPrefersDark, themesAreEqual, typeScaleToCSSVars, undo, undoReassignment, validateImport, validateTokenName };
|
|
910
|
+
export { type ConsistencyIssue$1 as AuditConsistencyIssue, type ContrastIssue$1 as AuditContrastIssue, type QualityBreakdown$1 as AuditQualityBreakdown, type AuditReport, BUILT_IN_PRESETS, COLOUR_BLINDNESS_TYPES, type ColourBlindnessInfo, type ColourBlindnessType, type ColourSuggestion, type ConsistencyIssue, type ContrastIssue$2 as ContrastIssue, type CustomPreset, type CustomTokenDef, DENSITY_CONFIGS, type DarkModeConfig, type DensityConfig, type DensityMode, type DesignSystemAdapter, type ThemePreset as DesignThemePreset, EASING_PRESETS, type EasingPreset, type ExtractedTokenDef, FONT_PAIRINGS, type FontPairing, type HSL, type HarmonyType, type QualityBreakdown$2 as QualityBreakdown, type ReassignmentAction, type ReassignmentState, type RegistryOverlay, SCALE_RATIOS, SURFACE_DEFINITIONS, type ScaleRatio, type SurfaceDefinition, type SurfaceType, THEME_CATEGORIES, THEME_DEFAULTS, THEME_KEY_TO_CSS, TOKEN_REGISTRY, type ThemeEditorState, type ThemeExport, type ThemeExportPayload, type ThemePreset$1 as ThemePreset, type ThemeSnapshot, type ThemeVersion, type TokenCategory, type TokenDefinition, type TokenUsageResult, type TypeScale, type TypeScaleLevel, type UnusedTokenResult, addCustomCategory, addExtractedToken, adjustSemanticForDark, applyAddCategory, applyBulkChange, applyBulkMove, applyChange, applyDarkModeToDOM, applyDensity, applyDensityToDOM, applyExtract, applyMove, applySurface, applySurfaceToDOM, applyThemeToDOM, auditReportToMarkdown, bulkMoveTokens, calculateQualityScore, captureSnapshot, checkConsistency, clampControlPoint, clearSnapshots, clearSurface, clearThemeFromDOM, clearUsageCache, contrastRatio, countTokenUsage, createOverlay, createReassignmentState, createThemeEditorState, customTokenDefaults, darken, downloadAuditReport, downloadStyleGuide, downloadThemeAsJSON, downloadW3CTokens, ensureContrastOnWhite, exportTheme, exportToW3CFormat, extractToken, findContrastIssues, findPreset, findPresetByValue, findToken, findUnusedTokens, formatCubicBezier, generateAuditReport, generateDarkTheme, generateScale, generateStyleGuide, generateTypeScale, getActiveDensity, getActiveSurface, getAllCategoryLabels, getDensityCSS, getDependents, getEffectiveCategories, getOpeningSnapshot, getPresetsByCategory, getSnapshot, getSurfaceDefinition, getSurfaceOverrides, getTokenCategory, getTokenChain, getTokenUsageCount, getTokenUsageStats, hasExtractedToken, hexToHSL, hexToHsl, hslToHex$1 as hslToHex, hslToHex as hslToHexDark, invertLightness, isDark, isDarkMode, lighten, luminance, makePreset, markSaved, moveToken, parseCubicBezier, readSnapshots, readThemeFromFile, redo, redoReassignment, resetToDefaults, resolveMode, rotateHue, sampleBezierCurve, setDarkMode, simulateColourBlindness, simulateThemeColourBlindness, snapToGrid, suggestFix, suggestPairings, suggestPalettes, suggestTokenName, systemPrefersDark, themesAreEqual, typeScaleToCSSVars, undo, undoReassignment, validateImport, validateTokenName };
|
package/dist/index.js
CHANGED
|
@@ -189,6 +189,11 @@ function suggestPalettes(primaryHex) {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
// src/theme-defaults.ts
|
|
192
|
+
function customTokenDefaults(tokens = []) {
|
|
193
|
+
const out = {};
|
|
194
|
+
for (const t of tokens) out[t.key] = t.defaultValue;
|
|
195
|
+
return out;
|
|
196
|
+
}
|
|
192
197
|
var THEME_DEFAULTS = {
|
|
193
198
|
// Primitives
|
|
194
199
|
primaryColor: "#2563eb",
|
|
@@ -2649,7 +2654,7 @@ function downloadAuditReport(report) {
|
|
|
2649
2654
|
}
|
|
2650
2655
|
|
|
2651
2656
|
// src/dom.ts
|
|
2652
|
-
function applyThemeToDOM(merged) {
|
|
2657
|
+
function applyThemeToDOM(merged, customTokens = []) {
|
|
2653
2658
|
const root = document.documentElement;
|
|
2654
2659
|
if (merged.primaryColor) {
|
|
2655
2660
|
merged.primaryColor = ensureContrastOnWhite(merged.primaryColor);
|
|
@@ -2686,12 +2691,23 @@ function applyThemeToDOM(merged) {
|
|
|
2686
2691
|
const accent = merged.accentColor || THEME_DEFAULTS.accentColor;
|
|
2687
2692
|
root.style.setProperty("--color-accent-light", lighten(accent, 0.85));
|
|
2688
2693
|
root.style.setProperty("--color-accent-hover", darken(accent, 0.15));
|
|
2694
|
+
for (const token of customTokens) {
|
|
2695
|
+
const value = merged[token.key] ?? token.defaultValue;
|
|
2696
|
+
if (value) {
|
|
2697
|
+
root.style.setProperty(token.cssVar, value);
|
|
2698
|
+
} else {
|
|
2699
|
+
root.style.removeProperty(token.cssVar);
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2689
2702
|
}
|
|
2690
|
-
function clearThemeFromDOM() {
|
|
2703
|
+
function clearThemeFromDOM(customTokens = []) {
|
|
2691
2704
|
const root = document.documentElement;
|
|
2692
2705
|
for (const cssVar of Object.values(THEME_KEY_TO_CSS)) {
|
|
2693
2706
|
root.style.removeProperty(cssVar);
|
|
2694
2707
|
}
|
|
2708
|
+
for (const token of customTokens) {
|
|
2709
|
+
root.style.removeProperty(token.cssVar);
|
|
2710
|
+
}
|
|
2695
2711
|
for (const v of [
|
|
2696
2712
|
"--color-sidebar-border",
|
|
2697
2713
|
"--color-sidebar-hover",
|
|
@@ -3056,6 +3072,7 @@ export {
|
|
|
3056
3072
|
createOverlay,
|
|
3057
3073
|
createReassignmentState,
|
|
3058
3074
|
createThemeEditorState,
|
|
3075
|
+
customTokenDefaults,
|
|
3059
3076
|
darken,
|
|
3060
3077
|
downloadAuditReport,
|
|
3061
3078
|
downloadStyleGuide,
|
package/dist/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snagtag/design-system",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"buildTimestamp": "2026-06-14T12:
|
|
5
|
-
"contentHash": "
|
|
3
|
+
"version": "0.2.3",
|
|
4
|
+
"buildTimestamp": "2026-06-14T12:39:20.596Z",
|
|
5
|
+
"contentHash": "2a8368cc6251997e",
|
|
6
6
|
"changes": [],
|
|
7
7
|
"breaking": false,
|
|
8
8
|
"siblings": {}
|