feat(gif): outlined GIF glyph, and GIF picker for the profile banner

The composer's GIF button drew a filled rounded rect with the letters knocked
out, which reads as a solid square rather than a picker. Invert it: stroked
outline with filled letters, reusing the original glyph paths scaled to centre.

Banners already accept absolute URLs on both ends (server isValidAssetUrl
allows http(s); the profile render branches on banner.startsWith('http')), so
the picker stores the remote URL directly with no upload path. Previews can now
hold either a blob: or an https: URL, so revoking is guarded — calling
revokeObjectURL on a remote URL is a silent no-op that would hide a mistake.
This commit is contained in:
2026-08-31 11:44:40 -03:00
parent c70b0095a9
commit 20526e1bc8
2 changed files with 55 additions and 7 deletions
@@ -959,8 +959,14 @@ export function MessageInput({ channelId, channelName, placeholder }: MessageInp
title="GIF"
aria-label="GIF picker"
>
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">
<path d="M2 5.5A2.5 2.5 0 0 1 4.5 3h15A2.5 2.5 0 0 1 22 5.5v13a2.5 2.5 0 0 1-2.5 2.5h-15A2.5 2.5 0 0 1 2 18.5v-13ZM5.1 14V10h3.2v1.2H6.5v.6h1.6v1.1H6.5V14H5.1Zm4.5 0V10h1.4v4H9.6Zm2.5 0V10h3.2v1.2h-1.8v.5h1.6v1h-1.6V14h-1.4Z" />
{/* Outlined badge, not a filled block: the solid rectangle read as
a plain square rather than a GIF picker. Letters reuse the
original glyph paths, scaled and centred inside the outline. */}
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true">
<rect x="3" y="6" width="18" height="12" rx="3" stroke="currentColor" strokeWidth="2" />
<g fill="currentColor" transform="translate(-1.77 -4.2) scale(1.35)">
<path d="M5.1 14V10h3.2v1.2H6.5v.6h1.6v1.1H6.5V14H5.1Zm4.5 0V10h1.4v4H9.6Zm2.5 0V10h3.2v1.2h-1.8v.5h1.6v1h-1.6V14h-1.4Z" />
</g>
</svg>
</button>
)}
@@ -5,6 +5,7 @@ import { useInstanceStore } from '../../../stores/instanceStore';
import { useSpaceStore } from '../../../stores/spaceStore';
import { Avatar } from '../../ui/Avatar';
import { ImageCropModal } from '../../ui/ImageCropModal';
import { GifPicker } from '../../chat/GifPicker';
import { DeleteAccountModal } from '../DeleteAccountModal';
import { api } from '../../../api/client';
import { useTransferStore } from '../../../stores/transferStore';
@@ -13,6 +14,16 @@ import { getAvatarGradient, adjustColor, mutedGradient, AVATAR_GRADIENT_MAP, BAN
import { AVATAR_COLORS } from '@backspace/shared';
import type { User, UserStatus, AvatarColor } from '@backspace/shared';
import type { FederationOpResult } from '../../../utils/federationOps';
/**
* Banner/avatar previews hold either a `blob:` object URL (local upload) or a
* remote `https:` URL (GIF picker). Only the former owns memory that must be
* released — calling revokeObjectURL on a remote URL is a silent no-op that
* would quietly hide a mistake here.
*/
function releasePreview(url: string | null): void {
if (url && url.startsWith('blob:')) URL.revokeObjectURL(url);
}
export function AccountPanel() {
const user = useAuthStore((s) => s.user);
const updateProfile = useAuthStore((s) => s.updateProfile);
@@ -37,6 +48,7 @@ export function AccountPanel() {
const [bannerFilename, setBannerFilename] = useState<string | null>(null);
const [uploadingBanner, setUploadingBanner] = useState(false);
const [bannerCropSrc, setBannerCropSrc] = useState<string | null>(null);
const [showBannerGif, setShowBannerGif] = useState(false);
const bannerInputRef = useRef<HTMLInputElement>(null);
const addToast = useUIStore((s) => s.addToast);
@@ -54,7 +66,7 @@ export function AccountPanel() {
setCustomHex(user.accentColor ?? '');
// Reset upload state
if (avatarPreview) URL.revokeObjectURL(avatarPreview);
if (bannerPreview) URL.revokeObjectURL(bannerPreview);
releasePreview(bannerPreview);
setAvatarPreview(null);
setAvatarFilename(null);
setBannerPreview(null);
@@ -202,7 +214,7 @@ export function AccountPanel() {
};
const handleBannerCropComplete = async (blob: Blob) => {
if (bannerPreview) URL.revokeObjectURL(bannerPreview);
releasePreview(bannerPreview);
const previewUrl = URL.createObjectURL(blob);
setBannerPreview(previewUrl);
setBannerCropSrc(null);
@@ -227,8 +239,21 @@ export function AccountPanel() {
setAvatarFilename('');
};
/**
* Banners accept absolute URLs end to end: the server's isValidAssetUrl
* allows http(s), and the profile render already branches on
* `banner.startsWith('http')`. So a picked GIF needs no upload — the remote
* URL is stored directly.
*/
const handleBannerGifSelect = (url: string) => {
releasePreview(bannerPreview);
setBannerPreview(url);
setBannerFilename(url);
setShowBannerGif(false);
};
const handleRemoveBanner = () => {
if (bannerPreview) URL.revokeObjectURL(bannerPreview);
releasePreview(bannerPreview);
setBannerPreview(null);
setBannerFilename('');
};
@@ -300,7 +325,7 @@ export function AccountPanel() {
setAvatarColorState(user.avatarColor ?? null);
setCustomHex(user.accentColor ?? '');
if (avatarPreview) URL.revokeObjectURL(avatarPreview);
if (bannerPreview) URL.revokeObjectURL(bannerPreview);
releasePreview(bannerPreview);
setAvatarPreview(null);
setAvatarFilename(null);
setBannerPreview(null);
@@ -482,7 +507,7 @@ export function AccountPanel() {
</div>
)}
</button>
<div className="flex gap-2 mt-1">
<div className="relative flex gap-2 mt-1">
<button
type="button"
onClick={() => bannerInputRef.current?.click()}
@@ -491,6 +516,23 @@ export function AccountPanel() {
>
Change Banner
</button>
<button
type="button"
onClick={() => setShowBannerGif((v) => !v)}
disabled={uploadingBanner}
className="text-xs text-accent-primary hover:underline"
>
Choose GIF
</button>
{showBannerGif && (
<>
{/* Click-away layer, below the panel but above the page */}
<div className="fixed inset-0 z-[290]" onClick={() => setShowBannerGif(false)} />
<div className="absolute left-0 top-full mt-2 z-[300] glass rounded-xl overflow-hidden">
<GifPicker onGifSelect={handleBannerGifSelect} />
</div>
</>
)}
{(displayBannerSrc || user.banner) && bannerFilename !== '' && (
<button
type="button"