|
|
@@ -1,11 +1,11 @@
|
|
|
import type { ColorValue, DesktopTheme, HexColor, ResolvedTheme, ThemeVariant } from "./types"
|
|
|
-import { blend, generateNeutralScale, generateScale, hexToOklch, hexToRgb, shift, withAlpha } from "./color"
|
|
|
+import { blend, generateNeutralScale, generateScale, hexToRgb, shift, withAlpha } from "./color"
|
|
|
|
|
|
export function resolveThemeVariant(variant: ThemeVariant, isDark: boolean): ResolvedTheme {
|
|
|
const colors = getColors(variant)
|
|
|
const { overrides = {} } = variant
|
|
|
|
|
|
- const neutral = generateNeutralScale(colors.neutral, isDark, colors.ink)
|
|
|
+ const neutral = generateNeutralScale(colors.neutral, isDark)
|
|
|
const primary = generateScale(colors.primary, isDark)
|
|
|
const accent = generateScale(colors.accent, isDark)
|
|
|
const success = generateScale(colors.success, isDark)
|
|
|
@@ -14,67 +14,42 @@ export function resolveThemeVariant(variant: ThemeVariant, isDark: boolean): Res
|
|
|
const info = generateScale(colors.info, isDark)
|
|
|
const interactive = generateScale(colors.interactive, isDark)
|
|
|
const amber = generateScale(
|
|
|
- shift(colors.warning, isDark ? { h: -16, l: -0.058, c: 1.14 } : { h: -22, l: -0.082, c: 0.94 }),
|
|
|
+ shift(colors.warning, isDark ? { h: -14, l: -0.028, c: 1.06 } : { h: -18, l: -0.042, c: 1.02 }),
|
|
|
isDark,
|
|
|
)
|
|
|
- const blue = generateScale(shift(colors.interactive, { h: -12, l: 0.128, c: 1.12 }), isDark)
|
|
|
+ const blue = generateScale(shift(colors.interactive, { h: -12, l: isDark ? 0.048 : 0.072, c: 1.06 }), isDark)
|
|
|
const diffAdd = generateScale(
|
|
|
- colors.diffAdd ?? shift(colors.success, { c: isDark ? 0.7 : 0.55, l: isDark ? -0.18 : 0.14 }),
|
|
|
+ colors.diffAdd ?? shift(colors.success, { c: isDark ? 0.82 : 0.72, l: isDark ? -0.06 : 0.06 }),
|
|
|
isDark,
|
|
|
)
|
|
|
const diffDelete = generateScale(
|
|
|
- colors.diffDelete ?? shift(colors.error, { c: isDark ? 0.82 : 0.7, l: isDark ? -0.08 : 0.08 }),
|
|
|
+ colors.diffDelete ?? shift(colors.error, { c: isDark ? 0.88 : 0.74, l: isDark ? -0.04 : 0.04 }),
|
|
|
isDark,
|
|
|
)
|
|
|
- const ink = colors.ink ?? colors.neutral
|
|
|
- const tint = colors.compact ? hexToOklch(ink) : undefined
|
|
|
- const body = tint
|
|
|
- ? shift(ink, {
|
|
|
- l: isDark ? Math.max(0, 0.88 - tint.l) * 0.4 : -Math.max(0, tint.l - 0.18) * 0.24,
|
|
|
- c: isDark ? 1.04 : 1.02,
|
|
|
- })
|
|
|
- : undefined
|
|
|
const backgroundOverride = overrides["background-base"]
|
|
|
const backgroundHex = getHex(backgroundOverride)
|
|
|
const overlay = Boolean(backgroundOverride) && !backgroundHex
|
|
|
- const content = (seed: HexColor, scale: HexColor[]) => {
|
|
|
- const base = hexToOklch(seed)
|
|
|
- const value = isDark ? (base.l > 0.84 ? shift(seed, { c: 1.18 }) : scale[10]) : scale[10]
|
|
|
- return shift(value, { l: isDark ? 0.034 : -0.024, c: isDark ? 1.3 : 1.18 })
|
|
|
- }
|
|
|
- const modified = () => {
|
|
|
- if (!colors.compact) return isDark ? "#ffba92" : "#FF8C00"
|
|
|
- const warningHue = hexToOklch(colors.warning).h
|
|
|
- const deleteHue = hexToOklch(colors.diffDelete ?? colors.error).h
|
|
|
- const delta = Math.abs(((((deleteHue - warningHue) % 360) + 540) % 360) - 180)
|
|
|
- if (delta < 48) return isDark ? "#ffba92" : "#FF8C00"
|
|
|
- return content(colors.warning, warning)
|
|
|
- }
|
|
|
- const surface = (
|
|
|
- seed: HexColor,
|
|
|
- alpha: { base: number; weak: number; weaker: number; strong: number; stronger: number },
|
|
|
- ) => {
|
|
|
- const base = alphaTone(seed, alpha.base)
|
|
|
- return {
|
|
|
- base,
|
|
|
- weak: alphaTone(seed, alpha.weak),
|
|
|
- weaker: alphaTone(seed, alpha.weaker),
|
|
|
- strong: alphaTone(seed, alpha.strong),
|
|
|
- stronger: alphaTone(seed, alpha.stronger),
|
|
|
- }
|
|
|
- }
|
|
|
const background = backgroundHex ?? neutral[0]
|
|
|
const alphaTone = (color: HexColor, alpha: number) =>
|
|
|
overlay ? (withAlpha(color, alpha) as ColorValue) : blend(color, background, alpha)
|
|
|
- const borderTone = (light: number, dark: number) =>
|
|
|
- alphaTone(ink, isDark ? Math.min(1, dark + 0.024 + (colors.compact ? 0.08 : 0)) : Math.min(1, light + 0.024))
|
|
|
+ const content = (scale: HexColor[], idx = 10) =>
|
|
|
+ shift(scale[idx], { l: isDark ? 0.012 : -0.014, c: isDark ? 0.94 : 0.9 })
|
|
|
+ const surface = (
|
|
|
+ seed: HexColor,
|
|
|
+ alpha: { base: number; weak: number; weaker: number; strong: number; stronger: number },
|
|
|
+ ) => ({
|
|
|
+ base: alphaTone(seed, alpha.base),
|
|
|
+ weak: alphaTone(seed, alpha.weak),
|
|
|
+ weaker: alphaTone(seed, alpha.weaker),
|
|
|
+ strong: alphaTone(seed, alpha.strong),
|
|
|
+ stronger: alphaTone(seed, alpha.stronger),
|
|
|
+ })
|
|
|
const diffHiddenSurface = surface(
|
|
|
- isDark ? shift(colors.interactive, { c: 0.55, l: 0 }) : shift(colors.interactive, { c: 0.45, l: 0.08 }),
|
|
|
+ isDark ? shift(colors.interactive, { c: 0.56 }) : shift(colors.interactive, { c: 0.42, l: 0.06 }),
|
|
|
isDark
|
|
|
? { base: 0.14, weak: 0.08, weaker: 0.18, strong: 0.26, stronger: 0.42 }
|
|
|
: { base: 0.12, weak: 0.08, weaker: 0.16, strong: 0.24, stronger: 0.36 },
|
|
|
)
|
|
|
-
|
|
|
const neutralAlpha = generateNeutralAlphaScale(neutral, isDark)
|
|
|
const brandb = primary[8]
|
|
|
const brandh = primary[9]
|
|
|
@@ -95,7 +70,7 @@ export function resolveThemeVariant(variant: ThemeVariant, isDark: boolean): Res
|
|
|
const infos = info[10]
|
|
|
const lum = (hex: HexColor) => {
|
|
|
const rgb = hexToRgb(hex)
|
|
|
- const lift = (v: number) => (v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4))
|
|
|
+ const lift = (value: number) => (value <= 0.04045 ? value / 12.92 : Math.pow((value + 0.055) / 1.055, 2.4))
|
|
|
return 0.2126 * lift(rgb.r) + 0.7152 * lift(rgb.g) + 0.0722 * lift(rgb.b)
|
|
|
}
|
|
|
const hit = (a: HexColor, b: HexColor) => {
|
|
|
@@ -110,40 +85,46 @@ export function resolveThemeVariant(variant: ThemeVariant, isDark: boolean): Res
|
|
|
const dark = "#000000" as HexColor
|
|
|
return hit(light, fill) > hit(dark, fill) ? light : dark
|
|
|
}
|
|
|
-
|
|
|
+ const pink = generateScale(shift(colors.error, isDark ? { h: -42, c: 0.84 } : { h: -48, l: 0.024, c: 0.74 }), isDark)
|
|
|
+ const mint = success
|
|
|
+ const orange = amber
|
|
|
+ const purple = accent
|
|
|
+ const cyan = info
|
|
|
+ const lime = generateScale(
|
|
|
+ shift(colors.primary, isDark ? { h: -76, l: -0.03, c: 0.78 } : { h: -86, l: 0.024, c: 0.72 }),
|
|
|
+ isDark,
|
|
|
+ )
|
|
|
const tokens: ResolvedTheme = {}
|
|
|
|
|
|
tokens["background-base"] = neutral[0]
|
|
|
tokens["background-weak"] = neutral[2]
|
|
|
tokens["background-strong"] = neutral[0]
|
|
|
- tokens["background-stronger"] = isDark ? neutral[1] : "#fcfcfc"
|
|
|
+ tokens["background-stronger"] = neutral[1]
|
|
|
|
|
|
tokens["surface-base"] = neutralAlpha[1]
|
|
|
tokens["base"] = neutralAlpha[1]
|
|
|
tokens["surface-base-hover"] = neutralAlpha[2]
|
|
|
tokens["surface-base-active"] = neutralAlpha[2]
|
|
|
- tokens["surface-base-interactive-active"] = withAlpha(interactive[2], 0.3) as ColorValue
|
|
|
+ tokens["surface-base-interactive-active"] = withAlpha(interactive[2], isDark ? 0.32 : 0.24) as ColorValue
|
|
|
tokens["base2"] = neutralAlpha[1]
|
|
|
tokens["base3"] = neutralAlpha[1]
|
|
|
tokens["surface-inset-base"] = neutralAlpha[1]
|
|
|
tokens["surface-inset-base-hover"] = neutralAlpha[2]
|
|
|
- tokens["surface-inset-strong"] = isDark
|
|
|
- ? (withAlpha(neutral[0], 0.5) as ColorValue)
|
|
|
- : (withAlpha(neutral[3], 0.09) as ColorValue)
|
|
|
- tokens["surface-inset-strong-hover"] = tokens["surface-inset-strong"]
|
|
|
+ tokens["surface-inset-strong"] = alphaTone(neutral[11], isDark ? 0.08 : 0.04)
|
|
|
+ tokens["surface-inset-strong-hover"] = alphaTone(neutral[11], isDark ? 0.12 : 0.06)
|
|
|
tokens["surface-raised-base"] = neutralAlpha[0]
|
|
|
tokens["surface-float-base"] = isDark ? neutral[1] : neutral[11]
|
|
|
tokens["surface-float-base-hover"] = isDark ? neutral[2] : neutral[10]
|
|
|
tokens["surface-raised-base-hover"] = neutralAlpha[1]
|
|
|
tokens["surface-raised-base-active"] = neutralAlpha[2]
|
|
|
tokens["surface-raised-strong"] = isDark ? neutralAlpha[3] : neutral[0]
|
|
|
- tokens["surface-raised-strong-hover"] = isDark ? neutralAlpha[5] : "#ffffff"
|
|
|
- tokens["surface-raised-stronger"] = isDark ? neutralAlpha[5] : "#ffffff"
|
|
|
- tokens["surface-raised-stronger-hover"] = isDark ? neutralAlpha[6] : "#ffffff"
|
|
|
+ tokens["surface-raised-strong-hover"] = isDark ? neutralAlpha[5] : neutral[0]
|
|
|
+ tokens["surface-raised-stronger"] = isDark ? neutralAlpha[5] : neutral[0]
|
|
|
+ tokens["surface-raised-stronger-hover"] = isDark ? neutralAlpha[6] : neutral[1]
|
|
|
tokens["surface-weak"] = neutralAlpha[2]
|
|
|
tokens["surface-weaker"] = neutralAlpha[3]
|
|
|
- tokens["surface-strong"] = isDark ? neutralAlpha[6] : "#ffffff"
|
|
|
- tokens["surface-raised-stronger-non-alpha"] = isDark ? neutral[2] : "#ffffff"
|
|
|
+ tokens["surface-strong"] = isDark ? neutralAlpha[6] : neutral[0]
|
|
|
+ tokens["surface-raised-stronger-non-alpha"] = isDark ? neutral[2] : neutral[0]
|
|
|
|
|
|
tokens["surface-brand-base"] = brandb
|
|
|
tokens["surface-brand-hover"] = brandh
|
|
|
@@ -191,21 +172,15 @@ export function resolveThemeVariant(variant: ThemeVariant, isDark: boolean): Res
|
|
|
tokens["input-focus"] = isDark ? interactive[6] : interactive[0]
|
|
|
tokens["input-disabled"] = neutral[3]
|
|
|
|
|
|
- tokens["text-base"] = colors.compact ? (body as HexColor) : neutral[10]
|
|
|
- tokens["text-weak"] = colors.compact ? shift(body as HexColor, { l: isDark ? -0.11 : 0.11, c: 0.9 }) : neutral[8]
|
|
|
- tokens["text-weaker"] = colors.compact
|
|
|
- ? shift(body as HexColor, { l: isDark ? -0.2 : 0.21, c: isDark ? 0.78 : 0.72 })
|
|
|
- : neutral[7]
|
|
|
- tokens["text-strong"] = colors.compact
|
|
|
- ? isDark
|
|
|
- ? blend("#ffffff", body as HexColor, 0.9)
|
|
|
- : shift(body as HexColor, { l: -0.07, c: 1.04 })
|
|
|
- : neutral[11]
|
|
|
+ tokens["text-base"] = neutral[10]
|
|
|
+ tokens["text-weak"] = neutral[8]
|
|
|
+ tokens["text-weaker"] = neutral[7]
|
|
|
+ tokens["text-strong"] = neutral[11]
|
|
|
tokens["text-invert-base"] = isDark ? neutral[10] : neutral[1]
|
|
|
tokens["text-invert-weak"] = isDark ? neutral[8] : neutral[2]
|
|
|
tokens["text-invert-weaker"] = isDark ? neutral[7] : neutral[3]
|
|
|
tokens["text-invert-strong"] = isDark ? neutral[11] : neutral[0]
|
|
|
- tokens["text-interactive-base"] = interactive[isDark ? 10 : 9]
|
|
|
+ tokens["text-interactive-base"] = content(interactive)
|
|
|
tokens["text-on-brand-base"] = on(brandb)
|
|
|
tokens["text-on-interactive-base"] = on(interb)
|
|
|
tokens["text-on-interactive-weak"] = on(interb)
|
|
|
@@ -215,10 +190,10 @@ export function resolveThemeVariant(variant: ThemeVariant, isDark: boolean): Res
|
|
|
tokens["text-on-critical-strong"] = on(crits)
|
|
|
tokens["text-on-warning-base"] = on(warnb)
|
|
|
tokens["text-on-info-base"] = on(infob)
|
|
|
- tokens["text-diff-add-base"] = diffAdd[10]
|
|
|
- tokens["text-diff-delete-base"] = diffDelete[9]
|
|
|
+ tokens["text-diff-add-base"] = content(diffAdd)
|
|
|
+ tokens["text-diff-delete-base"] = content(diffDelete)
|
|
|
tokens["text-diff-delete-strong"] = diffDelete[11]
|
|
|
- tokens["text-diff-add-strong"] = diffAdd[isDark ? 7 : 11]
|
|
|
+ tokens["text-diff-add-strong"] = diffAdd[11]
|
|
|
tokens["text-on-info-weak"] = on(infob)
|
|
|
tokens["text-on-info-strong"] = on(infos)
|
|
|
tokens["text-on-warning-weak"] = on(warnb)
|
|
|
@@ -235,25 +210,25 @@ export function resolveThemeVariant(variant: ThemeVariant, isDark: boolean): Res
|
|
|
tokens["button-ghost-hover"] = neutralAlpha[1]
|
|
|
tokens["button-ghost-hover2"] = neutralAlpha[2]
|
|
|
|
|
|
- tokens["border-base"] = colors.compact ? borderTone(0.22, 0.16) : neutralAlpha[6]
|
|
|
- tokens["border-hover"] = colors.compact ? borderTone(0.28, 0.2) : neutralAlpha[7]
|
|
|
- tokens["border-active"] = colors.compact ? borderTone(0.34, 0.24) : neutralAlpha[8]
|
|
|
+ tokens["border-base"] = neutralAlpha[6]
|
|
|
+ tokens["border-hover"] = neutralAlpha[7]
|
|
|
+ tokens["border-active"] = neutralAlpha[8]
|
|
|
tokens["border-selected"] = withAlpha(interactive[8], isDark ? 0.9 : 0.99) as ColorValue
|
|
|
- tokens["border-disabled"] = colors.compact ? borderTone(0.18, 0.12) : neutralAlpha[7]
|
|
|
- tokens["border-focus"] = colors.compact ? borderTone(0.34, 0.24) : neutralAlpha[8]
|
|
|
- tokens["border-weak-base"] = colors.compact ? borderTone(0.1, 0.08) : neutralAlpha[isDark ? 5 : 4]
|
|
|
- tokens["border-strong-base"] = colors.compact ? borderTone(0.34, 0.24) : neutralAlpha[isDark ? 7 : 6]
|
|
|
- tokens["border-strong-hover"] = colors.compact ? borderTone(0.4, 0.28) : neutralAlpha[7]
|
|
|
- tokens["border-strong-active"] = colors.compact ? borderTone(0.46, 0.32) : neutralAlpha[isDark ? 7 : 6]
|
|
|
+ tokens["border-disabled"] = neutralAlpha[7]
|
|
|
+ tokens["border-focus"] = neutralAlpha[8]
|
|
|
+ tokens["border-weak-base"] = neutralAlpha[isDark ? 5 : 4]
|
|
|
+ tokens["border-strong-base"] = neutralAlpha[isDark ? 7 : 6]
|
|
|
+ tokens["border-strong-hover"] = neutralAlpha[7]
|
|
|
+ tokens["border-strong-active"] = neutralAlpha[isDark ? 7 : 6]
|
|
|
tokens["border-strong-selected"] = withAlpha(interactive[5], 0.6) as ColorValue
|
|
|
- tokens["border-strong-disabled"] = colors.compact ? borderTone(0.14, 0.1) : neutralAlpha[5]
|
|
|
- tokens["border-strong-focus"] = colors.compact ? borderTone(0.46, 0.32) : neutralAlpha[isDark ? 7 : 6]
|
|
|
- tokens["border-weak-hover"] = colors.compact ? borderTone(0.16, 0.12) : neutralAlpha[isDark ? 6 : 5]
|
|
|
- tokens["border-weak-active"] = colors.compact ? borderTone(0.22, 0.16) : neutralAlpha[isDark ? 7 : 6]
|
|
|
+ tokens["border-strong-disabled"] = neutralAlpha[5]
|
|
|
+ tokens["border-strong-focus"] = neutralAlpha[isDark ? 7 : 6]
|
|
|
+ tokens["border-weak-hover"] = neutralAlpha[isDark ? 6 : 5]
|
|
|
+ tokens["border-weak-active"] = neutralAlpha[isDark ? 7 : 6]
|
|
|
tokens["border-weak-selected"] = withAlpha(interactive[4], isDark ? 0.6 : 0.5) as ColorValue
|
|
|
- tokens["border-weak-disabled"] = colors.compact ? borderTone(0.08, 0.06) : neutralAlpha[5]
|
|
|
- tokens["border-weak-focus"] = colors.compact ? borderTone(0.22, 0.16) : neutralAlpha[isDark ? 7 : 6]
|
|
|
- tokens["border-weaker-base"] = colors.compact ? borderTone(0.06, 0.04) : neutralAlpha[2]
|
|
|
+ tokens["border-weak-disabled"] = neutralAlpha[5]
|
|
|
+ tokens["border-weak-focus"] = neutralAlpha[isDark ? 7 : 6]
|
|
|
+ tokens["border-weaker-base"] = neutralAlpha[2]
|
|
|
|
|
|
tokens["border-interactive-base"] = interactive[6]
|
|
|
tokens["border-interactive-hover"] = interactive[7]
|
|
|
@@ -262,27 +237,27 @@ export function resolveThemeVariant(variant: ThemeVariant, isDark: boolean): Res
|
|
|
tokens["border-interactive-disabled"] = neutral[7]
|
|
|
tokens["border-interactive-focus"] = interactive[8]
|
|
|
|
|
|
- tokens["border-success-base"] = success[isDark ? 6 : 6]
|
|
|
- tokens["border-success-hover"] = success[isDark ? 7 : 7]
|
|
|
+ tokens["border-success-base"] = success[6]
|
|
|
+ tokens["border-success-hover"] = success[7]
|
|
|
tokens["border-success-selected"] = success[8]
|
|
|
- tokens["border-warning-base"] = warning[isDark ? 6 : 6]
|
|
|
- tokens["border-warning-hover"] = warning[isDark ? 7 : 7]
|
|
|
+ tokens["border-warning-base"] = warning[6]
|
|
|
+ tokens["border-warning-hover"] = warning[7]
|
|
|
tokens["border-warning-selected"] = warning[8]
|
|
|
- tokens["border-critical-base"] = error[isDark ? 6 : 6]
|
|
|
- tokens["border-critical-hover"] = error[isDark ? 7 : 7]
|
|
|
+ tokens["border-critical-base"] = error[6]
|
|
|
+ tokens["border-critical-hover"] = error[7]
|
|
|
tokens["border-critical-selected"] = error[8]
|
|
|
- tokens["border-info-base"] = info[isDark ? 6 : 6]
|
|
|
- tokens["border-info-hover"] = info[isDark ? 7 : 7]
|
|
|
+ tokens["border-info-base"] = info[6]
|
|
|
+ tokens["border-info-hover"] = info[7]
|
|
|
tokens["border-info-selected"] = info[8]
|
|
|
- tokens["border-color"] = "#ffffff"
|
|
|
+ tokens["border-color"] = neutral[0]
|
|
|
|
|
|
- tokens["icon-base"] = colors.compact && !isDark ? tokens["text-weak"] : neutral[isDark ? 9 : 8]
|
|
|
- tokens["icon-hover"] = colors.compact && !isDark ? tokens["text-base"] : neutral[10]
|
|
|
- tokens["icon-active"] = colors.compact && !isDark ? tokens["text-strong"] : neutral[11]
|
|
|
- tokens["icon-selected"] = colors.compact && !isDark ? tokens["text-strong"] : neutral[11]
|
|
|
+ tokens["icon-base"] = neutral[isDark ? 9 : 8]
|
|
|
+ tokens["icon-hover"] = neutral[10]
|
|
|
+ tokens["icon-active"] = neutral[11]
|
|
|
+ tokens["icon-selected"] = neutral[11]
|
|
|
tokens["icon-disabled"] = neutral[isDark ? 6 : 7]
|
|
|
- tokens["icon-focus"] = colors.compact && !isDark ? tokens["text-strong"] : neutral[11]
|
|
|
- tokens["icon-invert-base"] = isDark ? neutral[0] : "#ffffff"
|
|
|
+ tokens["icon-focus"] = neutral[11]
|
|
|
+ tokens["icon-invert-base"] = neutral[0]
|
|
|
tokens["icon-weak-base"] = neutral[isDark ? 5 : 6]
|
|
|
tokens["icon-weak-hover"] = neutral[isDark ? 11 : 7]
|
|
|
tokens["icon-weak-active"] = neutral[8]
|
|
|
@@ -290,12 +265,12 @@ export function resolveThemeVariant(variant: ThemeVariant, isDark: boolean): Res
|
|
|
tokens["icon-weak-disabled"] = neutral[isDark ? 3 : 5]
|
|
|
tokens["icon-weak-focus"] = neutral[8]
|
|
|
tokens["icon-strong-base"] = neutral[11]
|
|
|
- tokens["icon-strong-hover"] = isDark ? "#f6f3f3" : "#151313"
|
|
|
- tokens["icon-strong-active"] = isDark ? "#fcfcfc" : "#020202"
|
|
|
- tokens["icon-strong-selected"] = isDark ? "#fdfcfc" : "#020202"
|
|
|
+ tokens["icon-strong-hover"] = neutral[11]
|
|
|
+ tokens["icon-strong-active"] = neutral[11]
|
|
|
+ tokens["icon-strong-selected"] = neutral[11]
|
|
|
tokens["icon-strong-disabled"] = neutral[7]
|
|
|
- tokens["icon-strong-focus"] = isDark ? "#fdfcfc" : "#020202"
|
|
|
- tokens["icon-brand-base"] = isDark ? "#ffffff" : neutral[11]
|
|
|
+ tokens["icon-strong-focus"] = neutral[11]
|
|
|
+ tokens["icon-brand-base"] = on(brandb)
|
|
|
tokens["icon-interactive-base"] = interactive[8]
|
|
|
tokens["icon-success-base"] = success[isDark ? 8 : 6]
|
|
|
tokens["icon-success-hover"] = success[9]
|
|
|
@@ -333,104 +308,65 @@ export function resolveThemeVariant(variant: ThemeVariant, isDark: boolean): Res
|
|
|
tokens["icon-on-info-selected"] = on(infos)
|
|
|
|
|
|
tokens["icon-diff-add-base"] = diffAdd[10]
|
|
|
- tokens["icon-diff-add-hover"] = diffAdd[isDark ? 9 : 11]
|
|
|
- tokens["icon-diff-add-active"] = diffAdd[isDark ? 10 : 11]
|
|
|
- tokens["icon-diff-delete-base"] = diffDelete[9]
|
|
|
- tokens["icon-diff-delete-hover"] = diffDelete[isDark ? 10 : 10]
|
|
|
- tokens["icon-diff-modified-base"] = modified()
|
|
|
-
|
|
|
- if (colors.compact) {
|
|
|
- tokens["syntax-comment"] = "var(--text-weak)"
|
|
|
- tokens["syntax-regexp"] = "var(--text-base)"
|
|
|
- tokens["syntax-string"] = content(colors.success, success)
|
|
|
- tokens["syntax-keyword"] = content(colors.accent, accent)
|
|
|
- tokens["syntax-primitive"] = content(colors.primary, primary)
|
|
|
- tokens["syntax-operator"] = isDark ? "var(--text-weak)" : "var(--text-base)"
|
|
|
- tokens["syntax-variable"] = "var(--text-strong)"
|
|
|
- tokens["syntax-property"] = content(colors.info, info)
|
|
|
- tokens["syntax-type"] = content(colors.warning, warning)
|
|
|
- tokens["syntax-constant"] = content(colors.accent, accent)
|
|
|
- tokens["syntax-punctuation"] = isDark ? "var(--text-weak)" : "var(--text-base)"
|
|
|
- tokens["syntax-object"] = "var(--text-strong)"
|
|
|
- tokens["syntax-success"] = success[10]
|
|
|
- tokens["syntax-warning"] = amber[10]
|
|
|
- tokens["syntax-critical"] = error[10]
|
|
|
- tokens["syntax-info"] = content(colors.info, info)
|
|
|
- tokens["syntax-diff-add"] = diffAdd[10]
|
|
|
- tokens["syntax-diff-delete"] = diffDelete[10]
|
|
|
- tokens["syntax-diff-unknown"] = "#ff0000"
|
|
|
-
|
|
|
- tokens["markdown-heading"] = content(colors.primary, primary)
|
|
|
- tokens["markdown-text"] = tokens["text-base"]
|
|
|
- tokens["markdown-link"] = content(colors.interactive, interactive)
|
|
|
- tokens["markdown-link-text"] = content(colors.info, info)
|
|
|
- tokens["markdown-code"] = content(colors.success, success)
|
|
|
- tokens["markdown-block-quote"] = content(colors.warning, warning)
|
|
|
- tokens["markdown-emph"] = content(colors.warning, warning)
|
|
|
- tokens["markdown-strong"] = content(colors.accent, accent)
|
|
|
- tokens["markdown-horizontal-rule"] = tokens["border-base"]
|
|
|
- tokens["markdown-list-item"] = content(colors.interactive, interactive)
|
|
|
- tokens["markdown-list-enumeration"] = content(colors.info, info)
|
|
|
- tokens["markdown-image"] = content(colors.interactive, interactive)
|
|
|
- tokens["markdown-image-text"] = content(colors.info, info)
|
|
|
- tokens["markdown-code-block"] = tokens["text-base"]
|
|
|
- }
|
|
|
-
|
|
|
- if (!colors.compact) {
|
|
|
- tokens["syntax-comment"] = "var(--text-weak)"
|
|
|
- tokens["syntax-regexp"] = "var(--text-base)"
|
|
|
- tokens["syntax-string"] = isDark ? "#00ceb9" : "#006656"
|
|
|
- tokens["syntax-keyword"] = "var(--text-weak)"
|
|
|
- tokens["syntax-primitive"] = isDark ? "#ffba92" : "#fb4804"
|
|
|
- tokens["syntax-operator"] = isDark ? "var(--text-weak)" : "var(--text-base)"
|
|
|
- tokens["syntax-variable"] = "var(--text-strong)"
|
|
|
- tokens["syntax-property"] = isDark ? "#ff9ae2" : "#ed6dc8"
|
|
|
- tokens["syntax-type"] = isDark ? "#ecf58c" : "#596600"
|
|
|
- tokens["syntax-constant"] = isDark ? "#93e9f6" : "#007b80"
|
|
|
- tokens["syntax-punctuation"] = isDark ? "var(--text-weak)" : "var(--text-base)"
|
|
|
- tokens["syntax-object"] = "var(--text-strong)"
|
|
|
- tokens["syntax-success"] = success[10]
|
|
|
- tokens["syntax-warning"] = amber[10]
|
|
|
- tokens["syntax-critical"] = error[10]
|
|
|
- tokens["syntax-info"] = isDark ? "#93e9f6" : "#0092a8"
|
|
|
- tokens["syntax-diff-add"] = diffAdd[10]
|
|
|
- tokens["syntax-diff-delete"] = diffDelete[10]
|
|
|
- tokens["syntax-diff-unknown"] = "#ff0000"
|
|
|
-
|
|
|
- tokens["markdown-heading"] = isDark ? "#9d7cd8" : "#d68c27"
|
|
|
- tokens["markdown-text"] = isDark ? "#eeeeee" : "#1a1a1a"
|
|
|
- tokens["markdown-link"] = isDark ? "#fab283" : "#3b7dd8"
|
|
|
- tokens["markdown-link-text"] = isDark ? "#56b6c2" : "#318795"
|
|
|
- tokens["markdown-code"] = isDark ? "#7fd88f" : "#3d9a57"
|
|
|
- tokens["markdown-block-quote"] = isDark ? "#e5c07b" : "#b0851f"
|
|
|
- tokens["markdown-emph"] = isDark ? "#e5c07b" : "#b0851f"
|
|
|
- tokens["markdown-strong"] = isDark ? "#f5a742" : "#d68c27"
|
|
|
- tokens["markdown-horizontal-rule"] = isDark ? "#808080" : "#8a8a8a"
|
|
|
- tokens["markdown-list-item"] = isDark ? "#fab283" : "#3b7dd8"
|
|
|
- tokens["markdown-list-enumeration"] = isDark ? "#56b6c2" : "#318795"
|
|
|
- tokens["markdown-image"] = isDark ? "#fab283" : "#3b7dd8"
|
|
|
- tokens["markdown-image-text"] = isDark ? "#56b6c2" : "#318795"
|
|
|
- tokens["markdown-code-block"] = isDark ? "#eeeeee" : "#1a1a1a"
|
|
|
- }
|
|
|
-
|
|
|
- tokens["avatar-background-pink"] = isDark ? "#501b3f" : "#feeef8"
|
|
|
- tokens["avatar-background-mint"] = isDark ? "#033a34" : "#e1fbf4"
|
|
|
- tokens["avatar-background-orange"] = isDark ? "#5f2a06" : "#fff1e7"
|
|
|
- tokens["avatar-background-purple"] = isDark ? "#432155" : "#f9f1fe"
|
|
|
- tokens["avatar-background-cyan"] = isDark ? "#0f3058" : "#e7f9fb"
|
|
|
- tokens["avatar-background-lime"] = isDark ? "#2b3711" : "#eefadc"
|
|
|
- tokens["avatar-text-pink"] = isDark ? "#e34ba9" : "#cd1d8d"
|
|
|
- tokens["avatar-text-mint"] = isDark ? "#95f3d9" : "#147d6f"
|
|
|
- tokens["avatar-text-orange"] = isDark ? "#ff802b" : "#ed5f00"
|
|
|
- tokens["avatar-text-purple"] = isDark ? "#9d5bd2" : "#8445bc"
|
|
|
- tokens["avatar-text-cyan"] = isDark ? "#369eff" : "#0894b3"
|
|
|
- tokens["avatar-text-lime"] = isDark ? "#c4f042" : "#5d770d"
|
|
|
+ tokens["icon-diff-add-hover"] = diffAdd[11]
|
|
|
+ tokens["icon-diff-add-active"] = diffAdd[11]
|
|
|
+ tokens["icon-diff-delete-base"] = diffDelete[10]
|
|
|
+ tokens["icon-diff-delete-hover"] = diffDelete[11]
|
|
|
+ tokens["icon-diff-modified-base"] = amber[10]
|
|
|
+
|
|
|
+ tokens["syntax-comment"] = "var(--text-weak)"
|
|
|
+ tokens["syntax-regexp"] = content(primary)
|
|
|
+ tokens["syntax-string"] = content(success)
|
|
|
+ tokens["syntax-keyword"] = content(accent)
|
|
|
+ tokens["syntax-primitive"] = content(primary)
|
|
|
+ tokens["syntax-operator"] = content(info)
|
|
|
+ tokens["syntax-variable"] = "var(--text-strong)"
|
|
|
+ tokens["syntax-property"] = content(info)
|
|
|
+ tokens["syntax-type"] = content(warning)
|
|
|
+ tokens["syntax-constant"] = content(accent)
|
|
|
+ tokens["syntax-punctuation"] = "var(--text-weak)"
|
|
|
+ tokens["syntax-object"] = "var(--text-strong)"
|
|
|
+ tokens["syntax-success"] = success[10]
|
|
|
+ tokens["syntax-warning"] = amber[10]
|
|
|
+ tokens["syntax-critical"] = error[10]
|
|
|
+ tokens["syntax-info"] = content(info)
|
|
|
+ tokens["syntax-diff-add"] = diffAdd[10]
|
|
|
+ tokens["syntax-diff-delete"] = diffDelete[10]
|
|
|
+ tokens["syntax-diff-unknown"] = content(accent)
|
|
|
+
|
|
|
+ tokens["markdown-heading"] = content(primary)
|
|
|
+ tokens["markdown-text"] = tokens["text-base"]
|
|
|
+ tokens["markdown-link"] = content(interactive)
|
|
|
+ tokens["markdown-link-text"] = content(info)
|
|
|
+ tokens["markdown-code"] = content(success)
|
|
|
+ tokens["markdown-block-quote"] = content(warning)
|
|
|
+ tokens["markdown-emph"] = content(warning)
|
|
|
+ tokens["markdown-strong"] = content(accent)
|
|
|
+ tokens["markdown-horizontal-rule"] = tokens["border-base"]
|
|
|
+ tokens["markdown-list-item"] = content(interactive)
|
|
|
+ tokens["markdown-list-enumeration"] = content(info)
|
|
|
+ tokens["markdown-image"] = content(interactive)
|
|
|
+ tokens["markdown-image-text"] = content(info)
|
|
|
+ tokens["markdown-code-block"] = tokens["text-base"]
|
|
|
+
|
|
|
+ tokens["avatar-background-pink"] = pink[isDark ? 2 : 1]
|
|
|
+ tokens["avatar-background-mint"] = mint[isDark ? 2 : 1]
|
|
|
+ tokens["avatar-background-orange"] = orange[isDark ? 2 : 1]
|
|
|
+ tokens["avatar-background-purple"] = purple[isDark ? 2 : 1]
|
|
|
+ tokens["avatar-background-cyan"] = cyan[isDark ? 2 : 1]
|
|
|
+ tokens["avatar-background-lime"] = lime[isDark ? 2 : 1]
|
|
|
+ tokens["avatar-text-pink"] = pink[9]
|
|
|
+ tokens["avatar-text-mint"] = mint[9]
|
|
|
+ tokens["avatar-text-orange"] = orange[9]
|
|
|
+ tokens["avatar-text-purple"] = purple[9]
|
|
|
+ tokens["avatar-text-cyan"] = cyan[9]
|
|
|
+ tokens["avatar-text-lime"] = lime[9]
|
|
|
|
|
|
for (const [key, value] of Object.entries(overrides)) {
|
|
|
tokens[key] = value
|
|
|
}
|
|
|
|
|
|
- if (colors.compact && "text-weak" in overrides && !("text-weaker" in overrides)) {
|
|
|
+ if ("text-weak" in overrides && !("text-weaker" in overrides)) {
|
|
|
const weak = tokens["text-weak"]
|
|
|
if (weak.startsWith("#")) {
|
|
|
tokens["text-weaker"] = shift(weak as HexColor, { l: isDark ? -0.12 : 0.12, c: 0.75 })
|
|
|
@@ -439,15 +375,12 @@ export function resolveThemeVariant(variant: ThemeVariant, isDark: boolean): Res
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (colors.compact) {
|
|
|
- if (!("markdown-text" in overrides)) {
|
|
|
- tokens["markdown-text"] = tokens["text-base"]
|
|
|
- }
|
|
|
- if (!("markdown-code-block" in overrides)) {
|
|
|
- tokens["markdown-code-block"] = tokens["text-base"]
|
|
|
- }
|
|
|
+ if (!("markdown-text" in overrides)) {
|
|
|
+ tokens["markdown-text"] = tokens["text-base"]
|
|
|
+ }
|
|
|
+ if (!("markdown-code-block" in overrides)) {
|
|
|
+ tokens["markdown-code-block"] = tokens["text-base"]
|
|
|
}
|
|
|
-
|
|
|
if (!("text-stronger" in overrides)) {
|
|
|
tokens["text-stronger"] = tokens["text-strong"]
|
|
|
}
|
|
|
@@ -456,9 +389,7 @@ export function resolveThemeVariant(variant: ThemeVariant, isDark: boolean): Res
|
|
|
}
|
|
|
|
|
|
interface ThemeColors {
|
|
|
- compact: boolean
|
|
|
neutral: HexColor
|
|
|
- ink?: HexColor
|
|
|
primary: HexColor
|
|
|
accent: HexColor
|
|
|
success: HexColor
|
|
|
@@ -471,54 +402,30 @@ interface ThemeColors {
|
|
|
}
|
|
|
|
|
|
function getColors(variant: ThemeVariant): ThemeColors {
|
|
|
- const input = variant as { palette?: unknown; seeds?: unknown }
|
|
|
- if (input.palette && input.seeds) {
|
|
|
- throw new Error("Theme variant cannot define both `palette` and `seeds`")
|
|
|
- }
|
|
|
-
|
|
|
- if (variant.palette) {
|
|
|
- return {
|
|
|
- compact: true,
|
|
|
- neutral: variant.palette.neutral,
|
|
|
- ink: variant.palette.ink,
|
|
|
- primary: variant.palette.primary,
|
|
|
- accent: variant.palette.accent ?? variant.palette.info,
|
|
|
- success: variant.palette.success,
|
|
|
- warning: variant.palette.warning,
|
|
|
- error: variant.palette.error,
|
|
|
- info: variant.palette.info,
|
|
|
- interactive: variant.palette.interactive ?? variant.palette.primary,
|
|
|
- diffAdd: variant.palette.diffAdd,
|
|
|
- diffDelete: variant.palette.diffDelete,
|
|
|
- }
|
|
|
+ if (!variant.seeds) {
|
|
|
+ throw new Error("Theme variant requires `seeds`")
|
|
|
}
|
|
|
|
|
|
- if (variant.seeds) {
|
|
|
- return {
|
|
|
- compact: false,
|
|
|
- neutral: variant.seeds.neutral,
|
|
|
- ink: undefined,
|
|
|
- primary: variant.seeds.primary,
|
|
|
- accent: variant.seeds.info,
|
|
|
- success: variant.seeds.success,
|
|
|
- warning: variant.seeds.warning,
|
|
|
- error: variant.seeds.error,
|
|
|
- info: variant.seeds.info,
|
|
|
- interactive: variant.seeds.interactive,
|
|
|
- diffAdd: variant.seeds.diffAdd,
|
|
|
- diffDelete: variant.seeds.diffDelete,
|
|
|
- }
|
|
|
+ return {
|
|
|
+ neutral: variant.seeds.neutral,
|
|
|
+ primary: variant.seeds.primary,
|
|
|
+ accent: variant.seeds.accent ?? variant.seeds.info,
|
|
|
+ success: variant.seeds.success,
|
|
|
+ warning: variant.seeds.warning,
|
|
|
+ error: variant.seeds.error,
|
|
|
+ info: variant.seeds.info,
|
|
|
+ interactive: variant.seeds.interactive ?? variant.seeds.primary,
|
|
|
+ diffAdd: variant.seeds.diffAdd,
|
|
|
+ diffDelete: variant.seeds.diffDelete,
|
|
|
}
|
|
|
-
|
|
|
- throw new Error("Theme variant requires `palette` or `seeds`")
|
|
|
}
|
|
|
|
|
|
-function generateNeutralAlphaScale(neutralScale: HexColor[], isDark: boolean): HexColor[] {
|
|
|
- const alphas = isDark
|
|
|
+function generateNeutralAlphaScale(neutral: HexColor[], isDark: boolean): HexColor[] {
|
|
|
+ const alpha = isDark
|
|
|
? [0.038, 0.066, 0.1, 0.142, 0.19, 0.252, 0.334, 0.446, 0.58, 0.718, 0.854, 0.985]
|
|
|
: [0.03, 0.06, 0.1, 0.145, 0.2, 0.265, 0.35, 0.47, 0.61, 0.74, 0.86, 0.97]
|
|
|
|
|
|
- return alphas.map((alpha) => blend(neutralScale[11], neutralScale[0], alpha))
|
|
|
+ return alpha.map((value) => blend(neutral[11], neutral[0], value))
|
|
|
}
|
|
|
|
|
|
function getHex(value: ColorValue | undefined): HexColor | undefined {
|