All files / src/components CreateProfileForm.tsx

80% Statements 4/5
100% Branches 6/6
75% Functions 3/4
80% Lines 4/5

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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98    2x                                                               12x                   2x                             120x                                                                            
import { cn } from '../lib/utils'
 
const PROFILE_COLORS = [
  '#d97850',
  '#8fae6f',
  '#6b9dad',
  '#9d80b8',
  '#d16b6b',
  '#e6a05f',
  '#6bb8a5',
  '#c77a9e',
  '#7d9e6f',
  '#5b8abf',
]
 
interface CreateProfileFormProps {
  newName: string
  onNameChange: (name: string) => void
  selectedColor: string
  onColorChange: (color: string) => void
  creating: boolean
  onSubmit: (e: React.FormEvent) => void
  onCancel: () => void
}
 
export default function CreateProfileForm({
  newName,
  onNameChange,
  selectedColor,
  onColorChange,
  creating,
  onSubmit,
  onCancel,
}: CreateProfileFormProps) {
  return (
    <div className="rounded-lg border border-border bg-card p-6 shadow-sm">
      <h2 className="mb-4 text-lg font-medium text-card-foreground">
        Create Profile
      </h2>
      <form onSubmit={onSubmit}>
        <div className="mb-4">
          <input
            type="text"
            value={newName}
            onChange={(e) => onNameChange(e.target.value)}
            placeholder="Enter your name"
            className="w-full rounded-lg border border-border bg-input-background px-4 py-3 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
            autoFocus
            maxLength={20}
          />
        </div>
 
        {/* Color picker */}
        <div className="mb-6">
          <label className="mb-2 block text-sm text-muted-foreground">
            Choose a color
          </label>
          <div className="flex flex-wrap justify-center gap-2">
            {PROFILE_COLORS.map((color) => (
              <button
                key={color}
                type="button"
                onClick={() => onColorChange(color)}
                className={cn(
                  'h-10 w-10 rounded-full transition-transform hover:scale-110',
                  selectedColor === color &&
                    'ring-2 ring-ring ring-offset-2 ring-offset-card'
                )}
                style={{ backgroundColor: color }}
              />
            ))}
          </div>
        </div>
 
        {/* Buttons */}
        <div className="flex gap-3">
          <button
            type="button"
            onClick={onCancel}
            className="flex-1 rounded-lg border border-border bg-secondary px-4 py-2.5 text-secondary-foreground transition-colors hover:bg-muted"
          >
            Cancel
          </button>
          <button
            type="submit"
            disabled={!newName.trim() || creating}
            className="flex-1 rounded-lg bg-primary px-4 py-2.5 text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50"
          >
            {creating ? 'Creating...' : 'Create'}
          </button>
        </div>
      </form>
    </div>
  )
}
 
export { PROFILE_COLORS }
 
← Back to Dashboard