feat: enhance Card component with hover effect and update styles
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -150,3 +150,4 @@ dist
|
|||||||
# Built Visual Studio Code Extensions
|
# Built Visual Studio Code Extensions
|
||||||
*.vsix
|
*.vsix
|
||||||
|
|
||||||
|
package-lock.json
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
"framer-motion": "^12.11.0",
|
"framer-motion": "^12.11.0",
|
||||||
"html2canvas": "^1.4.1",
|
"html2canvas": "^1.4.1",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1"
|
"react-bootstrap": "^2.10.10",
|
||||||
|
"react-dom": "^18.3.1",
|
||||||
|
"react-router-dom": "^7.9.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.17.0",
|
"@eslint/js": "^9.17.0",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { useState, useEffect } from "react";
|
|||||||
|
|
||||||
export default function Card({ title, link }) {
|
export default function Card({ title, link }) {
|
||||||
const [image, setImage] = useState("");
|
const [image, setImage] = useState("");
|
||||||
|
const [buttonContent, setButtonContent] = useState(<>{title}</>);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getImage = async () => {
|
const getImage = async () => {
|
||||||
@@ -18,28 +19,37 @@ export default function Card({ title, link }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={"col-md-6 col-lg-3"}>
|
<div className={"col-md-6 col-lg-3"}>
|
||||||
<div className={"card"}>
|
|
||||||
<div className="card-header text-center bg-light">
|
<div className={"card shadow-sm"}>
|
||||||
<h5 className={"card-title m-0"}>{title}</h5>
|
|
||||||
</div>
|
|
||||||
<div className={"card-body p-0 text-center"}>
|
<div className={"card-body p-0 text-center"}>
|
||||||
<img src={image} className={"card-img-top"} alt={title}></img>
|
<img src={image} className={"card-img-top"} alt={title}></img>
|
||||||
</div>
|
</div>
|
||||||
<div className="card-footer p-0">
|
|
||||||
<a href={link} className={"btn btn-primary w-100"}>
|
<div className="card-footer border-0 p-0">
|
||||||
<FontAwesomeIcon icon={faArrowUpRightFromSquare} className={"me-2"} />
|
<div className="btn btn-primary w-100"
|
||||||
Link
|
onClick={() => window.open(link, "_blank")}
|
||||||
</a>
|
onMouseEnter={() => setButtonContent(
|
||||||
|
<>
|
||||||
|
<FontAwesomeIcon icon={faArrowUpRightFromSquare} className={"me-2"} />
|
||||||
|
Link
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
onMouseLeave={() => setButtonContent(
|
||||||
|
<>
|
||||||
|
{title}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{buttonContent}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Card.propTypes = {
|
Card.propTypes = {
|
||||||
title: PropTypes.string.isRequired,
|
title: PropTypes.string.isRequired,
|
||||||
description: PropTypes.string.isRequired,
|
link: PropTypes.string.isRequired
|
||||||
link: PropTypes.string.isRequired,
|
|
||||||
onHoverStart: PropTypes.func,
|
|
||||||
onHoverEnd: PropTypes.func,
|
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
color: var(--text-light);
|
color: var(--text-light);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
font-size: large;
|
||||||
border: none;
|
border: none;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user