Skip to content

Commit 1afb5c5

Browse files
committed
[fluent] feat: Implement system colors
This commit introduces system colors for Fluent UI components. These colors are used for attention, success, caution, critical, and neutral states. The colors are generated based on the dark mode setting and provide both solid and background variants.
1 parent 43768b6 commit 1afb5c5

File tree

1 file changed

+54
-0
lines changed
  • fluent/src/commonMain/kotlin/com/konyaco/fluent

1 file changed

+54
-0
lines changed

fluent/src/commonMain/kotlin/com/konyaco/fluent/Colors.kt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class Colors(
3939
internal set
4040
var borders by mutableStateOf(generateBorders(fillAccent, stroke, darkMode))
4141
internal set
42+
var system by mutableStateOf(generateSystemColors(darkMode))
43+
internal set
4244
}
4345

4446
data class Borders(
@@ -372,6 +374,22 @@ data class Background(
372374
)
373375
}
374376

377+
data class SystemColors(
378+
val attention: Color,
379+
val attentionBackground: Color,
380+
val solidAttentionBackground: Color,
381+
val success: Color,
382+
val successBackground: Color,
383+
val caution: Color,
384+
val cautionBackground: Color,
385+
val critical: Color,
386+
val criticalBackground: Color,
387+
val neutral: Color,
388+
val neutralBackground: Color,
389+
val solidNeutral: Color,
390+
val solidNeutralBackground: Color,
391+
)
392+
375393
fun generateShades(accent: Color): Shades {
376394
return getAccentShades()[accent] ?: getDefaultShades()
377395
}
@@ -720,3 +738,39 @@ private fun generateBorders(fillAccent: FillAccentColors, stroke: Stroke, darkMo
720738
0.9414f to fillAccent.default
721739
)
722740
)
741+
742+
private fun generateSystemColors(darkMode: Boolean): SystemColors {
743+
return if (darkMode) {
744+
SystemColors(
745+
attention = Color(0xFF60CDFF),
746+
attentionBackground = Color(0x08FFFFFF),
747+
solidAttentionBackground = Color(0xFF2E2E2E),
748+
success = Color(0xFF6CCB5F),
749+
successBackground = Color(0xFF393D1B),
750+
caution = Color(0xFFFCE100),
751+
cautionBackground = Color(0xFF433519),
752+
critical = Color(0xFFFF99A4),
753+
criticalBackground = Color(0xFF442726),
754+
neutral = Color(0x8BFFFFFF),
755+
neutralBackground = Color(0x08FFFFFF),
756+
solidNeutral = Color(0xFF9D9D9D),
757+
solidNeutralBackground = Color(0xFF2E2E2E),
758+
)
759+
} else {
760+
SystemColors(
761+
attention = Color(0xFF0070CB),
762+
attentionBackground = Color(0x80F6F6F6),
763+
solidAttentionBackground = Color(0xFFF7F7F7),
764+
success = Color(0xFF0F7B0F),
765+
successBackground = Color(0xFFDFF6DD),
766+
caution = Color(0xFF9D5D00),
767+
cautionBackground = Color(0xFFFFF4CE),
768+
critical = Color(0xFFC42B1C),
769+
criticalBackground = Color(0xFFFDE7E9),
770+
neutral = Color(0xFF72000000),
771+
neutralBackground = Color(0x06000000),
772+
solidNeutral = Color(0xFF8A8A8A),
773+
solidNeutralBackground = Color(0xFFF3F3F3),
774+
)
775+
}
776+
}

0 commit comments

Comments
 (0)