Use custom scrollbar style (#80)

This commit is contained in:
Carl-Robert Linnupuu 2023-04-14 12:15:29 +01:00
parent 0d9951aec1
commit 36caef792d
3 changed files with 33 additions and 0 deletions

View file

@ -7,6 +7,8 @@ import static ee.carlrobert.codegpt.util.ThemeUtils.getDisabledTextColorRGB;
import static ee.carlrobert.codegpt.util.ThemeUtils.getFontColorRGB;
import static ee.carlrobert.codegpt.util.ThemeUtils.getFontSize;
import static ee.carlrobert.codegpt.util.ThemeUtils.getPanelBackgroundColorRGB;
import static ee.carlrobert.codegpt.util.ThemeUtils.getScrollBarForegroundColorRGB;
import static ee.carlrobert.codegpt.util.ThemeUtils.getScrollBarRadius;
import static ee.carlrobert.codegpt.util.ThemeUtils.getSeparatorColorRGB;
import static icons.Icons.DefaultImageIcon;
import static java.lang.String.format;
@ -147,6 +149,8 @@ public class MarkdownJCEFHtmlPanel extends JCEFHtmlPanel {
.replace("[font-size]", String.valueOf(getFontSize()))
.replace("[separator-color]", getSeparatorColorRGB())
.replace("[disabled-color]", getDisabledTextColorRGB())
.replace("[scrollbar-color]", getScrollBarForegroundColorRGB())
.replace("[scrollbar-radius]", String.valueOf(getScrollBarRadius()))
.replace("[panel-background-color]", getPanelBackgroundColorRGB())
.replace("[button-background-color]", getButtonBackgroundColorRGB())
.replace("[button-disabled-background-color]", getDisabledButtonBackgroundColorRGB());

View file

@ -3,6 +3,7 @@ package ee.carlrobert.codegpt.util;
import static java.lang.String.format;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.ui.JBFont;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
@ -44,6 +45,14 @@ public class ThemeUtils {
return JBFont.regular().getSize();
}
public static String getScrollBarForegroundColorRGB() {
return "rgb(187, 187, 187, 0.8)"; // TODO: Get theme's scrollbar color
}
public static int getScrollBarRadius() {
return SystemInfo.isMac ? 10 : 0;
}
private static Color toDarker(Color color) {
var factor = 0.9;
return new Color(

View file

@ -23,11 +23,30 @@
--font-size: [font-size]px;
--separator-color: [separator-color];
--disabled-color: [disabled-color];
--scrollbar-color: [scrollbar-color];
--scrollbar-radius: [scrollbar-radius]px;
--panel-background-color: [panel-background-color];
--button-background-color: [button-background-color];
--button-disabled-background-color: [button-disabled-background-color];
}
*::-webkit-scrollbar-track {
background-color: transparent;
}
*::-webkit-scrollbar {
background-color: transparent;
transition: 0.3s;
width: 13px;
}
*::-webkit-scrollbar-thumb {
border-radius: var(--scrollbar-radius);
background-color: var(--scrollbar-color);
background-clip: content-box;
border: 3px solid transparent;
}
html {
scroll-behavior: smooth;
background-color: var(--bg);
@ -38,6 +57,7 @@
body {
margin: 0;
overflow: overlay;
}
pre, pre[class*='language-'] {