Skip to content
Merged
Changes from all commits
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 {
val (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 check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/theme/ThemeBrowserAdapter.kt#L29

Added line #L29 was not covered by tests
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)

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

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/theme/ThemeBrowserAdapter.kt#L46-L49

Added lines #L46 - L49 were not covered by tests
append(CssVariable.BorderDefault, theme.border)
append(CssVariable.TabActive, theme.activeTab)

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

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

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/theme/ThemeBrowserAdapter.kt#L53

Added line #L53 was not covered by tests

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

// 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 {

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

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/theme/ThemeBrowserAdapter.kt#L117-L118

Added lines #L117 - L118 were not covered by tests
// luma calculation for brightness
(0.2126 * it.red) + (0.7152 * it.green) + (0.0722 * it.blue)

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

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/theme/ThemeBrowserAdapter.kt#L120

Added line #L120 was not covered by tests
}
)
return Triple(colors[0], colors[1], colors[2])

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

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/theme/ThemeBrowserAdapter.kt#L123

Added line #L123 was not covered by tests
}
}
Loading