MCPcopy Create free account
hub / github.com/cesanta/mongoose / Button

Function Button

tutorials/http/device-dashboard/web_root/components.js:54–70  ·  view source on GitHub ↗
({title, onclick, disabled, cls, icon, ref, colors, hovercolor, disabledcolor})

Source from the content-addressed store, hash-verified

52};
53
54export function Button({title, onclick, disabled, cls, icon, ref, colors, hovercolor, disabledcolor}) {
55 const [spin, setSpin] = useState(false);
56 const cb = function(ev) {
57 const res = onclick ? onclick() : null;
58 if (res && typeof (res.catch) === 'function') {
59 setSpin(true);
60 res.catch(() => false).then(() => setSpin(false));
61 }
62 };
63 if (!colors) colors = 'bg-blue-600 hover:bg-blue-500 disabled:bg-blue-400';
64 return html`
65<button type="button" class="inline-flex justify-center items-center gap-2 rounded px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm ${colors} ${cls}"
66 ref=${ref} onclick=${cb} disabled=${disabled || spin} >
67 ${title}
68 <${spin ? Icons.refresh : icon} class="w-4 ${spin ? 'animate-spin' : ''}" />
69<//>`
70};
71
72export function Notification({ok, text, close}) {
73 const closebtn = useRef(null);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected