stear/extra/Pages/alert.js

64 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

2022-06-09 17:30:40 +02:00
import { SFrame, _ } from "../../main.js";
2022-10-09 16:38:50 +02:00
import { fadein, fadeout, subCancel } from "../../utils.js";
2022-06-09 17:30:40 +02:00
2022-10-09 16:38:50 +02:00
const call = async (stear, { find, resolve, render, call, event }, { text, titel = "" }) => {
event.onloaded = () => {
fadein(find.main, 200, true);
2022-08-10 21:56:12 +02:00
find.btn._.focus();
2022-10-09 16:38:50 +02:00
}
2022-08-10 21:56:12 +02:00
event.onresolve = async () => await fadeout(find.main);
2022-06-09 17:30:40 +02:00
2022-10-09 16:38:50 +02:00
const cancel = subCancel(() => {
resolve(false);
});
2022-06-09 17:30:40 +02:00
return _({
2022-08-10 21:56:12 +02:00
find: "main",
class: "stear_alert",
2022-06-09 17:30:40 +02:00
style: {
2022-08-10 21:56:12 +02:00
position: "fixed",
2022-06-09 17:30:40 +02:00
left: "0",
top: "0",
2022-08-10 21:56:12 +02:00
height: "100%",
width: "100%",
backgroundColor: "rgba(0,0,0,0.5)"
2022-06-09 17:30:40 +02:00
}
}, _({
2022-08-10 21:56:12 +02:00
style: {
2022-06-09 17:30:40 +02:00
left: "50%",
top: "50%",
transform: "translate(-50%, -50%)",
padding: "1rem",
paddingTop: "0",
position: "absolute",
backgroundColor: "#eee",
2022-06-09 17:33:54 +02:00
minHeight: "4rem",
minWidth: "8rem",
borderRadius: "1rem",
textAlign: "center"
2022-06-09 17:30:40 +02:00
}
}, [
2022-08-10 21:56:12 +02:00
_({ type: "h2", style: { marginBottom: 0 } }, titel),
_({ type: "p" }, text),
_({
2022-10-09 16:38:50 +02:00
type: "button",
find: "btn",
event: {
click: () => {
resolve(true);
cancel();
},
input: (e) => {
console.log(e);
}
},
2022-08-10 21:56:12 +02:00
style: {
borderRadius: "0.5rem",
}
}, "OK"),
2022-06-09 17:30:40 +02:00
]));
}
2022-06-09 21:37:23 +02:00
export default new SFrame({
2022-10-09 16:38:50 +02:00
preRender: true, call
2022-06-09 17:30:40 +02:00
});