Scoop API

scoop:scoop.ui.component:0.1.0

src/actions/preference_colors.scoop

Selected production source · src/actions/preference_colors.scoop

1package scoop.ui.component
3import scoop.ui.style.*
5/** Keep each high contrast foreground with the background it was resolved against. */
6internal fun actionContrastPair(
7 theme: Theme,
8 shape: ActionShape,
9 variant: ButtonVariant,
10 visual: InteractionVisual
11): ColorPair {
12 val colors = theme.tokens.palette
13 when (shape) {
14 case Toggle(_, _, val selected) -> {
15 if (selected || (visual.enabled && (visual.hovered || visual.pressed)))
16 return colors.muted
17 }
18 else -> {}
19 }
20 if (!visual.enabled)
21 return ColorPair(colors.background.background, colors.disabledText)
22 return when (variant) {
23 case Secondary -> colors.secondary
24 case Destructive -> colors.destructive
25 case Link -> ColorPair(colors.background.background, colors.primary.background)
26 else -> if (visual.hovered || visual.pressed)
27 colors.muted
28 else
29 colors.background
30 }