A local-first personal finance app
Tags: add light colors to tag color picker, update tag hover depending on tag background brightness (#6448)
Juulzda1a2457ba32
diff --git a/packages/component-library/src/ColorPicker.tsx b/packages/component-library/src/ColorPicker.tsxindex d42ff8a4f9..a7831a0440 100644--- a/packages/component-library/src/ColorPicker.tsx+++ b/packages/component-library/src/ColorPicker.tsx@@ -32,7 +32,6 @@ function ColorSwatch(props: ColorSwatchProps) {);}-// colors from https://materialui.co/colorsconst DEFAULT_COLOR_SET = ['#690CB0','#D32F2F',@@ -54,6 +53,26 @@ const DEFAULT_COLOR_SET = ['#5D4037','#616161','#455A64',+ '#FF6666', //red+ '#FF99FF', //magenta+ '#C39DDF', //purple+ '#6666FF', //blue+ '#B2FFFF', //cyan+ '#99cb99', //green+ '#FFFF7F', //yellow+ '#FFAB66', //orange+ '#D4B89C', //brown+ '#BFBFBF', //gray+ '#FFAEAE', //colors repeat from above with a lighter tint+ '#FFCCFF',+ '#E4D4FF', //this is now purple125+ '#B0B0FF',+ '#D8FFFF',+ '#CFE5CF',+ '#FFFFB2',+ '#FFD5B3',+ '#E4D3C3',+ '#DADADA',];type ColorSwatchPickerProps = {diff --git a/packages/desktop-client/src/hooks/useTagCSS.ts b/packages/desktop-client/src/hooks/useTagCSS.tsindex cc75d263e5..94d8e6feff 100644--- a/packages/desktop-client/src/hooks/useTagCSS.ts+++ b/packages/desktop-client/src/hooks/useTagCSS.ts@@ -44,16 +44,6 @@ export function useTagCSS() {);}-function getContrastedColor(hexcolor: string) {- // see: https://www.w3.org/TR/AERT/#color-contrast- const r = parseInt(hexcolor.substring(1, 3), 16);- const g = parseInt(hexcolor.substring(3, 5), 16);- const b = parseInt(hexcolor.substring(5, 7), 16);- const brightnessDiff = (r * 299 + g * 587 + b * 114) / 1000;-- return brightnessDiff >= 125 ? 'black' : 'white';-}-function getTagCSSColors(theme: Theme, color?: string | null) {if (!color) {return [@@ -63,9 +53,20 @@ function getTagCSSColors(theme: Theme, color?: string | null) {];}- return [- getContrastedColor(color),- color,- `color-mix(in srgb, ${color} 85%, white)`,- ];+ // see: https://www.w3.org/TR/AERT/#color-contrast+ const r = parseInt(color.substring(1, 3), 16);+ const g = parseInt(color.substring(3, 5), 16);+ const b = parseInt(color.substring(5, 7), 16);+ const brightnessDiff = (r * 299 + g * 587 + b * 114) / 1000;++ if (brightnessDiff >= 125) {+ // !important is used to override the hover text color in button.tsx used to style the tag button+ return [+ 'black !important',+ color,+ `color-mix(in srgb, ${color} 80%, black)`,+ ];+ }++ return ['white !important', color, `color-mix(in srgb, ${color} 70%, white)`];}diff --git a/packages/desktop-client/src/style/palette.ts b/packages/desktop-client/src/style/palette.tsindex f069be148c..5ca9ff1420 100644--- a/packages/desktop-client/src/style/palette.ts+++ b/packages/desktop-client/src/style/palette.ts@@ -71,6 +71,7 @@ export const red800 = oldColors.r2;export const red900 = oldColors.r1;export const purple50 = oldColors.p11;export const purple100 = oldColors.p10;+export const purple125 = '#e4d4ff';export const purple150 = oldColors.p9;export const purple200 = oldColors.p8;export const purple300 = oldColors.p7;diff --git a/packages/desktop-client/src/style/themes/development.ts b/packages/desktop-client/src/style/themes/development.tsindex ab6f3ca863..22b9babb81 100644--- a/packages/desktop-client/src/style/themes/development.ts+++ b/packages/desktop-client/src/style/themes/development.ts@@ -198,10 +198,10 @@ export const reportsGray = colorPalette.gray400;export const reportsLabel = colorPalette.navy900;export const reportsInnerLabel = colorPalette.navy800;-export const noteTagBackground = colorPalette.purple100;+export const noteTagBackground = colorPalette.purple125;export const noteTagBackgroundHover = colorPalette.purple150;-export const noteTagDefault = colorPalette.purple700;-export const noteTagText = colorPalette.purple700;+export const noteTagDefault = colorPalette.purple125;+export const noteTagText = colorPalette.black;export const budgetCurrentMonth = tableBackground;export const budgetOtherMonth = colorPalette.gray50;diff --git a/packages/desktop-client/src/style/themes/light.ts b/packages/desktop-client/src/style/themes/light.tsindex c90d7b27d6..12e1e3eea5 100644--- a/packages/desktop-client/src/style/themes/light.ts+++ b/packages/desktop-client/src/style/themes/light.ts@@ -200,10 +200,10 @@ export const reportsGray = colorPalette.gray400;export const reportsLabel = colorPalette.navy900;export const reportsInnerLabel = colorPalette.navy800;-export const noteTagBackground = colorPalette.purple100;+export const noteTagBackground = colorPalette.purple125;export const noteTagBackgroundHover = colorPalette.purple150;-export const noteTagDefault = colorPalette.purple700;-export const noteTagText = colorPalette.purple700;+export const noteTagDefault = colorPalette.purple125;+export const noteTagText = colorPalette.black;export const budgetCurrentMonth = tableBackground;export const budgetOtherMonth = colorPalette.gray50;diff --git a/upcoming-release-notes/6448.md b/upcoming-release-notes/6448.mdnew file mode 100644index 0000000000..eb5f6512eb--- /dev/null+++ b/upcoming-release-notes/6448.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [Juulz]+---++Tags: add light colors to tag color picker, update tag hover depending on tag background brightness