stack state working (when top-level parent)
This commit is contained in:
@@ -52,20 +52,22 @@ window.testSuites.push( class testState {
|
||||
|
||||
render() {
|
||||
VStack(() => {
|
||||
let asd = this.state.logs.length * 2
|
||||
p("hi")
|
||||
.fontSize(asd, vw)
|
||||
this.state.logs.forEach((log) => {
|
||||
p(log)
|
||||
})
|
||||
})
|
||||
.onAppear(() => {
|
||||
this.state.logs = ["one", "two"]
|
||||
this.state.logs.push("one")
|
||||
this.state.logs.push("two")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
register(Home, randomName("home"))
|
||||
window.Home()
|
||||
|
||||
if(!($("p").style.fontSize === "4vw")) return "state did not update!"
|
||||
}
|
||||
|
||||
if(!$("p")) return "no p's rendered"
|
||||
if($$("p")[0].innerText !== "one") return "state did not update!"
|
||||
if($$("p")[1].innerText !== "two") return "state did not update!"
|
||||
}
|
||||
})
|
||||
79
index.js
79
index.js
@@ -553,12 +553,6 @@ HTMLElement.prototype.fontSize = StyleFunction(function(value, unit = "px") {
|
||||
return this
|
||||
})
|
||||
|
||||
function checkPositionType(el) {
|
||||
let computed = window.getComputedStyle(el).position
|
||||
if(!(computed === "absolute" || computed === "fixed")) {
|
||||
el.style.position = "absolute"
|
||||
}
|
||||
}
|
||||
|
||||
HTMLElement.prototype.width = function(value, unit = "px") {
|
||||
if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value))
|
||||
@@ -580,6 +574,13 @@ HTMLElement.prototype.height = function(value, unit = "px") {
|
||||
return this
|
||||
}
|
||||
|
||||
function checkPositionType(el) {
|
||||
let computed = window.getComputedStyle(el).position
|
||||
if(!(computed === "absolute" || computed === "fixed")) {
|
||||
el.style.position = "absolute"
|
||||
}
|
||||
}
|
||||
|
||||
HTMLElement.prototype.x = function(value, unit = "px") {
|
||||
if (typeof value !== 'number' || isNaN(value))
|
||||
throw new Error(`Invalid value: ${value}. Expected a number.`);
|
||||
@@ -821,61 +822,47 @@ window.textarea = function(placeholder = "") {
|
||||
|
||||
/* STACKS */
|
||||
|
||||
window.VStack = function (cb = () => {}) {
|
||||
let styles = `
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
`
|
||||
handleStack = function(cb, name, styles="") {
|
||||
let nowRendering = quill.rendering[quill.rendering.length-1]
|
||||
if (nowRendering.innerHTML.trim() === "" && !quill.isStack(nowRendering)) {
|
||||
nowRendering.style.cssText += styles
|
||||
nowRendering.classList.add("VStack")
|
||||
nowRendering.classList.add(name)
|
||||
cb()
|
||||
if(quill.lastState) {
|
||||
nowRendering.addStateWatcher(quill.lastState, () => {
|
||||
nowRendering.innerHTML = ""
|
||||
cb()
|
||||
})
|
||||
}
|
||||
return nowRendering
|
||||
} else {
|
||||
let div = document.createElement("div")
|
||||
div.classList.add(name)
|
||||
div.style.cssText += styles
|
||||
div.render = cb
|
||||
quill.render(div)
|
||||
return div
|
||||
}
|
||||
}
|
||||
|
||||
let div = document.createElement("div")
|
||||
div.classList.add("VStack")
|
||||
div.style.cssText += styles
|
||||
div.render = cb
|
||||
quill.render(div)
|
||||
return div
|
||||
window.VStack = function (cb = () => {}) {
|
||||
let styles = `
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
`
|
||||
return handleStack(cb, "VStack", styles)
|
||||
}
|
||||
|
||||
window.HStack = function (cb = () => {}) {
|
||||
let styles = `
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
`;
|
||||
let nowRendering = quill.rendering[quill.rendering.length - 1];
|
||||
if (nowRendering.innerHTML.trim() === "" && !quill.isStack(nowRendering)) {
|
||||
nowRendering.style.cssText += styles;
|
||||
nowRendering.classList.add("HStack")
|
||||
cb();
|
||||
return nowRendering;
|
||||
}
|
||||
|
||||
let div = document.createElement("div");
|
||||
div.classList.add("HStack");
|
||||
div.style.cssText += styles;
|
||||
div.render = cb;
|
||||
quill.render(div);
|
||||
return div;
|
||||
return handleStack(cb, "HStack", styles)
|
||||
};
|
||||
|
||||
window.ZStack = function (cb = () => {}) {
|
||||
let nowRendering = quill.rendering[quill.rendering.length - 1];
|
||||
if (nowRendering.innerHTML.trim() === "" && !quill.isStack(nowRendering)) {
|
||||
nowRendering.classList.add("ZStack")
|
||||
cb();
|
||||
return nowRendering;
|
||||
}
|
||||
|
||||
let div = document.createElement("div");
|
||||
div.classList.add("ZStack");
|
||||
div.render = cb;
|
||||
quill.render(div);
|
||||
return div;
|
||||
return handleStack(cb, "ZStack")
|
||||
};
|
||||
|
||||
/* SHAPES */
|
||||
|
||||
Reference in New Issue
Block a user