Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

1.2 KB
Raw Blame
import { Textarea } from '@/components/ui/textarea';
import SurfaceBox from '@/components/SurfaceBox';
import { cn } from '@/lib/utils';
import { CAPTION_LIMIT } from './publishConstants';

interface CaptionBoxProps {
  caption: string;
  onChange: (caption: string) => void;
}

export default function CaptionBox({ caption, onChange }: CaptionBoxProps) {
  const nearLimit = caption.length > CAPTION_LIMIT * 0.9;
  return (
    <SurfaceBox title="Caption" subheader="Kept in this tab as you type, so a reload does not lose it.">
      <Textarea
        value={caption}
        onChange={e => onChange(e.target.value)}
        placeholder="Write a caption. Add #hashtags and @mentions."
        rows={7}
        maxLength={CAPTION_LIMIT}
        aria-label="Caption"
        aria-describedby="caption-count"
        className="min-h-40 rounded-control border-0 bg-transparent px-1 text-base leading-6 shadow-none hover:border-0"
      />
      <p id="caption-count" className={cn('mt-2 text-right text-caption tabular-nums', nearLimit ? 'text-warning' : 'text-ink-faint')}>
        {caption.length.toLocaleString()} of {CAPTION_LIMIT.toLocaleString()} characters
      </p>
    </SurfaceBox>
  );
}