UNPKG

@atlaskit/adf-schema

Version:

Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs

16 lines 576 B
import { clampLightness } from './clamp-lightness'; import { rgbFromHex } from './rgb-from-hex'; import { rgbToLch } from './rgb-to-lch'; var getLightness = function getLightness(color) { var rgb = rgbFromHex(color); if (rgb === null) { return 0; } var lch = rgbToLch(rgb); return lch.l; }; export var getDarkModeLCHColor = function getDarkModeLCHColor(currentBackgroundColor) { var lightness = getLightness(currentBackgroundColor); var newLightness = Math.abs(100 - lightness); return clampLightness(currentBackgroundColor, newLightness).toUpperCase(); };