Fix popup

This commit is contained in:
dvirlabs 2025-06-13 17:49:48 +03:00
parent 34a65efd2c
commit ab14a59235
3 changed files with 125 additions and 29 deletions

View File

@ -10,3 +10,20 @@
.btn:hover { .btn:hover {
background: #125ea8; background: #125ea8;
} }
select {
font-size: 14px;
padding: 6px;
border-radius: 6px;
border: 1px solid #ccc;
}
code {
background: #eee;
padding: 2px 4px;
border-radius: 4px;
}
.form-title {
color: #125ea8;
}

View File

@ -106,18 +106,61 @@ function Diagram() {
</div> </div>
{showForm && ( {showForm && (
<div style={{ position: 'absolute', zIndex: 20, right: 10, top: 80, background: '#fff', padding: 10, borderRadius: 6, boxShadow: '0 2px 4px rgba(0,0,0,0.2)' }}> <div
<h4>Add Node</h4> style={{
position: 'absolute',
zIndex: 20,
right: 10,
top: 80,
background: '#e6f0fa',
padding: '16px',
borderRadius: '12px',
boxShadow: '0 4px 8px rgba(0,0,0,0.15)',
width: 280,
}}
>
<h4
style={{
color: '#125ea8',
marginBottom: 12,
fontSize: 18,
display: 'flex',
alignItems: 'center',
gap: 8,
}}
>
🧩 Add New Node
</h4>
<label style={{ fontWeight: 'bold', marginBottom: 4, display: 'block', color: '#333' }}>
Label:
</label>
<input <input
type="text" type="text"
placeholder="Enter label" placeholder="Enter label"
value={newLabel} value={newLabel}
onChange={(e) => setNewLabel(e.target.value)} onChange={(e) => setNewLabel(e.target.value)}
style={{ marginBottom: 8, display: 'block', width: '100%' }} style={{
padding: '6px',
width: '100%',
borderRadius: 6,
border: '1px solid #ccc',
marginBottom: 12,
}}
/> />
<IconSelector onSelect={setSelectedIcon} /> <IconSelector onSelect={setSelectedIcon} />
<button className="btn" onClick={handleSubmitNode}> Add</button>
<button className="btn" style={{ marginLeft: 8 }} onClick={() => setShowForm(false)}> Cancel</button> <div style={{ marginTop: 12 }}>
<button className="btn" onClick={handleSubmitNode}> Add</button>
<button
className="btn"
style={{ marginLeft: 8, background: '#ccc', color: '#333' }}
onClick={() => setShowForm(false)}
>
Cancel
</button>
</div>
</div> </div>
)} )}

View File

@ -17,39 +17,75 @@ function IconSelector({ onSelect }) {
onSelect(''); onSelect('');
}; };
const handleIconChange = (e) => { const handleIconClick = (url) => {
const icon = e.target.value; setSelectedIcon(url);
setSelectedIcon(icon); onSelect(url);
onSelect(icon);
}; };
return ( return (
<div style={{ marginBottom: '1rem' }}> <div style={{ marginBottom: '1rem' }}>
<label>Category:&nbsp;</label> <div style={{ marginBottom: '0.5rem' }}>
<select value={selectedCategory} onChange={handleCategoryChange}> <label style={{ fontWeight: 'bold', color: '#333' }}>Category:&nbsp;</label>
<option value="">Select Category</option> <select
{Object.keys(categories).map((cat) => ( value={selectedCategory}
<option key={cat} value={cat}>{cat}</option> onChange={handleCategoryChange}
))} style={{
</select> padding: '6px',
borderRadius: '6px',
border: '1px solid #ccc',
fontSize: '14px',
}}
>
<option value="">Select Category</option>
{Object.keys(categories).map((cat) => (
<option key={cat} value={cat}>
{cat}
</option>
))}
</select>
</div>
{selectedCategory && ( {selectedCategory && (
<> <div>
<label style={{ marginLeft: '1rem' }}>Icon:&nbsp;</label> <label style={{ fontWeight: 'bold' }}>Choose an icon:</label>
<select value={selectedIcon} onChange={handleIconChange}> <div
<option value="">Select Icon</option> style={{
display: 'grid',
gridTemplateColumns: 'repeat(auto-fill, minmax(40px, 1fr))',
gap: '10px',
marginTop: '0.5rem',
maxHeight: 120,
overflowY: 'auto',
padding: '6px',
border: '1px solid #ddd',
borderRadius: '6px',
background: '#f9f9f9',
}}
>
{categories[selectedCategory].map((url) => ( {categories[selectedCategory].map((url) => (
<option key={url} value={url}>{url.split('/').pop()}</option> <img
key={url}
src={url}
alt=""
title={url.split('/').pop()}
onClick={() => handleIconClick(url)}
style={{
width: 32,
height: 32,
cursor: 'pointer',
border: url === selectedIcon ? '2px solid #1976d2' : '2px solid transparent',
borderRadius: 4,
backgroundColor: '#fff',
}}
/>
))} ))}
</select> </div>
{selectedIcon && ( {selectedIcon && (
<img <p style={{ marginTop: 8, fontSize: 13 }}>
src={selectedIcon} Selected: <code>{selectedIcon.split('/').pop()}</code>
alt="preview" </p>
style={{ width: 32, height: 32, marginLeft: 10, verticalAlign: 'middle' }}
/>
)} )}
</> </div>
)} )}
</div> </div>
); );