Skip to content

Commit

Permalink
Merge pull request #81 from Konyaco/style/system_colors
Browse files Browse the repository at this point in the history
[fluent] feat: Implement system colors
  • Loading branch information
Sanlorng authored Nov 15, 2024
2 parents d6e05e7 + 1afb5c5 commit 7ec1bd5
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions fluent/src/commonMain/kotlin/com/konyaco/fluent/Colors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class Colors(
internal set
var borders by mutableStateOf(generateBorders(fillAccent, stroke, darkMode))
internal set
var system by mutableStateOf(generateSystemColors(darkMode))
internal set
}

data class Borders(
Expand Down Expand Up @@ -372,6 +374,22 @@ data class Background(
)
}

data class SystemColors(
val attention: Color,
val attentionBackground: Color,
val solidAttentionBackground: Color,
val success: Color,
val successBackground: Color,
val caution: Color,
val cautionBackground: Color,
val critical: Color,
val criticalBackground: Color,
val neutral: Color,
val neutralBackground: Color,
val solidNeutral: Color,
val solidNeutralBackground: Color,
)

fun generateShades(accent: Color): Shades {
return getAccentShades()[accent] ?: getDefaultShades()
}
Expand Down Expand Up @@ -720,3 +738,39 @@ private fun generateBorders(fillAccent: FillAccentColors, stroke: Stroke, darkMo
0.9414f to fillAccent.default
)
)

private fun generateSystemColors(darkMode: Boolean): SystemColors {
return if (darkMode) {
SystemColors(
attention = Color(0xFF60CDFF),
attentionBackground = Color(0x08FFFFFF),
solidAttentionBackground = Color(0xFF2E2E2E),
success = Color(0xFF6CCB5F),
successBackground = Color(0xFF393D1B),
caution = Color(0xFFFCE100),
cautionBackground = Color(0xFF433519),
critical = Color(0xFFFF99A4),
criticalBackground = Color(0xFF442726),
neutral = Color(0x8BFFFFFF),
neutralBackground = Color(0x08FFFFFF),
solidNeutral = Color(0xFF9D9D9D),
solidNeutralBackground = Color(0xFF2E2E2E),
)
} else {
SystemColors(
attention = Color(0xFF0070CB),
attentionBackground = Color(0x80F6F6F6),
solidAttentionBackground = Color(0xFFF7F7F7),
success = Color(0xFF0F7B0F),
successBackground = Color(0xFFDFF6DD),
caution = Color(0xFF9D5D00),
cautionBackground = Color(0xFFFFF4CE),
critical = Color(0xFFC42B1C),
criticalBackground = Color(0xFFFDE7E9),
neutral = Color(0xFF72000000),
neutralBackground = Color(0x06000000),
solidNeutral = Color(0xFF8A8A8A),
solidNeutralBackground = Color(0xFFF3F3F3),
)
}
}

0 comments on commit 7ec1bd5

Please sign in to comment.