Skip to content

Commit

Permalink
refactor: fix card colors type and function to resolve vscode type er…
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty541 authored and devantler committed Sep 24, 2023
1 parent ea2c39b commit 1e29f0b
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ const flexLayout = ({ items, gap, direction, sizes = [] }) => {
/**
* Object containing card colors.
* @typedef {{
* titleColor: string | string[];
* iconColor: string | string[];
* textColor: string | string[];
* titleColor: string;
* iconColor: string;
* textColor: string;
* bgColor: string | string[];
* borderColor: string | string[];
* ringColor: string | string[];
* borderColor: string;
* ringColor: string;
* }} CardColors
*/

Expand Down Expand Up @@ -267,6 +267,18 @@ const getCardColors = ({
"#" + defaultBorderColor,
);

if (
typeof titleColor !== "string" ||
typeof textColor !== "string" ||
typeof ringColor !== "string" ||
typeof iconColor !== "string" ||
typeof borderColor !== "string"
) {
throw new Error(
"Unexpected behavior, all colors except background should be string.",
);
}

return { titleColor, iconColor, textColor, bgColor, borderColor, ringColor };
};

Expand Down

0 comments on commit 1e29f0b

Please sign in to comment.