mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-07-17 02:16:54 +00:00
feat: allow users to pass ring_color param (#2075)
* fix: prevent crash if undefined color is passed to func fallbackColor * feat: allow users to pass ring_color param Before this commit, the ring color was always equal to the title color. This commit allows the user to pass a ring_color property to allow him to style the ring color the way he pleases to. If no ring_color is passed we default to the title color. * docs: improves ring color documentation * fix: improve code style Co-authored-by: rickstaa <rick.staa@outlook.com>
This commit is contained in:
co-authored by
rickstaa
parent
0c829e9488
commit
9aa39dfe81
@@ -239,6 +239,39 @@ describe("Test renderStatsCard", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("should render custom ring_color properly", () => {
|
||||
const customColors = {
|
||||
title_color: "5a0",
|
||||
ring_color: "0000ff",
|
||||
icon_color: "1b998b",
|
||||
text_color: "9991",
|
||||
bg_color: "252525",
|
||||
};
|
||||
|
||||
document.body.innerHTML = renderStatsCard(stats, { ...customColors });
|
||||
|
||||
const styleTag = document.querySelector("style");
|
||||
const stylesObject = cssToObject(styleTag.innerHTML);
|
||||
|
||||
const headerClassStyles = stylesObject[":host"][".header "];
|
||||
const statClassStyles = stylesObject[":host"][".stat "];
|
||||
const iconClassStyles = stylesObject[":host"][".icon "];
|
||||
const rankCircleStyles = stylesObject[":host"][".rank-circle "];
|
||||
const rankCircleRimStyles = stylesObject[":host"][".rank-circle-rim "];
|
||||
|
||||
expect(headerClassStyles.fill.trim()).toBe(`#${customColors.title_color}`);
|
||||
expect(statClassStyles.fill.trim()).toBe(`#${customColors.text_color}`);
|
||||
expect(iconClassStyles.fill.trim()).toBe(`#${customColors.icon_color}`);
|
||||
expect(rankCircleStyles.stroke.trim()).toBe(`#${customColors.ring_color}`);
|
||||
expect(rankCircleRimStyles.stroke.trim()).toBe(
|
||||
`#${customColors.ring_color}`,
|
||||
);
|
||||
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
|
||||
"fill",
|
||||
"#252525",
|
||||
);
|
||||
});
|
||||
|
||||
it("should render icons correctly", () => {
|
||||
document.body.innerHTML = renderStatsCard(stats, {
|
||||
show_icons: true,
|
||||
|
||||
Reference in New Issue
Block a user