// screen-add.jsx — Add new idea slide-over drawer
const { useState: useAddState } = React;
function AddIdeaDrawer({ open, onClose, onSubmit }) {
const Icon = window.Icon;
const [title, setTitle] = useAddState('');
const [cat, setCat] = useAddState('');
const [catOpen, setCatOpen] = useAddState(false);
const [desc, setDesc] = useAddState('');
const [tags, setTags] = useAddState([]);
const [tagInput, setTagInput] = useAddState('');
const [imgs, setImgs] = useAddState([]);
const reset = () => { setTitle(''); setCat(''); setDesc(''); setTags([]); setTagInput(''); setImgs([]); };
const close = () => { onClose(); };
const addTag = (e) => {
if (e.key === 'Enter' && tagInput.trim() && tags.length < 5) {
e.preventDefault(); setTags([...tags, tagInput.trim()]); setTagInput('');
}
};
const valid = title.trim() && cat && desc.trim() && tags.length > 0;
const submit = () => { if (!valid) return; onSubmit({ title, cat }); reset(); };
return (
Add new idea
Share something worth building.
setTitle(e.target.value)} placeholder="Enter your idea's general title" className="fld" />
{catOpen && (
{window.CATEGORIES.map(c => (
))}
)}
{tags.map((t, i) => (
{t}
))}
{tags.length < 5 && setTagInput(e.target.value)} onKeyDown={addTag} placeholder={tags.length ? '' : 'Add tags, press Enter'} style={{ border: 'none', outline: 'none', flex: 1, minWidth: 100, fontSize: 14, background: 'none' }} />}
);
}
function Field({ label, required, children }) {
return (
{children}
);
}
function Dropzone({ label, hint, icon }) {
const Icon = window.Icon;
return (
{ e.currentTarget.style.borderColor = 'var(--accent-600)'; e.currentTarget.style.background = 'var(--accent-50)'; }}
onMouseLeave={e => { e.currentTarget.style.borderColor = 'var(--line-strong)'; e.currentTarget.style.background = 'transparent'; }}>
{hint}
);
}
window.AddIdeaDrawer = AddIdeaDrawer;