Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/note tree: tint the active item background according to the item's custom color
Adorian Doran75a79775f4fc
diff --git a/apps/client/src/services/css_class_manager.ts b/apps/client/src/services/css_class_manager.tsindex f148707c21..ad4ac1a415 100644--- a/apps/client/src/services/css_class_manager.ts+++ b/apps/client/src/services/css_class_manager.ts@@ -34,7 +34,9 @@ function createClassForColor(colorString: string | null) {$("head").append(`<style>.${className}, span.fancytree-active.${className} {--light-theme-custom-color: ${adjustedColor.lightThemeColor};+ --light-theme-custom-bg-color: ${adjustedColor.lightThemeBackgroundColor};--dark-theme-custom-color: ${adjustedColor.darkThemeColor};+ --dark-theme-custom-bg-color: ${adjustedColor.darkThemeBackgroundColor};}</style>`);@@ -59,8 +61,7 @@ function parseColor(color: string) {* according to the lightThemeMaxLightness and darkThemeMinLightness parameters.*/function adjustColorLightness(color: ColorInstance, lightThemeMaxLightness: number, darkThemeMinLightness: number) {- let labColor = color.lab();-+ const labColor = color.lab();const lightness = labColor.l();// For the light theme, limit the maximum lightness@@ -69,7 +70,18 @@ function adjustColorLightness(color: ColorInstance, lightThemeMaxLightness: numb// For the dark theme, limit the minimum lightnessconst darkThemeColor = labColor.l(Math.max(lightness, darkThemeMinLightness)).hex();- return {lightThemeColor, darkThemeColor};+ let darkThemeBackgroundColor = "unset";+ let lightThemeBackgroundColor = "unset";++ const hslColor = color.hsl();+ const hue = hslColor.hue();++ if (color.saturationl() > 0) {+ darkThemeBackgroundColor = Color({h: hue, s: 20, l: 33, alpha: .4}).hexa();+ lightThemeBackgroundColor = Color({h: hue, s: 100, l: 25, alpha: .1}).hexa();+ }++ return {lightThemeColor, lightThemeBackgroundColor, darkThemeColor, darkThemeBackgroundColor};}export default {diff --git a/apps/client/src/stylesheets/theme-dark.css b/apps/client/src/stylesheets/theme-dark.cssindex 01bd125ec1..95e6dccd84 100644--- a/apps/client/src/stylesheets/theme-dark.css+++ b/apps/client/src/stylesheets/theme-dark.css@@ -84,6 +84,7 @@ body ::-webkit-calendar-picker-indicator {#left-pane span.fancytree-node {--custom-color: var(--dark-theme-custom-color);+ --custom-bg-color: var(--dark-theme-custom-bg-color);}.excalidraw.theme--dark {diff --git a/apps/client/src/stylesheets/theme-light.css b/apps/client/src/stylesheets/theme-light.cssindex 55203712e4..933f5bfe6f 100644--- a/apps/client/src/stylesheets/theme-light.css+++ b/apps/client/src/stylesheets/theme-light.css@@ -84,4 +84,5 @@ html {#left-pane span.fancytree-node {--custom-color: var(--light-theme-custom-color);+ --custom-bg-color: var(--light-theme-custom-bg-color);}\ No newline at end of filediff --git a/apps/client/src/stylesheets/theme-next-dark.css b/apps/client/src/stylesheets/theme-next-dark.cssindex b2192a2a04..b9a66da0de 100644--- a/apps/client/src/stylesheets/theme-next-dark.css+++ b/apps/client/src/stylesheets/theme-next-dark.css@@ -270,6 +270,7 @@#left-pane span.fancytree-node {--custom-color: var(--dark-theme-custom-color);+ --custom-bg-color: var(--dark-theme-custom-bg-color);}body ::-webkit-calendar-picker-indicator {diff --git a/apps/client/src/stylesheets/theme-next/shell.css b/apps/client/src/stylesheets/theme-next/shell.cssindex ff0245ab21..b6bd38789d 100644--- a/apps/client/src/stylesheets/theme-next/shell.css+++ b/apps/client/src/stylesheets/theme-next/shell.css@@ -658,7 +658,7 @@ body.layout-vertical.background-effects div.quick-search .dropdown-menu {inset-inline-start: var(--left-pane-item-selected-shadow-size);bottom: var(--left-pane-item-selected-shadow-size);inset-inline-end: var(--left-pane-item-selected-shadow-size);- background: var(--left-pane-item-selected-background) !important;+ background: var(--custom-bg-color, var(--left-pane-item-selected-background)) !important;box-shadow: var(--left-pane-item-selected-shadow);border-radius: 6px;animation: left-pane-item-select 200ms ease-out;