diff --git a/projects/x-framework-core/src/lib/tools/x-color.tools.ts b/projects/x-framework-core/src/lib/tools/x-color.tools.ts index dbd9ac9..f21659a 100644 --- a/projects/x-framework-core/src/lib/tools/x-color.tools.ts +++ b/projects/x-framework-core/src/lib/tools/x-color.tools.ts @@ -104,8 +104,8 @@ export function parseXColor(color: XColorIdentifier): XColorDescribtor { const brightnessLevel: XColorBrightnessLevel = strColor.includes('tint') ? XColorBrightnessLevel.Tint : strColor.includes('shade') - ? XColorBrightnessLevel.Shade - : XColorBrightnessLevel.Regular; + ? XColorBrightnessLevel.Shade + : XColorBrightnessLevel.Regular; const name = strColor .replace('-', '') .replace('contrast', '') @@ -409,8 +409,8 @@ export function stringToRGBA(value: string): XRGBAColor { value = value.includes('rgba') ? value.replace('rgba', '') : value.includes('rgb') - ? value.replace('rgb', '') - : value; + ? value.replace('rgb', '') + : value; // // Replace paranteses ... @@ -890,14 +890,14 @@ export function stringToHsva(colorString: string = ''): XHSVAColor { const type = isHEX(colorString) ? 'hex' : isRGBA(colorString) - ? 'rgba' - : isRGB(colorString) - ? 'rgb' - : isHSVA(colorString) - ? 'hsva' - : isHSLA(colorString) - ? 'hsla' - : 'unknown'; + ? 'rgba' + : isRGB(colorString) + ? 'rgb' + : isHSVA(colorString) + ? 'hsva' + : isHSLA(colorString) + ? 'hsla' + : 'unknown'; // // get result value based on input type ... @@ -1179,3 +1179,37 @@ export function formatColor( } } } + +/** + * Retrieve Specified Color Identifier Value ... + * + * @param color Color Identifier ... + * + * @returns an string value which represent color ... + */ +export function getXColorValue(color: XColorIdentifier) { + // + let result = ''; + + // + if (!isNullOrUndefined(color)) { + // + const descriptor = parseXColor(color); + if (!isNullOrUndefined(descriptor)) { + // + var colorCssVarName = getXColorCssVariableName( + color, + descriptor.isContrast, + descriptor.brightnessLevel, + ); + if (!isNullOrEmptyString(colorCssVarName)) { + // + const computedStyle = getComputedStyle(document.documentElement); + result = computedStyle.getPropertyValue(colorCssVarName.trim()).trim(); + } + } + } + + // + return result; +}