Something went wrong. Try again.
A live media wall for your Bluesky follows
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127<script lang="ts"> import IconPlus from 'phosphor-svelte/lib/PlusIcon'; import StatusMessage from './StatusMessage.svelte'; import Button from './Button.svelte'; import { getContext } from 'svelte'; import { FOLLOW_CONTEXT, type FollowControls } from '../follow-controls.js';
let { did, handle, following, badge = false }: { did: string; handle: string; following?: string; badge?: boolean } = $props(); const getControls = getContext<() => FollowControls>(FOLLOW_CONTEXT); const controls = $derived(getControls?.()); const current = $derived(controls?.following.has(did) ? controls.following.get(did) : following); const pending = $derived(controls?.pending.has(did) ?? false); let error = $state('');
async function activate(event: MouseEvent) { event.preventDefault(); event.stopPropagation(); error = ''; if (!controls?.enabled) return; try { await controls.change(did, current ?? undefined); } catch (cause) { error = cause instanceof Error ? cause.message : 'Unable to update follow status.'; } }</script>
{#if controls && controls.account !== did && (!badge || !current)} <span class="follow-control" class:badge> {#if badge} <button type="button" disabled={pending || !controls.enabled} aria-busy={pending} aria-label={`Follow @${handle}`} title={`Follow @${handle}`} onclick={activate} > <span class="badge-face"><IconPlus size={10} aria-hidden="true" /></span> </button> {:else} <Button variant="primary" pill disabled={pending || !controls.enabled} aria-busy={pending} aria-label={`${current ? 'Unfollow' : 'Follow'} @${handle}`} title={`${current ? 'Unfollow' : 'Follow'} @${handle}`} onclick={activate} > {pending ? 'Saving…' : current ? 'Unfollow' : 'Follow'} </Button> {/if} {#if error}<span class="error"><StatusMessage kind="error" compact>{error}</StatusMessage></span >{/if} </span>{/if}
<style> .follow-control { display: inline-flex; flex-direction: column; align-items: flex-start; gap: var(--space-040); } button { position: static; border-radius: var(--radius-pill); color: var(--color-text-on-accent); cursor: pointer; } button:disabled { opacity: 0.5; cursor: default; } button[aria-busy='true'] { cursor: wait; } button:focus-visible { outline: 2px solid var(--color-foreground-emphasis); outline-offset: 3px; } .badge { position: absolute; left: calc(var(--portrait-size) - 19px); top: calc(50% + var(--portrait-size) / 2 - 22px); z-index: 1; pointer-events: auto; } .badge button { display: grid; place-items: center; width: var(--space-200); height: var(--space-200); padding: 0; border: 0; background: transparent; } .badge button:hover:not(:disabled) { background: transparent; } .badge-face { display: grid; place-items: center; box-sizing: border-box; width: 22px; height: 22px; border: 2px solid var(--color-surface-panel); border-radius: var(--radius-pill); background: var(--color-foreground-emphasis); } .badge button:hover:not(:disabled) .badge-face { background: var(--color-foreground-primary); } .error { max-width: 250px; } .badge .error { min-width: 180px; }</style>