Files
frm.so/notes.js

86 lines
2.4 KiB
JavaScript

img(`db/images/${networks[i].logo}`, "2.25em", "2.25em")
.marginTop(3, vh)
.paddingRight(0.5, em)
.onClick(function (finished) {
if(finished) {
this.setAttribute("selected", "")
}
})
.cursor("default")
.Default()
.opacity(0)
.borderLeft(0)
.paddingLeft(10, px)
.Hovered()
.opacity(0.8)
.Watch(global.currentNetwork)
.If((val) => val === this.getAttribute("network"))
.borderLeft("1px solid black")
.paddingLeft(9, px)
.ElseIf((val) => val !== this.getAttribute("network"))
.borderLeft("0")
.paddingLeft(10, px)
render() {
ZStack(() => {
Watch(global.currentNetwork)
.Case("Dashboard", () => {
Dashboard()
})
.Case("People", () => {
People()
})
})
.overflow("scroll")
.position("absolute")
.onEvent("resize", () => {
this.rerender()
})
quill gotchas
img element: width, height, x, and y do not work as usual. You have to put width and height in the constructor, and x and y should be "left" and "top" (or "bottom" and "right")
img(`db/images/${networks[i].logo}`, "2.25em", "2.25em")
forgetting to put a "/" at the beginning of the url for window.navigateTo (if you don't want to add to the existing url)
forgetting to define the event callback with or without the word "function", like so:
if you want "this" to be scoped to the element the listener is on:
.onClick(function (finished) {
if(finished) {
this.setAttribute("selected", "")
}
})
if you want "this" to be scoped to the parent shadow:
.onClick((finished) => {
if(finished) {
this.setAttribute("selected", "")
}
})
window.svg = async function svg(src, width, height) {
const res = await fetch(src);
const svgText = await res.text();
let container = document.createElement("div")
container.innerHTML = svgText;
const svg = container.querySelector("svg");
if(width)
svg.setAttribute("width", width);
if(height)
svg.setAttribute("height", height);
svg.style.display = "block";
svg.setAttribute("aria-hidden", "true");
quill.render(container)
return container
}
rendered 1 svg but gave an error on the attr() function