feat(админка): карточка клиента и drawer

This commit is contained in:
anor
2026-11-06 21:44:07 +10:00
parent c7558f2772
commit 9c9da0f85f
11 changed files with 351 additions and 4 deletions
+21
View File
@@ -0,0 +1,21 @@
import { h } from '/static/admin2/vendor/preact.module.js';
import { useEffect } from '/static/admin2/vendor/hooks.module.js';
import htm from '/static/admin2/vendor/htm.module.js';
const html = htm.bind(h);
export const Drawer = ({ title, onClose, children }) => {
useEffect(() => {
const esc = (e) => { if (e.key === 'Escape') onClose(); };
document.addEventListener('keydown', esc);
return () => document.removeEventListener('keydown', esc);
}, [onClose]);
return html`
<div class="overlay" onClick=${onClose}>
<aside class="drawer" role="dialog" aria-modal="true" aria-label=${title}
onClick=${(e) => e.stopPropagation()}>
<header class="drawer-head"><h2>${title}</h2>
<button type="button" class="drawer-close" onClick=${onClose} aria-label="Закрыть">×</button></header>
${children}
</aside>
</div>`;
};
+2 -2
View File
@@ -2,12 +2,12 @@ import { h } from '/static/admin2/vendor/preact.module.js';
import htm from '/static/admin2/vendor/htm.module.js';
const html = htm.bind(h);
export const Table = ({ columns, rows, empty = 'Никого не нашлось' }) => html`
export const Table = ({ columns, rows, empty = 'Никого не нашлось', onRowClick }) => html`
<div class="table-wrap">
<table>
<thead><tr>${columns.map((c) => html`<th key=${c.key} class=${c.num ? 'num' : ''}>${c.label}</th>`)}</tr></thead>
<tbody>${rows.length ? rows.map((row) => html`
<tr key=${row.key}>${columns.map((c) => html`
<tr key=${row.key} class="clickable" onClick=${() => onRowClick && onRowClick(row)}>${columns.map((c) => html`
<td key=${c.key} class=${c.num ? 'num' : ''}>${c.render ? c.render(row) : row[c.key]}</td>`)}</tr>`)
: html`<tr><td colSpan=${columns.length} class="empty">${empty}</td></tr>`}</tbody>
</table>