updating quill
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
Sam Russell
|
Sam Russell
|
||||||
Captured Sun
|
Captured Sun
|
||||||
2.24.26 - Allowing state() to watch other elements
|
3.27.26 - Adding quill router, removing dynamicText(), removing horizontal and verticalAlign() checks
|
||||||
2.21.26 - Making state() be called on initial definition, fixing fontSize so it works with clamp(), other strings
|
3.24.26 - Allowing state() to watch other elements
|
||||||
2.20.26 - Adding state()
|
3.21.26 - Making state() be called on initial definition, fixing fontSize so it works with clamp(), other strings
|
||||||
2.19.26 - Adding dynamicText()
|
3.20.26 - Adding state()
|
||||||
|
3.19.26 - Adding dynamicText()
|
||||||
|
3.4.26 - Making horizontalAlign() and verticalAlign() methods of checking for stacks more robust
|
||||||
|
2.27.26 - Adding parentShadow() function
|
||||||
2.16.26 - Adding event objects to the onTouch callbacks
|
2.16.26 - Adding event objects to the onTouch callbacks
|
||||||
1.16.26 - Moving nav event dispatch out of pushState, adding null feature to attr()
|
1.16.26 - Moving nav event dispatch out of pushState, adding null feature to attr()
|
||||||
1.5.26 - Switching verticalAlign and horizontalAlign names, adding borderVertical and Horizontal
|
1.5.26 - Switching verticalAlign and horizontalAlign names, adding borderVertical and Horizontal
|
||||||
@@ -182,6 +185,62 @@ Object.defineProperty(Array.prototype, 'last', {
|
|||||||
window.quill = {
|
window.quill = {
|
||||||
rendering: [],
|
rendering: [],
|
||||||
lastState: null,
|
lastState: null,
|
||||||
|
router: null,
|
||||||
|
|
||||||
|
router: class {
|
||||||
|
routes = []
|
||||||
|
|
||||||
|
route(route, cb) {
|
||||||
|
this.routes.push({route: route, cb: cb})
|
||||||
|
}
|
||||||
|
|
||||||
|
async findMatch() {
|
||||||
|
let matched;
|
||||||
|
for (const route of this.routes) {
|
||||||
|
const [match, params] = this.matchPath(route.route, window.location.pathname)
|
||||||
|
if (match) {
|
||||||
|
await route.cb(params)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!matched) throw new Error("Quill: couldn't match route!")
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
matchPath(pattern, pathname) {
|
||||||
|
const patternParts = pattern.split('/').filter(Boolean)
|
||||||
|
const pathParts = pathname.split('/').filter(Boolean)
|
||||||
|
|
||||||
|
if (patternParts.length !== pathParts.length) return [false]
|
||||||
|
|
||||||
|
const params = []
|
||||||
|
|
||||||
|
for (let i = 0; i < patternParts.length; i++) {
|
||||||
|
if (patternParts[i].startsWith(':')) {
|
||||||
|
params.push(pathParts[i])
|
||||||
|
} else if (patternParts[i] !== pathParts[i]) {
|
||||||
|
return [false]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [true, params]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
init: async (home, router) => {
|
||||||
|
if(router) {
|
||||||
|
quill.router = router
|
||||||
|
window.addEventListener("navigate", () => {
|
||||||
|
if(quill.router) {
|
||||||
|
router.findMatch()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(quill.router) {
|
||||||
|
await router.findMatch()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
home()
|
||||||
|
},
|
||||||
|
|
||||||
render: (el) => {
|
render: (el) => {
|
||||||
if(el instanceof Shadow) {
|
if(el instanceof Shadow) {
|
||||||
@@ -315,6 +374,17 @@ HTMLElement.prototype.rerender = function() {
|
|||||||
quill.rerender(this)
|
quill.rerender(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HTMLElement.prototype.parentShadow = function(selector) {
|
||||||
|
let el = this
|
||||||
|
while(el !== document.body) {
|
||||||
|
el = el.parentElement
|
||||||
|
if(el instanceof Shadow) {
|
||||||
|
return el
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
/* Styling */
|
/* Styling */
|
||||||
|
|
||||||
window.pct = "%"
|
window.pct = "%"
|
||||||
@@ -672,10 +742,6 @@ HTMLElement.prototype.centerY = function () {
|
|||||||
|
|
||||||
HTMLElement.prototype.verticalAlign = function (value) {
|
HTMLElement.prototype.verticalAlign = function (value) {
|
||||||
const direction = getComputedStyle(this).flexDirection;
|
const direction = getComputedStyle(this).flexDirection;
|
||||||
if(!direction) {
|
|
||||||
throw new Error("verticalAlign can be only be used on HStacks or VStacks!")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (direction === "column" || direction === "column-reverse") {
|
if (direction === "column" || direction === "column-reverse") {
|
||||||
this.style.justifyContent = value;
|
this.style.justifyContent = value;
|
||||||
} else {
|
} else {
|
||||||
@@ -686,10 +752,6 @@ HTMLElement.prototype.verticalAlign = function (value) {
|
|||||||
|
|
||||||
HTMLElement.prototype.horizontalAlign = function (value) {
|
HTMLElement.prototype.horizontalAlign = function (value) {
|
||||||
const direction = getComputedStyle(this).flexDirection;
|
const direction = getComputedStyle(this).flexDirection;
|
||||||
if(!direction) {
|
|
||||||
throw new Error("horizontalAlign can be only be used on HStacks or VStacks!")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (direction === "column" || direction === "column-reverse") {
|
if (direction === "column" || direction === "column-reverse") {
|
||||||
this.style.alignItems = value;
|
this.style.alignItems = value;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user