From 97c8539db5f043303a6346437fe4978c84a9c2f7 Mon Sep 17 00:00:00 2001 From: Ayush Bhardwaj Date: Sat, 19 Sep 2026 01:20:25 +0200 Subject: [PATCH] style(favorite): made the favorite button more visible * Replaced the emoji with an inline svg heart --- src/components/Favorite/Favorite.css | 46 +++++++++++++++---- src/components/Favorite/Favorite.test.tsx | 4 +- src/components/Favorite/Favorite.tsx | 8 +++- .../__snapshots__/Favorite.test.tsx.snap | 13 +++++- 4 files changed, 56 insertions(+), 15 deletions(-) diff --git a/src/components/Favorite/Favorite.css b/src/components/Favorite/Favorite.css index 70c97a4..8ac4d8c 100644 --- a/src/components/Favorite/Favorite.css +++ b/src/components/Favorite/Favorite.css @@ -1,22 +1,50 @@ .favorite-button { - background: transparent; - border: none; - font-size: 1.5rem; - cursor: pointer; - padding: 0.5rem; - border-radius: 50%; display: flex; align-items: center; justify-content: center; - transition: transform 0.2s ease-in-out; + width: 36px; + height: 36px; + padding: 0; + border: 1px solid var(--border); + background: var(--panel); + border-radius: 8px; + color: var(--muted); + cursor: pointer; + transition: + transform 0.2s ease-in-out, + color 0.2s, + border-color 0.2s, + background 0.2s; +} + +.favorite-button svg { + width: 20px; + height: 20px; + fill: none; + stroke: currentColor; + stroke-width: 2; } .favorite-button:hover { - transform: scale(1.2); + color: #e0245e; + border-color: #e0245e; + background: #fff0f4; + transform: scale(1.08); +} + +/* Filled red heart when the pokemon is a favorite */ +.favorite-button.is-favorite { + color: #e0245e; + border-color: #e0245e; + background: #fff0f4; +} + +.favorite-button.is-favorite svg { + fill: currentColor; } .favorite-button:focus-visible { - outline: 2px solid #0056b3; + outline: 2px solid var(--accent); outline-offset: 2px; } diff --git a/src/components/Favorite/Favorite.test.tsx b/src/components/Favorite/Favorite.test.tsx index ce3e580..5c116a9 100644 --- a/src/components/Favorite/Favorite.test.tsx +++ b/src/components/Favorite/Favorite.test.tsx @@ -7,8 +7,8 @@ describe("Favorite Component", () => { render( {}} />); const button = screen.getByRole("button", { name: "Add to favorites" }); - expect(button.textContent).toBe("🤍"); expect(button.getAttribute("aria-pressed")).toBe("false"); + expect(button.classList.contains("is-favorite")).toBe(false); }); test("shows filled heart when favorite", () => { @@ -17,8 +17,8 @@ describe("Favorite Component", () => { const button = screen.getByRole("button", { name: "Remove from favorites", }); - expect(button.textContent).toBe("❤️"); expect(button.getAttribute("aria-pressed")).toBe("true"); + expect(button.classList.contains("is-favorite")).toBe(true); }); test("calls onToggle when clicked", () => { diff --git a/src/components/Favorite/Favorite.tsx b/src/components/Favorite/Favorite.tsx index 11c4f3a..4cd31d7 100644 --- a/src/components/Favorite/Favorite.tsx +++ b/src/components/Favorite/Favorite.tsx @@ -8,12 +8,16 @@ type FavoriteProps = { export function Favorite({ isFavorite, onToggle }: FavoriteProps) { return ( ); } diff --git a/src/components/Favorite/__snapshots__/Favorite.test.tsx.snap b/src/components/Favorite/__snapshots__/Favorite.test.tsx.snap index 73aab3a..ef2448f 100644 --- a/src/components/Favorite/__snapshots__/Favorite.test.tsx.snap +++ b/src/components/Favorite/__snapshots__/Favorite.test.tsx.snap @@ -5,9 +5,18 @@ exports[`Favorite Component > matches snapshot 1`] = ` `;