({title, onclick, disabled, cls, icon, ref, colors, hovercolor, disabledcolor})
| 52 | }; |
| 53 | |
| 54 | export 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 | |
| 72 | export function Notification({ok, text, close}) { |
| 73 | const closebtn = useRef(null); |
nothing calls this directly
no outgoing calls
no test coverage detected