All files / src/components CreateCollectionForm.tsx

50% Statements 1/2
50% Branches 2/4
50% Functions 1/2
50% Lines 1/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60                                  1x                                                                                    
import { X } from 'lucide-react'
 
interface CreateCollectionFormProps {
  name: string
  onNameChange: (name: string) => void
  creating: boolean
  onSubmit: (e: React.FormEvent) => void
  onCancel: () => void
}
 
export default function CreateCollectionForm({
  name,
  onNameChange,
  creating,
  onSubmit,
  onCancel,
}: CreateCollectionFormProps) {
  return (
    <form
      onSubmit={onSubmit}
      className="mb-6 rounded-lg border border-border bg-card p-4"
    >
      <div className="mb-4 flex items-center justify-between">
        <h2 className="font-medium text-foreground">New Collection</h2>
        <button
          type="button"
          onClick={onCancel}
          className="rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground"
        >
          <X className="h-5 w-5" />
        </button>
      </div>
      <input
        type="text"
        value={name}
        onChange={(e) => onNameChange(e.target.value)}
        placeholder="Collection name"
        className="mb-3 w-full rounded-lg border border-border bg-input-background px-3 py-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
        autoFocus
      />
      <div className="flex justify-end gap-2">
        <button
          type="button"
          onClick={onCancel}
          className="rounded-lg px-4 py-2 text-sm text-muted-foreground hover:bg-muted hover:text-foreground"
        >
          Cancel
        </button>
        <button
          type="submit"
          disabled={!name.trim() || creating}
          className="rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50"
        >
          {creating ? 'Creating...' : 'Create'}
        </button>
      </div>
    </form>
  )
}
 
← Back to Dashboard