Skip to content

refactor: fix card colors type and function to resolve vscode type errors #3191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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