Skip to content

Commit 3b90b14

Browse files
authored
Merge pull request #33 from clowder-cloud/CL-139-Add-edit-button-to-clowder-cards
CL-139-Add-edit-button-to-clowder-cards
2 parents 70073a6 + ea9bd8d commit 3b90b14

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

src/Components/CatCard.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
import React from 'react';
22
import CatFromAxios from '../Interfaces/CatFromAxios';
33
import Card from './Styling/Card';
4+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5+
import { faPenToSquare } from '@fortawesome/free-solid-svg-icons';
46

57
interface Props {
68
cat: CatFromAxios;
9+
setSelectedCat: React.Dispatch<React.SetStateAction<CatFromAxios | null>>;
710
}
811

9-
export default function CatCard({ cat }: Props) {
12+
export default function CatCard({ cat, setSelectedCat }: Props) {
1013
return (
1114
<Card heading={cat.name}>
12-
<div className="flex justify-between">
13-
<img src={cat.picture_url ?? ''} alt={cat.name} className="w-20" />
15+
<div className="flex justify-between h-10 sm:h-16">
16+
<img
17+
src={cat.picture_url ?? ''}
18+
alt={cat.name}
19+
className="w-10 h-10 sm:w-16 sm:h-16"
20+
/>
1421
<div>
1522
<p>Level: {cat.battle_profile.level.toString()}</p>
1623
<p>XP: {cat.battle_profile.xp.toString()}</p>
1724
</div>
1825
<p>{cat.description ?? 'A good kitty'}</p>
26+
<FontAwesomeIcon
27+
className="h-full"
28+
icon={faPenToSquare}
29+
onClick={() => {
30+
setSelectedCat(cat);
31+
}}
32+
/>
1933
</div>
2034
</Card>
2135
);

src/Components/MyClowder.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import CatCard from './CatCard';
1010
export default function MyClowder() {
1111
const { userId } = useContext(UserContext);
1212
const [myCats, setMyCats] = useState<CatFromAxios[]>([]);
13+
const [selectedCat, setSelectedCat] = useState<CatFromAxios | null>(null);
1314

1415
useEffect(() => {
1516
if (userId) {
@@ -21,21 +22,20 @@ export default function MyClowder() {
2122
}
2223
}, [userId]);
2324

24-
return (
25+
return selectedCat ? (
26+
<ModalPopover>
27+
<CatProfile />
28+
</ModalPopover>
29+
) : (
2530
<>
2631
<H2>My Clowder</H2>
2732
<ul>
2833
{myCats.map((cat) => (
2934
<li key={cat.id}>
30-
<CatCard cat={cat}></CatCard>
35+
<CatCard cat={cat} setSelectedCat={setSelectedCat} />
3136
</li>
3237
))}
3338
</ul>
34-
{false && (
35-
<ModalPopover>
36-
<CatProfile></CatProfile>
37-
</ModalPopover>
38-
)}
3939
</>
4040
);
4141
}

src/Components/Styling/H3.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@ interface Props {
55
}
66

77
export default function H3({ children }: Props) {
8-
return <h3 className="text-2xl font-bold mb-5">{children}</h3>;
8+
return (
9+
<h3 className="text-xl sm:text-2xl lg:text-3xl xl:text-4xl font-bold mb-5">
10+
{children}
11+
</h3>
12+
);
913
}

0 commit comments

Comments
 (0)