grain.social is a photo sharing platform built on atproto.

show gallery favorites if creator but as a disabled button

Changed files
+17 -3
src
static
+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
··· 63 63 Sort order 64 64 </Button> 65 65 <ShareGalleryButton gallery={gallery} /> 66 + <FavoriteButton 67 + currentUserDid={currentUserDid} 68 + favs={favs} 69 + galleryUri={gallery.uri} 70 + /> 66 71 </div> 67 72 ) 68 73 : null}
-1
static/styles.css
··· 19 19 --color-black: #000; 20 20 --color-white: #fff; 21 21 --spacing: 0.25rem; 22 - --container-xs: 20rem; 23 22 --container-md: 28rem; 24 23 --container-xl: 36rem; 25 24 --container-5xl: 64rem;