fix(BOOK-622): Removed blending step for hover colors and respect original values from design system instead

Approved-by: Linus Flood
This commit is contained in:
Erik Tiekstra
2025-12-02 06:24:59 +00:00
parent 3e4ac2c270
commit 8f7e4b8d06
21 changed files with 747 additions and 428 deletions

View File

@@ -1,4 +1,4 @@
import { colord, extend } from 'colord'
import { extend } from 'colord'
import mixPlugin from 'colord/plugins/mix'
import fs from 'node:fs'
@@ -238,60 +238,6 @@ themes.forEach((themeTokenValues) => {
})
})
// Process hover alpha colors
// All */Hover* styles will blend with */Default
themes.forEach((themeTokenValue) => {
themeTokenValue.forEach((value, token) => {
if (token.toLowerCase().indexOf('hover') >= 0) {
const hoverValue = value.resolved
if (typeof hoverValue === 'string') {
if (hoverValue.startsWith('#') && hoverValue.length === 9) {
// The color that the hover color with alpha mixes with.
const baseToken = token
.split('/')
.map((tokenPart) => {
if (tokenPart.toLowerCase().indexOf('hover') >= 0) {
return 'Default'
}
return tokenPart
})
.join('/')
const baseValue =
themeTokenValue.get(baseToken) ??
themes.get(FALLBACK_THEME)?.get(baseToken)
if (baseValue) {
if (typeof baseValue.resolved === 'string' && baseValue.resolved) {
const baseColor = colord(baseValue.resolved)
const hoverColor = colord(hoverValue)
if (baseColor.alpha() > 0 && hoverColor.alpha() > 0) {
const computedHoverValue = baseColor
.mix(hoverColor.alpha(1), hoverColor.alpha())
.toHex()
themeTokenValue.set(token, {
// no alias for the computed hover color
resolved: computedHoverValue,
})
}
} else {
throw new Error(
`Base token ${baseToken} is unresolved: ${baseValue}`
)
}
} else {
throw new Error(
`Unable to find base token (${baseToken}) for hover token ${token}`
)
}
}
}
}
})
})
// Prepare for output
const variablesJsOutput = [
'/* This file is generated, do not edit manually! */',