feat: more highlight colours (#3062)
* feat(highlight): extend types and constants for custom hex colours * feat(highlight): update colour to support hex strings * refactor(annotator): update component to accept hex colours * feat(highlight): add colour picker with max 4 custom colors * feat(settings): add custom colour editor with limit * refactor: custom highlight colors can only be modified in settings --------- Co-authored-by: Huang Xin <chrox.huang@gmail.com>
This commit is contained in:
@@ -2,9 +2,12 @@ import { HIGHLIGHT_COLOR_HEX } from '@/services/constants';
|
||||
import { HighlightColor } from '@/types/book';
|
||||
import { SystemSettings } from '@/types/settings';
|
||||
|
||||
export const getHighlightColorHex = (settings: SystemSettings, color?: HighlightColor) => {
|
||||
if (!color) return color;
|
||||
|
||||
export const getHighlightColorHex = (
|
||||
settings: SystemSettings,
|
||||
color?: HighlightColor,
|
||||
): string | undefined => {
|
||||
if (!color) return undefined;
|
||||
if (color.startsWith('#')) return color;
|
||||
const customColors = settings.globalReadSettings.customHighlightColors;
|
||||
return customColors?.[color] ?? HIGHLIGHT_COLOR_HEX[color];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user