"use client"; import { useState } from "react"; import { commentsLabel } from "@/lib/feed-model"; import { SparkleButton } from "./Buttons"; import type { CurrentSlide } from "./MobileFeed"; import type { CardPost } from "@/lib/feed-model"; const icon = { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round" as const, strokeLinejoin: "round" as const, "aria-hidden": true, }; export interface MobileDockProps { /** The slide on screen; like and comments act on its post. */ slide: CurrentSlide; onToggleLike?: (post: CardPost) => void; likeBusy?: boolean; onOpenComments?: (postId: string) => void; onOpenComposer?: () => void; onOpenMore?: () => void; } /** What the like and comment buttons show and whether they work, for the slide on screen. */ export function dockState(slide: CurrentSlide, opts: { canLike?: boolean; likeBusy?: boolean } = {}) { const post = slide.kind === "post" ? slide.post : null; if (!post) { return { post: null, liked: false, likes: null, comments: null, likeLabel: "Like", commentsLabel: "Comments", likeDisabled: true, commentsDisabled: true }; } return { post, liked: post.isLiked, likes: post.likesCount, comments: post.commentsCount, likeLabel: post.isLiked ? `Unlike, ${post.likesCount} likes` : `Like, ${post.likesCount} likes`, commentsLabel: `Open comments, ${commentsLabel(post.commentsCount).toLowerCase()}`, likeDisabled: !post.id || !opts.canLike || !!opts.likeBusy, commentsDisabled: !post.id, }; } /** * Phone dock (spec "Mobile layout" > "Bottom dock"): a frosted bar 16px above the * bottom. Like and comments act on the post on screen and are disabled on the * featured and loading slides. Liked state and counts come from the post itself, * the same source as the desktop like button and double-tap. */ export function MobileDock({ slide, onToggleLike, likeBusy, onOpenComments, onOpenComposer, onOpenMore }: MobileDockProps) { const s = dockState(slide, { canLike: !!onToggleLike, likeBusy }); const [beat, setBeat] = useState(false); return ( ); }