feat(админка): карточка клиента и drawer
This commit is contained in:
@@ -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>`;
|
||||
};
|
||||
Reference in New Issue
Block a user