xonecas.ioDon't click! Sean Caetano Martin Sign in
tiny-adventure / web / js / chrome.js 12 lines485 bytes Raw
1import { drawText } from './text.js';
2
3export const PAD = 20;
4
5export function chrome(ctx, w, h, title, wd, f, m) {
6  f.panel(ctx, 0, 0, w, h, 'surface');
7  drawText(ctx, title, PAD, 12, { h: 26, size: 21, display: true, maxW: w - PAD * 2 - 40 });
8  const cx = w - PAD - 26;
9  f.button(ctx, cx, 12, 26, 26, '×', { hover: wd.hovered('close'), size: 16 });
10  wd.hit(cx, 12, 26, 26, { name: 'close', key: 'close', onClick: () => m.closePanel() });
11  f.rule(ctx, PAD, 48, w - PAD * 2);
12}