Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
}

private fun buildJsCodeToUpdateTheme(theme: AmazonQTheme) = buildString {
var (bg, altBg, inputBg) = determineInputAndBgColor(theme)

Check warning on line 29 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/theme/ThemeBrowserAdapter.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Local 'var' is never modified and can be declared as 'val'

Variable is never modified, so it can be declared using 'val'
appendDarkMode(theme.darkMode)

append("{\n")
Expand All @@ -42,14 +43,14 @@
append(CssVariable.TextColorWeak, theme.inactiveText)
append(CssVariable.TextColorDisabled, theme.inactiveText)

append(CssVariable.Background, theme.editorBackground)
append(CssVariable.BackgroundAlt, theme.background)
append(CssVariable.CardBackground, theme.editorBackground)
append(CssVariable.CardBackgroundAlt, theme.background)
append(CssVariable.Background, bg)
append(CssVariable.BackgroundAlt, altBg)
append(CssVariable.CardBackground, bg)
append(CssVariable.CardBackgroundAlt, altBg)
append(CssVariable.BorderDefault, theme.border)
append(CssVariable.TabActive, theme.activeTab)

append(CssVariable.InputBackground, theme.textFieldBackground)
append(CssVariable.InputBackground, inputBg)

append(CssVariable.ButtonBackground, theme.buttonBackground)
append(CssVariable.ButtonForeground, theme.buttonForeground)
Expand Down Expand Up @@ -110,4 +111,13 @@

// Some font names have characters that require them to be wrapped in quotes in the CSS variable, for example if they have spaces or a period.
private fun Font.toCssFontFamily(fallback: String = "system-ui") = "\"$family\", $fallback"

// darkest = bg, second darkest is alt bg, lightest is input bg
private fun determineInputAndBgColor(theme: AmazonQTheme): Triple<Color, Color, Color> {
val colors = arrayOf(theme.editorBackground, theme.background, theme.textFieldBackground).sortedWith(Comparator.comparing {
// luma calculation for brightness
(0.2126 * it.red) + (0.7152 * it.green) + (0.0722 * it.blue)
})
return Triple(colors[0], colors[1], colors[2])
}
}
Loading