diff --git a/ui/_/code/quill.js b/ui/_/code/quill.js index 23d06c1..8e102ad 100644 --- a/ui/_/code/quill.js +++ b/ui/_/code/quill.js @@ -1,6 +1,9 @@ /* Sam Russell Captured Sun + 11.17.25 - Added dynamic function to have units in style func parameters. + 11.14.25 - Added onTouch, onTap. Changed style setters to work with Safari. Added center() funcs. + 11.13.25 - changed onFocus() to be a boolean event, added onInput() 11.9.25 - changed p(innerText) to p(innerHTML), adjusted onNavigate to work for multiple elements and with correct "this" scope 11.7.25 - changed registerShadow() to register(), changed onClick() to be like onHover() 11.6.25 - adding default value for "button()" "children" parameter @@ -248,15 +251,63 @@ window.css = function css(cssString) { } function extendHTMLElementWithStyleSetters() { - let allStyleProps = Object.keys(document.createElement("div").style) + + function cssValueType(prop) { + const div = document.createElement("div"); + const style = div.style; + if (!(prop in style)) return "invalid"; + + // Does prop accept a value with px? + style[prop] = "10px"; + if (style[prop] === "10px") return "unit-number"; + + // Does prop accept a unitless number (opacity, zIndex, etc)? + style[prop] = "5"; + const computed = getComputedStyle(div)[prop]; + if (!isNaN(parseFloat(computed))) return "unitless-number"; + + return "string"; + } + + let allStyleProps = ["accentColor", "additiveSymbols", "alignContent", "alignItems", "alignSelf", "alignmentBaseline", "all", "anchorName", "anchorScope", "animation", "animationComposition", "animationDelay", "animationDirection", "animationDuration", "animationFillMode", "animationIterationCount", "animationName", "animationPlayState", "animationRange", "animationRangeEnd", "animationRangeStart", "animationTimeline", "animationTimingFunction", "appRegion", "appearance", "ascentOverride", "aspectRatio", "backdropFilter", "backfaceVisibility", "background", "backgroundAttachment", "backgroundBlendMode", "backgroundClip", "backgroundColor", "backgroundImage", "backgroundOrigin", "backgroundPosition", "backgroundPositionX", "backgroundPositionY", "backgroundRepeat", "backgroundSize", "basePalette", "baselineShift", "baselineSource", "blockSize", "border", "borderBlock", "borderBlockColor", "borderBlockEnd", "borderBlockEndColor", "borderBlockEndStyle", "borderBlockEndWidth", "borderBlockStart", "borderBlockStartColor", "borderBlockStartStyle", "borderBlockStartWidth", "borderBlockStyle", "borderBlockWidth", "borderBottom", "borderBottomColor", "borderBottomLeftRadius", "borderBottomRightRadius", "borderBottomStyle", "borderBottomWidth", "borderCollapse", "borderColor", "borderEndEndRadius", "borderEndStartRadius", "borderImage", "borderImageOutset", "borderImageRepeat", "borderImageSlice", "borderImageSource", "borderImageWidth", "borderInline", "borderInlineColor", "borderInlineEnd", "borderInlineEndColor", "borderInlineEndStyle", "borderInlineEndWidth", "borderInlineStart", "borderInlineStartColor", "borderInlineStartStyle", "borderInlineStartWidth", "borderInlineStyle", "borderInlineWidth", "borderLeft", "borderLeftColor", "borderLeftStyle", "borderLeftWidth", "borderRadius", "borderRight", "borderRightColor", "borderRightStyle", "borderRightWidth", "borderSpacing", "borderStartEndRadius", "borderStartStartRadius", "borderStyle", "borderTop", "borderTopColor", "borderTopLeftRadius", "borderTopRightRadius", "borderTopStyle", "borderTopWidth", "borderWidth", "bottom", "boxDecorationBreak", "boxShadow", "boxSizing", "breakAfter", "breakBefore", "breakInside", "bufferedRendering", "captionSide", "caretAnimation", "caretColor", "clear", "clip", "clipPath", "clipRule", "color", "colorInterpolation", "colorInterpolationFilters", "colorRendering", "colorScheme", "columnCount", "columnFill", "columnGap", "columnRule", "columnRuleColor", "columnRuleStyle", "columnRuleWidth", "columnSpan", "columnWidth", "columns", "contain", "containIntrinsicBlockSize", "containIntrinsicHeight", "containIntrinsicInlineSize", "containIntrinsicSize", "containIntrinsicWidth", "container", "containerName", "containerType", "content", "contentVisibility", "cornerBlockEndShape", "cornerBlockStartShape", "cornerBottomLeftShape", "cornerBottomRightShape", "cornerBottomShape", "cornerEndEndShape", "cornerEndStartShape", "cornerInlineEndShape", "cornerInlineStartShape", "cornerLeftShape", "cornerRightShape", "cornerShape", "cornerStartEndShape", "cornerStartStartShape", "cornerTopLeftShape", "cornerTopRightShape", "cornerTopShape", "counterIncrement", "counterReset", "counterSet", "cursor", "cx", "cy", "d", "descentOverride", "direction", "display", "dominantBaseline", "dynamicRangeLimit", "emptyCells", "fallback", "fieldSizing", "fill", "fillOpacity", "fillRule", "filter", "flex", "flexBasis", "flexDirection", "flexFlow", "flexGrow", "flexShrink", "flexWrap", "float", "floodColor", "floodOpacity", "font", "fontDisplay", "fontFamily", "fontFeatureSettings", "fontKerning", "fontOpticalSizing", "fontPalette", "fontSize", "fontSizeAdjust", "fontStretch", "fontStyle", "fontSynthesis", "fontSynthesisSmallCaps", "fontSynthesisStyle", "fontSynthesisWeight", "fontVariant", "fontVariantAlternates", "fontVariantCaps", "fontVariantEastAsian", "fontVariantEmoji", "fontVariantLigatures", "fontVariantNumeric", "fontVariantPosition", "fontVariationSettings", "fontWeight", "forcedColorAdjust", "gap", "grid", "gridArea", "gridAutoColumns", "gridAutoFlow", "gridAutoRows", "gridColumn", "gridColumnEnd", "gridColumnGap", "gridColumnStart", "gridGap", "gridRow", "gridRowEnd", "gridRowGap", "gridRowStart", "gridTemplate", "gridTemplateAreas", "gridTemplateColumns", "gridTemplateRows", "height", "hyphenateCharacter", "hyphenateLimitChars", "hyphens", "imageOrientation", "imageRendering", "inherits", "initialLetter", "initialValue", "inlineSize", "inset", "insetBlock", "insetBlockEnd", "insetBlockStart", "insetInline", "insetInlineEnd", "insetInlineStart", "interactivity", "interpolateSize", "isolation", "justifyContent", "justifyItems", "justifySelf", "left", "letterSpacing", "lightingColor", "lineBreak", "lineGapOverride", "lineHeight", "listStyle", "listStyleImage", "listStylePosition", "listStyleType", "margin", "marginBlock", "marginBlockEnd", "marginBlockStart", "marginBottom", "marginInline", "marginInlineEnd", "marginInlineStart", "marginLeft", "marginRight", "marginTop", "marker", "markerEnd", "markerMid", "markerStart", "mask", "maskClip", "maskComposite", "maskImage", "maskMode", "maskOrigin", "maskPosition", "maskRepeat", "maskSize", "maskType", "mathDepth", "mathShift", "mathStyle", "maxBlockSize", "maxHeight", "maxInlineSize", "maxWidth", "minBlockSize", "minHeight", "minInlineSize", "minWidth", "mixBlendMode", "navigation", "negative", "objectFit", "objectPosition", "objectViewBox", "offset", "offsetAnchor", "offsetDistance", "offsetPath", "offsetPosition", "offsetRotate", "opacity", "order", "orphans", "outline", "outlineColor", "outlineOffset", "outlineStyle", "outlineWidth", "overflow", "overflowAnchor", "overflowBlock", "overflowClipMargin", "overflowInline", "overflowWrap", "overflowX", "overflowY", "overlay", "overrideColors", "overscrollBehavior", "overscrollBehaviorBlock", "overscrollBehaviorInline", "overscrollBehaviorX", "overscrollBehaviorY", "pad", "padding", "paddingBlock", "paddingBlockEnd", "paddingBlockStart", "paddingBottom", "paddingInline", "paddingInlineEnd", "paddingInlineStart", "paddingLeft", "paddingRight", "paddingTop", "page", "pageBreakAfter", "pageBreakBefore", "pageBreakInside", "pageOrientation", "paintOrder", "perspective", "perspectiveOrigin", "placeContent", "placeItems", "placeSelf", "pointerEvents", "position", "positionAnchor", "positionArea", "positionTry", "positionTryFallbacks", "positionTryOrder", "positionVisibility", "prefix", "printColorAdjust", "quotes", "r", "range", "readingFlow", "readingOrder", "resize", "result", "right", "rotate", "rowGap", "rubyAlign", "rubyPosition", "rx", "ry", "scale", "scrollBehavior", "scrollInitialTarget", "scrollMargin", "scrollMarginBlock", "scrollMarginBlockEnd", "scrollMarginBlockStart", "scrollMarginBottom", "scrollMarginInline", "scrollMarginInlineEnd", "scrollMarginInlineStart", "scrollMarginLeft", "scrollMarginRight", "scrollMarginTop", "scrollMarkerGroup", "scrollPadding", "scrollPaddingBlock", "scrollPaddingBlockEnd", "scrollPaddingBlockStart", "scrollPaddingBottom", "scrollPaddingInline", "scrollPaddingInlineEnd", "scrollPaddingInlineStart", "scrollPaddingLeft", "scrollPaddingRight", "scrollPaddingTop", "scrollSnapAlign", "scrollSnapStop", "scrollSnapType", "scrollTargetGroup", "scrollTimeline", "scrollTimelineAxis", "scrollTimelineName", "scrollbarColor", "scrollbarGutter", "scrollbarWidth", "shapeImageThreshold", "shapeMargin", "shapeOutside", "shapeRendering", "size", "sizeAdjust", "speak", "speakAs", "src", "stopColor", "stopOpacity", "stroke", "strokeDasharray", "strokeDashoffset", "strokeLinecap", "strokeLinejoin", "strokeMiterlimit", "strokeOpacity", "strokeWidth", "suffix", "symbols", "syntax", "system", "tabSize", "tableLayout", "textAlign", "textAlignLast", "textAnchor", "textAutospace", "textBox", "textBoxEdge", "textBoxTrim", "textCombineUpright", "textDecoration", "textDecorationColor", "textDecorationLine", "textDecorationSkipInk", "textDecorationStyle", "textDecorationThickness", "textEmphasis", "textEmphasisColor", "textEmphasisPosition", "textEmphasisStyle", "textIndent", "textOrientation", "textOverflow", "textRendering", "textShadow", "textSizeAdjust", "textSpacingTrim", "textTransform", "textUnderlineOffset", "textUnderlinePosition", "textWrap", "textWrapMode", "textWrapStyle", "timelineScope", "top", "touchAction", "transform", "transformBox", "transformOrigin", "transformStyle", "transition", "transitionBehavior", "transitionDelay", "transitionDuration", "transitionProperty", "transitionTimingFunction", "translate", "types", "unicodeBidi", "unicodeRange", "userSelect", "vectorEffect", "verticalAlign", "viewTimeline", "viewTimelineAxis", "viewTimelineInset", "viewTimelineName", "viewTransitionClass", "viewTransitionGroup", "viewTransitionName", "visibility", "webkitAlignContent", "webkitAlignItems", "webkitAlignSelf", "webkitAnimation", "webkitAnimationDelay", "webkitAnimationDirection", "webkitAnimationDuration", "webkitAnimationFillMode", "webkitAnimationIterationCount", "webkitAnimationName", "webkitAnimationPlayState", "webkitAnimationTimingFunction", "webkitAppRegion", "webkitAppearance", "webkitBackfaceVisibility", "webkitBackgroundClip", "webkitBackgroundOrigin", "webkitBackgroundSize", "webkitBorderAfter", "webkitBorderAfterColor", "webkitBorderAfterStyle", "webkitBorderAfterWidth", "webkitBorderBefore", "webkitBorderBeforeColor", "webkitBorderBeforeStyle", "webkitBorderBeforeWidth", "webkitBorderBottomLeftRadius", "webkitBorderBottomRightRadius", "webkitBorderEnd", "webkitBorderEndColor", "webkitBorderEndStyle", "webkitBorderEndWidth", "webkitBorderHorizontalSpacing", "webkitBorderImage", "webkitBorderRadius", "webkitBorderStart", "webkitBorderStartColor", "webkitBorderStartStyle", "webkitBorderStartWidth", "webkitBorderTopLeftRadius", "webkitBorderTopRightRadius", "webkitBorderVerticalSpacing", "webkitBoxAlign", "webkitBoxDecorationBreak", "webkitBoxDirection", "webkitBoxFlex", "webkitBoxOrdinalGroup", "webkitBoxOrient", "webkitBoxPack", "webkitBoxReflect", "webkitBoxShadow", "webkitBoxSizing", "webkitClipPath", "webkitColumnBreakAfter", "webkitColumnBreakBefore", "webkitColumnBreakInside", "webkitColumnCount", "webkitColumnGap", "webkitColumnRule", "webkitColumnRuleColor", "webkitColumnRuleStyle", "webkitColumnRuleWidth", "webkitColumnSpan", "webkitColumnWidth", "webkitColumns", "webkitFilter", "webkitFlex", "webkitFlexBasis", "webkitFlexDirection", "webkitFlexFlow", "webkitFlexGrow", "webkitFlexShrink", "webkitFlexWrap", "webkitFontFeatureSettings", "webkitFontSmoothing", "webkitHyphenateCharacter", "webkitJustifyContent", "webkitLineBreak", "webkitLineClamp", "webkitLocale", "webkitLogicalHeight", "webkitLogicalWidth", "webkitMarginAfter", "webkitMarginBefore", "webkitMarginEnd", "webkitMarginStart", "webkitMask", "webkitMaskBoxImage", "webkitMaskBoxImageOutset", "webkitMaskBoxImageRepeat", "webkitMaskBoxImageSlice", "webkitMaskBoxImageSource", "webkitMaskBoxImageWidth", "webkitMaskClip", "webkitMaskComposite", "webkitMaskImage", "webkitMaskOrigin", "webkitMaskPosition", "webkitMaskPositionX", "webkitMaskPositionY", "webkitMaskRepeat", "webkitMaskSize", "webkitMaxLogicalHeight", "webkitMaxLogicalWidth", "webkitMinLogicalHeight", "webkitMinLogicalWidth", "webkitOpacity", "webkitOrder", "webkitPaddingAfter", "webkitPaddingBefore", "webkitPaddingEnd", "webkitPaddingStart", "webkitPerspective", "webkitPerspectiveOrigin", "webkitPerspectiveOriginX", "webkitPerspectiveOriginY", "webkitPrintColorAdjust", "webkitRtlOrdering", "webkitRubyPosition", "webkitShapeImageThreshold", "webkitShapeMargin", "webkitShapeOutside", "webkitTapHighlightColor", "webkitTextCombine", "webkitTextDecorationsInEffect", "webkitTextEmphasis", "webkitTextEmphasisColor", "webkitTextEmphasisPosition", "webkitTextEmphasisStyle", "webkitTextFillColor", "webkitTextOrientation", "webkitTextSecurity", "webkitTextSizeAdjust", "webkitTextStroke", "webkitTextStrokeColor", "webkitTextStrokeWidth", "webkitTransform", "webkitTransformOrigin", "webkitTransformOriginX", "webkitTransformOriginY", "webkitTransformOriginZ", "webkitTransformStyle", "webkitTransition", "webkitTransitionDelay", "webkitTransitionDuration", "webkitTransitionProperty", "webkitTransitionTimingFunction", "webkitUserDrag", "webkitUserModify", "webkitUserSelect", "webkitWritingMode", "whiteSpace", "whiteSpaceCollapse", "widows", "width", "willChange", "wordBreak", "wordSpacing", "wordWrap", "writingMode", "x", "y", "zIndex", "zoom"] + allStyleProps.forEach(prop => { - if(prop === "translate") return - HTMLElement.prototype[prop] = function(value) { - this.style[prop] = value; - return this; - }; + if (prop === "translate") return; + if(prop === "position") console.log("position") + + const type = cssValueType(prop); + + switch (type) { + case "unit-number": + HTMLElement.prototype[prop] = function(value, unit = "px") { + if (typeof value !== "number" || isNaN(value)) { + throw new Error(`Invalid value for ${prop}: ${value}. Expected a number.`); + } + this.style[prop] = value + unit; + return this; + }; + break; + + case "unitless-number": + HTMLElement.prototype[prop] = function(value) { + if (typeof value !== "number" || isNaN(value)) { + throw new Error(`Invalid value for ${prop}: ${value}. Expected a number.`); + } + this.style[prop] = String(value); + return this; + }; + break; + + case "string": + HTMLElement.prototype[prop] = function(value) { + this.style[prop] = value; + return this; + }; + break; + } }); } + extendHTMLElementWithStyleSetters(); HTMLElement.prototype.padding = function(one, two, three = "px") { @@ -285,34 +336,6 @@ HTMLElement.prototype.padding = function(one, two, three = "px") { return this; }; - HTMLElement.prototype.paddingTop = function(value, unit = "px") { - if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value)) - throw new Error(`Invalid value: ${value}. Expected a number.`); - this.style.paddingTop = value + unit - return this - } - - HTMLElement.prototype.paddingLeft = function(value, unit = "px") { - if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value)) - throw new Error(`Invalid value: ${value}. Expected a number.`); - this.style.paddingLeft = value + unit - return this - } - - HTMLElement.prototype.paddingBottom = function(value, unit = "px") { - if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value)) - throw new Error(`Invalid value: ${value}. Expected a number.`); - this.style.paddingBottom = value + unit - return this - } - - HTMLElement.prototype.paddingRight = function(value, unit = "px") { - if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value)) - throw new Error(`Invalid value: ${value}. Expected a number.`); - this.style.paddingRight = value + unit - return this - } - HTMLElement.prototype.paddingVertical = function(value, unit = "px") { if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value)) throw new Error(`Invalid value: ${value}. Expected a number.`); @@ -353,62 +376,6 @@ HTMLElement.prototype.margin = function(direction, value, unit = "px") { return this; }; - HTMLElement.prototype.marginTop = function(value, unit = "px") { - if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value)) - throw new Error(`Invalid value: ${value}. Expected a number.`); - this.style.marginTop = value + unit - return this - } - - HTMLElement.prototype.marginLeft = function(value, unit = "px") { - if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value)) - throw new Error(`Invalid value: ${value}. Expected a number.`); - this.style.marginLeft = value + unit - return this - } - - HTMLElement.prototype.marginBottom = function(value, unit = "px") { - if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value)) - throw new Error(`Invalid value: ${value}. Expected a number.`); - this.style.marginBottom = value + unit - return this - } - - HTMLElement.prototype.marginRight = function(value, unit = "px") { - if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value)) - throw new Error(`Invalid value: ${value}. Expected a number.`); - this.style.marginRight = value + unit - return this - } - -HTMLElement.prototype.width = function(value, unit = "px") { - if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value)) - throw new Error(`Invalid value: ${value}. Expected a number.`); - this.style.width = value + unit - return this -} - -HTMLElement.prototype.minWidth = function(value, unit = "px") { - if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value)) - throw new Error(`Invalid value: ${value}. Expected a number.`); - this.style.minWidth = value + unit - return this -} - -HTMLElement.prototype.height = function(value, unit = "px") { - if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value)) - throw new Error(`Invalid value: ${value}. Expected a number.`); - this.style.height = value + unit - return this -} - -HTMLElement.prototype.minHeight = function(value, unit = "px") { - if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value)) - throw new Error(`Invalid value: ${value}. Expected a number.`); - this.style.minHeight = value + unit - return this -} - HTMLElement.prototype.fontSize = function(value, unit = "px") { if ((typeof value !== 'number' && value !== "auto") || Number.isNaN(value)) throw new Error(`Invalid value: ${value}. Expected a number.`); @@ -496,29 +463,6 @@ HTMLElement.prototype.yBottom = function(value, unit = "px") { return this } -HTMLElement.prototype.borderRadius = function(value, unit = "px") { - if (typeof value !== 'number' || isNaN(value)) - throw new Error(`Invalid value: ${value}. Expected a number.`); - this.style.borderRadius = value + unit - return this -} - -HTMLElement.prototype.positionType = function (value) { - if(!(value === "absolute" || value === "relative" || value === "static" || value === "fixed" || value === "sticky")) { - console.error("HTMLElement.overlflow: must have valid overflow value!") - return; - } - this.style.position = value - return this -} - -HTMLElement.prototype.gap = function(value, unit = "px") { - if (typeof value !== 'number' || Number.isNaN(value)) - throw new Error(`Invalid value: ${value}. Expected a number.`); - this.style.gap = value + unit - return this -} - HTMLElement.prototype.backgroundImage = function (...values) { const formatted = values .map(v => { @@ -533,6 +477,21 @@ HTMLElement.prototype.backgroundImage = function (...values) { return this; }; +HTMLElement.prototype.center = function () { + this.style.transform = "translate(-50%, -50%)" + return this; +}; + +HTMLElement.prototype.centerX = function () { + this.style.transform = "translateX(-50%)" + return this; +}; + +HTMLElement.prototype.centerY = function () { + this.style.transform = "translateY(-50%)" + return this; +}; + /* Elements */ quill.setChildren = function(el, innerContent) { @@ -737,6 +696,99 @@ window.ZStack = function (cb = () => {}) { return div; }; +/* SHAPES */ + +window.svgMethods = function(svg) { + svg.pulse = function (duration = 600) { + this.style.transition = `transform ${duration}ms ease-in-out` + this.style.transform = "scale(1.2)" + setTimeout(() => { + this.style.transform = "scale(1)" + }, duration / 2) + return this + } + + // Rotate (e.g. loading spinner) + svg.rotate = function (degrees = 360, duration = 1000) { + this.style.transition = `transform ${duration}ms linear` + this.style.transform = `rotate(${degrees}deg)` + return this + } + + // Change color + svg.fill = function (color) { + this.setAttribute("fill", color) + return this + } + + svg.height = function (height) { + this.setAttribute("height", height) + return this + } + + svg.width = function (width) { + this.setAttribute("width", width) + return this + } + + svg.stroke = function (width, color) { + this.setAttribute("stroke", color) + this.setAttribute("stroke-width", width) + return this + } + + // Toggle visibility + svg.toggle = function () { + this.style.display = this.style.display === "none" ? "" : "none" + return this + } +} + +window.Rectangle = function (width = "40px", height = "40px") { + const svgNS = "http://www.w3.org/2000/svg"; + const svgEl = document.createElementNS(svgNS, "svg"); + const rectEl = document.createElementNS(svgNS, "rect"); + + // SVG size + svgEl.setAttribute("width", width); + svgEl.setAttribute("height", height); + svgEl.setAttribute("viewBox", "0 0 100 100"); + svgEl.setAttribute("preserveAspectRatio", "xMidYMid meet"); + + // Rectangle: full size, slightly rounded corners + rectEl.setAttribute("x", "15"); // 15% margin from edges + rectEl.setAttribute("y", "15"); + rectEl.setAttribute("width", "70"); // 70% of viewBox + rectEl.setAttribute("height", "70"); + // rectEl.setAttribute("rx", "8"); // rounded corners (optional) + // rectEl.setAttribute("ry", "8"); + + svgEl.appendChild(rectEl); + svgMethods(svgEl); // assuming you have this + quill.render(svgEl); + return svgEl; +} + +window.Triangle = function (width = "40px", height = "40px") { + const svgNS = "http://www.w3.org/2000/svg" + const svgEl = document.createElementNS(svgNS, "svg") + const pathEl = document.createElementNS(svgNS, "path") + + // SVG size + svgEl.setAttribute("width", width) + svgEl.setAttribute("height", height) + svgEl.setAttribute("viewBox", "0 0 100 100") + svgEl.setAttribute("preserveAspectRatio", "xMidYMid meet") + // Right-pointing triangle (Play icon) + pathEl.setAttribute("d", "M 25 15 L 90 50 L 25 85 Z") // ◄ adjust points if needed + + svgEl.appendChild(pathEl) + svgMethods(svgEl) + quill.render(svgEl) + return svgEl +} + + /* EVENTS */ HTMLElement.prototype.onAppear = function(func) { @@ -779,15 +831,10 @@ HTMLElement.prototype.onFocus = function(cb) { if (!this.matches('input, textarea, select, button')) { throw new Error("Can't put focus event on non-form element!"); } - this._storeListener("focus", cb); - return this; -}; - -HTMLElement.prototype.onBlur = function(cb) { - if (!this.matches('input, textarea, select, button')) { - throw new Error("Can't put blur event on non-form element!"); - } - this._storeListener("blur", cb); + const onFocus = () => cb.call(this, true); + const onBlur = () => cb.call(this, false); + this._storeListener("focus", onFocus); + this._storeListener("blur", onBlur); return this; }; @@ -796,10 +843,32 @@ HTMLElement.prototype.onKeyDown = function(cb) { return this; }; +HTMLElement.prototype.onInput = function(cb) { + if(!this.matches('input, textarea, [contenteditable=""], [contenteditable="true"]')) + throw new Error("Can't put input event on non-input element!") + this._storeListener("input", cb); + return this; +}; + +HTMLElement.prototype.onTouch = function(cb) { + const onStart = () => cb.call(this, true); + const onEnd = () => cb.call(this, false); + const onCancel = () => cb.call(this, null); + this._storeListener("touchstart", onStart); + this._storeListener("touchend", onEnd); + this._storeListener("touchcancel", onCancel); + return this; +}; + +HTMLElement.prototype.onTap = function(cb) { + this._storeListener("touchend", cb); + return this; +}; + /* WHY THIS LISTENER IS THE WAY IT IS: - If we dispatch the "navigate" event on the window (as one would expect for a "navigate" event), a listener placed on the element will not pick it up. -- However, if we add the event as a window event, it won't have the "this" scope that a callback normally would. -- Then, if we try to add that scope using bind(), it makes the function.toString() unreadable, which means we will get false positives for duplicate listeners. +- However, if we add the listener here on the window, it won't have the "this" scope that a callback normally would. Which makes it much less useful. +- Then, if we try to add that scope using bind(), it makes the function.toString() unreadable, which means we cannot detect duplicate listeners. - Therefore, we just have to attach the navigate event to the element, and manually trigger that when the window listener fires. */ HTMLElement.prototype.onNavigate = function(cb) { diff --git a/ui/_/code/shared.css b/ui/_/code/shared.css index 5749d7f..8b5591e 100644 --- a/ui/_/code/shared.css +++ b/ui/_/code/shared.css @@ -3,6 +3,7 @@ --accent: var(--darkbrown); --tan: #FFDFB4; + --gold: #F2B36F; --purple: #251D44; --green: #0B5538; --red: #BC1C02; @@ -17,7 +18,7 @@ @media (prefers-color-scheme: dark) { :root { --main: #251D44; - --accent: #AF7323; + --accent: var(--gold); --accent2: var(--periwinkle); } } @@ -30,21 +31,21 @@ } @font-face { - font-family: 'BonaNova'; + font-family: 'Bona Nova'; src: url('/_/fonts/BonaNova/BonaNova-Regular.woff') format('truetype'); font-weight: normal; font-style: normal; } @font-face { - font-family: 'BonaNova'; + font-family: 'Bona Nova'; src: url('/_/fonts/BonaNova/BonaNova-Bold.woff') format('truetype'); font-weight: bold; font-style: normal; } body { - font-family: 'BonaNova', sans-serif; + font-family: 'Bona Nova', sans-serif; font-size: 16px; background-color: var(--main); color: var(--accent); diff --git a/ui/_/images/fabric.png b/ui/_/images/fabric.png new file mode 100644 index 0000000..c0dfbda Binary files /dev/null and b/ui/_/images/fabric.png differ diff --git a/ui/_/images/knight.png b/ui/_/images/knight.png new file mode 100644 index 0000000..27dcf5e Binary files /dev/null and b/ui/_/images/knight.png differ diff --git a/ui/public/components/Home.js b/ui/public/components/Home.js new file mode 100644 index 0000000..2c35d51 --- /dev/null +++ b/ui/public/components/Home.js @@ -0,0 +1,25 @@ +import "./NavBar.js" + +class Home extends Shadow { + render() { + img("_/images/knight.png", "29vw") + .position("absolute") + .left(50, vw).top(50, vh) + .center() + + p("H Y P E R I A") + .x(50, vw).y(50, vh) + .center() + .color("var(--gold)") + .fontSize(5, vw) + + NavBar() + + p("A CLASSICAL CHRISTIAN ASSOCIATION") + .x(50, vw).y(94, vh) + .center() + .letterSpacing(0.3, em) + } +} + +register(Home) \ No newline at end of file diff --git a/ui/public/components/NavBar.js b/ui/public/components/NavBar.js index 9e97bb2..350bf91 100644 --- a/ui/public/components/NavBar.js +++ b/ui/public/components/NavBar.js @@ -1,150 +1,44 @@ -css(` - nav-bar { - position: fixed; - top: 0px; - left: 0px; - width: 100vw; - z-index: 1; - height: 100px; - } - - .title-div { - position: absolute; - left: 2em; - top: 2em; - display: flex; - align-items: center; - } - - .links-div { - position: absolute; - right: 3em; - top: 2.75em; - display: flex; - } - - .logo-p { - font-size: 2em; - margin: 0 0 0 15px; - letter-spacing: 1px; - text-align: center; - } - - .nav-hamburger { - margin-right: 8vw; - display: none; - max-height:40px; - } - - .nav-link { - font-size: 1em; - margin: 0 0 0 15px; - letter-spacing: 1px; - } - - @media only screen and (max-width: 820px) { - nav-bar a { - text-decoration: none; - color: var(--green); - } - - .title-div { - position: static - } - - .logo { - width: 10vw; - } - - .logo-p { - font-size: 8vw; - margin: 0 0 0 1vw; - } - - .nav-hamburger { - display: block; - } - - .links-div { - display:none; - } - - .outer-nav { - position: fixed; - left: 0; - top: 0; - width: 100%; - height: 20vw; - background: var(--tan); - display: flex; - z-index: 1; - justify-content: space-between; - align-items: center; - padding: 0 3vw; - max-height:80px; - } - } -`) +class NavBar extends Shadow { + render() { + HStack(() => { + p("WHY?") + p("EVENTS") + p("JOIN") + p("SIGN IN") + }) + .x(50, vw).y(4, em) + .center() + .fontSize(0.85, em) + .justifyContent("center") + .gap(3, em) + .paddingRight(2, em) + .onNavigate(() => { + console.log("hi") + }) + .onAppear(() => { + Array.from(this.$("p")).forEach((el) => { + el.addEventListener("mousedown", (e) => { + el.classList.add("touched") + }) + }) + window.addEventListener("mouseup", (e) => { + let target = e.target + if(!target.matches("app-menu p")) { + return + } -export default class NavBar extends HTMLElement { - connectedCallback() { - this.innerHTML += /* html */ ` -
- - `; + target.classList.remove("touched") - // Track which anchor was pressed down - let activeLink = null; - - // Get all anchor tags inside this element - const anchors = this.querySelectorAll('a'); - - anchors.forEach(anchor => { - anchor.addEventListener('mousedown', (e) => { - activeLink = anchor; - }); - }); - - // Listen globally for mouseup, to detect release anywhere - document.addEventListener('mouseup', (e) => { - if (activeLink) { - // Navigate to the href of the activeLink - window.location.href = activeLink.href; - activeLink = null; - } - }); - - const hamburger = this.querySelectorAll("img")[1] - const sidebar = document.querySelector("side-bar"); - - hamburger.addEventListener("click", () => { - if (sidebar.style.right === "0vw") { - sidebar.style.right = "-100vw"; - } else { - sidebar.style.right = "0vw"; - } - }); + if(target.classList.contains("selected")) { + this.selected = "" + window.navigateTo("/") + } else { + this.selected = target.innerText + window.navigateTo("/app/" + target.innerText.toLowerCase()) + } + }) + }) } } -customElements.define("nav-bar", NavBar) +register(NavBar) \ No newline at end of file diff --git a/ui/public/index.css b/ui/public/index.css deleted file mode 100644 index e69de29..0000000 diff --git a/ui/public/index.html b/ui/public/index.html index a750596..d836fa3 100644 --- a/ui/public/index.html +++ b/ui/public/index.html @@ -9,32 +9,12 @@ body { font-size: 16px; + background-image: url("_/images/fabric.png"); + background-size: 33vw auto; /* width height of each tile */ } - - .main-image { - content:url("_/images/castle.svg"); position: absolute; height: 70vh; bottom: 2vh; left: 55vw; transform: translateX(-50%); - user-select: none; - } - @media (max-width: 600px) { - .main-image { - max-width: 90vw; bottom: -7vh; - }} - @media (prefers-color-scheme: dark) { - .main-image { - content:url("_/images/castle-dark3.svg"); - height: 1000px; bottom: -34vmin; left: 26vw; - }} - @media (prefers-color-scheme: dark) and (max-width: 600px) { - .main-image { - max-width: 195vw; height: 80vh; left: 0vw; - }} - + - hyperia - -Hyperia is a private club, focused on promoting the Classical Christian movement in America.
-Inspired by Classical Christian schools, Hyperia is a similar space for adults.
-