-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
86 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import { ProjectDetailsButtonLink } from "./ProjectDetailsButtonLink"; | ||
import { Category } from "../shared/models"; | ||
|
||
describe("ProjectDetailsButtonLink", () => { | ||
it.each([ | ||
["Chrome Extension", "Get extension"], | ||
["Web development", "Open website"], | ||
] satisfies [Category, string][])( | ||
`renders the correct link title for %s category`, | ||
(category, title) => { | ||
render( | ||
<ProjectDetailsButtonLink | ||
category={category} | ||
url={"https://example.com"} | ||
/>, | ||
); | ||
const linkTitle = screen.getByText(title); | ||
expect(linkTitle).toBeInTheDocument(); | ||
}, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Image from "next/image"; | ||
import { FiGlobe } from "react-icons/fi"; | ||
import chromeWebStore from "@images/chrome-web-store.svg"; | ||
import { Category } from "@shared/models"; | ||
import { ButtonLink } from "@components/ButtonLink"; | ||
|
||
interface ProjectDetailsButtonLinkProps { | ||
category: Category; | ||
url: string; | ||
} | ||
|
||
const categoryToLinkIcon: Record< | ||
Category, | ||
{ title: string; icon: JSX.Element } | ||
> = { | ||
"Chrome Extension": { | ||
title: "Get extension", | ||
icon: <Image src={chromeWebStore} alt="Chrome Web Store" />, | ||
}, | ||
"Web development": { | ||
title: "Open website", | ||
icon: <FiGlobe className="w-full h-full text-primary" />, | ||
}, | ||
}; | ||
|
||
export function ProjectDetailsButtonLink({ | ||
category, | ||
url, | ||
}: ProjectDetailsButtonLinkProps): ReturnType<React.FC> { | ||
return ( | ||
<ButtonLink url={url} text={categoryToLinkIcon[category].title}> | ||
{categoryToLinkIcon[category].icon} | ||
</ButtonLink> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters