Skip to content
Snippets Groups Projects
Commit ba7476a3 authored by Jose Manuel Serrano Amaut's avatar Jose Manuel Serrano Amaut
Browse files

[FEAT]: Add completesureColor and default color for font

parent 8e566dce
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ import { NAMED_COLORS } from "./namedColors"; ...@@ -5,7 +5,7 @@ import { NAMED_COLORS } from "./namedColors";
* @param colorInput * @param colorInput
* @returns the darked color in * @returns the darked color in
*/ */
export const darkerColor = (colorInput: string, percentage = 25): string => { export const darkerColor = (colorInput: string, percentage = 25): string => {
let darkedColor = ""; let darkedColor = "";
const reduce = (100 - percentage) / 100; const reduce = (100 - percentage) / 100;
let component1: number = 0; let component1: number = 0;
...@@ -206,11 +206,26 @@ export const hexTodec = (letter: string): number => { ...@@ -206,11 +206,26 @@ export const hexTodec = (letter: string): number => {
* @param color param color given by user * @param color param color given by user
* @returns returns the same color * @returns returns the same color
*/ */
export const asureColor = (color?: string): string => { export const asureColor = (color?: string): string => {
if (color !== undefined && color !== "") { if (color !== undefined && color !== "") {
return color; return color;
} else { } else {
return "#646c7f"; return DEFAULT_FONT_COLOR;
} }
} }
/**
* Asure a base color. When not given or when given an incorrect color format
* default color is this kind of grey #5d6475
*
* @param color param color given by user
* @returns returns the same color
*/
export const completeAsureColor = (color?: string, perc = 1): string => {
return hexColorToRGB(asureColor(colourNameToHex(color)), perc);
}
export const DEFAULT_FONT_COLOR = "#646c7f";
\ No newline at end of file
...@@ -6,5 +6,6 @@ export { ...@@ -6,5 +6,6 @@ export {
darkerColor, darkerColor,
hexColorToRGB, hexColorToRGB,
hexTodec, hexTodec,
isHexColor isHexColor,
completeAsureColor
} from "./colors"; } from "./colors";
\ No newline at end of file
...@@ -163,7 +163,8 @@ export { ...@@ -163,7 +163,8 @@ export {
hexColorToRGB, hexColorToRGB,
hexTodec, hexTodec,
isHexColor, isHexColor,
NAMED_COLORS NAMED_COLORS,
completeAsureColor
} from "./color"; } from "./color";
export { export {
......
import { asureColor, colourNameToHex, hexColorToRGB } from "../color"; import { completeAsureColor, hexColorToRGB } from "../color";
const asureRippleColor = (color: string): string => { const asureRippleColor = (color: string): string => {
return hexColorToRGB( return completeAsureColor(color,
asureColor(colourNameToHex(color)),
0.4 0.4
); );
} }
...@@ -69,10 +68,7 @@ export function createRippleButton< ...@@ -69,10 +68,7 @@ export function createRippleButton<
circle.classList.add("ripple"); circle.classList.add("ripple");
if (variant !== "contained") { if (variant !== "contained") {
circle.style.backgroundColor = hexColorToRGB( circle.style.backgroundColor = asureRippleColor(color);
asureColor(colourNameToHex(color)),
0.4
);
} else { } else {
circle.style.backgroundColor = hexColorToRGB("#ffffff", 0.4); circle.style.backgroundColor = hexColorToRGB("#ffffff", 0.4);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment