scoop:scoop.ui.component:0.1.0
src/actions/preference_colors.scoop
Selected production source · src/actions/preference_colors.scoop
1
package scoop.ui.component3
import scoop.ui.style.*5
/** Keep each high contrast foreground with the background it was resolved against. */6
internal fun actionContrastPair(7
theme: Theme,8
shape: ActionShape,9
variant: ButtonVariant,10
visual: InteractionVisual11
): ColorPair {12
val colors = theme.tokens.palette13
when (shape) {14
case Toggle(_, _, val selected) -> {15
if (selected || (visual.enabled && (visual.hovered || visual.pressed)))16
return colors.muted17
}18
else -> {}19
}20
if (!visual.enabled)21
return ColorPair(colors.background.background, colors.disabledText)22
return when (variant) {23
case Secondary -> colors.secondary24
case Destructive -> colors.destructive25
case Link -> ColorPair(colors.background.background, colors.primary.background)26
else -> if (visual.hovered || visual.pressed)27
colors.muted28
else29
colors.background30
}31
}