Skip to content

Commit 0f35dfb

Browse files
committed
add edit button to cat list
1 parent 741350f commit 0f35dfb

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

src/Components/CatCard.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +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;
79
setSelectedCat: React.Dispatch<React.SetStateAction<CatFromAxios | null>>;
810
}
911

10-
export default function CatCard({ cat }: Props) {
12+
export default function CatCard({ cat, setSelectedCat }: Props) {
1113
return (
1214
<Card heading={cat.name}>
13-
<div className="flex justify-between">
14-
<img src={cat.picture_url ?? ''} alt={cat.name} className="w-20" />
15+
<div className="flex justify-between h-10 sm:h-32">
16+
<img
17+
src={cat.picture_url ?? ''}
18+
alt={cat.name}
19+
className="w-10 h-10 sm:w-32 sm:h-32"
20+
/>
1521
<div>
1622
<p>Level: {cat.battle_profile.level.toString()}</p>
1723
<p>XP: {cat.battle_profile.xp.toString()}</p>
1824
</div>
1925
<p>{cat.description ?? 'A good kitty'}</p>
26+
<FontAwesomeIcon
27+
className="h-full"
28+
icon={faPenToSquare}
29+
onClick={() => {
30+
setSelectedCat(cat);
31+
}}
32+
/>
2033
</div>
2134
</Card>
2235
);

src/Components/MyClowder.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ export default function MyClowder() {
2222
}
2323
}, [userId]);
2424

25-
return (
25+
return selectedCat ? (
26+
<ModalPopover>
27+
<CatProfile></CatProfile>
28+
</ModalPopover>
29+
) : (
2630
<>
2731
<H2>My Clowder</H2>
2832
<ul>
@@ -32,11 +36,6 @@ export default function MyClowder() {
3236
</li>
3337
))}
3438
</ul>
35-
{selectedCat && (
36-
<ModalPopover>
37-
<CatProfile></CatProfile>
38-
</ModalPopover>
39-
)}
4039
</>
4140
);
4241
}

0 commit comments

Comments
 (0)