scoop:scoop.ui.component:0.1.0
src/conversation/bubble_colors.scoop
Selected production source · src/conversation/bubble_colors.scoop
1
package scoop.ui.component3
import scoop.graphics.Color4
import scoop.ui.style.*6
internal struct BubbleColors(7
val background: Color,8
val foreground: Color,9
val hover: Color,10
val border: Color11
)13
internal fun bubbleColors(variant: BubbleVariant, theme: Theme): BubbleColors {14
val p = theme.tokens.palette15
val dark = theme.tokens.mode == ThemeMode.Dark16
val foreground =17
when (variant) {18
case Default -> p.primary.foreground19
case Secondary -> p.secondary.foreground20
case Destructive -> p.destructive.background21
else -> p.background.foreground22
}23
val background =24
when (variant) {25
case Default -> p.primary.background26
case Secondary -> p.secondary.background27
case Muted -> p.muted.background28
case Tinted -> bubbleTint(29
p.primary.background,30
if (dark)31
0.332
else33
0.93,34
0.435
)36
case Outline -> p.background.background37
case Ghost -> Color.Transparent38
case Destructive -> p.destructive.background.withAlpha(39
if (dark)40
0.241
else42
0.143
)44
}45
val hover =46
when (variant) {47
case Default -> background.withAlpha(background.alpha * 0.8)48
case Tinted -> bubbleTint(49
p.primary.background,50
if (dark)51
0.3552
else53
0.88,54
0.555
)56
case Destructive -> p.destructive.background.withAlpha(57
if (dark)58
0.359
else60
0.261
)62
case Ghost -> p.muted.background.withAlpha(63
if (dark)64
0.565
else66
1.067
)68
case Outline -> p.muted.background69
else -> secondaryHover(background, p.background.foreground)70
}71
return BubbleColors(72
background,73
foreground,74
hover,75
if (variant == BubbleVariant.Outline)76
p.border77
else78
Color.Transparent79
)80
}