fix: stats hide_border bug (#151)
* fix: stats hide border bug * fix white border on dark mode issue * chore: refactor code & tests Co-authored-by: anuraghazra <hazru.anurag@gmail.com>
This commit is contained in:
		
							parent
							
								
									7a8510641c
								
							
						
					
					
						commit
						9624cf6acd
					
				
					 2 changed files with 11 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -130,9 +130,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
 | 
			
		|||
    ? ""
 | 
			
		||||
    : `<text x="25" y="35" class="header">${name}'${apostrophe} GitHub Stats</text>`;
 | 
			
		||||
 | 
			
		||||
  const border = hide_border
 | 
			
		||||
    ? ""
 | 
			
		||||
    : `
 | 
			
		||||
  const border = `
 | 
			
		||||
    <rect 
 | 
			
		||||
      data-testid="card-bg"
 | 
			
		||||
      x="0.5"
 | 
			
		||||
| 
						 | 
				
			
			@ -142,6 +140,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
 | 
			
		|||
      rx="4.5"
 | 
			
		||||
      fill="${bgColor}"
 | 
			
		||||
      stroke="#E4E2E2"
 | 
			
		||||
      stroke-opacity="${hide_border ? 0 : 1}"
 | 
			
		||||
    />
 | 
			
		||||
  `;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -71,8 +71,16 @@ describe("Test renderStatsCard", () => {
 | 
			
		|||
 | 
			
		||||
  it("should hide_border", () => {
 | 
			
		||||
    document.body.innerHTML = renderStatsCard(stats, { hide_border: true });
 | 
			
		||||
    expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
 | 
			
		||||
      "stroke-opacity",
 | 
			
		||||
      "0"
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(queryByTestId(document.body, "card-bg")).not.toBeInTheDocument();
 | 
			
		||||
    document.body.innerHTML = renderStatsCard(stats, { hide_border: false });
 | 
			
		||||
    expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
 | 
			
		||||
      "stroke-opacity",
 | 
			
		||||
      "1"
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it("should hide_rank", () => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue