Fix popup
This commit is contained in:
parent
34a65efd2c
commit
ab14a59235
@ -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;
|
||||||
|
}
|
||||||
@ -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} />
|
||||||
|
|
||||||
|
<div style={{ marginTop: 12 }}>
|
||||||
<button className="btn" onClick={handleSubmitNode}>✅ Add</button>
|
<button className="btn" onClick={handleSubmitNode}>✅ Add</button>
|
||||||
<button className="btn" style={{ marginLeft: 8 }} onClick={() => setShowForm(false)}>❌ Cancel</button>
|
<button
|
||||||
|
className="btn"
|
||||||
|
style={{ marginLeft: 8, background: '#ccc', color: '#333' }}
|
||||||
|
onClick={() => setShowForm(false)}
|
||||||
|
>
|
||||||
|
❌ Cancel
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@ -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: </label>
|
<div style={{ marginBottom: '0.5rem' }}>
|
||||||
<select value={selectedCategory} onChange={handleCategoryChange}>
|
<label style={{ fontWeight: 'bold', color: '#333' }}>Category: </label>
|
||||||
|
<select
|
||||||
|
value={selectedCategory}
|
||||||
|
onChange={handleCategoryChange}
|
||||||
|
style={{
|
||||||
|
padding: '6px',
|
||||||
|
borderRadius: '6px',
|
||||||
|
border: '1px solid #ccc',
|
||||||
|
fontSize: '14px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
<option value="">Select Category</option>
|
<option value="">Select Category</option>
|
||||||
{Object.keys(categories).map((cat) => (
|
{Object.keys(categories).map((cat) => (
|
||||||
<option key={cat} value={cat}>{cat}</option>
|
<option key={cat} value={cat}>
|
||||||
|
{cat}
|
||||||
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
{selectedCategory && (
|
{selectedCategory && (
|
||||||
<>
|
<div>
|
||||||
<label style={{ marginLeft: '1rem' }}>Icon: </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>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
{selectedIcon && (
|
|
||||||
<img
|
<img
|
||||||
src={selectedIcon}
|
key={url}
|
||||||
alt="preview"
|
src={url}
|
||||||
style={{ width: 32, height: 32, marginLeft: 10, verticalAlign: 'middle' }}
|
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',
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{selectedIcon && (
|
||||||
|
<p style={{ marginTop: 8, fontSize: 13 }}>
|
||||||
|
Selected: <code>{selectedIcon.split('/').pop()}</code>
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
</>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user