diff --git a/components.js b/components.js index 27943af..2e62640 100644 --- a/components.js +++ b/components.js @@ -2,89 +2,112 @@ const smButton = document.createElement('template') smButton.innerHTML = `
@@ -93,7 +116,9 @@ customElements.define('sm-button', class extends HTMLElement { constructor() { super() - this.attachShadow({ mode: 'open' }).append(smButton.content.cloneNode(true)) + this.attachShadow({ + mode: 'open' + }).append(smButton.content.cloneNode(true)) } get disabled() { @@ -105,8 +130,7 @@ customElements.define('sm-button', this.isDisabled = true this.setAttribute('disabled', '') this.button.removeAttribute('tabindex') - } - else if (!value && this.isDisabled) { + } else if (!value && this.isDisabled) { this.isDisabled = false this.removeAttribute('disabled') } @@ -118,8 +142,7 @@ customElements.define('sm-button', bubbles: true, composed: true })) - } - else { + } else { this.dispatchEvent(new CustomEvent('clicked', { bubbles: true, composed: true @@ -149,7 +172,8 @@ smInput.innerHTML = ` *{ padding: 0; margin: 0; - box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; } input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button, @@ -171,12 +195,15 @@ input::-ms-clear { } input:invalid{ outline: none; - box-shadow: none; + -webkit-box-shadow: none; + box-shadow: none; } ::-moz-focus-inner{ border: none; } :host{ + display: -webkit-box; + display: -ms-flexbox; display: flex; } .hide{ @@ -204,18 +231,25 @@ border: none; border-radius: 10rem; } .input { + display: -webkit-box; + display: -ms-flexbox; display: flex; - align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; text-align: left; position: relative; gap: 1em; padding: 0.7em 1em; border-radius: 0.3em; + -webkit-transition: opacity 0.3s; + -o-transition: opacity 0.3s; transition: opacity 0.3s; background: rgba(var(--text-color), 0.06); - box-shadow: 0 0 0.2rem rgba(var(--text-color), 0.2) inset; + -webkit-box-shadow: 0 0 0.2rem rgba(var(--text-color), 0.2) inset; + box-shadow: 0 0 0.2rem rgba(var(--text-color), 0.2) inset; font-family: var(--font-family); - width: 100% + width: 100%; outline: none; min-width: 0; } @@ -230,26 +264,36 @@ input:focus{ caret-color: var(--accent-color); } .input:focus-within:not(.readonly){ - box-shadow: 0 0 0 0.1em var(--accent-color) inset; + -webkit-box-shadow: 0 0 0 0.1em var(--accent-color) inset; + box-shadow: 0 0 0 0.1em var(--accent-color) inset; } .disabled{ pointer-events: none; opacity: 0.6; } .label { - user-select: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; opacity: .7; font-weight: 400; font-size: 1em; position: absolute; top: 0; + -webkit-transition: -webkit-transform 0.3s; + transition: -webkit-transform 0.3s; + -o-transition: transform 0.3s; transition: transform 0.3s; + transition: transform 0.3s, -webkit-transform 0.3s; -webkit-transform-origin: left; - transform-origin: left; + -ms-transform-origin: left; + transform-origin: left; pointer-events: none; white-space: nowrap; overflow: hidden; - text-overflow: ellipsis; + -o-text-overflow: ellipsis; + text-overflow: ellipsis; width: 100%; will-change: transform; } @@ -259,10 +303,16 @@ input:focus{ } .container{ width: 100%; + display: -webkit-box; + display: -ms-flexbox; display: flex; position: relative; - align-items: center; - flex: 1; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1; } input{ font-size: 1em; @@ -274,12 +324,14 @@ input{ } .animate-label .container input { -webkit-transform: translateY(0.6em); - transform: translateY(0.6em); + -ms-transform: translateY(0.6em); + transform: translateY(0.6em); } .animate-label .container .label { -webkit-transform: translateY(-0.6em) scale(0.8); - transform: translateY(-0.6em) scale(0.8); + -ms-transform: translateY(-0.6em) scale(0.8); + transform: translateY(-0.6em) scale(0.8); opacity: 1; color: var(--accent-color) } @@ -323,7 +375,9 @@ customElements.define('sm-input', class extends HTMLElement { constructor() { super() - this.attachShadow({ mode: 'open' }).append(smInput.content.cloneNode(true)) + this.attachShadow({ + mode: 'open' + }).append(smInput.content.cloneNode(true)) } static get observedAttributes() { return ['placeholder'] @@ -364,11 +418,10 @@ customElements.define('sm-input', set readOnly(value) { if (value) { this.shadowRoot.querySelector('input').setAttribute('readonly', '') - this.shadowRoot.querySelector('.input').classList.add('readonly') - } - else { + this.shadowRoot.querySelector('.input').classList.add('readonly') + } else { this.shadowRoot.querySelector('input').removeAttribute('readonly') - this.shadowRoot.querySelector('.input').classList.remove('readonly') + this.shadowRoot.querySelector('.input').classList.remove('readonly') } } @@ -406,8 +459,7 @@ customElements.define('sm-input', this.label.classList.add('hide') if (!this.readonly) this.clearBtn.classList.remove('hide') - } - else { + } else { if (this.animate) this.inputParent.classList.remove('animate-label') else @@ -460,7 +512,7 @@ customElements.define('sm-input', } if (this.hasAttribute('readonly')) { this.input.setAttribute('readonly', '') - this.readonly = true + this.readonly = true } if (this.hasAttribute('disabled')) { this.inputParent.classList.add('disabled') @@ -472,11 +524,9 @@ customElements.define('sm-input', if (this.getAttribute('type') === 'number') { this.input.setAttribute('inputmode', 'numeric') this.input.setAttribute('type', 'number') - } - else + } else this.input.setAttribute('type', this.getAttribute('type')) - } - else + } else this.input.setAttribute('type', 'text') this.input.addEventListener('keydown', e => { if (this.getAttribute('type') === 'number') @@ -507,12 +557,15 @@ smTextarea.innerHTML = ` *{ padding: 0; margin: 0; - box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; } ::-moz-focus-inner{ border: none; } :host{ + display: -webkit-box; + display: -ms-flexbox; display: flex; } .hide{ @@ -537,16 +590,24 @@ smTextarea.innerHTML = ` min-width: 0; } .input { - flex: 1; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1; + display: -webkit-box; + display: -ms-flexbox; display: flex; - align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; position: relative; padding: 0.7em 1em; border-radius: 0.3em; + -webkit-transition: opacity 0.3s; + -o-transition: opacity 0.3s; transition: opacity 0.3s; background: rgba(var(--text-color), 0.1); font-family: var(--font-family); - width: 100% + width: 100%; outline: none; min-width: 0; } @@ -555,23 +616,33 @@ textarea:focus{ caret-color: var(--accent-color); } .input:focus-within{ - box-shadow: 0 0 0 0.1em var(--accent-color) inset; + -webkit-box-shadow: 0 0 0 0.1em var(--accent-color) inset; + box-shadow: 0 0 0 0.1em var(--accent-color) inset; } .label { - user-select: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; opacity: .7; font-weight: 400; font-size: 1em; position: absolute; top: 0.9em; + -webkit-transition: -webkit-transform 0.3s; + transition: -webkit-transform 0.3s; + -o-transition: transform 0.3s; transition: transform 0.3s; + transition: transform 0.3s, -webkit-transform 0.3s; -webkit-transform-origin: left; - transform-origin: left; + -ms-transform-origin: left; + transform-origin: left; pointer-events: none; white-space: nowrap; overflow: hidden; - text-overflow: ellipsis; + -o-text-overflow: ellipsis; + text-overflow: ellipsis; width: 100%; will-change: transform; } @@ -587,17 +658,20 @@ textarea{ } .animate-label textarea { -webkit-transform: translateY(0.6em); - transform: translateY(0.6em); + -ms-transform: translateY(0.6em); + transform: translateY(0.6em); } .animate-label .label { -webkit-transform: translateY(-0.6em) scale(0.8); - transform: translateY(-0.6em) scale(0.8); + -ms-transform: translateY(-0.6em) scale(0.8); + transform: translateY(-0.6em) scale(0.8); opacity: 1; color: var(--accent-color) } .clear{ - align-self: flex-start; + -ms-flex-item-align: start; + align-self: flex-start; } @media (any-hover: hover){ .icon:hover{ @@ -619,7 +693,9 @@ customElements.define('sm-textarea', class extends HTMLElement { constructor() { super() - this.attachShadow({ mode: 'open' }).append(smTextarea.content.cloneNode(true)) + this.attachShadow({ + mode: 'open' + }).append(smTextarea.content.cloneNode(true)) } static get observedAttributes() { return ['placeholder'] @@ -660,8 +736,7 @@ customElements.define('sm-textarea', this.inputParent.classList.add('animate-label') else this.label.classList.add('hide') - } - else { + } else { if (this.animate) this.inputParent.classList.remove('animate-label') else @@ -722,42 +797,52 @@ customElements.define('sm-textarea', const smTab = document.createElement('template') smTab.innerHTML = `
@@ -767,7 +852,9 @@ opacity: 1 customElements.define('sm-tab', class extends HTMLElement { constructor() { super() - this.shadow = this.attachShadow({ mode: 'open' }).append(smTab.content.cloneNode(true)) + this.shadow = this.attachShadow({ + mode: 'open' + }).append(smTab.content.cloneNode(true)) } }) @@ -776,88 +863,99 @@ customElements.define('sm-tab', class extends HTMLElement { const smCheckbox = document.createElement('template') smCheckbox.innerHTML = ` ` customElements.define('sm-checkbox', class extends HTMLElement { constructor() { super() - this.attachShadow({ mode: 'open' }).append(smCheckbox.content.cloneNode(true)) + this.attachShadow({ + mode: 'open' + }).append(smCheckbox.content.cloneNode(true)) this.checkbox = this.shadowRoot.querySelector('.checkbox'); this.input = this.shadowRoot.querySelector('input') @@ -907,8 +1005,7 @@ customElements.define('sm-checkbox', class extends HTMLElement { if (newValue === 'true') { this.checkbox.classList.add('disabled') this.isDisabled = true - } - else { + } else { this.checkbox.classList.remove('disabled') this.isDisabled = false } @@ -918,8 +1015,7 @@ customElements.define('sm-checkbox', class extends HTMLElement { this.isChecked = true this.input.checked = true this.dispatch() - } - else { + } else { this.isChecked = false this.input.checked = false this.dispatch() @@ -935,101 +1031,129 @@ customElements.define('sm-checkbox', class extends HTMLElement { const smSwitch = document.createElement('template') smSwitch.innerHTML = ` ` customElements.define('sm-switch', class extends HTMLElement { constructor() { super() - this.attachShadow({ mode: 'open' }).append(smSwitch.content.cloneNode(true)) + this.attachShadow({ + mode: 'open' + }).append(smSwitch.content.cloneNode(true)) this.switch = this.shadowRoot.querySelector('.switch'); this.input = this.shadowRoot.querySelector('input') this.isChecked = false @@ -1045,8 +1169,7 @@ customElements.define('sm-switch', class extends HTMLElement { this.disabled = true this.setAttribute('disabled', '') this.switch.classList.add('disabled') - } - else { + } else { this.disabled = false this.removeAttribute('disabled') this.switch.classList.remove('disabled') @@ -1063,8 +1186,7 @@ customElements.define('sm-switch', class extends HTMLElement { this.setAttribute('checked', '') this.isChecked = true this.input.checked = true - } - else { + } else { this.removeAttribute('checked') this.isChecked = false this.input.checked = false @@ -1100,83 +1222,107 @@ customElements.define('sm-switch', class extends HTMLElement { const smSelect = document.createElement('template') smSelect.innerHTML = `
@@ -1192,7 +1338,9 @@ smSelect.innerHTML = ` customElements.define('sm-select', class extends HTMLElement { constructor() { super() - this.attachShadow({ mode: 'open' }).append(smSelect.content.cloneNode(true)) + this.attachShadow({ + mode: 'open' + }).append(smSelect.content.cloneNode(true)) } static get observedAttributes() { return ['value'] @@ -1218,13 +1366,19 @@ customElements.define('sm-select', class extends HTMLElement { selection = this.shadowRoot.querySelector('.selection'), previousOption this.open = false; - this.slideDown = [ - { transform: `translateY(-0.5rem)` }, - { transform: `translateY(0)` } - ], - this.slideUp = [ - { transform: `translateY(0)` }, - { transform: `translateY(-0.5rem)` } + this.slideDown = [{ + transform: `translateY(-0.5rem)` + }, + { + transform: `translateY(0)` + } + ], + this.slideUp = [{ + transform: `translateY(0)` + }, + { + transform: `translateY(-0.5rem)` + } ], this.animationOptions = { duration: 300, @@ -1313,54 +1467,61 @@ customElements.define('sm-select', class extends HTMLElement { const smOption = document.createElement('template') smOption.innerHTML = `
@@ -1371,7 +1532,9 @@ smOption.innerHTML = ` customElements.define('sm-option', class extends HTMLElement { constructor() { super() - this.attachShadow({ mode: 'open' }).append(smOption.content.cloneNode(true)) + this.attachShadow({ + mode: 'open' + }).append(smOption.content.cloneNode(true)) } sendDetails(switching) { @@ -1419,100 +1582,119 @@ customElements.define('sm-option', class extends HTMLElement { const smStripSelect = document.createElement('template') smStripSelect.innerHTML = `
@@ -1532,7 +1714,9 @@ smStripSelect.innerHTML = ` customElements.define('sm-strip-select', class extends HTMLElement { constructor() { super() - this.attachShadow({ mode: 'open' }).append(smStripSelect.content.cloneNode(true)) + this.attachShadow({ + mode: 'open' + }).append(smStripSelect.content.cloneNode(true)) } static get observedAttributes() { return ['value'] @@ -1573,8 +1757,7 @@ customElements.define('sm-strip-select', class extends HTMLElement { if (entries[0].isIntersecting) { this.previousArrow.classList.add('hide') this.previousGradient.classList.add('hide') - } - else { + } else { this.previousArrow.classList.remove('hide') this.previousGradient.classList.remove('hide') } @@ -1586,8 +1769,7 @@ customElements.define('sm-strip-select', class extends HTMLElement { if (entries[0].isIntersecting) { this.nextArrow.classList.add('hide') this.nextGradient.classList.add('hide') - } - else { + } else { this.nextArrow.classList.remove('hide') this.nextGradient.classList.remove('hide') } @@ -1608,7 +1790,11 @@ customElements.define('sm-strip-select', class extends HTMLElement { if (previousOption) previousOption.classList.remove('active') e.target.classList.add('active') - e.target.scrollIntoView({ behavior: 'smooth', inline: 'center', block: 'nearest' }) + e.target.scrollIntoView({ + behavior: 'smooth', + inline: 'center', + block: 'nearest' + }) this.setAttribute('value', e.detail.value) this.dispatchEvent(new CustomEvent('change', { bubbles: true, @@ -1641,36 +1827,41 @@ customElements.define('sm-strip-select', class extends HTMLElement { const smStripOption = document.createElement('template') smStripOption.innerHTML = `
@@ -1678,7 +1869,9 @@ smStripOption.innerHTML = ` customElements.define('sm-strip-option', class extends HTMLElement { constructor() { super() - this.attachShadow({ mode: 'open' }).append(smStripOption.content.cloneNode(true)) + this.attachShadow({ + mode: 'open' + }).append(smStripOption.content.cloneNode(true)) } sendDetails() { let optionSelected = new CustomEvent('optionSelected', { @@ -1717,14 +1910,17 @@ smPopup.innerHTML = ` *{ padding: 0; margin: 0; - box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; } :host{ position: fixed; + display: -ms-grid; display: grid; z-index: 10; } .popup-container{ + display: -ms-grid; display: grid; position: fixed; top: 0; @@ -1733,39 +1929,71 @@ smPopup.innerHTML = ` right: 0; place-items: center; background: rgba(0, 0, 0, 0.6); + -webkit-transition: opacity 0.3s ease; + -o-transition: opacity 0.3s ease; transition: opacity 0.3s ease; z-index: 10; } :host(.stacked) .popup{ - transform: scale(0.9) translateY(-2rem) !important; + -webkit-transform: scale(0.9) translateY(-2rem) !important; + -ms-transform: scale(0.9) translateY(-2rem) !important; + transform: scale(0.9) translateY(-2rem) !important; } .popup{ + display: -webkit-box; + display: -ms-flexbox; display: flex; - flex-direction: column; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; position: relative; - align-self: flex-end; - align-items: flex-start; + -ms-flex-item-align: end; + align-self: flex-end; + -webkit-box-align: start; + -ms-flex-align: start; + align-items: flex-start; width: 100%; border-radius: 0.8rem 0.8rem 0 0; - transform: translateY(100%); + -webkit-transform: translateY(100%); + -ms-transform: translateY(100%); + transform: translateY(100%); + -webkit-transition: -webkit-transform 0.3s; + transition: -webkit-transform 0.3s; + -o-transition: transform 0.3s; transition: transform 0.3s; + transition: transform 0.3s, -webkit-transform 0.3s; background: rgba(var(--foreground-color), 1); - box-shadow: 0 -1rem 2rem #00000020; + -webkit-box-shadow: 0 -1rem 2rem #00000020; + box-shadow: 0 -1rem 2rem #00000020; max-height: 90vh; } .container-header{ + display: -webkit-box; + display: -ms-flexbox; display: flex; width: 100%; - align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; } .popup-top{ + display: -webkit-box; + display: -ms-flexbox; display: flex; width: 100%; } .popup-body{ + display: -webkit-box; + display: -ms-flexbox; display: flex; - flex-direction: column; - flex: 1; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1; width: 100%; padding: 1.5rem; overflow-y: auto; @@ -1782,18 +2010,30 @@ smPopup.innerHTML = ` } @media screen and (min-width: 640px){ .popup{ + width: -webkit-max-content; + width: -moz-max-content; width: max-content; - align-self: center; + -ms-flex-item-align: center; + -ms-grid-row-align: center; + align-self: center; border-radius: 0.4rem; height: auto; - transform: translateY(1rem); - box-shadow: 0 3rem 2rem -0.5rem #00000040; + -webkit-transform: translateY(1rem); + -ms-transform: translateY(1rem); + transform: translateY(1rem); + -webkit-box-shadow: 0 3rem 2rem -0.5rem #00000040; + box-shadow: 0 3rem 2rem -0.5rem #00000040; } } @media screen and (max-width: 640px){ .popup-top{ - flex-direction: column; - align-items: center; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; } .handle{ height: 0.3rem; @@ -1814,21 +2054,23 @@ smPopup.innerHTML = ` } `; customElements.define('sm-popup', class extends HTMLElement { constructor() { super() - this.attachShadow({ mode: 'open' }).append(smPopup.content.cloneNode(true)) + this.attachShadow({ + mode: 'open' + }).append(smPopup.content.cloneNode(true)) this.allowClosing = false } @@ -1842,14 +2084,14 @@ customElements.define('sm-popup', class extends HTMLElement { } show = (pinned, popupStack) => { - if(popupStack) + if (popupStack) this.popupStack = popupStack if (this.popupStack && !this.hasAttribute('open')) { this.popupStack.push({ popup: this, permission: pinned }) - if (this.popupStack.items.length > 1){ + if (this.popupStack.items.length > 1) { this.popupStack.items[this.popupStack.items.length - 2].popup.classList.add('stacked') } this.dispatchEvent( @@ -1860,7 +2102,7 @@ customElements.define('sm-popup', class extends HTMLElement { popupStack: this.popupStack } }) - ) + ) this.setAttribute('open', '') this.pinned = pinned this.popupContainer.classList.remove('hide') @@ -1870,7 +2112,7 @@ customElements.define('sm-popup', class extends HTMLElement { return this.popupStack } hide = () => { - if(window.innerWidth < 640) + if (window.innerWidth < 640) this.popup.style.transform = 'translateY(100%)'; else this.popup.style.transform = 'translateY(1rem)'; @@ -1878,14 +2120,12 @@ customElements.define('sm-popup', class extends HTMLElement { this.removeAttribute('open') if (typeof this.popupStack !== 'undefined') { this.popupStack.pop() - if (this.popupStack.items.length){ + if (this.popupStack.items.length) { this.popupStack.items[this.popupStack.items.length - 1].popup.classList.remove('stacked') - } - else { + } else { this.resumeScrolling() } - } - else { + } else { this.resumeScrolling() } @@ -1927,7 +2167,7 @@ customElements.define('sm-popup', class extends HTMLElement { this.popup.style.transform = `translateY(-${this.offset}px)` }*/ } - + handleTouchEnd = (e) => { this.touchEndTime = e.timeStamp cancelAnimationFrame(this.touchEndAnimataion) @@ -1938,20 +2178,17 @@ customElements.define('sm-popup', class extends HTMLElement { if (this.pinned) { this.show() return - } - else + } else this.hide() - } - else { + } else { this.show() } - } - else { + } else { if (this.touchEndY > this.touchStartY) - if (this.pinned) { - this.show() - return - } + if (this.pinned) { + this.show() + return + } else this.hide() } @@ -1983,8 +2220,7 @@ customElements.define('sm-popup', class extends HTMLElement { if (this.pinned) { this.show() return - } - else + } else this.hide() } }) @@ -2018,13 +2254,18 @@ smCarousel.innerHTML = ` *{ padding: 0; margin: 0; - box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; } :host{ + display: -webkit-box; + display: -ms-flexbox; display: flex; } .icon { position: absolute; + display: -webkit-box; + display: -ms-flexbox; display: flex; fill: none; height: 2.6rem; @@ -2039,10 +2280,14 @@ smCarousel.innerHTML = ` cursor: pointer; min-width: 0; background: rgba(var(--text-color), 1); - box-shadow: 0 0.2rem 0.2rem #00000020, + -webkit-box-shadow: 0 0.2rem 0.2rem #00000020, + 0 0.5rem 1rem #00000040; + box-shadow: 0 0.2rem 0.2rem #00000020, 0 0.5rem 1rem #00000040; -webkit-tap-highlight-color: transparent; - transform: scale(0); + -webkit-transform: scale(0); + -ms-transform: scale(0); + transform: scale(0); z-index: 1; } .hide{ @@ -2050,7 +2295,9 @@ smCarousel.innerHTML = ` opacity: 0; } .expand{ - transform: scale(1) + -webkit-transform: scale(1); + -ms-transform: scale(1); + transform: scale(1) } .previous-item{ left: 1rem; @@ -2060,21 +2307,31 @@ smCarousel.innerHTML = ` } .carousel-container{ position: relative; + display: -webkit-box; + display: -ms-flexbox; display: flex; width: 100%; - align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; } .carousel{ + display: -webkit-box; + display: -ms-flexbox; display: flex; max-width: 100%; width: 100%; overflow: auto hidden; - scroll-snap-type: x mandatory; + -ms-scroll-snap-type: x mandatory; + scroll-snap-type: x mandatory; } .indicators{ + display: -ms-grid; display: grid; grid-auto-flow: column; - justify-content: center; + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; position: absolute; bottom: -1rem; gap: 0.5rem; @@ -2085,10 +2342,14 @@ smCarousel.innerHTML = ` padding: 0.2rem; background: rgba(var(--text-color), 0.3); border-radius: 1rem; + -webkit-transition: 0.2s; + -o-transition: 0.2s; transition: 0.2s; } .dot.active{ - transform: scale(1.5); + -webkit-transform: scale(1.5); + -ms-transform: scale(1.5); + transform: scale(1.5); background: var(--accent-color); } slot::slotted(*){ @@ -2133,15 +2394,15 @@ scroll-snap-align: end; @@ -2150,7 +2411,9 @@ scroll-snap-align: end; customElements.define('sm-carousel', class extends HTMLElement { constructor() { super() - this.attachShadow({ mode: 'open' }).append(smCarousel.content.cloneNode(true)) + this.attachShadow({ + mode: 'open' + }).append(smCarousel.content.cloneNode(true)) } static get observedAttributes() { @@ -2187,37 +2450,37 @@ customElements.define('sm-carousel', class extends HTMLElement { let frag = document.createDocumentFragment(); if (this.hasAttribute('indicator')) this.showIndicator = true - - + + let firstVisible = false, lastVisible = false const allElementsObserver = new IntersectionObserver(entries => { entries.forEach(entry => { - if(this.showIndicator) + if (this.showIndicator) if (entry.isIntersecting) { this.indicators[parseInt(entry.target.attributes.rank.textContent)].classList.add('active') } - else - this.indicators[parseInt(entry.target.attributes.rank.textContent)].classList.remove('active') + else + this.indicators[parseInt(entry.target.attributes.rank.textContent)].classList.remove('active') if (!entry.target.previousElementSibling) - if(entry.isIntersecting) { + if (entry.isIntersecting) { this.previousArrow.classList.remove('expand') firstVisible = true } - else { - this.previousArrow.classList.add('expand') - firstVisible = false - } + else { + this.previousArrow.classList.add('expand') + firstVisible = false + } if (!entry.target.nextElementSibling) - if(entry.isIntersecting) { + if (entry.isIntersecting) { this.nextArrow.classList.remove('expand') lastVisible = true } - else { - this.nextArrow.classList.add('expand') + else { + this.nextArrow.classList.add('expand') - lastVisible = false - } + lastVisible = false + } if (firstVisible && lastVisible) this.indicatorsContainer.classList.add('hide') else @@ -2239,7 +2502,7 @@ customElements.define('sm-carousel', class extends HTMLElement { this.carouselSlot.addEventListener('slotchange', e => { this.carouselItems = this.carouselSlot.assignedElements() this.carouselItems.forEach(item => allElementsObserver.observe(item)) - if(this.showIndicator){ + if (this.showIndicator) { this.indicatorsContainer.innerHTML = `` this.carouselItems.forEach((item, index) => { let dot = document.createElement('div') @@ -2283,131 +2546,153 @@ customElements.define('sm-carousel', class extends HTMLElement { const smNotifications = document.createElement('template') smNotifications.innerHTML = `
@@ -2416,10 +2701,12 @@ stroke-width: 6; customElements.define('sm-notifications', class extends HTMLElement { constructor() { super() - this.shadow = this.attachShadow({ mode: 'open' }).append(smNotifications.content.cloneNode(true)) + this.shadow = this.attachShadow({ + mode: 'open' + }).append(smNotifications.content.cloneNode(true)) } - handleTouchStart =(e) => { + handleTouchStart = (e) => { this.notification = e.target.closest('.notification') this.touchStartX = e.changedTouches[0].clientX this.notification.style.transition = 'initial' @@ -2431,8 +2718,7 @@ customElements.define('sm-notifications', class extends HTMLElement { if (this.touchStartX < e.changedTouches[0].clientX) { this.offset = e.changedTouches[0].clientX - this.touchStartX; this.touchEndAnimataion = requestAnimationFrame(this.movePopup) - } - else { + } else { this.offset = -(this.touchStartX - e.changedTouches[0].clientX); this.touchEndAnimataion = requestAnimationFrame(this.movePopup) } @@ -2446,19 +2732,15 @@ customElements.define('sm-notifications', class extends HTMLElement { if (this.touchEndTime - this.touchStartTime > 200) { if (this.touchEndX - this.touchStartX > this.threshold) { this.removeNotification(this.notification) - } - else if (this.touchStartX - this.touchEndX > this.threshold) { + } else if (this.touchStartX - this.touchEndX > this.threshold) { this.removeNotification(this.notification, true) - } - else { + } else { this.resetPosition() } - } - else { + } else { if (this.touchEndX > this.touchStartX) { this.removeNotification(this.notification) - } - else { + } else { this.removeNotification(this.notification, true) } } @@ -2485,8 +2767,7 @@ customElements.define('sm-notifications', class extends HTMLElement { ` - } - else if (type === 'success') { + } else if (type === 'success') { composition += ` @@ -2502,8 +2783,7 @@ customElements.define('sm-notifications', class extends HTMLElement { notification.innerHTML = composition this.notificationPanel.prepend(notification) if (window.innerWidth > 640) { - notification.animate([ - { + notification.animate([{ transform: `translateX(1rem)`, opacity: '0' }, @@ -2514,8 +2794,7 @@ customElements.define('sm-notifications', class extends HTMLElement { ], this.animationOptions).onfinish = () => { notification.setAttribute('style', `transform: none;`); } - } - else { + } else { notification.setAttribute('style', `transform: translateY(0); opacity: 1`) } notification.addEventListener('touchstart', this.handleTouchStart) @@ -2528,8 +2807,7 @@ customElements.define('sm-notifications', class extends HTMLElement { this.offset = 0; if (toLeft) - notification.animate([ - { + notification.animate([{ transform: `translateX(${this.offset}px)`, opacity: '1' }, @@ -2541,8 +2819,7 @@ customElements.define('sm-notifications', class extends HTMLElement { notification.remove() } else { - notification.animate([ - { + notification.animate([{ transform: `translateX(${this.offset}px)`, opacity: '1' }, @@ -2580,7 +2857,7 @@ customElements.define('sm-notifications', class extends HTMLElement { this.touchEndAnimataion; this.notificationPanel.addEventListener('click', e => { - if (e.target.closest('.close')) ( + if (e.target.closest('.close'))( this.removeNotification(e.target.closest('.notification')) ) }) @@ -2597,8 +2874,7 @@ customElements.define('sm-notifications', class extends HTMLElement { this.notificationPanel.style.padding = '1.5rem 0 3rem 1.5rem'; else this.notificationPanel.style.padding = '1rem 1rem 2rem 1rem'; - } - else if (mutation.removedNodes.length && !this.notificationPanel.children.length) { + } else if (mutation.removedNodes.length && !this.notificationPanel.children.length) { this.notificationPanel.style.padding = 0; } } @@ -2617,92 +2893,121 @@ customElements.define('sm-notifications', class extends HTMLElement { const smMenu = document.createElement('template') smMenu.innerHTML = `