File size: 6,706 Bytes
ffe328b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import React, { useState } from 'react';
import { SAMPLE_PROJECTS } from '../constants/sampleProjects';
import { FolderPlus, X, Sparkles, Layers } from 'lucide-react';

interface NewProjectModalProps {
  isOpen: boolean;
  onClose: () => void;
  onCreateProject: (name: string, description: string, templateId?: string) => void;
}

export const NewProjectModal: React.FC<NewProjectModalProps> = ({
  isOpen,
  onClose,
  onCreateProject,
}) => {
  const [name, setName] = useState('');
  const [description, setDescription] = useState('');
  const [selectedTemplate, setSelectedTemplate] = useState<string>('scratch');

  if (!isOpen) return null;

  const handleSubmit = (e: React.FormEvent) => {
    e.preventDefault();
    if (!name.trim()) return;
    onCreateProject(
      name.trim(),
      description.trim() || 'Created with RiShre AI Vibe Coding Platform',
      selectedTemplate !== 'scratch' ? selectedTemplate : undefined
    );
    setName('');
    setDescription('');
    setSelectedTemplate('scratch');
    onClose();
  };

  return (
    <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/75 backdrop-blur-md p-4 animate-in fade-in">
      <div className="w-full max-w-lg bg-[#0c061a] border border-purple-500/30 rounded-3xl shadow-[0_0_60px_rgba(168,85,247,0.25)] overflow-hidden flex flex-col">
        {/* Header */}
        <div className="px-6 py-4 bg-[#120826]/90 border-b border-purple-500/25 flex items-center justify-between">
          <div className="flex items-center gap-2.5">
            <div className="w-6 h-6 rounded-lg bg-gradient-to-tr from-purple-600 to-fuchsia-500 flex items-center justify-center shadow-[0_0_10px_rgba(168,85,247,0.4)]">
              <FolderPlus className="w-3.5 h-3.5 text-white" />
            </div>
            <h2 className="text-sm font-bold text-white tracking-wide">Create New Vibe Project</h2>
          </div>
          <button
            onClick={onClose}
            aria-label="Close"
            className="p-1 rounded-lg text-purple-300 hover:text-white transition-colors cursor-pointer"
          >
            <X className="w-4 h-4" />
          </button>
        </div>

        {/* Form */}
        <form onSubmit={handleSubmit} className="p-6 space-y-5">
          <div className="space-y-1.5">
            <label className="text-xs font-bold text-purple-200 font-mono">Project Name</label>
            <input
              type="text"
              required
              autoFocus
              placeholder="e.g. Royal Void Dashboard"
              value={name}
              onChange={(e) => setName(e.target.value)}
              className="w-full bg-[#120826] border border-purple-500/30 rounded-xl px-3.5 py-2 text-xs text-white focus:outline-none focus:border-purple-400 font-mono shadow-inner"
            />
          </div>

          <div className="space-y-1.5">
            <label className="text-xs font-bold text-purple-200 font-mono">Description (Optional)</label>
            <input
              type="text"
              placeholder="Brief summary of what this application does..."
              value={description}
              onChange={(e) => setDescription(e.target.value)}
              className="w-full bg-[#120826] border border-purple-500/30 rounded-xl px-3.5 py-2 text-xs text-white focus:outline-none focus:border-purple-400 font-mono shadow-inner"
            />
          </div>

          {/* Starter Template Selection */}
          <div className="space-y-2">
            <label className="text-xs font-bold text-purple-200 font-mono flex items-center gap-1.5">
              <Layers className="w-3.5 h-3.5 text-fuchsia-400" />
              <span>Starting Preset</span>
            </label>

            <div className="grid grid-cols-1 gap-2 max-h-48 overflow-y-auto pr-1">
              <div
                onClick={() => setSelectedTemplate('scratch')}
                className={`p-3 rounded-2xl border text-xs transition-all cursor-pointer ${
                  selectedTemplate === 'scratch'
                    ? 'bg-purple-600/20 border-purple-400/50 text-purple-100 shadow-[0_0_15px_rgba(168,85,247,0.2)]'
                    : 'bg-[#120826]/70 border-purple-500/20 text-purple-300 hover:border-purple-400/40'
                }`}
              >
                <div className="font-bold flex items-center gap-1.5">
                  <Sparkles className="w-3.5 h-3.5 text-fuchsia-400" />
                  <span>Start from Scratch (Empty Vibe Workspace)</span>
                </div>
                <p className="text-[11px] text-purple-300/70 mt-0.5">
                  Fresh canvas with boilerplate index.html, style.css, and app.js.
                </p>
              </div>

              {SAMPLE_PROJECTS.map((sp) => (
                <div
                  key={sp.id}
                  onClick={() => {
                    setSelectedTemplate(sp.id);
                    if (!name) setName(sp.name);
                    if (!description) setDescription(sp.description);
                  }}
                  className={`p-3 rounded-2xl border text-xs transition-all cursor-pointer ${
                    selectedTemplate === sp.id
                      ? 'bg-purple-600/20 border-purple-400/50 text-purple-100 shadow-[0_0_15px_rgba(168,85,247,0.2)]'
                      : 'bg-[#120826]/70 border-purple-500/20 text-purple-300 hover:border-purple-400/40'
                  }`}
                >
                  <div className="font-bold flex items-center gap-1.5">
                    <span>⚡</span>
                    <span>{sp.name}</span>
                  </div>
                  <p className="text-[11px] text-purple-300/70 mt-0.5">{sp.description}</p>
                </div>
              ))}
            </div>
          </div>

          {/* Footer */}
          <div className="flex justify-end gap-2 pt-2 border-t border-purple-500/25">
            <button
              type="button"
              onClick={onClose}
              className="px-4 py-2 rounded-xl text-xs font-medium text-purple-300 hover:text-white transition-colors cursor-pointer"
            >
              Cancel
            </button>
            <button
              type="submit"
              disabled={!name.trim()}
              className="px-5 py-2 rounded-xl bg-gradient-to-r from-purple-600 via-fuchsia-600 to-pink-500 hover:from-purple-500 hover:to-pink-500 text-white font-bold text-xs uppercase tracking-wider transition-all shadow-[0_0_20px_rgba(168,85,247,0.4)] disabled:opacity-50 cursor-pointer active:scale-95"
            >
              Create Project
            </button>
          </div>
        </form>
      </div>
    </div>
  );
};