+12
-2
src/components/FavoriteButton.tsx
+12
-2
src/components/FavoriteButton.tsx
···
1
1
import { Record as Favorite } from "$lexicon/types/social/grain/favorite.ts";
2
+
import { AtUri } from "@atproto/syntax";
2
3
import { WithBffMeta } from "@bigmoves/bff";
3
4
import { Button, cn } from "@bigmoves/bff/components";
4
5
···
11
12
favs: WithBffMeta<Favorite>[];
12
13
galleryUri: string;
13
14
}>) {
15
+
const isCreator = currentUserDid === new AtUri(galleryUri).hostname;
14
16
const favUri = favs.find((s) => currentUserDid === s.did)?.uri;
15
17
return (
16
18
<Button
17
19
variant="primary"
18
-
class="self-start w-full sm:w-fit whitespace-nowrap"
20
+
class={cn(
21
+
"self-start w-full sm:w-fit whitespace-nowrap",
22
+
isCreator &&
23
+
"bg-zinc-100 dark:bg-zinc-800 border-zinc-100 dark:border-zinc-800 text-zinc-950 dark:text-zinc-50",
24
+
)}
19
25
type="button"
20
26
hx-post={`/actions/favorite?galleryUri=${galleryUri}${
21
27
favUri ? "&favUri=" + favUri : ""
22
28
}`}
23
29
hx-target="this"
24
30
hx-swap="outerHTML"
31
+
disabled={isCreator}
25
32
>
26
-
<i class={cn("fa-heart", favUri ? "fa-solid" : "fa-regular")}></i>{" "}
33
+
<i
34
+
class={cn("fa-heart", favUri || isCreator ? "fa-solid" : "fa-regular")}
35
+
>
36
+
</i>{" "}
27
37
{favs.length}
28
38
</Button>
29
39
);
+5
src/components/GalleryPage.tsx
+5
src/components/GalleryPage.tsx