diff --git a/components.js b/components.js index 6351d6e..36a44c3 100644 --- a/components.js +++ b/components.js @@ -1,3775 +1,13 @@ /*jshint esversion: 6 */ -//Button -const smButton = document.createElement('template') -smButton.innerHTML = ` - -`; -customElements.define('sm-button', - class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(smButton.content.cloneNode(true)) - } - - get disabled() { - return this.isDisabled - } - - set disabled(value) { - if (value && !this.isDisabled) { - this.isDisabled = true - this.setAttribute('disabled', '') - this.button.removeAttribute('tabindex') - } else if (!value && this.isDisabled) { - this.isDisabled = false - this.removeAttribute('disabled') - } - } - - dispatch() { - if (this.isDisabled) { - this.dispatchEvent(new CustomEvent('disabled', { - bubbles: true, - composed: true - })) - } else { - this.dispatchEvent(new CustomEvent('clicked', { - bubbles: true, - composed: true - })) - } - } - - connectedCallback() { - this.isDisabled = false - this.button = this.shadowRoot.querySelector('.button') - if (this.hasAttribute('disabled') && !this.isDisabled) - this.isDisabled = true - this.addEventListener('click', (e) => { - this.dispatch() - }) - } - }) - -//Input -const smInput = document.createElement('template') -smInput.innerHTML = ` - -
- -
-
-`; -customElements.define('sm-input', - class extends HTMLElement { - - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(smInput.content.cloneNode(true)) - - this.inputParent = this.shadowRoot.querySelector('.input') - this.input = this.shadowRoot.querySelector('input') - this.clearBtn = this.shadowRoot.querySelector('.clear') - this.label = this.shadowRoot.querySelector('.label') - this.feedbackText = this.shadowRoot.querySelector('.feedback-text') - this.validationFunction - this.observeList = ['type', 'required', 'disabled', 'readonly', 'min', 'max', 'pattern', 'minlength', 'maxlength', 'step'] - } - - static get observedAttributes() { - return ['placeholder', 'type', 'required', 'disabled', 'readonly', 'min', 'max', 'pattern', 'minlength', 'maxlength', 'step'] - } - - get value() { - return this.input.value - } - - set value(val) { - this.input.value = val; - this.checkInput() - this.fireEvent() - } - - get placeholder() { - return this.getAttribute('placeholder') - } - - set placeholder(val) { - this.setAttribute('placeholder', val) - } - - get type() { - return this.getAttribute('type') - } - - set type(val) { - this.setAttribute('type', val) - } - - get isValid() { - if (this.hasAttribute('data-flo-id') || this.hasAttribute('data-private-key')) { - return this.validationFunction(this.input.value) - } - else { - return this.input.checkValidity() - } - } - - get validity() { - return this.input.validity - } - - set disabled(value) { - if (value) - this.inputParent.classList.add('disabled') - else - this.inputParent.classList.remove('disabled') - } - set readOnly(value) { - if (value) { - this.setAttribute('readonly', '') - } else { - this.removeAttribute('readonly') - } - } - set customValidation(val) { - this.validationFunction = val - } - reset = () => { - this.value = '' - } - - setValidity = (message) => { - this.feedbackText.textContent = message - } - - showValidity = () => { - this.feedbackText.classList.remove('hide-completely') - } - - hideValidity = () => { - this.feedbackText.classList.add('hide-completely') - } - - focusIn = () => { - this.input.focus() - } - - focusOut = () => { - this.input.blur() - } - - fireEvent = () => { - let event = new Event('input', { - bubbles: true, - cancelable: true, - composed: true - }); - this.dispatchEvent(event); - } - - checkInput = (e) => { - if (!this.hasAttribute('readonly')) { - if (this.input.value !== '') { - this.clearBtn.classList.remove('hide') - } else { - this.clearBtn.classList.add('hide') - } - } - if (!this.hasAttribute('placeholder') || this.getAttribute('placeholder') === '') return; - if (this.input.value !== '') { - if (this.animate) - this.inputParent.classList.add('animate-label') - else - this.label.classList.add('hide') - } else { - if (this.animate) - this.inputParent.classList.remove('animate-label') - else - this.label.classList.remove('hide') - } - } - - - connectedCallback() { - this.animate = this.hasAttribute('animate') - if (this.hasAttribute('value')) { - this.input.value = this.getAttribute('value') - this.checkInput() - } - if (this.hasAttribute('error-text')) { - this.feedbackText.textContent = this.getAttribute('error-text') - } - if (!this.hasAttribute('type')) { - this.setAttribute('type', 'text') - } - - this.input.addEventListener('input', e => { - this.checkInput(e) - }) - this.clearBtn.addEventListener('click', this.reset) - } - - attributeChangedCallback(name, oldValue, newValue) { - if (oldValue !== newValue) { - if (this.observeList.includes(name)) { - if (this.hasAttribute(name)) { - this.input.setAttribute(name, this.getAttribute(name) ? this.getAttribute(name) : '') - } - else { - this.input.removeAttribute(name) - } - } - if (name === 'placeholder') { - this.label.textContent = newValue; - this.setAttribute('aria-label', newValue); - } - else if (name === 'type') { - if (this.hasAttribute('type') && this.getAttribute('type') === 'number') { - this.input.setAttribute('inputmode', 'numeric') - } - } - else if (name === 'readonly') { - if (this.hasAttribute('readonly')) { - this.inputParent.classList.add('readonly') - } else { - this.inputParent.classList.remove('readonly') - } - } - else if (name === 'disabled') { - if (this.hasAttribute('disabled')) { - this.inputParent.classList.add('disabled') - } - else { - this.inputParent.classList.remove('disabled') - } - } - } - } - }) - -//textarea -const smTextarea = document.createElement('template') -smTextarea.innerHTML = ` - - -`; -customElements.define('sm-textarea', - class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(smTextarea.content.cloneNode(true)) - - this.textarea = this.shadowRoot.querySelector('textarea') - this.textareaBox = this.shadowRoot.querySelector('.textarea') - this.placeholder = this.shadowRoot.querySelector('.placeholder') - this.observeList = ['required', 'readonly', 'rows', 'minlength', 'maxlength'] - } - static get observedAttributes() { - return ['value', 'placeholder', 'required', 'readonly', 'rows', 'minlength', 'maxlength'] - } - get value() { - return this.textarea.value - } - set value(val) { - this.setAttribute('value', val) - this.fireEvent() - } - get isValid() { - return this.textarea.checkValidity() - } - reset = () => { - this.setAttribute('value', '') - } - focusIn = () => { - this.textarea.focus() - } - fireEvent = () => { - let event = new Event('input', { - bubbles: true, - cancelable: true, - composed: true - }); - this.dispatchEvent(event); - } - checkInput = () => { - if (!this.hasAttribute('placeholder') || this.getAttribute('placeholder') === '') - return; - if (this.textarea.value !== '') { - this.placeholder.classList.add('hide') - } else { - this.placeholder.classList.remove('hide') - } - } - connectedCallback() { - this.textarea.addEventListener('input', e => { - this.textareaBox.dataset.value = this.textarea.value - this.checkInput() - }) - } - attributeChangedCallback(name, oldValue, newValue) { - if (this.observeList.includes(name)) { - if (this.hasAttribute(name)) { - this.textarea.setAttribute(name, this.getAttribute(name) ? this.getAttribute(name) : '') - } - else { - this.input.removeAttribute(name) - } - } - else if (name === 'placeholder') { - this.placeholder.textContent = this.getAttribute('placeholder') - } - else if (name === 'value') { - this.textarea.value = newValue; - this.textareaBox.dataset.value = newValue - this.checkInput() - } - } - }) - -// tab -const smTab = document.createElement('template') -smTab.innerHTML = ` - -
- -
-`; - -customElements.define('sm-tab', class extends HTMLElement { - constructor() { - super() - this.shadow = this.attachShadow({ - mode: 'open' - }).append(smTab.content.cloneNode(true)) - } -}) - -//chcekbox - -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.checkbox = this.shadowRoot.querySelector('.checkbox'); - this.input = this.shadowRoot.querySelector('input') - - this.isChecked = false - this.isDisabled = false - } - - static get observedAttributes() { - return ['disabled', 'checked'] - } - - get disabled() { - return this.isDisabled - } - - set disabled(val) { - if (val) { - this.setAttribute('disabled', '') - } else { - this.removeAttribute('disabled') - } - } - - get checked() { - return this.isChecked - } - - set checked(value) { - if (value) { - this.setAttribute('checked', '') - } - else { - this.removeAttribute('checked') - } - } - - set value(val) { - this.val = val - this.setAttribute('value', value) - } - - get value() { - return getAttribute('value') - } - - dispatch = () => { - this.dispatchEvent(new CustomEvent('change', { - bubbles: true, - composed: true - })) - } - handleKeyup = e => { - if ((e.code === "Enter" || e.code === "Space") && this.isDisabled == false) { - if (this.hasAttribute('checked')) { - this.input.checked = false - this.removeAttribute('checked') - } - else { - this.input.checked = true - this.setAttribute('checked', '') - } - } - } - handleChange = e => { - if (this.input.checked) { - this.setAttribute('checked', '') - } - else { - this.removeAttribute('checked') - } - } - - connectedCallback() { - this.val = '' - this.addEventListener('keyup', this.handleKeyup) - this.input.addEventListener('change', this.handleChange) - } - attributeChangedCallback(name, oldValue, newValue) { - if (oldValue !== newValue) { - if (name === 'disabled') { - if (newValue === 'true') { - this.isDisabled = true - } else { - this.isDisabled = false - } - } - else if (name === 'checked') { - if (this.hasAttribute('checked')) { - this.isChecked = true - this.input.checked = true - } - else { - this.input.checked = false - this.isChecked = false - } - this.dispatch() - } - } - } - disconnectedCallback() { - this.removeEventListener('keyup', this.handleKeyup) - this.removeEventListener('change', this.handleChange) - } -}) - -//switch - -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.switch = this.shadowRoot.querySelector('.switch'); - this.input = this.shadowRoot.querySelector('input') - this.isChecked = false - this.isDisabled = false - } - - static get observedAttributes() { - return ['disabled', 'checked'] - } - - get disabled() { - return this.isDisabled - } - - set disabled(val) { - if (val) { - this.setAttribute('disabled', '') - } else { - this.removeAttribute('disabled') - } - } - - get checked() { - return this.isChecked - } - - set checked(value) { - if (value) { - this.setAttribute('checked', '') - } else { - this.removeAttribute('checked') - } - } - - dispatch = () => { - this.dispatchEvent(new CustomEvent('change', { - bubbles: true, - composed: true, - detail: { - value: this.isChecked - } - })) - } - - connectedCallback() { - this.addEventListener('keyup', e => { - if ((e.code === "Enter" || e.code === "Space") && !this.isDisabled) { - this.input.click() - } - }) - this.input.addEventListener('click', e => { - if (this.input.checked) - this.checked = true - else - this.checked = false - this.dispatch() - }) - } - attributeChangedCallback(name, oldValue, newValue) { - if (oldValue !== newValue) { - if (name === 'disabled') { - if (this.hasAttribute('disabled')) { - this.disabled = true - } - else { - this.disabled = false - } - } - else if (name === 'checked') { - if (this.hasAttribute('checked')) { - this.isChecked = true - this.input.checked = true - } - else { - this.isChecked = false - this.input.checked = false - } - } - } - } - -}) - -// select -const smSelect = document.createElement('template') -smSelect.innerHTML = ` - -
-
-
- - - -
-
- -
-
`; -customElements.define('sm-select', class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(smSelect.content.cloneNode(true)) - } - static get observedAttributes() { - return ['value'] - } - get value() { - return this.getAttribute('value') - } - set value(val) { - this.setAttribute('value', val) - } - - reset = () => { - - } - - collapse() { - this.chevron.classList.remove('rotate') - this.optionList.animate(this.slideUp, this.animationOptions) - .onfinish = () => { - this.optionList.classList.add('hide') - this.open = false - } - } - connectedCallback() { - this.availableOptions - this.optionList = this.shadowRoot.querySelector('.options') - this.chevron = this.shadowRoot.querySelector('.toggle') - let slot = this.shadowRoot.querySelector('.options slot'), - selection = this.shadowRoot.querySelector('.selection'), - previousOption - this.open = false; - this.slideDown = [{ - transform: `translateY(-0.5rem)`, - opacity: 0 - }, - { - transform: `translateY(0)`, - opacity: 1 - } - ] - this.slideUp = [{ - transform: `translateY(0)`, - opacity: 1 - }, - { - transform: `translateY(-0.5rem)`, - opacity: 0 - } - ] - this.animationOptions = { - duration: 300, - fill: "forwards", - easing: 'ease' - } - selection.addEventListener('click', e => { - if (!this.open) { - this.optionList.classList.remove('hide') - this.optionList.animate(this.slideDown, this.animationOptions) - this.chevron.classList.add('rotate') - this.open = true - } else { - this.collapse() - } - }) - selection.addEventListener('keydown', e => { - if (e.code === 'ArrowDown' || e.code === 'ArrowRight') { - e.preventDefault() - this.availableOptions[0].focus() - } - if (e.code === 'Enter' || e.code === 'Space') - if (!this.open) { - this.optionList.classList.remove('hide') - this.optionList.animate(this.slideDown, this.animationOptions) - this.chevron.classList.add('rotate') - this.open = true - } else { - this.collapse() - } - }) - this.optionList.addEventListener('keydown', e => { - if (e.code === 'ArrowUp' || e.code === 'ArrowRight') { - e.preventDefault() - if (document.activeElement.previousElementSibling) { - document.activeElement.previousElementSibling.focus() - } - } - if (e.code === 'ArrowDown' || e.code === 'ArrowLeft') { - e.preventDefault() - if (document.activeElement.nextElementSibling) - document.activeElement.nextElementSibling.focus() - } - }) - this.addEventListener('optionSelected', e => { - if (previousOption !== e.target) { - this.setAttribute('value', e.detail.value) - this.shadowRoot.querySelector('.option-text').textContent = e.detail.text; - this.dispatchEvent(new CustomEvent('change', { - bubbles: true, - composed: true, - detail: { - value: e.detail.value - } - })) - if (previousOption) { - previousOption.classList.remove('check-selected') - } - previousOption = e.target; - } - if (!e.detail.switching) - this.collapse() - - e.target.classList.add('check-selected') - }) - slot.addEventListener('slotchange', e => { - this.availableOptions = slot.assignedElements() - if (this.availableOptions[0]) { - let firstElement = this.availableOptions[0]; - previousOption = firstElement; - firstElement.classList.add('check-selected') - this.setAttribute('value', firstElement.getAttribute('value')) - this.shadowRoot.querySelector('.option-text').textContent = firstElement.textContent - this.availableOptions.forEach((element, index) => { - element.setAttribute('data-rank', index + 1); - element.setAttribute('tabindex', "0"); - }) - } - }); - document.addEventListener('mousedown', e => { - if (!this.contains(e.target) && this.open) { - this.collapse() - } - }) - } -}) - -// option -const smOption = document.createElement('template') -smOption.innerHTML = ` - -
- - - - -
`; -customElements.define('sm-option', class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(smOption.content.cloneNode(true)) - } - - sendDetails(switching) { - let optionSelected = new CustomEvent('optionSelected', { - bubbles: true, - composed: true, - detail: { - text: this.textContent, - value: this.getAttribute('value'), - switching: switching - } - }) - this.dispatchEvent(optionSelected) - } - - connectedCallback() { - let validKey = [ - 'ArrowUp', - 'ArrowDown', - 'ArrowLeft', - 'ArrowRight' - ] - this.addEventListener('click', e => { - this.sendDetails() - }) - this.addEventListener('keyup', e => { - if (e.code === 'Enter' || e.code === 'Space') { - e.preventDefault() - this.sendDetails(false) - } - if (validKey.includes(e.code)) { - e.preventDefault() - this.sendDetails(true) - } - }) - if (this.hasAttribute('default')) { - setTimeout(() => { - this.sendDetails() - }, 0); - } - } -}) - -// strip select -const stripSelect = document.createElement('template') -stripSelect.innerHTML = ` - -
-
- -
- -
- -
-
- -` -customElements.define('strip-select', class extends HTMLElement{ - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(stripSelect.content.cloneNode(true)) - this.stripSelect = this.shadowRoot.querySelector('.strip-select') - this.slottedOptions - this._value - this.scrollDistance - } - get value() { - return this._value - } - scrollLeft = () => { - this.stripSelect.scrollBy({ - left: -this.scrollDistance, - behavior: 'smooth' - }) - } - - scrollRight = () => { - this.stripSelect.scrollBy({ - left: this.scrollDistance, - behavior: 'smooth' - }) - } - fireEvent = () => { - this.dispatchEvent( - new CustomEvent("change", { - bubbles: true, - composed: true, - detail: { - value: this._value - } - }) - ) - } - connectedCallback() { - const slot = this.shadowRoot.querySelector('slot') - const coverLeft = this.shadowRoot.querySelector('.cover--left') - const coverRight = this.shadowRoot.querySelector('.cover--right') - const navButtonLeft = this.shadowRoot.querySelector('.nav-button--left') - const navButtonRight = this.shadowRoot.querySelector('.nav-button--right') - slot.addEventListener('slotchange', e => { - const assignedElements = slot.assignedElements() - assignedElements.forEach(elem => { - if (elem.hasAttribute('selected')) { - elem.setAttribute('active', '') - this._value = elem.value - } - }) - if (assignedElements.length > 0) { - firstOptionObserver.observe(slot.assignedElements()[0]) - lastOptionObserver.observe(slot.assignedElements()[slot.assignedElements().length - 1]) - } - else { - navButtonLeft.classList.add('hide') - navButtonRight.classList.add('hide') - coverLeft.classList.add('hide') - coverRight.classList.add('hide') - firstOptionObserver.disconnect() - lastOptionObserver.disconnect() - } - }) - const resObs = new ResizeObserver(entries => { - entries.forEach(entry => { - if(entry.contentBoxSize) { - // Firefox implements `contentBoxSize` as a single content rect, rather than an array - const contentBoxSize = Array.isArray(entry.contentBoxSize) ? entry.contentBoxSize[0] : entry.contentBoxSize; - - this.scrollDistance = contentBoxSize.inlineSize * 0.6 - } else { - this.scrollDistance = entry.contentRect.width * 0.6 - } - }) - }) - resObs.observe(this) - this.stripSelect.addEventListener('option-clicked', e => { - if (this._value !== e.target.value) { - this._value = e.target.value - slot.assignedElements().forEach(elem => elem.removeAttribute('active')) - e.target.setAttribute('active', '') - e.target.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "center" }) - this.fireEvent() - } - }) - const firstOptionObserver = new IntersectionObserver(entries => { - entries.forEach(entry => { - if (entry.isIntersecting) { - navButtonLeft.classList.add('hide') - coverLeft.classList.add('hide') - } - else { - navButtonLeft.classList.remove('hide') - coverLeft.classList.remove('hide') - } - }) - }, - { - threshold: 0.9, - root: this - }) - const lastOptionObserver = new IntersectionObserver(entries => { - entries.forEach(entry => { - if (entry.isIntersecting) { - navButtonRight.classList.add('hide') - coverRight.classList.add('hide') - } - else { - navButtonRight.classList.remove('hide') - coverRight.classList.remove('hide') - } - }) - }, - { - threshold: 0.9, - root: this - }) - navButtonLeft.addEventListener('click', this.scrollLeft) - navButtonRight.addEventListener('click', this.scrollRight) - } -}) - -const stripOption = document.createElement('template') -stripOption.innerHTML = ` - - -` - -//Strip option -customElements.define('strip-option', class extends HTMLElement{ - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(stripOption.content.cloneNode(true)) - this._value - this.radioButton = this.shadowRoot.querySelector('input') - } - get value() { - return this._value - } - fireEvent = () => { - this.dispatchEvent( - new CustomEvent("option-clicked", { - bubbles: true, - composed: true, - detail: { - value: this._value - } - }) - ) - } - handleKeyDown = (e) => { - if (e.key === 'Enter' || e.key === 'Space') { - this.fireEvent() - } - } - connectedCallback() { - this._value = this.getAttribute('value') - this.addEventListener('click', this.fireEvent) - this.addEventListener('keydown', this.handleKeyDown) - } - disconnectedCallback() { - this.removeEventListener('click', this.fireEvent) - this.removeEventListener('keydown', this.handleKeyDown) - } -}) - - -//popup -const smPopup = document.createElement('template') -smPopup.innerHTML = ` - - -`; -customElements.define('sm-popup', class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(smPopup.content.cloneNode(true)) - - this.allowClosing = false - this.isOpen = false - } - - get open() { - return this.isOpen - } - - resumeScrolling = () => { - const scrollY = document.body.style.top; - window.scrollTo(0, parseInt(scrollY || '0') * -1); - setTimeout(() => { - document.body.style.overflow = 'auto'; - document.body.style.top= 'initial' - }, 300); - } - - show = (pinned, 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) { - this.popupStack.items[this.popupStack.items.length - 2].popup.classList.add('stacked') - } - this.dispatchEvent( - new CustomEvent("popupopened", { - bubbles: true, - detail: { - popup: this, - popupStack: this.popupStack - } - }) - ) - this.setAttribute('open', '') - this.pinned = pinned - this.isOpen = true - } - this.popupContainer.classList.remove('hide') - this.popup.style.transform = 'none'; - document.body.style.overflow = 'hidden'; - document.body.style.top= `-${window.scrollY}px` - return this.popupStack - } - hide = () => { - if (window.innerWidth < 640) - this.popup.style.transform = 'translateY(100%)'; - else - this.popup.style.transform = 'translateY(3rem)'; - this.popupContainer.classList.add('hide') - this.removeAttribute('open') - if (typeof this.popupStack !== 'undefined') { - this.popupStack.pop() - if (this.popupStack.items.length) { - this.popupStack.items[this.popupStack.items.length - 1].popup.classList.remove('stacked') - } else { - this.resumeScrolling() - } - } else { - this.resumeScrolling() - } - - if (this.inputFields.length) { - setTimeout(() => { - this.inputFields.forEach(field => { - if (field.type === 'radio' || field.tagName === 'SM-CHECKBOX') - field.checked = false - if (field.tagName === 'SM-INPUT' || field.tagName === 'TEXTAREA'|| field.tagName === 'SM-TEXTAREA') - field.value = '' - }) - }, 300); - } - setTimeout(() => { - this.dispatchEvent( - new CustomEvent("popupclosed", { - bubbles: true, - detail: { - popup: this, - popupStack: this.popupStack - } - }) - ) - this.isOpen = false - }, 300); - } - - handleTouchStart = (e) => { - this.touchStartY = e.changedTouches[0].clientY - this.popup.style.transition = 'transform 0.1s' - this.touchStartTime = e.timeStamp - } - - handleTouchMove = (e) => { - if (this.touchStartY < e.changedTouches[0].clientY) { - this.offset = e.changedTouches[0].clientY - this.touchStartY; - this.touchEndAnimataion = window.requestAnimationFrame(() => this.movePopup()) - } - /*else { - this.offset = this.touchStartY - e.changedTouches[0].clientY; - this.popup.style.transform = `translateY(-${this.offset}px)` - }*/ - } - - handleTouchEnd = (e) => { - this.touchEndTime = e.timeStamp - cancelAnimationFrame(this.touchEndAnimataion) - this.touchEndY = e.changedTouches[0].clientY - this.popup.style.transition = 'transform 0.3s' - this.threshold = this.popup.getBoundingClientRect().height * 0.3 - if (this.touchEndTime - this.touchStartTime > 200) { - if (this.touchEndY - this.touchStartY > this.threshold) { - if (this.pinned) { - this.show() - return - } else - this.hide() - } else { - this.show() - } - } else { - if (this.touchEndY > this.touchStartY) - if (this.pinned) { - this.show() - return - } - else - this.hide() - } - } - - movePopup = () => { - this.popup.style.transform = `translateY(${this.offset}px)` - } - - connectedCallback() { - this.pinned = false - this.popupStack - this.popupContainer = this.shadowRoot.querySelector('.popup-container') - this.popup = this.shadowRoot.querySelector('.popup') - this.popupBodySlot = this.shadowRoot.querySelector('.popup-body slot') - this.offset - this.popupHeader = this.shadowRoot.querySelector('.popup-top') - this.touchStartY = 0 - this.touchEndY = 0 - this.touchStartTime = 0 - this.touchEndTime = 0 - this.touchEndAnimataion; - this.threshold = this.popup.getBoundingClientRect().height * 0.3 - - if (this.hasAttribute('open')) - this.show() - this.popupContainer.addEventListener('mousedown', e => { - if (e.target === this.popupContainer && !this.pinned) { - if (this.pinned) { - this.show() - return - } else - this.hide() - } - }) - - this.popupBodySlot.addEventListener('slotchange', () => { - setTimeout(() => { - this.threshold = this.popup.getBoundingClientRect().height * 0.3 - }, 200); - this.inputFields = this.querySelectorAll('sm-input', 'sm-checkbox', 'textarea', 'sm-textarea', 'radio') - }) - - this.popupHeader.addEventListener('touchstart', (e) => { this.handleTouchStart(e) }, {passive: true}) - this.popupHeader.addEventListener('touchmove', (e) => {this.handleTouchMove(e)}, {passive: true}) - this.popupHeader.addEventListener('touchend', (e) => {this.handleTouchEnd(e)}, {passive: true}) - } - disconnectedCallback() { - this.popupHeader.removeEventListener('touchstart', this.handleTouchStart, {passive: true}) - this.popupHeader.removeEventListener('touchmove', this.handleTouchMove, {passive: true}) - this.popupHeader.removeEventListener('touchend', this.handleTouchEnd, {passive: true}) - } -}) - -//carousel - -const smCarousel = document.createElement('template') -smCarousel.innerHTML = ` - - -`; - -customElements.define('sm-carousel', class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(smCarousel.content.cloneNode(true)) - - this.isAutoPlaying = false - this.autoPlayInterval = 5000 - this.autoPlayTimeout - this.initialTimeout - this.activeSlideNum = 0 - this.carouselItems - this.indicators - this.showIndicator = false - this.carousel = this.shadowRoot.querySelector('.carousel') - this.carouselContainer = this.shadowRoot.querySelector('.carousel-container') - this.carouselSlot = this.shadowRoot.querySelector('slot') - this.nextArrow = this.shadowRoot.querySelector('.carousel__button--right') - this.previousArrow = this.shadowRoot.querySelector('.carousel__button--left') - this.indicatorsContainer = this.shadowRoot.querySelector('.indicators') - } - - static get observedAttributes() { - return ['indicator', 'autoplay', 'interval'] - } - - scrollLeft = () => { - this.carousel.scrollBy({ - left: -this.scrollDistance, - behavior: 'smooth' - }) - } - - scrollRight = () => { - this.carousel.scrollBy({ - left: this.scrollDistance, - behavior: 'smooth' - }) - } - - handleIndicatorClick = (e) => { - if (e.target.closest('.dot')) { - const slideNum = parseInt(e.target.closest('.dot').dataset.rank) - if (this.activeSlideNum !== slideNum) { - this.showSlide(slideNum) - } - } - } - - showSlide = (slideNum) => { - this.carousel.scrollTo({ - left: (this.carouselItems[slideNum].getBoundingClientRect().left - this.carousel.getBoundingClientRect().left + this.carousel.scrollLeft), - behavior: 'smooth' - }) - } - - nextSlide = () => { - if (!this.carouselItems) return - let showSlideNo = (this.activeSlideNum + 1) < this.carouselItems.length ? this.activeSlideNum + 1 : 0 - this.showSlide(showSlideNo) - } - - autoPlay = () => { - this.nextSlide() - if (this.isAutoPlaying) { - this.autoPlayTimeout = setTimeout(() => { - this.autoPlay() - }, this.autoPlayInterval); - } - } - - startAutoPlay = () => { - this.setAttribute('autoplay', '') - } - - stopAutoPlay = () => { - this.removeAttribute('autoplay') - } - - connectedCallback() { - this.scrollDistance = this.carouselContainer.getBoundingClientRect().width / 3 - 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) { - const activeRank = parseInt(entry.target.dataset.rank) - if (entry.isIntersecting) { - this.indicators[activeRank].classList.add('active') - this.activeSlideNum = activeRank - } - else - this.indicators[activeRank].classList.remove('active') - } - if (!entry.target.previousElementSibling) - if (entry.isIntersecting) { - this.previousArrow.classList.remove('expand') - firstVisible = true - } - else { - this.previousArrow.classList.add('expand') - firstVisible = false - } - if (!entry.target.nextElementSibling) - if (entry.isIntersecting) { - this.nextArrow.classList.remove('expand') - lastVisible = true - } - else { - this.nextArrow.classList.add('expand') - lastVisible = false - } - if (firstVisible && lastVisible) - this.indicatorsContainer.classList.add('hide') - else - this.indicatorsContainer.classList.remove('hide') - }) - }, { - root: this.carouselContainer, - threshold: 0.9 - }) - - const carouselObserver = new IntersectionObserver(entries => { - if (entries[0].isIntersecting) { - this.scrollDistance = this.carouselContainer.getBoundingClientRect().width / 3 - } - }) - - carouselObserver.observe(this.carouselContainer) - - this.carouselSlot.addEventListener('slotchange', e => { - this.carouselItems = this.carouselSlot.assignedElements() - this.carouselItems.forEach(item => allElementsObserver.observe(item)) - if (this.showIndicator) { - this.indicatorsContainer.innerHTML = `` - this.carouselItems.forEach((item, index) => { - let dot = document.createElement('div') - dot.classList.add('dot') - dot.dataset.rank = index - frag.append(dot) - item.dataset.rank = index - }) - this.indicatorsContainer.append(frag) - this.indicators = this.indicatorsContainer.children - } - }) - - this.addEventListener('keyup', e => { - if (e.code === 'ArrowLeft') - this.scrollRight() - else if (e.code === 'ArrowRight') - this.scrollRight() - }) - - this.nextArrow.addEventListener('click', this.scrollRight) - this.previousArrow.addEventListener('click', this.scrollLeft) - this.indicatorsContainer.addEventListener('click', this.handleIndicatorClick) - } - - async attributeChangedCallback(name, oldValue, newValue) { - if (oldValue !== newValue) { - if (name === 'indicator') { - if (this.hasAttribute('indicator')) - this.showIndicator = true - else - this.showIndicator = false - } - if (name === 'autoplay') { - if (this.hasAttribute('autoplay')) { - this.initialTimeout = setTimeout(() => { - this.isAutoPlaying = true - this.autoPlay() - }, this.autoPlayInterval); - } - else { - this.isAutoPlaying = false - clearTimeout(this.autoPlayTimeout) - clearTimeout(this.initialTimeout) - } - - } - if (name === 'interval') { - if (this.hasAttribute('interval') && this.getAttribute('interval').trim() !== '') { - this.autoPlayInterval = Math.abs(parseInt(this.getAttribute('interval').trim())) - } - else { - this.autoPlayInterval = 5000 - } - } - } - } - - disconnectedCallback() { - this.nextArrow.removeEventListener('click', this.scrollRight) - this.previousArrow.removeEventListener('click', this.scrollLeft) - this.indicatorsContainer.removeEventListener('click', this.handleIndicatorClick) - } -}) - -//notifications - -const smNotifications = document.createElement('template') -smNotifications.innerHTML = ` - -
-` - -customElements.define('sm-notifications', class extends HTMLElement { - constructor() { - super() - this.shadow = this.attachShadow({ - mode: 'open' - }).append(smNotifications.content.cloneNode(true)) - } - - handleTouchStart = (e) => { - this.notification = e.target.closest('.notification') - this.touchStartX = e.changedTouches[0].clientX - this.notification.style.transition = 'initial' - this.touchStartTime = e.timeStamp - } - - handleTouchMove = (e) => { - e.preventDefault() - if (this.touchStartX < e.changedTouches[0].clientX) { - this.offset = e.changedTouches[0].clientX - this.touchStartX; - this.touchEndAnimataion = requestAnimationFrame(this.movePopup) - } else { - this.offset = -(this.touchStartX - e.changedTouches[0].clientX); - this.touchEndAnimataion = requestAnimationFrame(this.movePopup) - } - } - - handleTouchEnd = (e) => { - this.notification.style.transition = 'transform 0.3s, opacity 0.3s' - this.touchEndTime = e.timeStamp - cancelAnimationFrame(this.touchEndAnimataion) - this.touchEndX = e.changedTouches[0].clientX - 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) { - this.removeNotification(this.notification, true) - } else { - this.resetPosition() - } - } else { - if (this.touchEndX > this.touchStartX) { - this.removeNotification(this.notification) - } else { - this.removeNotification(this.notification, true) - } - } - } - - movePopup = () => { - this.notification.style.transform = `translateX(${this.offset}px)` - } - - resetPosition = () => { - this.notification.style.transform = `translateX(0)` - } - - push = (messageBody, type, pinned) => { - let notification = document.createElement('div'), - composition = `` - notification.classList.add('notification') - if (pinned) - notification.classList.add('pinned') - if (type === 'error') { - composition += ` - - - - - ` - } else if (type === 'success') { - composition += ` - - - ` - } - composition += ` -

${messageBody}

- - Close - - - ` - notification.innerHTML = composition - this.notificationPanel.prepend(notification) - if (window.innerWidth > 640) { - notification.animate([{ - transform: `translateX(1rem)`, - opacity: '0' - }, - { - transform: 'translateX(0)', - opacity: '1' - } - ], this.animationOptions).onfinish = () => { - notification.setAttribute('style', `transform: none;`); - } - } else { - notification.setAttribute('style', `transform: translateY(0); opacity: 1`) - } - notification.addEventListener('touchstart', this.handleTouchStart) - notification.addEventListener('touchmove', this.handleTouchMove) - notification.addEventListener('touchend', this.handleTouchEnd) - } - - removeNotification = (notification, toLeft) => { - if (!this.offset) - this.offset = 0; - - if (toLeft) - notification.animate([{ - transform: `translateX(${this.offset}px)`, - opacity: '1' - }, - { - transform: `translateX(-100%)`, - opacity: '0' - } - ], this.animationOptions).onfinish = () => { - notification.remove() - } - else { - notification.animate([{ - transform: `translateX(${this.offset}px)`, - opacity: '1' - }, - { - transform: `translateX(100%)`, - opacity: '0' - } - ], this.animationOptions).onfinish = () => { - notification.remove() - } - } - } - - clearAll = () => { - Array.from(this.notificationPanel.children).forEach(child => { - this.removeNotification(child) - }) - } - - connectedCallback() { - this.notificationPanel = this.shadowRoot.querySelector('.notification-panel') - this.animationOptions = { - duration: 300, - fill: "forwards", - easing: "ease" - } - this.fontSize = Number(window.getComputedStyle(document.body).getPropertyValue('font-size').match(/\d+/)[0]) - this.notification - this.offset - this.touchStartX = 0 - this.touchEndX = 0 - this.touchStartTime = 0 - this.touchEndTime = 0 - this.threshold = this.notificationPanel.getBoundingClientRect().width * 0.3 - this.touchEndAnimataion; - - this.notificationPanel.addEventListener('click', e => { - if (e.target.closest('.close'))( - this.removeNotification(e.target.closest('.notification')) - ) - }) - - const observer = new MutationObserver(mutationList => { - mutationList.forEach(mutation => { - if (mutation.type === 'childList') { - if (mutation.addedNodes.length) { - if (!mutation.addedNodes[0].classList.contains('pinned')) - setTimeout(() => { - this.removeNotification(mutation.addedNodes[0]) - }, 5000); - if (window.innerWidth > 640) - 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) { - this.notificationPanel.style.padding = 0; - } - } - }) - }) - observer.observe(this.notificationPanel, { - attributes: true, - childList: true, - subtree: true - }) - } -}) - - - -// sm-menu -const smMenu = document.createElement('template') -smMenu.innerHTML = ` - -
- -
- -
-
`; -customElements.define('sm-menu', class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(smMenu.content.cloneNode(true)) - } - static get observedAttributes() { - return ['value'] - } - get value() { - return this.getAttribute('value') - } - set value(val) { - this.setAttribute('value', val) - } - expand = () => { - if (!this.open) { - this.optionList.classList.remove('hide') - this.optionList.classList.add('no-transformations') - this.open = true - this.icon.classList.add('focused') - this.availableOptions.forEach(option => { - option.setAttribute('tabindex', '0') - }) - } - } - collapse() { - if (this.open) { - this.open = false - this.icon.classList.remove('focused') - this.optionList.classList.add('hide') - this.optionList.classList.remove('no-transformations') - this.availableOptions.forEach(option => { - option.removeAttribute('tabindex') - }) - } - } - connectedCallback() { - this.availableOptions - this.containerDimensions - this.optionList = this.shadowRoot.querySelector('.options') - let slot = this.shadowRoot.querySelector('.options slot'), - menu = this.shadowRoot.querySelector('.menu') - this.icon = this.shadowRoot.querySelector('.icon') - this.open = false; - menu.addEventListener('click', e => { - if (!this.open) { - this.expand() - } else { - this.collapse() - } - }) - menu.addEventListener('keydown', e => { - if (e.code === 'ArrowDown' || e.code === 'ArrowRight') { - e.preventDefault() - this.availableOptions[0].focus() - } - if (e.code === 'Enter' || e.code === 'Space') { - e.preventDefault() - if (!this.open) { - this.expand() - } else { - this.collapse() - } - } - }) - this.optionList.addEventListener('keydown', e => { - if (e.code === 'ArrowUp' || e.code === 'ArrowRight') { - e.preventDefault() - if (document.activeElement.previousElementSibling) { - document.activeElement.previousElementSibling.focus() - } - } - if (e.code === 'ArrowDown' || e.code === 'ArrowLeft') { - e.preventDefault() - if (document.activeElement.nextElementSibling) - document.activeElement.nextElementSibling.focus() - } - }) - this.optionList.addEventListener('click', e => { - this.collapse() - }) - slot.addEventListener('slotchange', e => { - this.availableOptions = slot.assignedElements() - this.containerDimensions = this.optionList.getBoundingClientRect() - }); - window.addEventListener('mousedown', e => { - if (!this.contains(e.target) && e.button !== 2) { - this.collapse() - } - }) - } -}) - -// option -const smMenuOption = document.createElement('template') -smMenuOption.innerHTML = ` - -
- -
`; -customElements.define('sm-menu-option', class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(smMenuOption.content.cloneNode(true)) - } - - connectedCallback() { - this.addEventListener('keyup', e => { - if (e.code === 'Enter' || e.code === 'Space') { - e.preventDefault() - this.click() - } - }) - } -}) - - -// tags input -const tagsInput = document.createElement('template') -tagsInput.innerHTML = ` - -
- -

-
-` - -customElements.define('tags-input', class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(tagsInput.content.cloneNode(true)) - this.input = this.shadowRoot.querySelector('input') - this.tagsWrapper = this.shadowRoot.querySelector('.tags-wrapper') - this.placeholder = this.shadowRoot.querySelector('.placeholder') - this.observeList = ['placeholder', 'limit'] - this.limit = undefined - this.tags = new Set() - } - static get observedAttributes() { - return ['placeholder', 'limit'] - } - get value() { - return [...this.tags].join() - } - reset = () => { - this.input.value = '' - this.tags.clear() - while (this.input.previousElementSibling) { - this.input.previousElementSibling.remove() - } - } - handleInput = e => { - const inputValueLength = e.target.value.trim().length - e.target.setAttribute('size', inputValueLength ? inputValueLength : '3') - if (inputValueLength) { - this.placeholder.classList.add('hide') - } - else if (!inputValueLength && !this.tags.size) { - this.placeholder.classList.remove('hide') - } - } - handleKeydown = e => { - if (e.key === ',' || e.key === '/') { - e.preventDefault() - } - if (e.target.value.trim() !== '') { - if (e.key === 'Enter' || e.key === ',' || e.key === '/' || e.code === 'Space') { - const tagValue = e.target.value.trim() - if (this.tags.has(tagValue)) { - this.tagsWrapper.querySelector(`[data-value="${tagValue}"]`).animate([ - { - backgroundColor: 'initial' - }, - { - backgroundColor: 'var(--accent-color)' - }, - { - backgroundColor: 'initial' - }, - ], { - duration: 300 - }) - } - else { - const tag = document.createElement('span') - tag.dataset.value = tagValue - tag.className = 'tag' - tag.innerHTML = ` - ${tagValue} - - ` - this.input.before(tag) - this.tags.add(tagValue) - } - e.target.value = '' - e.target.setAttribute('size', '3') - if (this.limit && this.limit < this.tags.size + 1) { - this.input.readOnly = true - return - } - } - } - else { - if (e.key === 'Backspace' && this.input.previousElementSibling) { - this.removeTag(this.input.previousElementSibling) - } - if (this.limit && this.limit > this.tags.size){ - this.input.readOnly = false - } - } - } - handleClick = e => { - if (e.target.closest('.tag')) { - this.removeTag(e.target.closest('.tag')) - } - else { - this.input.focus() - } - } - removeTag = (tag) => { - this.tags.delete(tag.dataset.value) - tag.remove() - if (!this.tags.size) { - this.placeholder.classList.remove('hide') - } - } - connectedCallback() { - this.input.addEventListener('input', this.handleInput) - this.input.addEventListener('keydown', this.handleKeydown) - this.tagsWrapper.addEventListener('click', this.handleClick) - } - attributeChangedCallback(name, oldValue, newValue) { - if (name === 'placeholder') { - this.placeholder.textContent = newValue - } - if (name === 'limit') { - this.limit = parseInt(newValue) - } - } - disconnectedCallback() { - this.input.removeEventListener('input', this.handleInput) - this.input.removeEventListener('keydown', this.handleKeydown) - this.tagsWrapper.removeEventListener('click', this.handleClick) - } -}) - -// file input -const fileInput = document.createElement('template') -fileInput.innerHTML = ` - - - -` - -customElements.define('file-input', class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(fileInput.content.cloneNode(true)) - this.input = this.shadowRoot.querySelector('input') - this.fileInput = this.shadowRoot.querySelector('.file-input') - this.filesPreviewWraper = this.shadowRoot.querySelector('.files-preview-wrapper') - this.observeList = ['accept', 'multiple', 'capture'] - } - static get observedAttributes() { - return ['accept', 'multiple', 'capture'] - } - get files() { - return this.input.files - } - set accept(val) { - this.setAttribute('accept', val) - } - set multiple(val) { - if (val) { - this.setAttribute('mutiple', '') - } - else { - this.removeAttribute('mutiple') - } - } - set capture(val) { - this.setAttribute('capture', val) - } - set value(val) { - this.input.value = val - } - get isValid() { - return this.input.value !== '' - } - reset = () => { - this.input.value = '' - this.filesPreviewWraper.innerHTML = '' - } - formatBytes = (a,b=2) => {if(0===a)return"0 Bytes";const c=0>b?0:b,d=Math.floor(Math.log(a)/Math.log(1024));return parseFloat((a/Math.pow(1024,d)).toFixed(c))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][d]} - createFilePreview = (file) => { - const filePreview = document.createElement('li') - const {name, size} = file - filePreview.className = 'file-preview' - filePreview.innerHTML = ` -
${name}
-
${this.formatBytes(size)}
- ` - return filePreview - } - handleChange = (e) => { - this.filesPreviewWraper.innerHTML = '' - const frag = document.createDocumentFragment() - Array.from(e.target.files).forEach(file => { - frag.append( - this.createFilePreview(file) - ) - }); - this.filesPreviewWraper.append(frag) - } - handleKeyDown = e => { - if (e.key === 'Enter' || e.code === 'Space') { - e.preventDefault() - this.input.click() - } - } - connectedCallback() { - this.setAttribute('role', 'button') - this.setAttribute('aria-label', 'File upload') - this.input.addEventListener('change', this.handleChange) - this.fileInput.addEventListener('keydown', this.handleKeyDown) - } - attributeChangedCallback(name) { - if (this.observeList.includes(name)){ - if (this.hasAttribute(name)) { - this.input.setAttribute(name, this.getAttribute(name) ? this.getAttribute(name) : '') - } - else { - this.input.removeAttribute(name) - } - } - } - disconnectedCallback() { - this.input.removeEventListener('change', this.handleChange) - this.fileInput.removeEventListener('keydown', this.handleKeyDown) - } -}) - -// sm-form -const smForm = document.createElement('template') -smForm.innerHTML = ` - -
- -
-` - -customElements.define('sm-form', class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(smForm.content.cloneNode(true)) - - this.form = this.shadowRoot.querySelector('form') - this.formElements - this.requiredElements - this.submitButton - this.resetButton - this.allRequiredValid = false - } - debounce = (callback, wait) => { - let timeoutId = null; - return (...args) => { - window.clearTimeout(timeoutId); - timeoutId = window.setTimeout(() => { - callback.apply(null, args); - }, wait); - }; - } - handleInput = this.debounce((e) => { - this.allRequiredValid = this.requiredElements.every(elem => elem.isValid) - if (!this.submitButton) return; - if (this.allRequiredValid) { - this.submitButton.disabled = false; - } - else { - this.submitButton.disabled = true; - } - }, 100) - handleKeydown = this.debounce((e) => { - if (e.key === 'Enter') { - if (this.allRequiredValid) { - this.submitButton.click() - } - else { - // implement show validity logic - } - } - }, 100) - reset = () => { - this.formElements.forEach(elem => elem.reset()) - } - connectedCallback() { - const slot = this.shadowRoot.querySelector('slot') - slot.addEventListener('slotchange', e => { - this.formElements = [...this.querySelectorAll('sm-input, sm-textarea, sm-checkbox, tags-input, file-input, sm-switch, sm-checkbox')] - this.requiredElements = this.formElements.filter(elem => elem.hasAttribute('required')) - this.submitButton = e.target.assignedElements().find(elem => elem.getAttribute('variant') === 'primary' || elem.getAttribute('type') === 'submit'); - this.resetButton = e.target.assignedElements().find(elem => elem.getAttribute('type') === 'reset'); - if (this.resetButton) { - this.resetButton.addEventListener('click', this.reset) - } - }) - this.addEventListener('input', this.handleInput) - this.addEventListener('keydown', this.handleKeydown) - } - disconnectedCallback() { - this.removeEventListener('input', this.handleInput) - } -}) \ No newline at end of file +// Components downloaded: chips,file-input,form,input,notifications,popup,select,spinner,tags-input,textarea,theme-toggle +const smChips = document.createElement("template"); smChips.innerHTML = '
', customElements.define("sm-chips", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smChips.content.cloneNode(!0)), this.chipsWrapper = this.shadowRoot.querySelector(".sm-chips"), this.coverLeft = this.shadowRoot.querySelector(".cover--left"), this.coverRight = this.shadowRoot.querySelector(".cover--right"), this.navButtonLeft = this.shadowRoot.querySelector(".nav-button--left"), this.navButtonRight = this.shadowRoot.querySelector(".nav-button--right"), this.slottedOptions = void 0, this._value = void 0, this.scrollDistance = 0, this.assignedElements = [], this.scrollLeft = this.scrollLeft.bind(this), this.scrollRight = this.scrollRight.bind(this), this.fireEvent = this.fireEvent.bind(this), this.setSelectedOption = this.setSelectedOption.bind(this) } get value() { return this._value } set value(t) { this.setSelectedOption(t) } scrollLeft() { this.chipsWrapper.scrollBy({ left: -this.scrollDistance, behavior: "smooth" }) } scrollRight() { this.chipsWrapper.scrollBy({ left: this.scrollDistance, behavior: "smooth" }) } setSelectedOption(t) { this._value !== t && (this._value = t, this.assignedElements.forEach(e => { e.value == t ? (e.setAttribute("selected", ""), e.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "center" })) : e.removeAttribute("selected") })) } fireEvent() { this.dispatchEvent(new CustomEvent("change", { bubbles: !0, composed: !0, detail: { value: this._value } })) } connectedCallback() { this.setAttribute("role", "listbox"); const t = this.shadowRoot.querySelector("slot"); t.addEventListener("slotchange", e => { clearTimeout(this.slotChangeTimeout), this.slotChangeTimeout = setTimeout(() => { n.disconnect(), i.disconnect(), this.assignedElements = t.assignedElements(), this.assignedElements.forEach(t => { t.hasAttribute("selected") && (this._value = t.value) }), this.hasAttribute("multiline") || (this.assignedElements.length > 0 ? (n.observe(this.assignedElements[0]), i.observe(this.assignedElements[this.assignedElements.length - 1])) : (this.navButtonLeft.classList.add("hide"), this.navButtonRight.classList.add("hide"), this.coverLeft.classList.add("hide"), this.coverRight.classList.add("hide"), n.disconnect(), i.disconnect())) }, 100) }); const e = new ResizeObserver(t => { t.forEach(t => { if (t.contentBoxSize) { const e = Array.isArray(t.contentBoxSize) ? t.contentBoxSize[0] : t.contentBoxSize; this.scrollDistance = .6 * e.inlineSize } else this.scrollDistance = .6 * t.contentRect.width }) }); e.observe(this), this.chipsWrapper.addEventListener("option-clicked", t => { this._value !== t.target.value && (this.setSelectedOption(t.target.value), this.fireEvent()) }); const n = new IntersectionObserver(t => { t.forEach(t => { t.isIntersecting ? (this.navButtonLeft.classList.add("hide"), this.coverLeft.classList.add("hide")) : (this.navButtonLeft.classList.remove("hide"), this.coverLeft.classList.remove("hide")) }) }, { threshold: .9, root: this }), i = new IntersectionObserver(t => { t.forEach(t => { t.isIntersecting ? (this.navButtonRight.classList.add("hide"), this.coverRight.classList.add("hide")) : (this.navButtonRight.classList.remove("hide"), this.coverRight.classList.remove("hide")) }) }, { threshold: .9, root: this }); this.navButtonLeft.addEventListener("click", this.scrollLeft), this.navButtonRight.addEventListener("click", this.scrollRight) } disconnectedCallback() { this.navButtonLeft.removeEventListener("click", this.scrollLeft), this.navButtonRight.removeEventListener("click", this.scrollRight) } }); const smChip = document.createElement("template"); smChip.innerHTML = ' ', customElements.define("sm-chip", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smChip.content.cloneNode(!0)), this._value = void 0, this.radioButton = this.shadowRoot.querySelector("input"), this.fireEvent = this.fireEvent.bind(this), this.handleKeyDown = this.handleKeyDown.bind(this) } get value() { return this._value } fireEvent() { this.dispatchEvent(new CustomEvent("option-clicked", { bubbles: !0, composed: !0, detail: { value: this._value } })) } handleKeyDown(t) { "Enter" !== t.key && "Space" !== t.key || this.fireEvent() } connectedCallback() { this.setAttribute("role", "option"), this.setAttribute("tabindex", "0"), this._value = this.getAttribute("value"), this.addEventListener("click", this.fireEvent), this.addEventListener("keydown", this.handleKeyDown) } disconnectedCallback() { this.removeEventListener("click", this.fireEvent), this.removeEventListener("keydown", this.handleKeyDown) } }); +const fileInput = document.createElement("template"); fileInput.innerHTML = ' \t\t \t', customElements.define("file-input", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(fileInput.content.cloneNode(!0)), this.input = this.shadowRoot.querySelector("input"), this.fileInput = this.shadowRoot.querySelector(".file-input"), this.filesPreviewWrapper = this.shadowRoot.querySelector(".files-preview-wrapper"), this.reflectedAttributes = ["accept", "multiple", "capture", "type"], this.reset = this.reset.bind(this), this.formatBytes = this.formatBytes.bind(this), this.createFilePreview = this.createFilePreview.bind(this), this.handleChange = this.handleChange.bind(this), this.handleKeyDown = this.handleKeyDown.bind(this) } static get observedAttributes() { return ["accept", "multiple", "capture", "type"] } get files() { return this.input.files } set accept(t) { this.setAttribute("accept", t) } set multiple(t) { t ? this.setAttribute("multiple", "") : this.removeAttribute("multiple") } set capture(t) { this.setAttribute("capture", t) } set value(t) { this.input.value = t } get isValid() { return "" !== this.input.value } reset() { this.input.value = "", this.filesPreviewWrapper.innerHTML = "" } formatBytes(t, e = 2) { if (0 === t) return "0 Bytes"; const n = 0 > e ? 0 : e, i = Math.floor(Math.log(t) / Math.log(1024)); return parseFloat((t / Math.pow(1024, i)).toFixed(n)) + " " + ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][i] } createFilePreview(t) { const e = document.createElement("li"), { name: n, size: i } = t; return e.className = "file-preview", e.innerHTML = `\t\t\t
${n}
${this.formatBytes(i)}
\t\t`, e } handleChange(t) { this.filesPreviewWrapper.innerHTML = ""; const e = document.createDocumentFragment(); Array.from(t.target.files).forEach(t => { e.append(this.createFilePreview(t)) }), this.filesPreviewWrapper.append(e) } handleKeyDown(t) { "Enter" !== t.key && " " !== t.key || (t.preventDefault(), this.input.click()) } connectedCallback() { this.setAttribute("role", "button"), this.setAttribute("aria-label", "File upload"), this.input.addEventListener("change", this.handleChange), this.fileInput.addEventListener("keydown", this.handleKeyDown) } attributeChangedCallback(t) { this.reflectedAttributes.includes(t) && (this.hasAttribute(t) ? this.input.setAttribute(t, this.getAttribute(t) ? this.getAttribute(t) : "") : this.input.removeAttribute(t)) } disconnectedCallback() { this.input.removeEventListener("change", this.handleChange), this.fileInput.removeEventListener("keydown", this.handleKeyDown) } }); +const smForm = document.createElement("template"); smForm.innerHTML = `
`, customElements.define("sm-form", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smForm.content.cloneNode(!0)), this.form = this.shadowRoot.querySelector("form"), this.invalidFields = !1, this.skipSubmit = !1, this.isFormValid = !1, this.supportedElements = new Set(["INPUT", "SM-INPUT", "SM-TEXTAREA", "SM-CHECKBOX", "TAGS-INPUT", "FILE-INPUT", "SM-SWITCH", "SM-RADIO"]), this.debounce = this.debounce.bind(this), this._checkValidity = this._checkValidity.bind(this), this.handleKeydown = this.handleKeydown.bind(this), this.reset = this.reset.bind(this), this.elementsChanged = this.elementsChanged.bind(this) } static get observedAttributes() { return ["skip-submit"] } get validity() { return this.isFormValid } debounce(t, e) { let i = null; return (...s) => { window.clearTimeout(i), i = window.setTimeout(() => { t.apply(null, s) }, e) } } _checkValidity() { this.submitButton && (this.invalidFields = this._requiredElements.filter(([t, e]) => e ? !t.isValid : !t.checkValidity()), this.isFormValid = 0 === this.invalidFields.length, this.skipSubmit || (this.submitButton.disabled = !this.isFormValid), this.isFormValid ? this.dispatchEvent(new CustomEvent("valid", { bubbles: !0, composed: !0 })) : this.dispatchEvent(new CustomEvent("invalid", { bubbles: !0, composed: !0 }))) } handleKeydown(t) { if ("Enter" === t.key && t.target.tagName.includes("INPUT")) { if (this.invalidFields.length) for (let [e, i] of this._requiredElements) { let s = i ? !e.isValid : !e.checkValidity(); if (s) { (e?.shadowRoot?.lastElementChild || e).animate([{ transform: "translateX(-1rem)" }, { transform: "translateX(1rem)" }, { transform: "translateX(-0.5rem)" }, { transform: "translateX(0.5rem)" }, { transform: "translateX(0)" },], { duration: 300, easing: "ease" }), i ? e.focusIn() : e.focus(); break } } else this.submitButton && this.submitButton.click(), this.dispatchEvent(new CustomEvent("submit", { bubbles: !0, composed: !0 })) } } reset() { this.formElements.forEach(([t, e]) => { e ? t.reset() : t.value = "" }) } elementsChanged() { this.formElements = [...this.querySelectorAll("input, sm-input, sm-textarea, sm-checkbox, tags-input, file-input, sm-switch, sm-radio")].map(t => [t, t.tagName.includes("-")]), this._requiredElements = this.formElements.filter(([t]) => t.hasAttribute("required")), this.submitButton = this.querySelector('[variant="primary"], [type="submit"]'), this.resetButton = this.querySelector('[type="reset"]'), this.resetButton && this.resetButton.addEventListener("click", this.reset), this._checkValidity() } connectedCallback() { let t = this.debounce(this.elementsChanged, 100); this.shadowRoot.querySelector("slot").addEventListener("slotchange", t), this.addEventListener("input", this.debounce(this._checkValidity, 100)), this.addEventListener("keydown", this.debounce(this.handleKeydown, 100)), this.mutationObserver = new MutationObserver(e => { e.forEach(e => { ("childList" === e.type && [...e.addedNodes].some(t => this.supportedElements.has(t.tagName)) || [...e.removedNodes].some(t => this.supportedElements.has(t.tagName))) && t() }) }), this.mutationObserver.observe(this, { childList: !0, subtree: !0 }) } attributeChangedCallback(t, e, i) { "skip-submit" === t && (this.skipSubmit = null !== i) } disconnectedCallback() { this.removeEventListener("input", this.debounce(this._checkValidity, 100)), this.removeEventListener("keydown", this.debounce(this.handleKeydown, 100)), this.mutationObserver.disconnect() } }); +const smInput = document.createElement("template"); smInput.innerHTML = '

', customElements.define("sm-input", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smInput.content.cloneNode(!0)), this.inputParent = this.shadowRoot.querySelector(".input"), this.input = this.shadowRoot.querySelector("input"), this.clearBtn = this.shadowRoot.querySelector(".clear"), this.label = this.shadowRoot.querySelector(".label"), this.feedbackText = this.shadowRoot.querySelector(".feedback-text"), this.outerContainer = this.shadowRoot.querySelector(".outer-container"), this.optionList = this.shadowRoot.querySelector(".datalist"), this._helperText = "", this._errorText = "", this.isRequired = !1, this.datalist = [], this.validationFunction = void 0, this.reflectedAttributes = ["value", "required", "disabled", "type", "inputmode", "readonly", "min", "max", "pattern", "minlength", "maxlength", "step", "list", "autocomplete"], this.reset = this.reset.bind(this), this.clear = this.clear.bind(this), this.focusIn = this.focusIn.bind(this), this.focusOut = this.focusOut.bind(this), this.fireEvent = this.fireEvent.bind(this), this.checkInput = this.checkInput.bind(this), this.allowOnlyNum = this.allowOnlyNum.bind(this), this.handleOptionClick = this.handleOptionClick.bind(this), this.handleInputNavigation = this.handleInputNavigation.bind(this), this.handleDatalistNavigation = this.handleDatalistNavigation.bind(this), this.handleFocus = this.handleFocus.bind(this), this.handleBlur = this.handleBlur.bind(this) } static get observedAttributes() { return ["value", "placeholder", "required", "disabled", "type", "inputmode", "readonly", "min", "max", "pattern", "minlength", "maxlength", "step", "helper-text", "error-text", "list"] } get value() { return this.input.value } set value(t) { t !== this.input.value && (this.input.value = t, this.checkInput()) } get placeholder() { return this.getAttribute("placeholder") } set placeholder(t) { this.setAttribute("placeholder", t) } get type() { return this.getAttribute("type") } set type(t) { this.setAttribute("type", t) } get validity() { return this.input.validity } get disabled() { return this.hasAttribute("disabled") } set disabled(t) { t ? this.inputParent.classList.add("disabled") : this.inputParent.classList.remove("disabled") } get readOnly() { return this.hasAttribute("readonly") } set readOnly(t) { t ? this.setAttribute("readonly", "") : this.removeAttribute("readonly") } set customValidation(t) { this.validationFunction = t } set errorText(t) { this._errorText = t } set helperText(t) { this._helperText = t } get isValid() { if ("" !== this.input.value) { const t = this.input.checkValidity(); let e = !0; return this.validationFunction && (e = Boolean(this.validationFunction(this.input.value))), t && e ? (this.feedbackText.classList.remove("error"), this.feedbackText.classList.add("success"), this.feedbackText.textContent = "") : this._errorText && (this.feedbackText.classList.add("error"), this.feedbackText.classList.remove("success"), this.feedbackText.innerHTML = ` ${this._errorText}`), t && e } } reset() { this.value = "" } clear() { this.value = "", this.input.focus(), this.fireEvent() } focusIn() { this.input.focus() } focusOut() { this.input.blur() } fireEvent() { let t = new Event("input", { bubbles: !0, cancelable: !0, composed: !0 }); this.dispatchEvent(t) } searchDatalist(t) { const e = this.datalist.filter(e => e.toLowerCase().includes(t.toLowerCase())); if (e.sort((e, n) => { const i = e.toLowerCase().indexOf(t.toLowerCase()), s = n.toLowerCase().indexOf(t.toLowerCase()); return i - s }), e.length) { if (this.optionList.children.length > e.length) { const t = this.optionList.children.length - e.length; for (let e = 0; e < t; e++)this.optionList.removeChild(this.optionList.lastChild) } e.forEach((t, e) => { if (this.optionList.children[e]) this.optionList.children[e].textContent = t; else { const e = document.createElement("li"); e.textContent = t, e.classList.add("datalist-item"), e.setAttribute("tabindex", "0"), this.optionList.appendChild(e) } }), this.optionList.classList.remove("hidden") } else this.optionList.classList.add("hidden") } checkInput(t) { this.hasAttribute("readonly") || ("" !== this.input.value ? this.clearBtn.classList.remove("hidden") : this.clearBtn.classList.add("hidden")), this.hasAttribute("placeholder") && "" !== this.getAttribute("placeholder").trim() && ("" !== this.input.value ? (this.animate ? this.inputParent.classList.add("animate-placeholder") : this.label.classList.add("hidden"), this.datalist.length && (this.searchTimeout && clearTimeout(this.searchTimeout), this.searchTimeout = setTimeout(() => { this.searchDatalist(this.input.value.trim()) }, 100))) : (this.animate ? this.inputParent.classList.remove("animate-placeholder") : this.label.classList.remove("hidden"), this.feedbackText.textContent = "", this.datalist.length && (this.optionList.innerHTML = "", this.optionList.classList.add("hidden")))) } allowOnlyNum(t) { 1 === t.key.length && (("." !== t.key || !t.target.value.includes(".") && 0 !== t.target.value.length) && ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."].includes(t.key) || t.preventDefault()) } handleOptionClick(t) { this.input.value = t.target.textContent, this.optionList.classList.add("hidden"), this.input.focus() } handleInputNavigation(t) { "ArrowDown" === t.key ? (t.preventDefault(), this.optionList.children.length && this.optionList.children[0].focus()) : "ArrowUp" === t.key && (t.preventDefault(), this.optionList.children.length && this.optionList.children[this.optionList.children.length - 1].focus()) } handleDatalistNavigation(t) { "ArrowUp" === t.key ? (t.preventDefault(), this.shadowRoot.activeElement.previousElementSibling ? this.shadowRoot.activeElement.previousElementSibling.focus() : this.input.focus()) : "ArrowDown" === t.key ? (t.preventDefault(), this.shadowRoot.activeElement.nextElementSibling ? this.shadowRoot.activeElement.nextElementSibling.focus() : this.input.focus()) : "Enter" !== t.key && " " !== t.key || (t.preventDefault(), this.input.value = t.target.textContent, this.optionList.classList.add("hidden"), this.input.focus()) } handleFocus(t) { this.datalist.length && this.searchDatalist(this.input.value.trim()) } handleBlur(t) { this.datalist.length && this.optionList.classList.add("hidden") } connectedCallback() { this.animate = this.hasAttribute("animate"), this.setAttribute("role", "textbox"), this.input.addEventListener("input", this.checkInput), this.clearBtn.addEventListener("click", this.clear), this.datalist.length && (this.optionList.addEventListener("click", this.handleOptionClick), this.input.addEventListener("keydown", this.handleInputNavigation), this.optionList.addEventListener("keydown", this.handleDatalistNavigation)), this.input.addEventListener("focusin", this.handleFocus), this.addEventListener("focusout", this.handleBlur) } attributeChangedCallback(t, e, n) { e !== n && (this.reflectedAttributes.includes(t) && (this.hasAttribute(t) ? this.input.setAttribute(t, this.getAttribute(t) ? this.getAttribute(t) : "") : this.input.removeAttribute(t)), "placeholder" === t ? (this.label.textContent = n, this.setAttribute("aria-label", n)) : this.hasAttribute("value") ? this.checkInput() : "type" === t ? this.hasAttribute("type") && "number" === this.getAttribute("type") ? (this.input.setAttribute("inputmode", "decimal"), this.input.addEventListener("keydown", this.allowOnlyNum)) : this.input.removeEventListener("keydown", this.allowOnlyNum) : "helper-text" === t ? this._helperText = this.getAttribute("helper-text") : "error-text" === t ? this._errorText = this.getAttribute("error-text") : "required" === t ? (this.isRequired = this.hasAttribute("required"), this.isRequired ? this.setAttribute("aria-required", "true") : this.setAttribute("aria-required", "false")) : "readonly" === t ? this.hasAttribute("readonly") ? this.inputParent.classList.add("readonly") : this.inputParent.classList.remove("readonly") : "disabled" === t ? this.hasAttribute("disabled") ? this.inputParent.classList.add("disabled") : this.inputParent.classList.remove("disabled") : "list" === t && this.hasAttribute("list") && "" !== this.getAttribute("list").trim() && (this.datalist = this.getAttribute("list").split(","))) } disconnectedCallback() { this.input.removeEventListener("input", this.checkInput), this.clearBtn.removeEventListener("click", this.clear), this.input.removeEventListener("keydown", this.allowOnlyNum), this.optionList.removeEventListener("click", this.handleOptionClick), this.input.removeEventListener("keydown", this.handleInputNavigation), this.optionList.removeEventListener("keydown", this.handleDatalistNavigation), this.input.removeEventListener("focusin", this.handleFocus), this.removeEventListener("focusout", this.handleBlur) } }); +const smNotifications = document.createElement("template"); smNotifications.innerHTML = '
', customElements.define("sm-notifications", class extends HTMLElement { constructor() { super(), this.shadow = this.attachShadow({ mode: "open" }).append(smNotifications.content.cloneNode(!0)), this.notificationPanel = this.shadowRoot.querySelector(".notification-panel"), this.animationOptions = { duration: 300, fill: "forwards", easing: "cubic-bezier(0.175, 0.885, 0.32, 1.275)" }, this.push = this.push.bind(this), this.createNotification = this.createNotification.bind(this), this.removeNotification = this.removeNotification.bind(this), this.clearAll = this.clearAll.bind(this), this.remove = this.remove.bind(this), this.handlePointerMove = this.handlePointerMove.bind(this), this.startX = 0, this.currentX = 0, this.endX = 0, this.swipeDistance = 0, this.swipeDirection = "", this.swipeThreshold = 0, this.startTime = 0, this.swipeTime = 0, this.swipeTimeThreshold = 200, this.currentTarget = null, this.mediaQuery = window.matchMedia("(min-width: 640px)"), this.handleOrientationChange = this.handleOrientationChange.bind(this), this.isLandscape = !1 } randString(n) { let t = ""; const i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; for (let e = 0; e < n; e++)t += i.charAt(Math.floor(Math.random() * i.length)); return t } createNotification(n, t = {}) { const { pinned: i = !1, icon: e = "", action: o } = t, r = document.createElement("div"); r.id = this.randString(8), r.classList.add("notification"); let a = ""; return a += `
${e}
${n} `, o && (a += ` `), i && (r.classList.add("pinned"), a += ' '), r.innerHTML = a, r } push(n, t = {}) { const i = this.createNotification(n, t); return this.isLandscape ? this.notificationPanel.append(i) : this.notificationPanel.prepend(i), this.notificationPanel.animate([{ transform: `translateY(${this.isLandscape ? "" : "-"}${i.clientHeight}px)` }, { transform: "none" }], this.animationOptions), i.animate([{ transform: "translateY(-1rem)", opacity: "0" }, { transform: "none", opacity: "1" }], this.animationOptions).onfinish = (n => { n.target.commitStyles(), n.target.cancel() }), i.querySelector(".action") && i.querySelector(".action").addEventListener("click", t.action.callback), i.id } removeNotification(n, t = "left") { if (!n) return; const i = "left" === t ? "-" : "+"; n.animate([{ transform: this.currentX ? `translateX(${this.currentX}px)` : "none", opacity: "1" }, { transform: `translateX(calc(${i}${Math.abs(this.currentX)}px ${i} 1rem))`, opacity: "0" }], this.animationOptions).onfinish = (() => { n.remove() }) } remove(n) { const t = this.notificationPanel.querySelector(`#${n}`); t && this.removeNotification(t) } clearAll() { Array.from(this.notificationPanel.children).forEach(n => { this.removeNotification(n) }) } handlePointerMove(n) { this.currentX = n.clientX - this.startX, this.currentTarget.style.transform = `translateX(${this.currentX}px)` } handleOrientationChange(n) { this.isLandscape = n.matches, n.matches } connectedCallback() { this.handleOrientationChange(this.mediaQuery), this.mediaQuery.addEventListener("change", this.handleOrientationChange), this.notificationPanel.addEventListener("pointerdown", n => { n.target.closest(".close") ? this.removeNotification(n.target.closest(".notification")) : n.target.closest(".notification") && (this.swipeThreshold = n.target.closest(".notification").getBoundingClientRect().width / 2, this.currentTarget = n.target.closest(".notification"), this.currentTarget.setPointerCapture(n.pointerId), this.startTime = Date.now(), this.startX = n.clientX, this.startY = n.clientY, this.notificationPanel.addEventListener("pointermove", this.handlePointerMove)) }), this.notificationPanel.addEventListener("pointerup", n => { this.endX = n.clientX, this.endY = n.clientY, this.swipeDistance = Math.abs(this.endX - this.startX), this.swipeTime = Date.now() - this.startTime, this.endX > this.startX ? this.swipeDirection = "right" : this.swipeDirection = "left", this.swipeTime < this.swipeTimeThreshold ? this.swipeDistance > 50 && this.removeNotification(this.currentTarget, this.swipeDirection) : this.swipeDistance > this.swipeThreshold ? this.removeNotification(this.currentTarget, this.swipeDirection) : this.currentTarget.animate([{ transform: `translateX(${this.currentX}px)` }, { transform: "none" }], this.animationOptions).onfinish = (n => { n.target.commitStyles(), n.target.cancel() }), this.notificationPanel.removeEventListener("pointermove", this.handlePointerMove), this.notificationPanel.releasePointerCapture(n.pointerId), this.currentX = 0 }); const n = new MutationObserver(n => { n.forEach(n => { "childList" === n.type && n.addedNodes.length && !n.addedNodes[0].classList.contains("pinned") && setTimeout(() => { this.removeNotification(n.addedNodes[0]) }, 5e3) }) }); n.observe(this.notificationPanel, { childList: !0 }) } disconnectedCallback() { mediaQueryList.removeEventListener("change", handleOrientationChange) } }); +class Stack { constructor() { this.items = [] } push(t) { this.items.push(t) } pop() { return 0 == this.items.length ? "Underflow" : this.items.pop() } peek() { return this.items[this.items.length - 1] } } const popupStack = new Stack, smPopup = document.createElement("template"); smPopup.innerHTML = ` `, customElements.define("sm-popup", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smPopup.content.cloneNode(!0)), this.allowClosing = !1, this.isOpen = !1, this.offset = 0, this.touchStartY = 0, this.touchEndY = 0, this.touchStartTime = 0, this.touchEndTime = 0, this.touchEndAnimation = void 0, this.focusable, this.autoFocus, this.mutationObserver, this.popupContainer = this.shadowRoot.querySelector(".popup-container"), this.backdrop = this.shadowRoot.querySelector(".backdrop"), this.dialogBox = this.shadowRoot.querySelector(".popup"), this.popupBodySlot = this.shadowRoot.querySelector(".popup-body slot"), this.popupHeader = this.shadowRoot.querySelector(".popup-top"), this.resumeScrolling = this.resumeScrolling.bind(this), this.setStateOpen = this.setStateOpen.bind(this), this.show = this.show.bind(this), this.hide = this.hide.bind(this), this.handleTouchStart = this.handleTouchStart.bind(this), this.handleTouchMove = this.handleTouchMove.bind(this), this.handleTouchEnd = this.handleTouchEnd.bind(this), this.detectFocus = this.detectFocus.bind(this), this.handleSoftDismiss = this.handleSoftDismiss.bind(this), this.debounce = this.debounce.bind(this) } static get observedAttributes() { return ["open"] } get open() { return this.isOpen } animateTo(t, e, i) { let s = t.animate(e, { ...i, fill: "both" }); return s.finished.then(() => { s.commitStyles(), s.cancel() }), s } resumeScrolling() { let t = document.body.style.top; window.scrollTo(0, -1 * parseInt(t || "0")), document.body.style.overflow = "", document.body.style.top = "initial" } setStateOpen() { if (!this.isOpen || this.offset) { let t = window.innerWidth > 640 ? "scale(1.1)" : `translateY(${this.offset ? `${this.offset}px` : "100%"})`; this.animateTo(this.dialogBox, [{ opacity: this.offset ? 1 : 0, transform: t }, { opacity: 1, transform: "none" },], { duration: 300, easing: "ease" }) } } show(t = {}) { let { pinned: e = !1, payload: i } = t; if (this.isOpen) return; let s = { duration: 300, easing: "ease" }; return this.payload = i, popupStack.push({ popup: this, permission: e }), popupStack.items.length > 1 && this.animateTo(popupStack.items[popupStack.items.length - 2].popup.shadowRoot.querySelector(".popup"), [{ transform: "none" }, { transform: window.innerWidth > 640 ? "scale(0.95)" : "translateY(-1.5rem)" },], s), this.popupContainer.classList.remove("hide"), this.offset || (this.backdrop.animate([{ opacity: 0 }, { opacity: 1 },], s).onfinish = () => { this.resolveOpen(this.payload) }, this.dispatchEvent(new CustomEvent("popupopened", { bubbles: !0, composed: !0, detail: { payload: this.payload } })), document.body.style.overflow = "hidden", document.body.style.top = `-${window.scrollY}px`), this.setStateOpen(), this.pinned = e, this.isOpen = !0, setTimeout(() => { let t = this.autoFocus || this.focusable?.[0] || this.dialogBox; t && (t.tagName.includes("-") ? t.focusIn() : t.focus()) }, 0), this.hasAttribute("open") || (this.setAttribute("open", ""), this.addEventListener("keydown", this.detectFocus), this.resizeObserver.observe(this), this.mutationObserver.observe(this, { attributes: !0, childList: !0, subtree: !0 }), this.popupHeader.addEventListener("touchstart", this.handleTouchStart, { passive: !0 }), this.backdrop.addEventListener("mousedown", this.handleSoftDismiss)), { opened: new Promise(t => { this.resolveOpen = t }), closed: new Promise(t => { this.resolveClose = t }) } } hide(t = {}) { let { payload: e } = t, i = { duration: 150, easing: "ease" }; this.backdrop.animate([{ opacity: 1 }, { opacity: 0 }], i), this.animateTo(this.dialogBox, [{ opacity: 1, transform: window.innerWidth > 640 ? "none" : `translateY(${this.offset ? `${this.offset}px` : "0"})` }, { opacity: 0, transform: window.innerWidth > 640 ? "scale(1.1)" : "translateY(100%)" },], i).finished.finally(() => { this.popupContainer.classList.add("hide"), this.dialogBox.style = "", this.removeAttribute("open"), this.forms.length && this.forms.forEach(t => t.reset()), this.dispatchEvent(new CustomEvent("popupclosed", { bubbles: !0, composed: !0, detail: { payload: e || this.payload } })), this.resolveClose(e || this.payload), this.isOpen = !1 }), popupStack.pop(), popupStack.items.length ? this.animateTo(popupStack.items[popupStack.items.length - 1].popup.shadowRoot.querySelector(".popup"), [{ transform: window.innerWidth > 640 ? "scale(0.95)" : "translateY(-1.5rem)" }, { transform: "none" },], i) : this.resumeScrolling(), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), this.removeEventListener("keydown", this.detectFocus), this.popupHeader.removeEventListener("touchstart", this.handleTouchStart, { passive: !0 }), this.backdrop.removeEventListener("mousedown", this.handleSoftDismiss) } handleTouchStart(t) { this.offset = 0, this.popupHeader.addEventListener("touchmove", this.handleTouchMove, { passive: !0 }), this.popupHeader.addEventListener("touchend", this.handleTouchEnd, { passive: !0 }), this.touchStartY = t.changedTouches[0].clientY, this.touchStartTime = t.timeStamp } handleTouchMove(t) { this.touchStartY < t.changedTouches[0].clientY && (this.offset = t.changedTouches[0].clientY - this.touchStartY, this.touchEndAnimation = window.requestAnimationFrame(() => { this.dialogBox.style.transform = `translateY(${this.offset}px)` })) } handleTouchEnd(t) { if (this.touchEndTime = t.timeStamp, cancelAnimationFrame(this.touchEndAnimation), this.touchEndY = t.changedTouches[0].clientY, this.threshold = .3 * this.dialogBox.getBoundingClientRect().height, this.touchEndTime - this.touchStartTime > 200) { if (this.touchEndY - this.touchStartY > this.threshold) { if (this.pinned) { this.setStateOpen(); return } this.hide() } else this.setStateOpen() } else if (this.touchEndY > this.touchStartY) { if (this.pinned) { this.setStateOpen(); return } this.hide() } this.popupHeader.removeEventListener("touchmove", this.handleTouchMove, { passive: !0 }), this.popupHeader.removeEventListener("touchend", this.handleTouchEnd, { passive: !0 }) } detectFocus(t) { if ("Tab" === t.key && this.focusable.length) { if (!this.firstFocusable) { for (let e = 0; e < this.focusable.length; e++)if (!this.focusable[e].disabled) { this.firstFocusable = this.focusable[e]; break } } if (!this.lastFocusable) { for (let i = this.focusable.length - 1; i >= 0; i--)if (!this.focusable[i].disabled) { this.lastFocusable = this.focusable[i]; break } } t.shiftKey && document.activeElement === this.firstFocusable ? (t.preventDefault(), this.lastFocusable.tagName.includes("SM-") ? this.lastFocusable.focusIn() : this.lastFocusable.focus()) : t.shiftKey || document.activeElement !== this.lastFocusable || (t.preventDefault(), this.firstFocusable.tagName.includes("SM-") ? this.firstFocusable.focusIn() : this.firstFocusable.focus()) } } updateFocusableList() { this.focusable = this.querySelectorAll('sm-button:not([disabled]), button:not([disabled]), [href], sm-input, input:not([readonly]), sm-select, select, sm-checkbox, sm-textarea, textarea, [tabindex]:not([tabindex="-1"])'), this.autoFocus = this.querySelector("[autofocus]"), this.firstFocusable = null, this.lastFocusable = null } handleSoftDismiss() { this.pinned ? this.dialogBox.animate([{ transform: "translateX(-1rem)" }, { transform: "translateX(1rem)" }, { transform: "translateX(-0.5rem)" }, { transform: "translateX(0.5rem)" }, { transform: "translateX(0)" },], { duration: 300, easing: "ease" }) : this.hide() } debounce(t, e) { let i = null; return (...s) => { window.clearTimeout(i), i = window.setTimeout(() => { t.apply(null, s) }, e) } } connectedCallback() { this.popupBodySlot.addEventListener("slotchange", this.debounce(() => { this.forms = this.querySelectorAll("sm-form"), this.updateFocusableList() }, 0)), this.resizeObserver = new ResizeObserver(t => { t.forEach(t => { if (t.contentBoxSize) { let e = Array.isArray(t.contentBoxSize) ? t.contentBoxSize[0] : t.contentBoxSize; this.threshold = .3 * e.blockSize.height } else this.threshold = .3 * t.contentRect.height }) }), this.mutationObserver = new MutationObserver(t => { this.updateFocusableList() }) } disconnectedCallback() { this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), this.removeEventListener("keydown", this.detectFocus), this.popupHeader.removeEventListener("touchstart", this.handleTouchStart, { passive: !0 }), this.backdrop.removeEventListener("mousedown", this.handleSoftDismiss) } attributeChangedCallback(t) { "open" === t && this.hasAttribute("open") && this.show() } }); +const smSelect = document.createElement("template"); smSelect.innerHTML = '
', customElements.define("sm-select", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smSelect.content.cloneNode(!0)), this.focusIn = this.focusIn.bind(this), this.reset = this.reset.bind(this), this.open = this.open.bind(this), this.collapse = this.collapse.bind(this), this.toggle = this.toggle.bind(this), this.handleOptionsNavigation = this.handleOptionsNavigation.bind(this), this.handleOptionSelection = this.handleOptionSelection.bind(this), this.handleKeydown = this.handleKeydown.bind(this), this.handleClickOutside = this.handleClickOutside.bind(this), this.selectOption = this.selectOption.bind(this), this.debounce = this.debounce.bind(this), this.availableOptions = [], this.previousOption, this.isOpen = !1, this.label = "", this.defaultSelected = "", this.isUnderViewport = !1, this.animationOptions = { duration: 300, fill: "forwards", easing: "ease" }, this.optionList = this.shadowRoot.querySelector(".options"), this.selection = this.shadowRoot.querySelector(".selection"), this.selectedOptionText = this.shadowRoot.querySelector(".selected-option-text") } static get observedAttributes() { return ["disabled", "label"] } get value() { return this.getAttribute("value") } set value(t) { const e = this.shadowRoot.querySelector("slot").assignedElements().find(e => e.getAttribute("value") === t); e ? (this.setAttribute("value", t), this.selectOption(e)) : console.warn(`There is no option with ${t} as value`) } debounce(t, e) { let n = null; return (...i) => { window.clearTimeout(n), n = window.setTimeout(() => { t.apply(null, i) }, e) } } reset(t = !0) { if (this.availableOptions[0] && this.previousOption !== this.availableOptions[0]) { const e = this.availableOptions.find(t => t.hasAttribute("selected")) || this.availableOptions[0]; this.value = e.getAttribute("value"), t && this.fireEvent() } } selectOption(t) { this.previousOption !== t && (this.querySelectorAll("[selected]").forEach(t => t.removeAttribute("selected")), this.selectedOptionText.textContent = `${this.label}${t.textContent}`, t.setAttribute("selected", ""), this.previousOption = t) } focusIn() { this.selection.focus() } open() { this.availableOptions.forEach(t => t.setAttribute("tabindex", 0)), this.optionList.classList.remove("hidden"), this.isUnderViewport = this.getBoundingClientRect().bottom + this.optionList.getBoundingClientRect().height > window.innerHeight, this.isUnderViewport ? this.setAttribute("isUnder", "") : this.removeAttribute("isUnder"), this.optionList.animate([{ transform: `translateY(${this.isUnderViewport ? "" : "-"}0.5rem)`, opacity: 0 }, { transform: "translateY(0)", opacity: 1 }], this.animationOptions), this.setAttribute("open", ""), this.style.zIndex = 1e3, (this.availableOptions.find(t => t.hasAttribute("selected")) || this.availableOptions[0]).focus(), document.addEventListener("mousedown", this.handleClickOutside), this.isOpen = !0 } collapse() { this.removeAttribute("open"), this.optionList.animate([{ transform: "translateY(0)", opacity: 1 }, { transform: `translateY(${this.isUnderViewport ? "" : "-"}0.5rem)`, opacity: 0 }], this.animationOptions).onfinish = (() => { this.availableOptions.forEach(t => t.removeAttribute("tabindex")), document.removeEventListener("mousedown", this.handleClickOutside), this.optionList.classList.add("hidden"), this.isOpen = !1, this.style.zIndex = "auto" }) } toggle() { this.isOpen || this.hasAttribute("disabled") ? this.collapse() : this.open() } fireEvent() { this.dispatchEvent(new CustomEvent("change", { bubbles: !0, composed: !0, detail: { value: this.value } })) } handleOptionsNavigation(t) { "ArrowUp" === t.key ? (t.preventDefault(), document.activeElement.previousElementSibling ? document.activeElement.previousElementSibling.focus() : this.availableOptions[this.availableOptions.length - 1].focus()) : "ArrowDown" === t.key && (t.preventDefault(), document.activeElement.nextElementSibling ? document.activeElement.nextElementSibling.focus() : this.availableOptions[0].focus()) } handleOptionSelection(t) { this.previousOption !== document.activeElement && (this.value = document.activeElement.getAttribute("value"), this.fireEvent()) } handleClick(t) { t.target === this ? this.toggle() : (this.handleOptionSelection(), this.collapse()) } handleKeydown(t) { t.target === this ? this.isOpen && "ArrowDown" === t.key ? (t.preventDefault(), (this.availableOptions.find(t => t.hasAttribute("selected")) || this.availableOptions[0]).focus(), this.handleOptionSelection(t)) : " " === t.key && (t.preventDefault(), this.toggle()) : (this.handleOptionsNavigation(t), this.handleOptionSelection(t), ["Enter", " ", "Escape", "Tab"].includes(t.key) && (t.preventDefault(), this.collapse(), this.focusIn())) } handleClickOutside(t) { this.isOpen && !this.contains(t.target) && this.collapse() } connectedCallback() { this.setAttribute("role", "listbox"), this.hasAttribute("disabled") || this.selection.setAttribute("tabindex", "0"); let t = this.shadowRoot.querySelector("slot"); t.addEventListener("slotchange", this.debounce(e => { this.availableOptions = t.assignedElements(), this.reset(!1), this.defaultSelected = this.value }, 100)), new IntersectionObserver((t, e) => { t.forEach(t => { if (t.isIntersecting) { const t = this.selection.getBoundingClientRect().left; t < window.innerWidth / 2 ? this.setAttribute("align-select", "left") : this.setAttribute("align-select", "right") } }) }).observe(this), this.addEventListener("click", this.handleClick), this.addEventListener("keydown", this.handleKeydown) } disconnectedCallback() { this.removeEventListener("click", this.handleClick), this.removeEventListener("click", this.toggle), this.removeEventListener("keydown", this.handleKeydown) } attributeChangedCallback(t) { "disabled" === t ? this.hasAttribute("disabled") ? this.selection.removeAttribute("tabindex") : this.selection.setAttribute("tabindex", "0") : "label" === t && (this.label = this.hasAttribute("label") ? `${this.getAttribute("label")} ` : "") } }); const smOption = document.createElement("template"); smOption.innerHTML = "
", customElements.define("sm-option", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smOption.content.cloneNode(!0)) } connectedCallback() { this.setAttribute("role", "option") } }); +const spinner = document.createElement("template"); spinner.innerHTML = ''; class SpinnerLoader extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(spinner.content.cloneNode(!0)) } } window.customElements.define("sm-spinner", SpinnerLoader); +const tagsInput = document.createElement("template"); tagsInput.innerHTML = '

', customElements.define("tags-input", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(tagsInput.content.cloneNode(!0)), this.input = this.shadowRoot.querySelector("input"), this.tagsWrapper = this.shadowRoot.querySelector(".tags-wrapper"), this.placeholder = this.shadowRoot.querySelector(".placeholder"), this.reflectedAttributes = ["placeholder", "limit"], this.limit = void 0, this.tags = new Set, this.reset = this.reset.bind(this), this.handleInput = this.handleInput.bind(this), this.addTag = this.addTag.bind(this), this.handleKeydown = this.handleKeydown.bind(this), this.handleClick = this.handleClick.bind(this), this.removeTag = this.removeTag.bind(this) } static get observedAttributes() { return ["placeholder", "limit"] } get value() { return [...this.tags].filter(t => void 0 !== t) } set value(t) { this.reset(), [...new Set(t.filter(t => void 0 !== t))].forEach(t => this.addTag(t)) } get isValid() { return this.tags.size } focusIn() { this.input.focus() } reset() { for (this.input.value = "", this.tags.clear(); this.input.previousElementSibling;)this.input.previousElementSibling.remove() } addTag(t) { const e = document.createElement("span"); e.dataset.value = t, e.className = "tag", e.innerHTML = ` ${t} `, this.input.before(e), this.tags.add(t) } handleInput(t) { const e = t.target.value.trim().length; t.target.setAttribute("size", e || "3"), e ? this.placeholder.classList.add("hide") : e || this.tags.size || this.placeholder.classList.remove("hide") } handleKeydown(t) { if ("," !== t.key && "/" !== t.key || t.preventDefault(), "" !== t.target.value.trim()) { if ("Enter" === t.key || "," === t.key || "/" === t.key) { const e = t.target.value.trim(); if (this.tags.has(e) ? this.tagsWrapper.querySelector(`[data-value="${e}"]`).animate([{ backgroundColor: "initial" }, { backgroundColor: "var(--accent-color,teal)" }, { backgroundColor: "initial" }], { duration: 300, easing: "ease" }) : this.addTag(e), t.target.value = "", t.target.setAttribute("size", "3"), this.limit && this.limit < this.tags.size + 1) return void (this.input.readOnly = !0) } } else "Backspace" === t.key && this.input.previousElementSibling && this.removeTag(this.input.previousElementSibling), this.limit && this.limit > this.tags.size && (this.input.readOnly = !1) } handleClick(t) { t.target.closest(".tag") ? this.removeTag(t.target.closest(".tag")) : this.input.focus() } removeTag(t) { this.tags.delete(t.dataset.value), t.remove(), this.tags.size || this.placeholder.classList.remove("hide") } connectedCallback() { this.input.addEventListener("input", this.handleInput), this.input.addEventListener("keydown", this.handleKeydown), this.tagsWrapper.addEventListener("click", this.handleClick) } attributeChangedCallback(t, e, n) { "placeholder" === t && (this.placeholder.textContent = n), "limit" === t && (this.limit = parseInt(n)) } disconnectedCallback() { this.input.removeEventListener("input", this.handleInput), this.input.removeEventListener("keydown", this.handleKeydown), this.tagsWrapper.removeEventListener("click", this.handleClick) } }); +const smTextarea = document.createElement("template"); smTextarea.innerHTML = ' ', customElements.define("sm-textarea", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smTextarea.content.cloneNode(!0)), this.textarea = this.shadowRoot.querySelector("textarea"), this.textareaBox = this.shadowRoot.querySelector(".textarea"), this.placeholder = this.shadowRoot.querySelector(".placeholder"), this.reflectedAttributes = ["disabled", "required", "readonly", "rows", "minlength", "maxlength"], this.reset = this.reset.bind(this), this.focusIn = this.focusIn.bind(this), this.fireEvent = this.fireEvent.bind(this), this.checkInput = this.checkInput.bind(this) } static get observedAttributes() { return ["disabled", "value", "placeholder", "required", "readonly", "rows", "minlength", "maxlength"] } get value() { return this.textarea.value } set value(e) { this.setAttribute("value", e), this.fireEvent() } get disabled() { return this.hasAttribute("disabled") } set disabled(e) { e ? this.setAttribute("disabled", "") : this.removeAttribute("disabled") } get isValid() { return this.textarea.checkValidity() } reset() { this.setAttribute("value", "") } focusIn() { this.textarea.focus() } fireEvent() { let e = new Event("input", { bubbles: !0, cancelable: !0, composed: !0 }); this.dispatchEvent(e) } checkInput() { this.hasAttribute("placeholder") && "" !== this.getAttribute("placeholder") && ("" !== this.textarea.value ? this.placeholder.classList.add("hide") : this.placeholder.classList.remove("hide")) } connectedCallback() { this.textarea.addEventListener("input", e => { this.textareaBox.dataset.value = this.textarea.value, this.checkInput() }) } attributeChangedCallback(e, t, n) { this.reflectedAttributes.includes(e) ? this.hasAttribute(e) ? this.textarea.setAttribute(e, this.getAttribute(e) ? this.getAttribute(e) : "") : this.textContent.removeAttribute(e) : "placeholder" === e ? this.placeholder.textContent = this.getAttribute("placeholder") : "value" === e && (this.textarea.value = n, this.textareaBox.dataset.value = n, this.checkInput()) } }); +const themeToggle = document.createElement("template"); themeToggle.innerHTML = ' '; class ThemeToggle extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(themeToggle.content.cloneNode(!0)), this.isChecked = !1, this.hasTheme = "light", this.toggleState = this.toggleState.bind(this), this.fireEvent = this.fireEvent.bind(this), this.handleThemeChange = this.handleThemeChange.bind(this) } static get observedAttributes() { return ["checked"] } daylight() { this.hasTheme = "light", document.body.dataset.theme = "light", this.setAttribute("aria-checked", "false") } nightlight() { this.hasTheme = "dark", document.body.dataset.theme = "dark", this.setAttribute("aria-checked", "true") } toggleState() { this.toggleAttribute("checked"), this.fireEvent() } handleKeyDown(e) { " " === e.key && this.toggleState() } handleThemeChange(e) { e.detail.theme !== this.hasTheme && ("dark" === e.detail.theme ? this.setAttribute("checked", "") : this.removeAttribute("checked")) } fireEvent() { this.dispatchEvent(new CustomEvent("themechange", { bubbles: !0, composed: !0, detail: { theme: this.hasTheme } })) } connectedCallback() { this.setAttribute("role", "switch"), this.setAttribute("aria-label", "theme toggle"), "dark" === localStorage.getItem(`${window.location.hostname}-theme`) ? (this.nightlight(), this.setAttribute("checked", "")) : "light" === localStorage.getItem(`${window.location.hostname}-theme`) ? (this.daylight(), this.removeAttribute("checked")) : window.matchMedia("(prefers-color-scheme: dark)").matches ? (this.nightlight(), this.setAttribute("checked", "")) : (this.daylight(), this.removeAttribute("checked")), this.addEventListener("click", this.toggleState), this.addEventListener("keydown", this.handleKeyDown), document.addEventListener("themechange", this.handleThemeChange) } disconnectedCallback() { this.removeEventListener("click", this.toggleState), this.removeEventListener("keydown", this.handleKeyDown), document.removeEventListener("themechange", this.handleThemeChange) } attributeChangedCallback(e, t, n) { "checked" === e && (this.hasAttribute("checked") ? (this.nightlight(), localStorage.setItem(`${window.location.hostname}-theme`, "dark")) : (this.daylight(), localStorage.setItem(`${window.location.hostname}-theme`, "light"))) } } window.customElements.define("theme-toggle", ThemeToggle); \ No newline at end of file diff --git a/css/main.css b/css/main.css index 9e9e92c..27e3aa9 100644 --- a/css/main.css +++ b/css/main.css @@ -9,33 +9,34 @@ font-size: clamp(1rem, 1.2vmax, 3rem); } -html, body { +html, +body { height: 100%; scroll-behavior: smooth; } body { - --accent-color: #304FFE; + --accent-color: #304ffe; --light-shade: rgba(var(--text-color), 0.06); --text-color: 17, 17, 17; --text-color-light: 100, 100, 100; --foreground-color: 255, 255, 255; - --background-color: #F6f6f6; + --background-color: 243, 245, 250; --error-color: red; --green: #00843b; color: rgba(var(--text-color), 1); - background: var(--background-color); + background: rgba(var(--background-color), 1); display: flex; flex-direction: column; } body[data-theme=dark] { - --accent-color: #2353FF; + --accent-color: #a6b9ff; --green: #13ff5a; --text-color: 240, 240, 240; --text-color-light: 170, 170, 170; - --foreground-color: 20, 20, 20; - --background-color: #0a0a0a; + --foreground-color: 27, 28, 29; + --background-color: 21, 22, 22; --error-color: rgb(255, 106, 106); } @@ -43,6 +44,26 @@ main { flex: 1; } +sm-chips { + --gap: 0.3rem; +} + +sm-chip { + position: relative; + font-size: 0.9rem; + --border-radius: 0.5rem; + --padding: 0.5rem 0.8rem; + --background: rgba(var(--text-color), 0.06); + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; + font-weight: 500; +} +sm-chip[selected] { + --background: var(--accent-color); + color: rgba(var(--foreground-color), 1); +} + .full-bleed { grid-column: 1/4; } @@ -86,7 +107,8 @@ p:not(:last-of-type) { } img { - object-fit: cover; + -o-object-fit: cover; + object-fit: cover; } a { @@ -97,59 +119,80 @@ a:focus-visible { box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset; } +.button, button { + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; position: relative; display: inline-flex; + border: none; + background-color: transparent; overflow: hidden; + -webkit-tap-highlight-color: transparent; align-items: center; - background: none; - cursor: pointer; - outline: none; - color: inherit; font-size: 0.9rem; font-weight: 500; - border-radius: 0.2rem; - padding: 0.5rem 0.6rem; - -webkit-tap-highlight-color: transparent; - border: none; + white-space: nowrap; + padding: 0.8rem; + border-radius: 0.5rem; + justify-content: center; + color: inherit; + min-width: -webkit-max-content; + min-width: -moz-max-content; + min-width: max-content; } - -button:focus-visible { - outline: rgba(var(--text-color), 1) 0.1rem solid; -} - -a.button:any-link { - position: relative; - display: inline-flex; - align-items: center; - background: none; +.button:not(:disabled), +button:not(:disabled) { cursor: pointer; - outline: none; - font-weight: 500; - font-size: 0.8rem; - border-radius: 0.3rem; - padding: 0.5rem 0.6rem; - align-self: flex-start; - text-decoration: none; - color: rgba(var(--text-color), 0.7); - -webkit-tap-highlight-color: transparent; - background-color: rgba(var(--text-color), 0.06); -} -a.button:any-link .icon { - margin-right: 0.3rem; - height: 1.2rem; -} - -a:any-link:focus-visible { - outline: rgba(var(--text-color), 1) 0.1rem solid; } .button { - background-color: rgba(var(--text-color), 0.06); + color: var(--accent-color); + background-color: var(--blue-accent-1); +} +.button .icon { + fill: var(--accent-color); +} +.button--primary, .button--danger { + color: rgba(var(--background-color), 1) !important; +} +.button--primary .icon, .button--danger .icon { + fill: rgba(var(--background-color), 1); +} +.button--primary { + width: 100%; + background-color: var(--accent-color); +} +.button--danger { + background-color: var(--danger-color); +} +.button--small { + padding: 0.4rem 0.6rem; } -sm-button { - --border-radius: 0.3rem; +.cta { + text-transform: uppercase; + font-size: 0.8rem; + font-weight: 700; + letter-spacing: 0.05em; + padding: 0.8rem 1rem; +} + +.icon { + width: 1.2rem; + height: 1.2rem; + fill: rgba(var(--text-color), 0.8); + flex-shrink: 0; +} + +.icon-only { + padding: 0.5rem; + border-radius: 0.3rem; +} + +button:disabled { + opacity: 0.5; } ul { @@ -169,7 +212,7 @@ ul { pointer-events: none; } -.hide-completely { +.hidden { display: none !important; } @@ -189,8 +232,6 @@ ul { word-wrap: break-word; -ms-word-break: break-all; word-break: break-word; - -ms-hyphens: auto; - -moz-hyphens: auto; -webkit-hyphens: auto; hyphens: auto; } @@ -308,10 +349,6 @@ ul { fill: rgba(var(--text-color), 0.9); } -.button__icon { - height: 1.2rem; - width: 1.2rem; -} .button__icon--left { margin-right: 0.5rem; } @@ -433,7 +470,17 @@ ul { stroke-dasharray: 202; margin: 2rem 0; stroke: rgba(var(--text-color), 1); - animation: stroke-anim 2s infinite alternate; + -webkit-animation: stroke-anim 2s infinite alternate; + animation: stroke-anim 2s infinite alternate; +} + +@-webkit-keyframes stroke-anim { + 0% { + stroke-dashoffset: 202; + } + 100% { + stroke-dashoffset: 0; + } } @keyframes stroke-anim { @@ -462,7 +509,6 @@ ul { --background: rgba(var(--text-color), 0.06); } .search-torrent .icon { - height: 1.2rem; fill: rgba(var(--text-color), 0.7); } @@ -574,8 +620,6 @@ ul { .progress-loader, .placeholder-loader { - height: 1.2rem; - width: 1.2rem; fill: none; padding: 0.1rem; stroke-width: 12; @@ -673,15 +717,10 @@ ul { } #torrent_download_button { - align-self: flex-start; - color: white; - flex-shrink: 0; - padding: 0.7rem; - justify-content: center; - background-color: var(--accent-color); + width: auto; + padding: 1rem; } #torrent_download_button .icon { - fill: white; margin-right: 0.5rem; } @@ -693,7 +732,6 @@ ul { border: solid var(--accent-color) thin; } #torrent_index_tx .icon { - height: 1.2rem; margin-right: 0.5rem; } @@ -736,7 +774,9 @@ sm-option { cursor: pointer; font-weight: 500; font-size: 0.95rem; - user-select: none; + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; border-radius: 0.3rem; padding: 0.3rem 0.6rem; transition: background-color 0.3s; @@ -753,7 +793,9 @@ sm-option { } .selected-filter { - user-select: none; + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; cursor: pointer; display: inline-flex; align-items: center; @@ -763,12 +805,11 @@ sm-option { border-radius: 0.3rem; } .selected-filter .icon { - height: 1.2rem; width: 1.2rem; } -#page_selector strip-option, -#search_page_selector strip-option { +#page_selector sm-chip, +#search_page_selector sm-chip { --border-radius: 0.3rem; --active-option-color: white; --active-option-backgroud-color: var(--accent-color); @@ -815,11 +856,9 @@ sm-option { .torrent-card .progress-indicator { margin-top: 1rem; } - #torrent_tags { font-size: 0.8rem; } - #torrent_download_button, #loader_container { width: 100%; @@ -830,36 +869,28 @@ sm-option { .popup__header { padding: 1.5rem 1.5rem 0 0.5rem; } - .auto-grid-2 { grid-template-columns: 1fr 1fr; } - .page-layout { grid-template-columns: 1fr 90vw 1fr; } - #main_header { padding: 1.5rem; } - .page__title { font-size: 3rem; } - .torrent-card { padding: 1.5rem; } - .torrent-preview { gap: 3rem; } - #torrent_name { font-size: 4rem; max-width: 16ch; } - .info-section { grid-template-columns: 1fr 1fr; } @@ -881,7 +912,6 @@ sm-option { width: 0.5rem; height: 0.5rem; } - ::-webkit-scrollbar-thumb { background: rgba(var(--text-color), 0.3); border-radius: 1rem; @@ -889,7 +919,6 @@ sm-option { ::-webkit-scrollbar-thumb:hover { background: rgba(var(--text-color), 0.5); } - .search-suggestion:hover { background-color: rgba(var(--text-color), 0.1); } diff --git a/css/main.min.css b/css/main.min.css index dcaaa5d..28b5c0b 100644 --- a/css/main.min.css +++ b/css/main.min.css @@ -1 +1 @@ -a,a.button:any-link{text-decoration:none}a,button{color:inherit}*{padding:0;margin:0;box-sizing:border-box;font-family:Inter,sans-serif}:root{font-size:clamp(1rem,1.2vmax,3rem)}body,html{height:100%;scroll-behavior:smooth}body{--accent-color:#304FFE;--light-shade:rgba(var(--text-color), 0.06);--text-color:17,17,17;--text-color-light:100,100,100;--foreground-color:255,255,255;--background-color:#F6f6f6;--error-color:red;--green:#00843b;color:rgba(var(--text-color),1);background:var(--background-color);display:flex;flex-direction:column}a.button:any-link,button{display:inline-flex;background:0 0;position:relative;font-weight:500;cursor:pointer}body[data-theme=dark]{--accent-color:#2353FF;--green:#13ff5a;--text-color:240,240,240;--text-color-light:170,170,170;--foreground-color:20,20,20;--background-color:#0a0a0a;--error-color:rgb(255, 106, 106)}main{flex:1}.full-bleed{grid-column:1/4}.h1{font-size:2.5rem}.h2{font-size:2rem}.h3{font-size:1.4rem}.h4{font-size:1rem}.h5{font-size:.8rem}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}p{font-size:.8;max-width:60ch;line-height:1.7;color:rgba(var(--text-color),.8)}p:not(:last-of-type){margin-bottom:1rem}img{object-fit:cover}a:focus-visible{box-shadow:0 0 0 .1rem rgba(var(--text-color),1) inset}button{overflow:hidden;align-items:center;outline:0;font-size:.9rem;border-radius:.2rem;padding:.5rem .6rem;-webkit-tap-highlight-color:transparent;border:none}.torrent-card,a.button:any-link{border-radius:.3rem;-webkit-tap-highlight-color:transparent}button:focus-visible{outline:solid rgba(var(--text-color),1)}a.button:any-link{align-items:center;outline:0;font-size:.8rem;padding:.5rem .6rem;align-self:flex-start;color:rgba(var(--text-color),.7);background-color:rgba(var(--text-color),.06)}a.button:any-link .icon{margin-right:.3rem;height:1.2rem}a:any-link:focus-visible{outline:solid rgba(var(--text-color),1)}.button{background-color:rgba(var(--text-color),.06)}sm-button{--border-radius:0.3rem}ul{list-style:none}.hide{opacity:0;pointer-events:none}.hide-completely{display:none!important}.no-transformations{transform:none!important}.overflow-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.breakable{overflow-wrap:break-word;word-wrap:break-word;-ms-word-break:break-all;word-break:break-word;-ms-hyphens:auto;-moz-hyphens:auto;-webkit-hyphens:auto;hyphens:auto}.flex{display:flex}.grid{display:grid}.flow-column{grid-auto-flow:column}.gap-0-5{gap:.5rem}.gap-1{gap:1rem}.gap-1-5{gap:1.5rem}.gap-2{gap:2rem}.gap-3{gap:3rem}.text-align-right{text-align:right}.align-start{align-items:flex-start}.align-center{align-items:center}.text-center{text-align:center}.justify-start{justify-content:start}.justify-center{justify-content:center}.justify-right{margin-left:auto}.align-self-center{align-self:center}.justify-self-center{justify-self:center}.justify-self-start{justify-self:start}.direction-column{flex-direction:column}.space-between{justify-content:space-between}.w-100{width:100%}.ripple{position:absolute;border-radius:50%;transform:scale(0);background:rgba(var(--text-color),.16);pointer-events:none}.interact{position:relative;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:transparent}.observe-empty-state:empty{display:none}.observe-empty-state:not(:empty)~.empty-state{display:none}.icon{width:1.5rem;height:1.5rem;fill:rgba(var(--text-color),.9)}.button__icon{height:1.2rem;width:1.2rem}.button__icon--left{margin-right:.5rem}.button__icon--right{margin-left:.5rem}.page-layout{position:relative;display:grid;grid-template-columns:1rem minmax(0,1fr) 1rem}.page-layout>*{grid-column:2/3}.popup__header{display:grid;gap:.5rem;width:100%;padding:0 1.5rem 0 .5rem;align-items:center;grid-template-columns:auto 1fr}.popup__header__close{padding:.5rem;cursor:pointer}.button--primary{color:#fff;font-weight:500;padding:.5rem 1.2rem;background-color:var(--accent-color)}.auto-grid-2{gap:2rem;grid-template-columns:1fr}#error_page,#loading_page{position:relative;display:grid;height:100%;place-content:center;justify-items:center}#main_header{position:relative;display:grid;gap:1rem;padding:1rem;align-items:center;grid-template-columns:1fr auto auto}#main_header a.button{font-size:.9rem;font-weight:500;border:thin solid var(--accent-color)}#main_header__logo{height:1.8rem;width:1.8rem}.theme-switcher{position:relative;justify-self:flex-end;width:1.5rem;height:1.5rem;cursor:pointer;-webkit-tap-highlight-color:transparent}.theme-switcher .icon{position:absolute;transition:transform .6s}.theme-switcher__checkbox{display:none}.theme-switcher__checkbox:checked~.moon-icon{transform:scale(0) rotate(90deg)}.theme-switcher__checkbox:not(:checked)~.sun-icon{transform:scale(0) rotate(-90deg)}.page{padding-bottom:3rem}.page__title{font-size:2rem}#search_section{position:relative;display:grid;gap:.5rem 0;padding:4rem 0;justify-items:center}.app-icon{height:3rem;width:3rem}.app-icon-loader{fill:none;stroke-width:2;justify-self:center;stroke-dasharray:202;margin:2rem 0;stroke:rgba(var(--text-color),1);animation:stroke-anim 2s infinite alternate}@keyframes stroke-anim{0%{stroke-dashoffset:202}100%{stroke-dashoffset:0}}.app-name{font-weight:500;margin-bottom:1rem;font-size:.9rem;color:rgba(var(--text-color),.7)}.search-container{position:relative;margin-bottom:1rem;width:min(28rem,100%)}.search-torrent{--border-radius:2rem;--background:rgba(var(--text-color), 0.06)}.search-torrent .icon{height:1.2rem;fill:rgba(var(--text-color),.7)}.search-suggestions-container{top:100%;position:absolute;z-index:1;width:100%;border-radius:1rem;margin-top:.5rem;box-shadow:0 .5rem 1rem -.5rem rgba(0,0,0,.2);background-color:rgba(var(--foreground-color),1)}.search-suggestions-container:not(:empty){padding:.5rem 0}.search-suggestion{display:flex;cursor:pointer;font-weight:700;font-size:.9rem;padding:.8rem 1rem;color:rgba(var(--text-color),.8);outline:0}.search-suggestion:active,.search-suggestion:focus{outline:0;border:0}.search-suggestion:focus,.search-suggestion:focus-visible{outline:transparent;background-color:rgba(var(--text-color),.1)}.search-suggestion span{font-weight:450}.search-suggestion pre{white-space:pre-wrap}.torrent-container{padding:1.5rem 0;display:grid;gap:.5rem;padding-bottom:4rem}.torrent-card{display:grid;gap:0 1rem;align-items:center;grid-template-columns:1fr auto;padding:1rem;background-color:rgba(var(--text-color),.06)}.torrent-card .torrent-info{gap:0 1rem;grid-template-columns:auto 1fr;grid-template-areas:"torrent-icon ." "torrent-icon ."}.torrent-card .torrent-type-icon{padding:.8rem}.torrent-card__icon{grid-area:torrent-icon}.torrent-card__icon .icon{height:1.4rem;width:1.4rem}.torrent-card__title{font-weight:600;font-size:1.1rem;margin-bottom:.5rem}.torrent-card__tags,.torrent-card__uploader{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:.85rem;color:rgba(var(--text-color),.7)}.torrent-card__download-button{justify-self:flex-end;background-color:rgba(var(--text-color),.1)}.torrent-card__download-button .icon{height:1.4rem;margin-right:.5rem}.progress-indicator{position:relative;justify-self:flex-end;height:2.3rem;padding:0 .6rem}.progress-percent{font-size:.9rem;font-weight:500;color:rgba(var(--text-color),.8);width:9ch;text-align:right}.placeholder-loader,.progress-loader{height:1.2rem;width:1.2rem;fill:none;padding:.1rem;stroke-width:12;overflow:visible}.progress-loader{stroke-dasharray:201;stroke-dashoffset:201;transform:rotate(-90deg);stroke:var(--accent-color);transition:stroke-dashoffset .3s;z-index:1}.placeholder-loader{position:absolute;stroke:rgba(var(--text-color),.1)}.torrent-preview{display:grid;justify-content:center}.torrent-preview__info-section{display:flex;flex-direction:column;align-content:flex-start}.torrent-type-icon{display:flex;padding:1rem;border-radius:50%;align-items:center;justify-content:center;align-self:flex-start;aspect-ratio:1/1;flex-shrink:0;background-color:var(--accent-color)}#main_footer,#torrent_type_icon{background-color:rgba(var(--text-color),.06)}.torrent-type-icon .icon{fill:#fff}#torrent_type_icon{align-self:center;justify-self:center;padding:2rem;margin:3rem 0 4rem}#torrent_type_icon .icon{height:3rem;width:3rem;fill:rgba(var(--text-color),.3)}#torrent_tags,#torrent_uploader{display:flex;width:100%;font-size:.85rem;margin-bottom:.5rem;color:rgba(var(--text-color),.8)}#torrent_name{line-height:1.1;font-size:1.8rem;margin-bottom:2rem}#torrent_description{font-size:1rem;color:rgba(var(--text-color),.8)}#torrent_uploader{font-weight:500;margin:1.5rem 0 1rem;width:auto;border-radius:1.5rem;padding:.3rem .8rem;align-self:flex-start;background-color:rgba(var(--text-color),.1)}#download_container{display:flex;align-items:center;height:3rem;margin-top:2rem}#torrent_download_button{align-self:flex-start;color:#fff;flex-shrink:0;padding:.7rem;justify-content:center;background-color:var(--accent-color)}#torrent_download_button .icon{fill:#fff;margin-right:.5rem}#torrent_index_tx{padding:.4rem;font-size:.9rem;border-radius:.5rem;align-self:flex-start;border:var(--accent-color) solid thin}#torrent_index_tx .icon{height:1.2rem;margin-right:.5rem}#advance_search_section{align-items:flex-start;padding:1rem 0;margin-bottom:1rem}#filters_bar{padding:.5rem 0}sm-option{font-size:.9rem}#filter_popup{--width:min(32rem, 100%)}.option-selector{padding:1rem 0}.filter-option{display:inline-flex;margin:0 .5rem .8rem 0;-webkit-tap-highlight-color:transparent}.filter-option input{display:none}.filter-option input:checked~.option-text{color:rgba(255,255,255,.9);background-color:var(--accent-color);border:var(--accent-color) solid thin}.filter-option .option-text{cursor:pointer;font-weight:500;font-size:.95rem;user-select:none;border-radius:.3rem;padding:.3rem .6rem;transition:background-color .3s;color:rgba(var(--text-color),.8);border:rgba(var(--text-color),.2) solid thin}#filters_bar{display:grid;gap:1rem;margin-top:1rem;align-items:flex-start;grid-template-columns:minmax(0,1fr) auto}.selected-filter{user-select:none;cursor:pointer;display:inline-flex;align-items:center;padding:.4rem .5rem;margin:0 .5rem .8rem 0;border:rgba(var(--text-color),.2) solid thin;border-radius:.3rem}.selected-filter .icon{height:1.2rem;width:1.2rem}#page_selector strip-option,#search_page_selector strip-option{--border-radius:0.3rem;--active-option-color:white;--active-option-backgroud-color:var(--accent-color)}#how_it_works{padding-bottom:8rem}#how_it_works .page__title{margin:6rem 0 1rem}.info-section{display:grid;gap:1.5rem;margin-top:3rem;align-items:center;grid-template-columns:1fr}.info__title{margin-bottom:1rem}#main_footer{padding:2rem 0}@media only screen and (max-width:640px){.torrent-card{grid-template-columns:1fr}.torrent-card__icon{margin:0}.torrent-card__title{font-size:.95rem}.torrent-card__tags,.torrent-card__uploader{font-size:.7rem}.torrent-card .progress-indicator,.torrent-card__download-button{margin-top:1rem}#torrent_tags{font-size:.8rem}#loader_container,#torrent_download_button{width:100%;justify-content:center}}@media only screen and (min-width:640px){.popup__header{padding:1.5rem 1.5rem 0 .5rem}#main_header,.torrent-card{padding:1.5rem}.auto-grid-2{grid-template-columns:1fr 1fr}.page-layout{grid-template-columns:1fr 90vw 1fr}.page__title{font-size:3rem}.torrent-preview{gap:3rem}#torrent_name{font-size:4rem;max-width:16ch}.info-section{grid-template-columns:1fr 1fr}.info-section:nth-of-type(even) .info__image{grid-column:2/3}.info-section:nth-of-type(even) .textual-info{grid-row:1/2;grid-column:1/2}}@media only screen and (min-width:1280px){.page-layout{grid-template-columns:1fr 80vw 1fr}}@media (any-hover:hover){::-webkit-scrollbar{width:.5rem;height:.5rem}::-webkit-scrollbar-thumb{background:rgba(var(--text-color),.3);border-radius:1rem}::-webkit-scrollbar-thumb:hover{background:rgba(var(--text-color),.5)}.search-suggestion:hover{background-color:rgba(var(--text-color),.1)}} \ No newline at end of file +*{padding:0;margin:0;box-sizing:border-box;font-family:"Inter",sans-serif}:root{font-size:clamp(1rem,1.2vmax,3rem)}html,body{height:100%;scroll-behavior:smooth}body{--accent-color: #304ffe;--light-shade: rgba(var(--text-color), 0.06);--text-color: 17, 17, 17;--text-color-light: 100, 100, 100;--foreground-color: 255, 255, 255;--background-color: 243, 245, 250;--error-color: red;--green: #00843b;color:rgba(var(--text-color), 1);background:rgba(var(--background-color), 1);display:flex;flex-direction:column}body[data-theme=dark]{--accent-color: #a6b9ff;--green: #13ff5a;--text-color: 240, 240, 240;--text-color-light: 170, 170, 170;--foreground-color: 27, 28, 29;--background-color: 21, 22, 22;--error-color: rgb(255, 106, 106)}main{flex:1}sm-chips{--gap: 0.3rem}sm-chip{position:relative;font-size:.9rem;--border-radius: 0.5rem;--padding: 0.5rem 0.8rem;--background: rgba(var(--text-color), 0.06);-webkit-user-select:none;-moz-user-select:none;user-select:none;font-weight:500}sm-chip[selected]{--background: var(--accent-color);color:rgba(var(--foreground-color), 1)}.full-bleed{grid-column:1/4}.h1{font-size:2.5rem}.h2{font-size:2rem}.h3{font-size:1.4rem}.h4{font-size:1rem}.h5{font-size:.8rem}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}p{font-size:.8;max-width:60ch;line-height:1.7;color:rgba(var(--text-color), 0.8)}p:not(:last-of-type){margin-bottom:1rem}img{-o-object-fit:cover;object-fit:cover}a{color:inherit;text-decoration:none}a:focus-visible{box-shadow:0 0 0 .1rem rgba(var(--text-color), 1) inset}.button,button{-webkit-user-select:none;-moz-user-select:none;user-select:none;position:relative;display:inline-flex;border:none;background-color:rgba(0,0,0,0);overflow:hidden;-webkit-tap-highlight-color:rgba(0,0,0,0);align-items:center;font-size:.9rem;font-weight:500;white-space:nowrap;padding:.8rem;border-radius:.5rem;justify-content:center;color:inherit;min-width:-webkit-max-content;min-width:-moz-max-content;min-width:max-content}.button:not(:disabled),button:not(:disabled){cursor:pointer}.button{color:var(--accent-color);background-color:var(--blue-accent-1)}.button .icon{fill:var(--accent-color)}.button--primary,.button--danger{color:rgba(var(--background-color), 1) !important}.button--primary .icon,.button--danger .icon{fill:rgba(var(--background-color), 1)}.button--primary{width:100%;background-color:var(--accent-color)}.button--danger{background-color:var(--danger-color)}.button--small{padding:.4rem .6rem}.cta{text-transform:uppercase;font-size:.8rem;font-weight:700;letter-spacing:.05em;padding:.8rem 1rem}.icon{width:1.2rem;height:1.2rem;fill:rgba(var(--text-color), 0.8);flex-shrink:0}.icon-only{padding:.5rem;border-radius:.3rem}button:disabled{opacity:.5}ul{list-style:none}.flex{display:flex}.grid{display:grid}.hide{opacity:0;pointer-events:none}.hidden{display:none !important}.no-transformations{transform:none !important}.overflow-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.breakable{overflow-wrap:break-word;word-wrap:break-word;-ms-word-break:break-all;word-break:break-word;-webkit-hyphens:auto;hyphens:auto}.flex{display:flex}.grid{display:grid}.flow-column{grid-auto-flow:column}.gap-0-5{gap:.5rem}.gap-1{gap:1rem}.gap-1-5{gap:1.5rem}.gap-2{gap:2rem}.gap-3{gap:3rem}.text-align-right{text-align:right}.align-start{align-items:flex-start}.align-center{align-items:center}.text-center{text-align:center}.justify-start{justify-content:start}.justify-center{justify-content:center}.justify-right{margin-left:auto}.align-self-center{align-self:center}.justify-self-center{justify-self:center}.justify-self-start{justify-self:start}.direction-column{flex-direction:column}.space-between{justify-content:space-between}.w-100{width:100%}.ripple{position:absolute;border-radius:50%;transform:scale(0);background:rgba(var(--text-color), 0.16);pointer-events:none}.interact{position:relative;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0)}.observe-empty-state:empty{display:none}.observe-empty-state:not(:empty)~.empty-state{display:none}.icon{width:1.5rem;height:1.5rem;fill:rgba(var(--text-color), 0.9)}.button__icon--left{margin-right:.5rem}.button__icon--right{margin-left:.5rem}.page-layout{position:relative;display:grid;grid-template-columns:1rem minmax(0, 1fr) 1rem}.page-layout>*{grid-column:2/3}.popup__header{display:grid;gap:.5rem;width:100%;padding:0 1.5rem 0 .5rem;align-items:center;grid-template-columns:auto 1fr}.popup__header__close{padding:.5rem;cursor:pointer}.button--primary{color:#fff;font-weight:500;padding:.5rem 1.2rem;background-color:var(--accent-color)}.auto-grid-2{gap:2rem;grid-template-columns:1fr}#loading_page,#error_page{position:relative;display:grid;height:100%;place-content:center;justify-items:center}#main_header{position:relative;display:grid;gap:1rem;padding:1rem;align-items:center;grid-template-columns:1fr auto auto}#main_header a.button{font-size:.9rem;font-weight:500;border:solid thin var(--accent-color)}#main_header__logo{height:1.8rem;width:1.8rem}.theme-switcher{position:relative;justify-self:flex-end;width:1.5rem;height:1.5rem;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0)}.theme-switcher .icon{position:absolute;transition:transform .6s}.theme-switcher__checkbox{display:none}.theme-switcher__checkbox:checked~.moon-icon{transform:scale(0) rotate(90deg)}.theme-switcher__checkbox:not(:checked)~.sun-icon{transform:scale(0) rotate(-90deg)}.page{padding-bottom:3rem}.page__title{font-size:2rem}#search_section{position:relative;display:grid;gap:.5rem 0;padding:4rem 0;justify-items:center}.app-icon{height:3rem;width:3rem}.app-icon-loader{fill:none;stroke-width:2;justify-self:center;stroke-dasharray:202;margin:2rem 0;stroke:rgba(var(--text-color), 1);-webkit-animation:stroke-anim 2s infinite alternate;animation:stroke-anim 2s infinite alternate}@-webkit-keyframes stroke-anim{0%{stroke-dashoffset:202}100%{stroke-dashoffset:0}}@keyframes stroke-anim{0%{stroke-dashoffset:202}100%{stroke-dashoffset:0}}.app-name{font-weight:500;margin-bottom:1rem;font-size:.9rem;color:rgba(var(--text-color), 0.7)}.search-container{position:relative;margin-bottom:1rem;width:min(28rem,100%)}.search-torrent{--border-radius: 2rem;--background: rgba(var(--text-color), 0.06)}.search-torrent .icon{fill:rgba(var(--text-color), 0.7)}.search-suggestions-container{top:100%;position:absolute;z-index:1;width:100%;border-radius:1rem;margin-top:.5rem;box-shadow:0 .5rem 1rem -0.5rem rgba(0,0,0,.2);background-color:rgba(var(--foreground-color), 1)}.search-suggestions-container:not(:empty){padding:.5rem 0}.search-suggestion{display:flex;cursor:pointer;font-weight:700;font-size:.9rem;padding:.8rem 1rem;color:rgba(var(--text-color), 0.8);outline:none}.search-suggestion:focus,.search-suggestion:active{outline:none;border:0}.search-suggestion:focus,.search-suggestion:focus-visible{outline:rgba(0,0,0,0);background-color:rgba(var(--text-color), 0.1)}.search-suggestion span{font-weight:450}.search-suggestion pre{white-space:pre-wrap}.torrent-container{padding:1.5rem 0;display:grid;gap:.5rem;padding-bottom:4rem}.torrent-card{display:grid;gap:0 1rem;align-items:center;grid-template-columns:1fr auto;padding:1rem;border-radius:.3rem;-webkit-tap-highlight-color:rgba(0,0,0,0);background-color:rgba(var(--text-color), 0.06)}.torrent-card .torrent-info{gap:0 1rem;grid-template-columns:auto 1fr;grid-template-areas:"torrent-icon ." "torrent-icon ."}.torrent-card .torrent-type-icon{padding:.8rem}.torrent-card__icon{grid-area:torrent-icon}.torrent-card__icon .icon{height:1.4rem;width:1.4rem}.torrent-card__title{font-weight:600;font-size:1.1rem;margin-bottom:.5rem}.torrent-card__tags,.torrent-card__uploader{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:.85rem;color:rgba(var(--text-color), 0.7)}.torrent-card__download-button{justify-self:flex-end;background-color:rgba(var(--text-color), 0.1)}.torrent-card__download-button .icon{height:1.4rem;margin-right:.5rem}.progress-indicator{position:relative;justify-self:flex-end;height:2.3rem;padding:0 .6rem}.progress-percent{font-size:.9rem;font-weight:500;color:rgba(var(--text-color), 0.8);width:9ch;text-align:right}.progress-loader,.placeholder-loader{fill:none;padding:.1rem;stroke-width:12;overflow:visible}.progress-loader{stroke-dasharray:201;stroke-dashoffset:201;transform:rotate(-90deg);stroke:var(--accent-color);transition:stroke-dashoffset .3s;z-index:1}.placeholder-loader{position:absolute;stroke:rgba(var(--text-color), 0.1)}.torrent-preview{display:grid;justify-content:center}.torrent-preview__info-section{display:flex;flex-direction:column;align-content:flex-start}.torrent-type-icon{display:flex;padding:1rem;border-radius:50%;align-items:center;justify-content:center;align-self:flex-start;aspect-ratio:1/1;flex-shrink:0;background-color:var(--accent-color)}.torrent-type-icon .icon{fill:#fff}#torrent_type_icon{align-self:center;justify-self:center;padding:2rem;margin:3rem 0 4rem 0;background-color:rgba(var(--text-color), 0.06)}#torrent_type_icon .icon{height:3rem;width:3rem;fill:rgba(var(--text-color), 0.3)}#torrent_tags,#torrent_uploader{display:flex;width:100%;font-size:.85rem;margin-bottom:.5rem;color:rgba(var(--text-color), 0.8)}#torrent_name{line-height:1.1;font-size:1.8rem;margin-bottom:2rem}#torrent_description{font-size:1rem;color:rgba(var(--text-color), 0.8)}#torrent_uploader{font-weight:500;margin:1.5rem 0 1rem 0;width:auto;border-radius:1.5rem;padding:.3rem .8rem;align-self:flex-start;background-color:rgba(var(--text-color), 0.1)}#download_container{display:flex;align-items:center;height:3rem;margin-top:2rem}#torrent_download_button{width:auto;padding:1rem}#torrent_download_button .icon{margin-right:.5rem}#torrent_index_tx{padding:.4rem;font-size:.9rem;border-radius:.5rem;align-self:flex-start;border:solid var(--accent-color) thin}#torrent_index_tx .icon{margin-right:.5rem}#advance_search_section{align-items:flex-start;padding:1rem 0;margin-bottom:1rem}#filters_bar{padding:.5rem 0}sm-option{font-size:.9rem}#filter_popup{--width: min(32rem, 100%)}.option-selector{padding:1rem 0}.filter-option{display:inline-flex;margin:0 .5rem .8rem 0;-webkit-tap-highlight-color:rgba(0,0,0,0)}.filter-option input{display:none}.filter-option input:checked~.option-text{color:rgba(255,255,255,.9);background-color:var(--accent-color);border:solid var(--accent-color) thin}.filter-option .option-text{cursor:pointer;font-weight:500;font-size:.95rem;-webkit-user-select:none;-moz-user-select:none;user-select:none;border-radius:.3rem;padding:.3rem .6rem;transition:background-color .3s;color:rgba(var(--text-color), 0.8);border:solid rgba(var(--text-color), 0.2) thin}#filters_bar{display:grid;gap:1rem;margin-top:1rem;align-items:flex-start;grid-template-columns:minmax(0, 1fr) auto}.selected-filter{-webkit-user-select:none;-moz-user-select:none;user-select:none;cursor:pointer;display:inline-flex;align-items:center;padding:.4rem .5rem;margin:0 .5rem .8rem 0;border:solid rgba(var(--text-color), 0.2) thin;border-radius:.3rem}.selected-filter .icon{width:1.2rem}#page_selector sm-chip,#search_page_selector sm-chip{--border-radius: 0.3rem;--active-option-color: white;--active-option-backgroud-color: var(--accent-color)}#how_it_works{padding-bottom:8rem}#how_it_works .page__title{margin:6rem 0 1rem 0}.info-section{display:grid;gap:1.5rem;margin-top:3rem;align-items:center;grid-template-columns:1fr}.info__title{margin-bottom:1rem}#main_footer{padding:2rem 0;background-color:rgba(var(--text-color), 0.06)}@media only screen and (max-width: 640px){.torrent-card{grid-template-columns:1fr}.torrent-card__icon{margin:0}.torrent-card__title{font-size:.95rem}.torrent-card__tags,.torrent-card__uploader{font-size:.7rem}.torrent-card__download-button,.torrent-card .progress-indicator{margin-top:1rem}#torrent_tags{font-size:.8rem}#torrent_download_button,#loader_container{width:100%;justify-content:center}}@media only screen and (min-width: 640px){.popup__header{padding:1.5rem 1.5rem 0 .5rem}.auto-grid-2{grid-template-columns:1fr 1fr}.page-layout{grid-template-columns:1fr 90vw 1fr}#main_header{padding:1.5rem}.page__title{font-size:3rem}.torrent-card{padding:1.5rem}.torrent-preview{gap:3rem}#torrent_name{font-size:4rem;max-width:16ch}.info-section{grid-template-columns:1fr 1fr}.info-section:nth-of-type(even) .info__image{grid-column:2/3}.info-section:nth-of-type(even) .textual-info{grid-row:1/2;grid-column:1/2}}@media only screen and (min-width: 1280px){.page-layout{grid-template-columns:1fr 80vw 1fr}}@media(any-hover: hover){::-webkit-scrollbar{width:.5rem;height:.5rem}::-webkit-scrollbar-thumb{background:rgba(var(--text-color), 0.3);border-radius:1rem}::-webkit-scrollbar-thumb:hover{background:rgba(var(--text-color), 0.5)}.search-suggestion:hover{background-color:rgba(var(--text-color), 0.1)}} \ No newline at end of file diff --git a/css/main.scss b/css/main.scss index 18bbcc0..57f296c 100644 --- a/css/main.scss +++ b/css/main.scss @@ -1,810 +1,832 @@ -*{ - padding: 0; - margin: 0; - box-sizing: border-box; - font-family: 'Inter', sans-serif; +* { + padding: 0; + margin: 0; + box-sizing: border-box; + font-family: "Inter", sans-serif; } -:root{ - font-size: clamp(1rem, 1.2vmax, 3rem); +:root { + font-size: clamp(1rem, 1.2vmax, 3rem); } -html, body{ - height: 100%; - scroll-behavior: smooth; +html, +body { + height: 100%; + scroll-behavior: smooth; } body { - --accent-color: #304FFE; - --light-shade: rgba(var(--text-color), 0.06); - --text-color: 17, 17, 17; - --text-color-light: 100, 100, 100; - --foreground-color: 255, 255, 255; - --background-color: #F6f6f6; - --error-color: red; - --green: #00843b; - color: rgba(var(--text-color), 1); - background: var(--background-color); - display: flex; - flex-direction: column; + --accent-color: #304ffe; + --light-shade: rgba(var(--text-color), 0.06); + --text-color: 17, 17, 17; + --text-color-light: 100, 100, 100; + --foreground-color: 255, 255, 255; + --background-color: 243, 245, 250; + --error-color: red; + --green: #00843b; + color: rgba(var(--text-color), 1); + background: rgba(var(--background-color), 1); + display: flex; + flex-direction: column; } -body[data-theme='dark']{ - --accent-color: #2353FF; - --green: #13ff5a; - --text-color: 240, 240, 240; - --text-color-light: 170, 170, 170; - --foreground-color: 20, 20, 20; - --background-color: #0a0a0a; - --error-color: rgb(255, 106, 106); +body[data-theme="dark"] { + --accent-color: #a6b9ff; + --green: #13ff5a; + --text-color: 240, 240, 240; + --text-color-light: 170, 170, 170; + --foreground-color: 27, 28, 29; + --background-color: 21, 22, 22; + --error-color: rgb(255, 106, 106); } -main{ - flex: 1; +main { + flex: 1; +} +sm-chips { + --gap: 0.3rem; } -.full-bleed{ - grid-column: 1/4; -} -.h1{ - font-size: 2.5rem; -} -.h2{ - font-size: 2rem; -} -.h3{ - font-size: 1.4rem; -} -.h4{ - font-size: 1rem; -} -.h5{ - font-size: 0.8rem; +sm-chip { + position: relative; + font-size: 0.9rem; + --border-radius: 0.5rem; + --padding: 0.5rem 0.8rem; + --background: rgba(var(--text-color), 0.06); + user-select: none; + font-weight: 500; + &[selected] { + --background: var(--accent-color); + color: rgba(var(--foreground-color), 1); + } } -.uppercase{ - text-transform: uppercase; +.full-bleed { + grid-column: 1/4; } -.capitalize{ - text-transform: capitalize; +.h1 { + font-size: 2.5rem; +} +.h2 { + font-size: 2rem; +} +.h3 { + font-size: 1.4rem; +} +.h4 { + font-size: 1rem; +} +.h5 { + font-size: 0.8rem; +} + +.uppercase { + text-transform: uppercase; +} +.capitalize { + text-transform: capitalize; } p { - font-size: 0.8; - max-width: 60ch; - line-height: 1.7; - color: rgba(var(--text-color), 0.8); - &:not(:last-of-type){ - margin-bottom: 1rem; - } + font-size: 0.8; + max-width: 60ch; + line-height: 1.7; + color: rgba(var(--text-color), 0.8); + &:not(:last-of-type) { + margin-bottom: 1rem; + } } -img{ - object-fit: cover; +img { + object-fit: cover; } -a{ - color: inherit; - text-decoration: none; - &:focus-visible{ - box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset; - } +a { + color: inherit; + text-decoration: none; + &:focus-visible { + box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset; + } } -button{ - position: relative; - display: inline-flex; - overflow: hidden; - align-items: center; - background: none; +.button, +button { + user-select: none; + position: relative; + display: inline-flex; + border: none; + background-color: transparent; + overflow: hidden; + -webkit-tap-highlight-color: transparent; + align-items: center; + font-size: 0.9rem; + font-weight: 500; + white-space: nowrap; + padding: 0.8rem; + border-radius: 0.5rem; + justify-content: center; + color: inherit; + min-width: max-content; + &:not(:disabled) { cursor: pointer; - outline: none; - color: inherit; + } +} +.button { + color: var(--accent-color); + background-color: var(--blue-accent-1); + .icon { + fill: var(--accent-color); + } + &--primary, + &--danger { + color: rgba(var(--background-color), 1) !important; + .icon { + fill: rgba(var(--background-color), 1); + } + } + &--primary { + width: 100%; + background-color: var(--accent-color); + } + &--danger { + background-color: var(--danger-color); + } + &--small { + padding: 0.4rem 0.6rem; + } +} +.cta { + text-transform: uppercase; + font-size: 0.8rem; + font-weight: 700; + letter-spacing: 0.05em; + padding: 0.8rem 1rem; +} +.icon { + width: 1.2rem; + height: 1.2rem; + fill: rgba(var(--text-color), 0.8); + flex-shrink: 0; +} +.icon-only { + padding: 0.5rem; + border-radius: 0.3rem; +} + +button:disabled { + opacity: 0.5; +} +ul { + list-style: none; +} +.flex { + display: flex; +} +.grid { + display: grid; +} +.hide { + opacity: 0; + pointer-events: none; +} +.hidden { + display: none !important; +} +.no-transformations { + transform: none !important; +} +.overflow-ellipsis { + width: 100%; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} +.breakable { + overflow-wrap: break-word; + word-wrap: break-word; + -ms-word-break: break-all; + word-break: break-word; + -ms-hyphens: auto; + -moz-hyphens: auto; + -webkit-hyphens: auto; + hyphens: auto; +} +.flex { + display: flex; +} +.grid { + display: grid; +} +.flow-column { + grid-auto-flow: column; +} +.gap-0-5 { + gap: 0.5rem; +} +.gap-1 { + gap: 1rem; +} +.gap-1-5 { + gap: 1.5rem; +} +.gap-2 { + gap: 2rem; +} +.gap-3 { + gap: 3rem; +} +.text-align-right { + text-align: right; +} +.align-start { + align-items: flex-start; +} +.align-center { + align-items: center; +} +.text-center { + text-align: center; +} +.justify-start { + justify-content: start; +} +.justify-center { + justify-content: center; +} +.justify-right { + margin-left: auto; +} +.align-self-center { + align-self: center; +} +.justify-self-center { + justify-self: center; +} +.justify-self-start { + justify-self: start; +} +.direction-column { + flex-direction: column; +} +.space-between { + justify-content: space-between; +} +.w-100 { + width: 100%; +} +.ripple { + position: absolute; + border-radius: 50%; + transform: scale(0); + background: rgba(var(--text-color), 0.16); + pointer-events: none; +} +.interact { + position: relative; + overflow: hidden; + cursor: pointer; + -webkit-tap-highlight-color: transparent; +} +.observe-empty-state:empty { + display: none; +} +.observe-empty-state:not(:empty) ~ .empty-state { + display: none; +} + +.icon { + width: 1.5rem; + height: 1.5rem; + fill: rgba(var(--text-color), 0.9); +} +.button__icon { + &--left { + margin-right: 0.5rem; + } + &--right { + margin-left: 0.5rem; + } +} + +.page-layout { + position: relative; + display: grid; + grid-template-columns: 1rem minmax(0, 1fr) 1rem; + & > * { + grid-column: 2/3; + } +} +.popup__header { + display: grid; + gap: 0.5rem; + width: 100%; + padding: 0 1.5rem 0 0.5rem; + align-items: center; + grid-template-columns: auto 1fr; +} +.popup__header__close { + padding: 0.5rem; + cursor: pointer; +} + +.button--primary { + color: white; + font-weight: 500; + padding: 0.5rem 1.2rem; + background-color: var(--accent-color); +} + +.auto-grid-2 { + gap: 2rem; + grid-template-columns: 1fr; +} + +#loading_page, +#error_page { + position: relative; + display: grid; + height: 100%; + place-content: center; + justify-items: center; +} + +#main_header { + position: relative; + display: grid; + gap: 1rem; + padding: 1rem; + align-items: center; + grid-template-columns: 1fr auto auto; + a.button { font-size: 0.9rem; font-weight: 500; - border-radius: 0.2rem; - padding: 0.5rem 0.6rem; - -webkit-tap-highlight-color: transparent; - border: none; + border: solid thin var(--accent-color); + } } -button:focus-visible{ - outline: rgba(var(--text-color), 1) 0.1rem solid; +#main_header__logo { + height: 1.8rem; + width: 1.8rem; } -a.button:any-link{ - position: relative; - display: inline-flex; - align-items: center; - background: none; - cursor: pointer; + +.theme-switcher { + position: relative; + justify-self: flex-end; + width: 1.5rem; + height: 1.5rem; + cursor: pointer; + -webkit-tap-highlight-color: transparent; + .icon { + position: absolute; + transition: transform 0.6s; + } +} +.theme-switcher__checkbox { + display: none; + &:checked ~ .moon-icon { + transform: scale(0) rotate(90deg); + } + &:not(:checked) ~ .sun-icon { + transform: scale(0) rotate(-90deg); + } +} + +.page { + padding-bottom: 3rem; +} +.page__title { + font-size: 2rem; +} + +#search_section { + position: relative; + display: grid; + gap: 0.5rem 0; + padding: 4rem 0; + justify-items: center; +} +.app-icon { + height: 3rem; + width: 3rem; +} + +.app-icon-loader { + fill: none; + stroke-width: 2; + justify-self: center; + stroke-dasharray: 202; + margin: 2rem 0; + stroke: rgba(var(--text-color), 1); + animation: stroke-anim 2s infinite alternate; +} +@keyframes stroke-anim { + 0% { + stroke-dashoffset: 202; + } + 100% { + stroke-dashoffset: 0; + } +} +.app-name { + font-weight: 500; + margin-bottom: 1rem; + font-size: 0.9rem; + color: rgba(var(--text-color), 0.7); +} +.search-container { + position: relative; + margin-bottom: 1rem; + width: min(28rem, 100%); +} +.search-torrent { + --border-radius: 2rem; + --background: rgba(var(--text-color), 0.06); + .icon { + fill: rgba(var(--text-color), 0.7); + } +} +.search-suggestions-container { + top: 100%; + position: absolute; + z-index: 1; + width: 100%; + border-radius: 1rem; + margin-top: 0.5rem; + box-shadow: 0 0.5rem 1rem -0.5rem rgba(0, 0, 0, 0.2); + background-color: rgba(var(--foreground-color), 1); + &:not(:empty) { + padding: 0.5rem 0; + } +} +.search-suggestion { + display: flex; + cursor: pointer; + font-weight: 700; + font-size: 0.9rem; + padding: 0.8rem 1rem; + color: rgba(var(--text-color), 0.8); + outline: none; + &:focus, + &:active { outline: none; - font-weight: 500; - font-size: 0.8rem; - border-radius: 0.3rem; - padding: 0.5rem 0.6rem; - align-self: flex-start; - text-decoration: none; - color: rgba(var(--text-color), 0.7); - -webkit-tap-highlight-color: transparent; - background-color: rgba(var(--text-color), 0.06); - .icon{ - margin-right: 0.3rem; - height: 1.2rem; + border: 0; + } + &:focus, + &:focus-visible { + outline: transparent; + background-color: rgba(var(--text-color), 0.1); + } + span { + font-weight: 450; + } + pre { + white-space: pre-wrap; + } +} + +.torrent-container { + padding: 1.5rem 0; + display: grid; + gap: 0.5rem; + padding-bottom: 4rem; +} +.torrent-card { + display: grid; + gap: 0 1rem; + align-items: center; + grid-template-columns: 1fr auto; + padding: 1rem; + border-radius: 0.3rem; + -webkit-tap-highlight-color: transparent; + background-color: rgba(var(--text-color), 0.06); + .torrent-info { + gap: 0 1rem; + grid-template-columns: auto 1fr; + grid-template-areas: "torrent-icon ." "torrent-icon ."; + } + .torrent-type-icon { + padding: 0.8rem; + } + &__icon { + grid-area: torrent-icon; + .icon { + height: 1.4rem; + width: 1.4rem; } -} -a:any-link:focus-visible{ - outline: rgba(var(--text-color), 1) 0.1rem solid; -} -.button{ - background-color: rgba(var(--text-color), 0.06); -} -sm-button{ - --border-radius: 0.3rem; -} -ul{ - list-style: none; -} -.flex{ - display: flex; -} -.grid{ - display: grid; -} -.hide{ - opacity: 0; - pointer-events: none; -} -.hide-completely{ - display: none !important; -} -.no-transformations{ - transform: none !important; -} -.overflow-ellipsis{ - width: 100%; + } + &__title { + font-weight: 600; + font-size: 1.1rem; + margin-bottom: 0.5rem; + } + &__tags, + &__uploader { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; -} -.breakable{ - overflow-wrap: break-word; - word-wrap: break-word; - -ms-word-break: break-all; - word-break: break-word; - -ms-hyphens: auto; - -moz-hyphens: auto; - -webkit-hyphens: auto; - hyphens: auto; -} -.flex{ - display: flex; -} -.grid{ - display: grid; -} -.flow-column{ - grid-auto-flow: column; -} -.gap-0-5{ - gap: 0.5rem; -} -.gap-1{ - gap: 1rem; -} -.gap-1-5{ - gap: 1.5rem; -} -.gap-2{ - gap: 2rem; -} -.gap-3{ - gap: 3rem; -} -.text-align-right{ - text-align: right; -} -.align-start{ - align-items: flex-start; -} -.align-center{ - align-items: center; -} -.text-center{ - text-align: center; -} -.justify-start{ - justify-content: start; -} -.justify-center{ - justify-content: center; -} -.justify-right{ - margin-left: auto; -} -.align-self-center{ - align-self: center; -} -.justify-self-center{ - justify-self: center; -} -.justify-self-start{ - justify-self: start; -} -.direction-column{ - flex-direction: column; -} -.space-between{ - justify-content: space-between; -} -.w-100{ - width: 100%; -} -.ripple{ - position: absolute; - border-radius: 50%; - transform: scale(0); - background: rgba(var(--text-color), 0.16); - pointer-events: none; -} -.interact{ - position: relative; - overflow: hidden; - cursor: pointer; - -webkit-tap-highlight-color: transparent; -} -.observe-empty-state:empty{ - display: none; -} -.observe-empty-state:not(:empty) ~ .empty-state{ - display: none; -} - - -.icon{ - width: 1.5rem; - height: 1.5rem; - fill: rgba(var(--text-color), 0.9); -} -.button__icon{ - height: 1.2rem; - width: 1.2rem; - &--left{ - margin-right: 0.5rem; - } - &--right{ - margin-left: 0.5rem; - } -} - -.page-layout{ - position: relative; - display: grid; - grid-template-columns: 1rem minmax(0, 1fr) 1rem; - & > * { - grid-column: 2/3; - } -} -.popup__header{ - display: grid; - gap: 0.5rem; - width: 100%; - padding: 0 1.5rem 0 0.5rem; - align-items: center; - grid-template-columns: auto 1fr; -} -.popup__header__close{ - padding: 0.5rem; - cursor: pointer; -} - -.button--primary{ - color: white; - font-weight: 500; - padding: 0.5rem 1.2rem; - background-color: var(--accent-color); -} - -.auto-grid-2{ - gap: 2rem; - grid-template-columns: 1fr; -} - - -#loading_page, -#error_page{ - position: relative; - display: grid; - height: 100%; - place-content: center; - justify-items: center; -} - -#main_header{ - position: relative; - display: grid; - gap: 1rem; - padding: 1rem; - align-items: center; - grid-template-columns: 1fr auto auto; - a.button{ - font-size: 0.9rem; - font-weight: 500; - border: solid thin var(--accent-color); - } -} -#main_header__logo{ - height: 1.8rem; - width: 1.8rem; -} - -.theme-switcher{ - position: relative; - justify-self: flex-end; - width: 1.5rem; - height: 1.5rem; - cursor: pointer; - -webkit-tap-highlight-color: transparent; - .icon{ - position: absolute; - transition: transform 0.6s; - } -} -.theme-switcher__checkbox{ - display: none; - &:checked ~ .moon-icon{ - transform: scale(0) rotate(90deg); - } - &:not(:checked) ~ .sun-icon{ - transform: scale(0) rotate(-90deg); - } -} - -.page{ - padding-bottom: 3rem; -} -.page__title{ - font-size: 2rem; -} - -#search_section{ - position: relative; - display: grid; - gap: 0.5rem 0; - padding: 4rem 0; - justify-items: center; -} -.app-icon{ - height: 3rem; - width: 3rem; -} - -.app-icon-loader{ - fill: none; - stroke-width: 2; - justify-self: center; - stroke-dasharray: 202; - margin: 2rem 0; - stroke: rgba(var(--text-color), 1); - animation: stroke-anim 2s infinite alternate; -} -@keyframes stroke-anim { - 0%{ - stroke-dashoffset: 202; - } - 100%{ - stroke-dashoffset: 0; - } -} -.app-name{ - font-weight: 500; - margin-bottom: 1rem; - font-size: 0.9rem; + font-size: 0.85rem; color: rgba(var(--text-color), 0.7); -} -.search-container{ - position: relative; - margin-bottom: 1rem; - width: min(28rem, 100%); -} -.search-torrent{ - --border-radius: 2rem; - --background: rgba(var(--text-color), 0.06); - .icon{ - height: 1.2rem; - fill: rgba(var(--text-color), 0.7); - } -} -.search-suggestions-container{ - top: 100%; - position: absolute; - z-index: 1; - width: 100%; - border-radius: 1rem; - margin-top: 0.5rem; - box-shadow: 0 0.5rem 1rem -0.5rem rgba(0,0,0,0.2); - background-color: rgba(var(--foreground-color), 1); - &:not(:empty){ - padding: 0.5rem 0; - } -} -.search-suggestion{ - display: flex; - cursor: pointer; - font-weight: 700; - font-size: 0.9rem; - padding: 0.8rem 1rem; - color: rgba(var(--text-color), 0.8); - outline: none; - &:focus, - &:active{ - outline: none; - border: 0; - } - &:focus, - &:focus-visible{ - outline: transparent; - background-color: rgba(var(--text-color), 0.1); - } - span{ - font-weight: 450; - } - pre{ - white-space: pre-wrap; - } -} - -.torrent-container{ - padding: 1.5rem 0; - display: grid; - gap: 0.5rem; - padding-bottom: 4rem; -} -.torrent-card{ - display: grid; - gap: 0 1rem; - align-items: center; - grid-template-columns: 1fr auto; - padding: 1rem; - border-radius: 0.3rem; - -webkit-tap-highlight-color: transparent; - background-color: rgba(var(--text-color), 0.06); - .torrent-info{ - gap: 0 1rem; - grid-template-columns: auto 1fr; - grid-template-areas: 'torrent-icon .' 'torrent-icon .'; - } - .torrent-type-icon{ - padding: 0.8rem; - } - &__icon{ - grid-area: torrent-icon; - .icon{ - height: 1.4rem; - width: 1.4rem; - } - } - &__title{ - font-weight: 600; - font-size: 1.1rem; - margin-bottom: 0.5rem; - } - &__tags, - &__uploader{ - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - font-size: 0.85rem; - color: rgba(var(--text-color), 0.7); - } - &__download-button{ - justify-self: flex-end; - background-color: rgba(var(--text-color), 0.1); - .icon{ - height: 1.4rem; - margin-right: 0.5rem; - } - } -} -.progress-indicator{ - position: relative; + } + &__download-button { justify-self: flex-end; - height: 2.3rem; - padding: 0 0.6rem; + background-color: rgba(var(--text-color), 0.1); + .icon { + height: 1.4rem; + margin-right: 0.5rem; + } + } } -.progress-percent{ - font-size: 0.9rem; - font-weight: 500; - color: rgba(var(--text-color), 0.8); - width: 9ch; - text-align: right; +.progress-indicator { + position: relative; + justify-self: flex-end; + height: 2.3rem; + padding: 0 0.6rem; +} +.progress-percent { + font-size: 0.9rem; + font-weight: 500; + color: rgba(var(--text-color), 0.8); + width: 9ch; + text-align: right; } .progress-loader, -.placeholder-loader{ - height: 1.2rem; - width: 1.2rem; - fill: none; - padding: 0.1rem; - stroke-width: 12; - overflow: visible; -}.progress-loader{ - stroke-dasharray: 201; - stroke-dashoffset: 201; - transform: rotate(-90deg); - stroke: var(--accent-color); - transition: stroke-dashoffset 0.3s; - z-index: 1; +.placeholder-loader { + fill: none; + padding: 0.1rem; + stroke-width: 12; + overflow: visible; } -.placeholder-loader{ - position: absolute; - stroke: rgba(var(--text-color), 0.1); +.progress-loader { + stroke-dasharray: 201; + stroke-dashoffset: 201; + transform: rotate(-90deg); + stroke: var(--accent-color); + transition: stroke-dashoffset 0.3s; + z-index: 1; } -.torrent-preview{ - display: grid; - justify-content: center; +.placeholder-loader { + position: absolute; + stroke: rgba(var(--text-color), 0.1); } -.torrent-preview__info-section{ - display: flex; - flex-direction: column; - align-content: flex-start; +.torrent-preview { + display: grid; + justify-content: center; } -.torrent-type-icon{ - display: flex; - padding: 1rem; - border-radius: 50%; - align-items: center; - justify-content: center; - align-self: flex-start; - aspect-ratio: 1/1; - flex-shrink: 0; - background-color: var(--accent-color); - .icon{ - fill: white; - } +.torrent-preview__info-section { + display: flex; + flex-direction: column; + align-content: flex-start; } -#torrent_type_icon{ - align-self: center; - justify-self: center; - padding: 2rem; - margin: 3rem 0 4rem 0; - background-color: rgba(var(--text-color), 0.06); - .icon{ - height: 3rem; - width: 3rem; - fill: rgba(var(--text-color), 0.3); - } +.torrent-type-icon { + display: flex; + padding: 1rem; + border-radius: 50%; + align-items: center; + justify-content: center; + align-self: flex-start; + aspect-ratio: 1/1; + flex-shrink: 0; + background-color: var(--accent-color); + .icon { + fill: white; + } +} +#torrent_type_icon { + align-self: center; + justify-self: center; + padding: 2rem; + margin: 3rem 0 4rem 0; + background-color: rgba(var(--text-color), 0.06); + .icon { + height: 3rem; + width: 3rem; + fill: rgba(var(--text-color), 0.3); + } } #torrent_tags, -#torrent_uploader{ - display: flex; - width: 100%; - font-size: 0.85rem; - margin-bottom: 0.5rem; - color: rgba(var(--text-color), 0.8); +#torrent_uploader { + display: flex; + width: 100%; + font-size: 0.85rem; + margin-bottom: 0.5rem; + color: rgba(var(--text-color), 0.8); } -#torrent_name{ - line-height: 1.1; - font-size: 1.8rem; - margin-bottom: 2rem; +#torrent_name { + line-height: 1.1; + font-size: 1.8rem; + margin-bottom: 2rem; } -#torrent_description{ - font-size: 1rem; - color: rgba(var(--text-color), 0.8); +#torrent_description { + font-size: 1rem; + color: rgba(var(--text-color), 0.8); } -#torrent_uploader{ - font-weight: 500; - margin: 1.5rem 0 1rem 0; - width: auto; - border-radius: 1.5rem; - padding: 0.3rem 0.8rem; - align-self: flex-start; - background-color: rgba(var(--text-color), 0.1); +#torrent_uploader { + font-weight: 500; + margin: 1.5rem 0 1rem 0; + width: auto; + border-radius: 1.5rem; + padding: 0.3rem 0.8rem; + align-self: flex-start; + background-color: rgba(var(--text-color), 0.1); } -#download_container{ - display: flex; - align-items: center; - height: 3rem; - margin-top: 2rem; +#download_container { + display: flex; + align-items: center; + height: 3rem; + margin-top: 2rem; } -#torrent_download_button{ - align-self: flex-start; - color: white; - flex-shrink: 0; - padding: 0.7rem; - justify-content: center; +#torrent_download_button { + width: auto; + padding: 1rem; + .icon { + margin-right: 0.5rem; + } +} +#torrent_index_tx { + padding: 0.4rem; + font-size: 0.9rem; + border-radius: 0.5rem; + align-self: flex-start; + border: solid var(--accent-color) thin; + .icon { + margin-right: 0.5rem; + } +} +#advance_search_section { + align-items: flex-start; + padding: 1rem 0; + margin-bottom: 1rem; +} + +#filters_bar { + padding: 0.5rem 0; +} +sm-option { + font-size: 0.9rem; +} + +#filter_popup { + --width: min(32rem, 100%); +} + +.option-selector { + padding: 1rem 0; +} +.filter-option { + display: inline-flex; + margin: 0 0.5rem 0.8rem 0; + -webkit-tap-highlight-color: transparent; + input { + display: none; + } + input:checked ~ .option-text { + color: rgba(255, 255, 255, 0.9); background-color: var(--accent-color); - .icon{ - fill: white; - margin-right: 0.5rem; - } -} -#torrent_index_tx{ - padding: 0.4rem; - font-size: 0.9rem; - border-radius: 0.5rem; - align-self: flex-start; border: solid var(--accent-color) thin; - .icon{ - height: 1.2rem; - margin-right: 0.5rem; - } -} -#advance_search_section{ - align-items: flex-start; - padding: 1rem 0; - margin-bottom: 1rem; -} - - -#filters_bar{ - padding: 0.5rem 0; -} -sm-option{ - font-size: 0.9rem; -} - -#filter_popup{ - --width: min(32rem, 100%); -} - -.option-selector{ - padding: 1rem 0; -} -.filter-option{ - display: inline-flex; - margin: 0 0.5rem 0.8rem 0; - -webkit-tap-highlight-color: transparent; - input{ - display: none; - } - input:checked ~ .option-text{ - color: rgba(255, 255, 255, 0.9); - background-color: var(--accent-color); - border: solid var(--accent-color) thin; - } - .option-text{ - cursor: pointer; - font-weight: 500; - font-size: 0.95rem; - user-select: none; - border-radius: 0.3rem; - padding: 0.3rem 0.6rem; - transition: background-color 0.3s; - color: rgba(var(--text-color), 0.8); - border: solid rgba(var(--text-color), 0.2) thin; - } -} -#filters_bar{ - display: grid; - gap: 1rem; - margin-top: 1rem; - align-items: flex-start; - grid-template-columns: minmax(0, 1fr) auto; -} -.selected-filter{ - user-select: none; + } + .option-text { cursor: pointer; - display: inline-flex; - align-items: center; - padding: 0.4rem 0.5rem; - margin: 0 0.5rem 0.8rem 0; - border: solid rgba(var(--text-color), 0.2) thin; + font-weight: 500; + font-size: 0.95rem; + user-select: none; border-radius: 0.3rem; - .icon{ - height: 1.2rem; - width: 1.2rem; - } + padding: 0.3rem 0.6rem; + transition: background-color 0.3s; + color: rgba(var(--text-color), 0.8); + border: solid rgba(var(--text-color), 0.2) thin; + } +} +#filters_bar { + display: grid; + gap: 1rem; + margin-top: 1rem; + align-items: flex-start; + grid-template-columns: minmax(0, 1fr) auto; +} +.selected-filter { + user-select: none; + cursor: pointer; + display: inline-flex; + align-items: center; + padding: 0.4rem 0.5rem; + margin: 0 0.5rem 0.8rem 0; + border: solid rgba(var(--text-color), 0.2) thin; + border-radius: 0.3rem; + .icon { + width: 1.2rem; + } } #page_selector, -#search_page_selector{ - strip-option{ - --border-radius: 0.3rem; - --active-option-color: white; - --active-option-backgroud-color: var(--accent-color); - } +#search_page_selector { + sm-chip { + --border-radius: 0.3rem; + --active-option-color: white; + --active-option-backgroud-color: var(--accent-color); + } } -#how_it_works{ - padding-bottom: 8rem; - .page__title{ - margin: 6rem 0 1rem 0; - } +#how_it_works { + padding-bottom: 8rem; + .page__title { + margin: 6rem 0 1rem 0; + } } -.info-section{ - display: grid; - gap: 1.5rem; - margin-top: 3rem; - align-items: center; - grid-template-columns: 1fr; +.info-section { + display: grid; + gap: 1.5rem; + margin-top: 3rem; + align-items: center; + grid-template-columns: 1fr; } -.info__title{ - margin-bottom: 1rem; +.info__title { + margin-bottom: 1rem; } -#main_footer{ - padding: 2rem 0; - background-color: rgba(var(--text-color), 0.06); +#main_footer { + padding: 2rem 0; + background-color: rgba(var(--text-color), 0.06); } @media only screen and (max-width: 640px) { - .torrent-card{ - grid-template-columns: 1fr; - &__icon{ - margin: 0; - } - &__title{ - font-size: 0.95rem; - } - &__tags, - &__uploader{ - font-size: 0.7rem; - } - &__download-button, - .progress-indicator{ - margin-top: 1rem; - } + .torrent-card { + grid-template-columns: 1fr; + &__icon { + margin: 0; } - #torrent_tags{ - font-size: 0.8rem; + &__title { + font-size: 0.95rem; } - #torrent_download_button, - #loader_container{ - width: 100%; - justify-content: center; + &__tags, + &__uploader { + font-size: 0.7rem; } + &__download-button, + .progress-indicator { + margin-top: 1rem; + } + } + #torrent_tags { + font-size: 0.8rem; + } + #torrent_download_button, + #loader_container { + width: 100%; + justify-content: center; + } } @media only screen and (min-width: 640px) { - .popup__header{ - padding: 1.5rem 1.5rem 0 0.5rem; - } - .auto-grid-2{ - grid-template-columns: 1fr 1fr; - } - .page-layout{ - grid-template-columns: 1fr 90vw 1fr; - } - #main_header{ - padding: 1.5rem; - } - .page__title{ - font-size: 3rem; - } - .torrent-card{ - padding: 1.5rem; - } - .torrent-preview{ - gap: 3rem; - } - #torrent_name{ - font-size: 4rem; - max-width: 16ch; - } - .info-section{ - grid-template-columns: 1fr 1fr; - &:nth-of-type(even){ - .info__image{ - grid-column: 2/3; - } - .textual-info{ - grid-row: 1/2; - grid-column: 1/2; - } - } + .popup__header { + padding: 1.5rem 1.5rem 0 0.5rem; + } + .auto-grid-2 { + grid-template-columns: 1fr 1fr; + } + .page-layout { + grid-template-columns: 1fr 90vw 1fr; + } + #main_header { + padding: 1.5rem; + } + .page__title { + font-size: 3rem; + } + .torrent-card { + padding: 1.5rem; + } + .torrent-preview { + gap: 3rem; + } + #torrent_name { + font-size: 4rem; + max-width: 16ch; + } + .info-section { + grid-template-columns: 1fr 1fr; + &:nth-of-type(even) { + .info__image { + grid-column: 2/3; + } + .textual-info { + grid-row: 1/2; + grid-column: 1/2; + } } + } } @media only screen and (min-width: 1280px) { - .page-layout{ - grid-template-columns: 1fr 80vw 1fr; - } + .page-layout { + grid-template-columns: 1fr 80vw 1fr; + } } -@media (any-hover: hover){ - ::-webkit-scrollbar{ - width: 0.5rem; - height: 0.5rem; +@media (any-hover: hover) { + ::-webkit-scrollbar { + width: 0.5rem; + height: 0.5rem; + } + + ::-webkit-scrollbar-thumb { + background: rgba(var(--text-color), 0.3); + border-radius: 1rem; + &:hover { + background: rgba(var(--text-color), 0.5); } - - ::-webkit-scrollbar-thumb{ - background: rgba(var(--text-color), 0.3); - border-radius: 1rem; - &:hover{ - background: rgba(var(--text-color), 0.5); - } + } + .search-suggestion { + &:hover { + background-color: rgba(var(--text-color), 0.1); } - .search-suggestion{ - &:hover{ - background-color: rgba(var(--text-color), 0.1); - } - } -} \ No newline at end of file + } +} diff --git a/css/uploader-style.css b/css/uploader-style.css index 94d0637..6a2d778 100644 --- a/css/uploader-style.css +++ b/css/uploader-style.css @@ -9,7 +9,8 @@ font-size: clamp(1rem, 1.2vmax, 3rem); } -html, body { +html, +body { height: 100%; scroll-behavior: smooth; } @@ -20,11 +21,11 @@ body { --text-color: 17, 17, 17; --text-color-light: 100, 100, 100; --foreground-color: 255, 255, 255; - --background-color: #F6f6f6; + --background-color: 243, 245, 250; --error-color: red; --green: #00843b; color: rgba(var(--text-color), 1); - background: var(--background-color); + background: rgba(var(--background-color), 1); display: flex; flex-direction: column; } @@ -34,8 +35,8 @@ body[data-theme=dark] { --green: #13ff5a; --text-color: 240, 240, 240; --text-color-light: 170, 170, 170; - --foreground-color: 20, 20, 20; - --background-color: #0a0a0a; + --foreground-color: 27, 28, 29; + --background-color: 21, 22, 22; --error-color: rgb(255, 106, 106); } @@ -82,7 +83,8 @@ p:not(:last-of-type) { } img { - object-fit: cover; + -o-object-fit: cover; + object-fit: cover; } a { @@ -93,59 +95,80 @@ a:focus-visible { box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset; } +.button, button { + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; position: relative; display: inline-flex; + border: none; + background-color: transparent; overflow: hidden; + -webkit-tap-highlight-color: transparent; align-items: center; - background: none; - cursor: pointer; - outline: none; - color: inherit; font-size: 0.9rem; font-weight: 500; - border-radius: 0.2rem; - padding: 0.5rem 0.6rem; - -webkit-tap-highlight-color: transparent; - border: none; + white-space: nowrap; + padding: 0.8rem; + border-radius: 0.5rem; + justify-content: center; + color: inherit; + min-width: -webkit-max-content; + min-width: -moz-max-content; + min-width: max-content; } - -button:focus-visible { - outline: rgba(var(--text-color), 1) 0.1rem solid; -} - -a.button:any-link { - position: relative; - display: inline-flex; - align-items: center; - background: none; +.button:not(:disabled), +button:not(:disabled) { cursor: pointer; - outline: none; - font-weight: 500; - font-size: 0.8rem; - border-radius: 0.3rem; - padding: 0.5rem 0.6rem; - align-self: flex-start; - text-decoration: none; - color: rgba(var(--text-color), 0.7); - -webkit-tap-highlight-color: transparent; - background-color: rgba(var(--text-color), 0.06); -} -a.button:any-link .icon { - margin-right: 0.3rem; - height: 1.2rem; -} - -a:any-link:focus-visible { - outline: rgba(var(--text-color), 1) 0.1rem solid; } .button { - background-color: rgba(var(--text-color), 0.06); + color: var(--accent-color); + background-color: var(--blue-accent-1); +} +.button .icon { + fill: var(--accent-color); +} +.button--primary, .button--danger { + color: rgba(var(--background-color), 1) !important; +} +.button--primary .icon, .button--danger .icon { + fill: rgba(var(--background-color), 1); +} +.button--primary { + width: 100%; + background-color: var(--accent-color); +} +.button--danger { + background-color: var(--danger-color); +} +.button--small { + padding: 0.4rem 0.6rem; } -sm-button { - --border-radius: 0.3rem; +.cta { + text-transform: uppercase; + font-size: 0.8rem; + font-weight: 700; + letter-spacing: 0.05em; + padding: 0.8rem 1rem; +} + +.icon { + width: 1.2rem; + height: 1.2rem; + fill: rgba(var(--text-color), 0.8); + flex-shrink: 0; +} + +.icon-only { + padding: 0.5rem; + border-radius: 0.3rem; +} + +button:disabled { + opacity: 0.5; } sm-popup { @@ -169,7 +192,7 @@ ul { pointer-events: none; } -.hide-completely { +.hidden { display: none !important; } @@ -189,8 +212,6 @@ ul { word-wrap: break-word; -ms-word-break: break-all; word-break: break-word; - -ms-hyphens: auto; - -moz-hyphens: auto; -webkit-hyphens: auto; hyphens: auto; } @@ -454,7 +475,17 @@ tags-input { fill: none; stroke-dashoffset: 180; stroke-dasharray: 180; - animation: load 3.6s linear infinite, spin 1s linear infinite; + -webkit-animation: load 3.6s linear infinite, spin 1s linear infinite; + animation: load 3.6s linear infinite, spin 1s linear infinite; +} + +@-webkit-keyframes load { + 50% { + stroke-dashoffset: 0; + } + 100% { + stroke-dashoffset: -180; + } } @keyframes load { @@ -465,6 +496,11 @@ tags-input { stroke-dashoffset: -180; } } +@-webkit-keyframes spin { + 100% { + transform: rotate(360deg); + } +} @keyframes spin { 100% { transform: rotate(360deg); @@ -507,16 +543,18 @@ sm-select { file-input { font-size: 0.9rem; - --button-color: var(--background-color); + --button-color: rgba(var(--background-color), 1); } file-input .icon { height: 1.2rem; width: 1.2rem; - fill: var(--background-color); + fill: rgba(var(--background-color), 1); } summary { - user-select: none; + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; cursor: pointer; justify-self: center; margin-bottom: 1.5rem; @@ -547,7 +585,6 @@ summary { #main_header { padding: 1.5rem 2rem; } - #torrent_form { width: 32rem; } @@ -557,7 +594,6 @@ summary { width: 0.5rem; height: 0.5rem; } - ::-webkit-scrollbar-thumb { background: rgba(var(--text-color), 0.3); border-radius: 1rem; diff --git a/css/uploader-style.min.css b/css/uploader-style.min.css index 403f7ea..de0c96a 100644 --- a/css/uploader-style.min.css +++ b/css/uploader-style.min.css @@ -1 +1 @@ -a,button{color:inherit}a,a.button:any-link{text-decoration:none}*{padding:0;margin:0;box-sizing:border-box;font-family:Inter,sans-serif}:root{font-size:clamp(1rem,1.2vmax,3rem)}body,html{height:100%;scroll-behavior:smooth}body{--accent-color:#0eaf8f;--light-shade:rgba(var(--text-color), 0.06);--text-color:17,17,17;--text-color-light:100,100,100;--foreground-color:255,255,255;--background-color:#F6f6f6;--error-color:red;--green:#00843b;color:rgba(var(--text-color),1);background:var(--background-color);display:flex;flex-direction:column}a.button:any-link,button{position:relative;display:inline-flex;background:0 0;padding:.5rem .6rem;font-weight:500;-webkit-tap-highlight-color:transparent;cursor:pointer}body[data-theme=dark]{--accent-color:#1abc9c;--green:#13ff5a;--text-color:240,240,240;--text-color-light:170,170,170;--foreground-color:20,20,20;--background-color:#0a0a0a;--error-color:rgb(255, 106, 106)}.full-bleed{grid-column:1/4}.h1{font-size:2.5rem}.h2{font-size:2rem}.h3{font-size:1.4rem}.h4{font-size:1rem}.h5{font-size:.8rem}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}p{font-size:.8;max-width:60ch;line-height:1.7;color:rgba(var(--text-color),.8)}#main_header a.button,button,file-input,tags-input{font-size:.9rem}p:not(:last-of-type){margin-bottom:1rem}img{object-fit:cover}a:focus-visible{box-shadow:0 0 0 .1rem rgba(var(--text-color),1) inset}button{overflow:hidden;align-items:center;outline:0;border-radius:.2rem;border:none}button:focus-visible{outline:solid rgba(var(--text-color),1)}a.button:any-link{align-items:center;outline:0;font-size:.8rem;border-radius:.3rem;align-self:flex-start;color:rgba(var(--text-color),.7);background-color:rgba(var(--text-color),.06)}a.button:any-link .icon{margin-right:.3rem;height:1.2rem}a:any-link:focus-visible{outline:solid rgba(var(--text-color),1)}.button{background-color:rgba(var(--text-color),.06)}sm-button{--border-radius:0.3rem}sm-popup{--width:min(24rem, 100%)}ul{list-style:none}.hide{opacity:0;pointer-events:none}.hide-completely{display:none!important}.no-transformations{transform:none!important}.overflow-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.breakable{overflow-wrap:break-word;word-wrap:break-word;-ms-word-break:break-all;word-break:break-word;-ms-hyphens:auto;-moz-hyphens:auto;-webkit-hyphens:auto;hyphens:auto}.flex{display:flex}.grid{display:grid}.flow-column{grid-auto-flow:column}.gap-0-5{gap:.5rem}.gap-1{gap:1rem}.gap-1-5{gap:1.5rem}.gap-2{gap:2rem}.gap-3{gap:3rem}.text-align-right{text-align:right}.align-start{align-items:flex-start}.align-center{align-items:center}.text-center{text-align:center}.justify-start{justify-content:start}.justify-center{justify-content:center}.justify-right{margin-left:auto}.align-self-center{align-self:center}.justify-self-center{justify-self:center}.justify-self-start{justify-self:start}.justify-self-end{justify-self:end}.direction-column{flex-direction:column}.space-between{justify-content:space-between}#main_header,.popup__header{align-items:center;display:grid}.w-100{width:100%}.ripple{position:absolute;border-radius:50%;transform:scale(0);background:rgba(var(--text-color),.16);pointer-events:none}#main_header,.interact,.page-layout,.theme-switcher{position:relative}.interact{overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:transparent}.observe-empty-state:empty{display:none}.observe-empty-state:not(:empty)~.empty-state{display:none}.icon{width:1.5rem;height:1.5rem;fill:rgba(var(--text-color),.9)}.button__icon{height:1.2rem;width:1.2rem}.button__icon--left{margin-right:.5rem}.button__icon--right{margin-left:.5rem}.page-layout{display:grid;grid-template-columns:1rem minmax(0,1fr) 1rem}.page-layout>*{grid-column:2/3}.popup__header{gap:.5rem;width:100%;padding:0 1.5rem 0 .5rem;grid-template-columns:auto 1fr}.popup__header__close{padding:.5rem;cursor:pointer}.button--primary{color:#fff;font-weight:500;padding:.5rem 1.2rem;background-color:var(--accent-color)}#confirmation_popup,#prompt_popup{flex-direction:column}#confirmation_popup h4,#prompt_popup h4{font-weight:500;margin-bottom:.5rem}#confirmation_popup sm-button,#prompt_popup sm-button{margin:0}#confirmation_popup .flex,#prompt_popup .flex{padding:0;margin-top:1rem}#confirmation_popup .flex sm-button:first-of-type,#prompt_popup .flex sm-button:first-of-type{margin-right:.6rem;margin-left:auto}#main_header{padding:1rem;margin-bottom:1rem;grid-template-columns:1fr auto auto}#main_header a.button{font-weight:500;border:thin solid var(--accent-color)}#main_header__logo{height:1.8rem;width:1.8rem}.theme-switcher{justify-self:flex-end;width:1.5rem;height:1.5rem;cursor:pointer;-webkit-tap-highlight-color:transparent}.theme-switcher .icon{position:absolute;transition:transform .6s}.theme-switcher__checkbox{display:none}.theme-switcher__checkbox:checked~.moon-icon{transform:scale(0) rotate(90deg)}.theme-switcher__checkbox:not(:checked)~.sun-icon{transform:scale(0) rotate(-90deg)}.fieldset{display:grid;gap:1rem;border:none;padding:1rem;border-radius:.5rem;background-color:rgba(var(--text-color),.06)}.torrent-upload-section{display:grid;place-items:center;flex:1;padding:0 0 2rem}#torrent_form{display:grid;padding:0 1rem;margin-bottom:3rem}.loader{height:1.6rem;width:1.6rem;stroke-width:8;overflow:visible;stroke:var(--accent-color);fill:none;stroke-dashoffset:180;stroke-dasharray:180;animation:load 3.6s linear infinite,spin 1s linear infinite}@keyframes load{50%{stroke-dashoffset:0}100%{stroke-dashoffset:-180}}@keyframes spin{100%{transform:rotate(360deg)}}.progress-bar{position:relative;display:flex;width:100%;align-items:center;height:.5rem;border-radius:2rem}.progress{position:absolute;left:0;height:100%;border-radius:2rem;transition:width .3s;background-color:var(--accent-color)}#overlay_content,#overlay_content>*{display:grid;gap:1.5rem;justify-content:center;justify-items:center;text-align:center}#upload_torrent_button{width:100%}sm-select{--max-height:40vh}file-input{--button-color:var(--background-color)}file-input .icon{height:1.2rem;width:1.2rem;fill:var(--background-color)}summary{user-select:none;cursor:pointer;justify-self:center;margin-bottom:1.5rem}.page-footer{display:grid;gap:1.5rem;padding:2rem 1.5rem;text-align:center;justify-items:center;background-color:rgba(var(--text-color),.06)}.page-footer .icon{height:1.6rem;width:1.6rem;margin-left:-.4rem;margin-right:.1rem}.page-footer h5{font-weight:400}.page-footer h4{font-weight:600}@media screen and (min-width:640px){#main_header{padding:1.5rem 2rem}#torrent_form{width:32rem}}@media (any-hover:hover){::-webkit-scrollbar{width:.5rem;height:.5rem}::-webkit-scrollbar-thumb{background:rgba(var(--text-color),.3);border-radius:1rem}::-webkit-scrollbar-thumb:hover{background:rgba(var(--text-color),.5)}} \ No newline at end of file +*{padding:0;margin:0;box-sizing:border-box;font-family:"Inter",sans-serif}:root{font-size:clamp(1rem,1.2vmax,3rem)}html,body{height:100%;scroll-behavior:smooth}body{--accent-color: #0eaf8f;--light-shade: rgba(var(--text-color), 0.06);--text-color: 17, 17, 17;--text-color-light: 100, 100, 100;--foreground-color: 255, 255, 255;--background-color: 243, 245, 250;--error-color: red;--green: #00843b;color:rgba(var(--text-color), 1);background:rgba(var(--background-color), 1);display:flex;flex-direction:column}body[data-theme=dark]{--accent-color: #1abc9c;--green: #13ff5a;--text-color: 240, 240, 240;--text-color-light: 170, 170, 170;--foreground-color: 27, 28, 29;--background-color: 21, 22, 22;--error-color: rgb(255, 106, 106)}.full-bleed{grid-column:1/4}.h1{font-size:2.5rem}.h2{font-size:2rem}.h3{font-size:1.4rem}.h4{font-size:1rem}.h5{font-size:.8rem}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}p{font-size:.8;max-width:60ch;line-height:1.7;color:rgba(var(--text-color), 0.8)}p:not(:last-of-type){margin-bottom:1rem}img{-o-object-fit:cover;object-fit:cover}a{color:inherit;text-decoration:none}a:focus-visible{box-shadow:0 0 0 .1rem rgba(var(--text-color), 1) inset}.button,button{-webkit-user-select:none;-moz-user-select:none;user-select:none;position:relative;display:inline-flex;border:none;background-color:rgba(0,0,0,0);overflow:hidden;-webkit-tap-highlight-color:rgba(0,0,0,0);align-items:center;font-size:.9rem;font-weight:500;white-space:nowrap;padding:.8rem;border-radius:.5rem;justify-content:center;color:inherit;min-width:-webkit-max-content;min-width:-moz-max-content;min-width:max-content}.button:not(:disabled),button:not(:disabled){cursor:pointer}.button{color:var(--accent-color);background-color:var(--blue-accent-1)}.button .icon{fill:var(--accent-color)}.button--primary,.button--danger{color:rgba(var(--background-color), 1) !important}.button--primary .icon,.button--danger .icon{fill:rgba(var(--background-color), 1)}.button--primary{width:100%;background-color:var(--accent-color)}.button--danger{background-color:var(--danger-color)}.button--small{padding:.4rem .6rem}.cta{text-transform:uppercase;font-size:.8rem;font-weight:700;letter-spacing:.05em;padding:.8rem 1rem}.icon{width:1.2rem;height:1.2rem;fill:rgba(var(--text-color), 0.8);flex-shrink:0}.icon-only{padding:.5rem;border-radius:.3rem}button:disabled{opacity:.5}sm-popup{--width: min(24rem, 100%)}ul{list-style:none}.flex{display:flex}.grid{display:grid}.hide{opacity:0;pointer-events:none}.hidden{display:none !important}.no-transformations{transform:none !important}.overflow-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.breakable{overflow-wrap:break-word;word-wrap:break-word;-ms-word-break:break-all;word-break:break-word;-webkit-hyphens:auto;hyphens:auto}.flex{display:flex}.grid{display:grid}.flow-column{grid-auto-flow:column}.gap-0-5{gap:.5rem}.gap-1{gap:1rem}.gap-1-5{gap:1.5rem}.gap-2{gap:2rem}.gap-3{gap:3rem}.text-align-right{text-align:right}.align-start{align-items:flex-start}.align-center{align-items:center}.text-center{text-align:center}.justify-start{justify-content:start}.justify-center{justify-content:center}.justify-right{margin-left:auto}.align-self-center{align-self:center}.justify-self-center{justify-self:center}.justify-self-start{justify-self:start}.justify-self-end{justify-self:end}.direction-column{flex-direction:column}.space-between{justify-content:space-between}.w-100{width:100%}.ripple{position:absolute;border-radius:50%;transform:scale(0);background:rgba(var(--text-color), 0.16);pointer-events:none}.interact{position:relative;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0)}.observe-empty-state:empty{display:none}.observe-empty-state:not(:empty)~.empty-state{display:none}.icon{width:1.5rem;height:1.5rem;fill:rgba(var(--text-color), 0.9)}.button__icon{height:1.2rem;width:1.2rem}.button__icon--left{margin-right:.5rem}.button__icon--right{margin-left:.5rem}.page-layout{position:relative;display:grid;grid-template-columns:1rem minmax(0, 1fr) 1rem}.page-layout>*{grid-column:2/3}.popup__header{display:grid;gap:.5rem;width:100%;padding:0 1.5rem 0 .5rem;align-items:center;grid-template-columns:auto 1fr}.popup__header__close{padding:.5rem;cursor:pointer}.button--primary{color:#fff;font-weight:500;padding:.5rem 1.2rem;background-color:var(--accent-color)}#confirmation_popup,#prompt_popup{flex-direction:column}#confirmation_popup h4,#prompt_popup h4{font-weight:500;margin-bottom:.5rem}#confirmation_popup sm-button,#prompt_popup sm-button{margin:0}#confirmation_popup .flex,#prompt_popup .flex{padding:0;margin-top:1rem}#confirmation_popup .flex sm-button:first-of-type,#prompt_popup .flex sm-button:first-of-type{margin-right:.6rem;margin-left:auto}#main_header{position:relative;display:grid;padding:1rem;align-items:center;margin-bottom:1rem;grid-template-columns:1fr auto auto}#main_header a.button{font-size:.9rem;font-weight:500;border:solid thin var(--accent-color)}#main_header__logo{height:1.8rem;width:1.8rem}.theme-switcher{position:relative;justify-self:flex-end;width:1.5rem;height:1.5rem;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0)}.theme-switcher .icon{position:absolute;transition:transform .6s}.theme-switcher__checkbox{display:none}.theme-switcher__checkbox:checked~.moon-icon{transform:scale(0) rotate(90deg)}.theme-switcher__checkbox:not(:checked)~.sun-icon{transform:scale(0) rotate(-90deg)}.fieldset{display:grid;gap:1rem;border:none;padding:1rem;border-radius:.5rem;background-color:rgba(var(--text-color), 0.06)}tags-input{font-size:.9rem}.torrent-upload-section{display:grid;place-items:center;flex:1;padding:0 0 2rem 0}#torrent_form{display:grid;padding:0 1rem;margin-bottom:3rem}.loader{height:1.6rem;width:1.6rem;stroke-width:8;overflow:visible;stroke:var(--accent-color);fill:none;stroke-dashoffset:180;stroke-dasharray:180;-webkit-animation:load 3.6s linear infinite,spin 1s linear infinite;animation:load 3.6s linear infinite,spin 1s linear infinite}@-webkit-keyframes load{50%{stroke-dashoffset:0}100%{stroke-dashoffset:-180}}@keyframes load{50%{stroke-dashoffset:0}100%{stroke-dashoffset:-180}}@-webkit-keyframes spin{100%{transform:rotate(360deg)}}@keyframes spin{100%{transform:rotate(360deg)}}.progress-bar{position:relative;display:flex;width:100%;align-items:center;height:.5rem;border-radius:2rem}.progress{position:absolute;left:0;height:100%;border-radius:2rem;transition:width .3s;background-color:var(--accent-color)}#overlay_content,#overlay_content>*{display:grid;gap:1.5rem;justify-content:center;justify-items:center;text-align:center}#upload_torrent_button{width:100%}sm-select{--max-height: 40vh}file-input{font-size:.9rem;--button-color: rgba(var(--background-color), 1)}file-input .icon{height:1.2rem;width:1.2rem;fill:rgba(var(--background-color), 1)}summary{-webkit-user-select:none;-moz-user-select:none;user-select:none;cursor:pointer;justify-self:center;margin-bottom:1.5rem}.page-footer{display:grid;gap:1.5rem;padding:2rem 1.5rem;text-align:center;justify-items:center;background-color:rgba(var(--text-color), 0.06)}.page-footer .icon{height:1.6rem;width:1.6rem;margin-left:-0.4rem;margin-right:.1rem}.page-footer h5{font-weight:400}.page-footer h4{font-weight:600}@media screen and (min-width: 640px){#main_header{padding:1.5rem 2rem}#torrent_form{width:32rem}}@media(any-hover: hover){::-webkit-scrollbar{width:.5rem;height:.5rem}::-webkit-scrollbar-thumb{background:rgba(var(--text-color), 0.3);border-radius:1rem}::-webkit-scrollbar-thumb:hover{background:rgba(var(--text-color), 0.5)}} \ No newline at end of file diff --git a/css/uploader-style.scss b/css/uploader-style.scss index c36112a..533757e 100644 --- a/css/uploader-style.scss +++ b/css/uploader-style.scss @@ -1,495 +1,514 @@ -*{ - padding: 0; - margin: 0; - box-sizing: border-box; - font-family: 'Inter', sans-serif; +* { + padding: 0; + margin: 0; + box-sizing: border-box; + font-family: "Inter", sans-serif; } -:root{ - font-size: clamp(1rem, 1.2vmax, 3rem); +:root { + font-size: clamp(1rem, 1.2vmax, 3rem); } -html, body{ - height: 100%; - scroll-behavior: smooth; +html, +body { + height: 100%; + scroll-behavior: smooth; } body { - --accent-color: #0eaf8f; - --light-shade: rgba(var(--text-color), 0.06); - --text-color: 17, 17, 17; - --text-color-light: 100, 100, 100; - --foreground-color: 255, 255, 255; - --background-color: #F6f6f6; - --error-color: red; - --green: #00843b; - color: rgba(var(--text-color), 1); - background: var(--background-color); - display: flex; - flex-direction: column; + --accent-color: #0eaf8f; + --light-shade: rgba(var(--text-color), 0.06); + --text-color: 17, 17, 17; + --text-color-light: 100, 100, 100; + --foreground-color: 255, 255, 255; + --background-color: 243, 245, 250; + --error-color: red; + --green: #00843b; + color: rgba(var(--text-color), 1); + background: rgba(var(--background-color), 1); + display: flex; + flex-direction: column; } -body[data-theme='dark']{ - --accent-color: #1abc9c; - --green: #13ff5a; - --text-color: 240, 240, 240; - --text-color-light: 170, 170, 170; - --foreground-color: 20, 20, 20; - --background-color: #0a0a0a; - --error-color: rgb(255, 106, 106); +body[data-theme="dark"] { + --accent-color: #1abc9c; + --green: #13ff5a; + --text-color: 240, 240, 240; + --text-color-light: 170, 170, 170; + --foreground-color: 27, 28, 29; + --background-color: 21, 22, 22; + --error-color: rgb(255, 106, 106); } -.full-bleed{ - grid-column: 1/4; +.full-bleed { + grid-column: 1/4; } -.h1{ - font-size: 2.5rem; +.h1 { + font-size: 2.5rem; } -.h2{ - font-size: 2rem; +.h2 { + font-size: 2rem; } -.h3{ - font-size: 1.4rem; +.h3 { + font-size: 1.4rem; } -.h4{ - font-size: 1rem; +.h4 { + font-size: 1rem; } -.h5{ - font-size: 0.8rem; +.h5 { + font-size: 0.8rem; } -.uppercase{ - text-transform: uppercase; +.uppercase { + text-transform: uppercase; } -.capitalize{ - text-transform: capitalize; +.capitalize { + text-transform: capitalize; } p { - font-size: 0.8; - max-width: 60ch; - line-height: 1.7; - color: rgba(var(--text-color), 0.8); - &:not(:last-of-type){ - margin-bottom: 1rem; - } + font-size: 0.8; + max-width: 60ch; + line-height: 1.7; + color: rgba(var(--text-color), 0.8); + &:not(:last-of-type) { + margin-bottom: 1rem; + } } -img{ - object-fit: cover; +img { + object-fit: cover; } -a{ - color: inherit; - text-decoration: none; - &:focus-visible{ - box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset; - } +a { + color: inherit; + text-decoration: none; + &:focus-visible { + box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset; + } } -button{ - position: relative; - display: inline-flex; - overflow: hidden; - align-items: center; - background: none; +.button, +button { + user-select: none; + position: relative; + display: inline-flex; + border: none; + background-color: transparent; + overflow: hidden; + -webkit-tap-highlight-color: transparent; + align-items: center; + font-size: 0.9rem; + font-weight: 500; + white-space: nowrap; + padding: 0.8rem; + border-radius: 0.5rem; + justify-content: center; + color: inherit; + min-width: max-content; + &:not(:disabled) { cursor: pointer; - outline: none; - color: inherit; - font-size: 0.9rem; - font-weight: 500; - border-radius: 0.2rem; - padding: 0.5rem 0.6rem; - -webkit-tap-highlight-color: transparent; - border: none; + } } -button:focus-visible{ - outline: rgba(var(--text-color), 1) 0.1rem solid; -} -a.button:any-link{ - position: relative; - display: inline-flex; - align-items: center; - background: none; - cursor: pointer; - outline: none; - font-weight: 500; - font-size: 0.8rem; - border-radius: 0.3rem; - padding: 0.5rem 0.6rem; - align-self: flex-start; - text-decoration: none; - color: rgba(var(--text-color), 0.7); - -webkit-tap-highlight-color: transparent; - background-color: rgba(var(--text-color), 0.06); - .icon{ - margin-right: 0.3rem; - height: 1.2rem; +.button { + color: var(--accent-color); + background-color: var(--blue-accent-1); + .icon { + fill: var(--accent-color); + } + &--primary, + &--danger { + color: rgba(var(--background-color), 1) !important; + .icon { + fill: rgba(var(--background-color), 1); } -} -a:any-link:focus-visible{ - outline: rgba(var(--text-color), 1) 0.1rem solid; -} -.button{ - background-color: rgba(var(--text-color), 0.06); -} -sm-button{ - --border-radius: 0.3rem; -} -sm-popup{ - --width: min(24rem, 100%); -} -ul{ - list-style: none; -} -.flex{ - display: flex; -} -.grid{ - display: grid; -} -.hide{ - opacity: 0; - pointer-events: none; -} -.hide-completely{ - display: none !important; -} -.no-transformations{ - transform: none !important; -} -.overflow-ellipsis{ + } + &--primary { width: 100%; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; -} -.breakable{ - overflow-wrap: break-word; - word-wrap: break-word; - -ms-word-break: break-all; - word-break: break-word; - -ms-hyphens: auto; - -moz-hyphens: auto; - -webkit-hyphens: auto; - hyphens: auto; -} -.flex{ - display: flex; -} -.grid{ - display: grid; -} -.flow-column{ - grid-auto-flow: column; -} -.gap-0-5{ - gap: 0.5rem; -} -.gap-1{ - gap: 1rem; -} -.gap-1-5{ - gap: 1.5rem; -} -.gap-2{ - gap: 2rem; -} -.gap-3{ - gap: 3rem; -} -.text-align-right{ - text-align: right; -} -.align-start{ - align-items: flex-start; -} -.align-center{ - align-items: center; -} -.text-center{ - text-align: center; -} -.justify-start{ - justify-content: start; -} -.justify-center{ - justify-content: center; -} -.justify-right{ - margin-left: auto; -} -.align-self-center{ - align-self: center; -} -.justify-self-center{ - justify-self: center; -} -.justify-self-start{ - justify-self: start; -} -.justify-self-end{ - justify-self: end; -} -.direction-column{ - flex-direction: column; -} -.space-between{ - justify-content: space-between; -} -.w-100{ - width: 100%; -} -.ripple{ - position: absolute; - border-radius: 50%; - transform: scale(0); - background: rgba(var(--text-color), 0.16); - pointer-events: none; -} -.interact{ - position: relative; - overflow: hidden; - cursor: pointer; - -webkit-tap-highlight-color: transparent; -} -.observe-empty-state:empty{ - display: none; -} -.observe-empty-state:not(:empty) ~ .empty-state{ - display: none; -} - - -.icon{ - width: 1.5rem; - height: 1.5rem; - fill: rgba(var(--text-color), 0.9); -} -.button__icon{ - height: 1.2rem; - width: 1.2rem; - &--left{ - margin-right: 0.5rem; - } - &--right{ - margin-left: 0.5rem; - } -} - -.page-layout{ - position: relative; - display: grid; - grid-template-columns: 1rem minmax(0, 1fr) 1rem; - & > * { - grid-column: 2/3; - } -} -.popup__header{ - display: grid; - gap: 0.5rem; - width: 100%; - padding: 0 1.5rem 0 0.5rem; - align-items: center; - grid-template-columns: auto 1fr; -} -.popup__header__close{ - padding: 0.5rem; - cursor: pointer; -} - -.button--primary{ - color: white; - font-weight: 500; - padding: 0.5rem 1.2rem; background-color: var(--accent-color); + } + &--danger { + background-color: var(--danger-color); + } + &--small { + padding: 0.4rem 0.6rem; + } +} +.cta { + text-transform: uppercase; + font-size: 0.8rem; + font-weight: 700; + letter-spacing: 0.05em; + padding: 0.8rem 1rem; +} +.icon { + width: 1.2rem; + height: 1.2rem; + fill: rgba(var(--text-color), 0.8); + flex-shrink: 0; +} +.icon-only { + padding: 0.5rem; + border-radius: 0.3rem; +} + +button:disabled { + opacity: 0.5; +} + +sm-popup { + --width: min(24rem, 100%); +} +ul { + list-style: none; +} +.flex { + display: flex; +} +.grid { + display: grid; +} +.hide { + opacity: 0; + pointer-events: none; +} +.hidden { + display: none !important; +} +.no-transformations { + transform: none !important; +} +.overflow-ellipsis { + width: 100%; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} +.breakable { + overflow-wrap: break-word; + word-wrap: break-word; + -ms-word-break: break-all; + word-break: break-word; + -ms-hyphens: auto; + -moz-hyphens: auto; + -webkit-hyphens: auto; + hyphens: auto; +} +.flex { + display: flex; +} +.grid { + display: grid; +} +.flow-column { + grid-auto-flow: column; +} +.gap-0-5 { + gap: 0.5rem; +} +.gap-1 { + gap: 1rem; +} +.gap-1-5 { + gap: 1.5rem; +} +.gap-2 { + gap: 2rem; +} +.gap-3 { + gap: 3rem; +} +.text-align-right { + text-align: right; +} +.align-start { + align-items: flex-start; +} +.align-center { + align-items: center; +} +.text-center { + text-align: center; +} +.justify-start { + justify-content: start; +} +.justify-center { + justify-content: center; +} +.justify-right { + margin-left: auto; +} +.align-self-center { + align-self: center; +} +.justify-self-center { + justify-self: center; +} +.justify-self-start { + justify-self: start; +} +.justify-self-end { + justify-self: end; +} +.direction-column { + flex-direction: column; +} +.space-between { + justify-content: space-between; +} +.w-100 { + width: 100%; +} +.ripple { + position: absolute; + border-radius: 50%; + transform: scale(0); + background: rgba(var(--text-color), 0.16); + pointer-events: none; +} +.interact { + position: relative; + overflow: hidden; + cursor: pointer; + -webkit-tap-highlight-color: transparent; +} +.observe-empty-state:empty { + display: none; +} +.observe-empty-state:not(:empty) ~ .empty-state { + display: none; +} + +.icon { + width: 1.5rem; + height: 1.5rem; + fill: rgba(var(--text-color), 0.9); +} +.button__icon { + height: 1.2rem; + width: 1.2rem; + &--left { + margin-right: 0.5rem; + } + &--right { + margin-left: 0.5rem; + } +} + +.page-layout { + position: relative; + display: grid; + grid-template-columns: 1rem minmax(0, 1fr) 1rem; + & > * { + grid-column: 2/3; + } +} +.popup__header { + display: grid; + gap: 0.5rem; + width: 100%; + padding: 0 1.5rem 0 0.5rem; + align-items: center; + grid-template-columns: auto 1fr; +} +.popup__header__close { + padding: 0.5rem; + cursor: pointer; +} + +.button--primary { + color: white; + font-weight: 500; + padding: 0.5rem 1.2rem; + background-color: var(--accent-color); } #confirmation_popup, #prompt_popup { - flex-direction: column; - h4 { - font-weight: 500; - margin-bottom: 0.5rem; - } - sm-button{ - margin: 0; - } - .flex { - padding: 0; - margin-top: 1rem; - sm-button:first-of-type { - margin-right: 0.6rem; - margin-left: auto; - } + flex-direction: column; + h4 { + font-weight: 500; + margin-bottom: 0.5rem; + } + sm-button { + margin: 0; + } + .flex { + padding: 0; + margin-top: 1rem; + sm-button:first-of-type { + margin-right: 0.6rem; + margin-left: auto; } + } } -#main_header{ - position: relative; - display: grid; - padding: 1rem; - align-items: center; - margin-bottom: 1rem; - grid-template-columns: 1fr auto auto; - a.button{ - font-size: 0.9rem; - font-weight: 500; - border: solid thin var(--accent-color); - } -} -#main_header__logo{ - height: 1.8rem; - width: 1.8rem; -} - -.theme-switcher{ - position: relative; - justify-self: flex-end; - width: 1.5rem; - height: 1.5rem; - cursor: pointer; - -webkit-tap-highlight-color: transparent; - .icon{ - position: absolute; - transition: transform 0.6s; - } -} -.theme-switcher__checkbox{ - display: none; - &:checked ~ .moon-icon{ - transform: scale(0) rotate(90deg); - } - &:not(:checked) ~ .sun-icon{ - transform: scale(0) rotate(-90deg); - } -} - -.fieldset{ - display: grid; - gap: 1rem; - border: none; - padding: 1rem; - border-radius: 0.5rem; - background-color: rgba(var(--text-color), 0.06); -} - -tags-input{ +#main_header { + position: relative; + display: grid; + padding: 1rem; + align-items: center; + margin-bottom: 1rem; + grid-template-columns: 1fr auto auto; + a.button { font-size: 0.9rem; + font-weight: 500; + border: solid thin var(--accent-color); + } } -.torrent-upload-section{ - display: grid; - place-items: center; - flex: 1; - padding: 0 0 2rem 0; +#main_header__logo { + height: 1.8rem; + width: 1.8rem; } -#torrent_form{ - display: grid; - padding: 0 1rem; - margin-bottom: 3rem; + +.theme-switcher { + position: relative; + justify-self: flex-end; + width: 1.5rem; + height: 1.5rem; + cursor: pointer; + -webkit-tap-highlight-color: transparent; + .icon { + position: absolute; + transition: transform 0.6s; + } +} +.theme-switcher__checkbox { + display: none; + &:checked ~ .moon-icon { + transform: scale(0) rotate(90deg); + } + &:not(:checked) ~ .sun-icon { + transform: scale(0) rotate(-90deg); + } +} + +.fieldset { + display: grid; + gap: 1rem; + border: none; + padding: 1rem; + border-radius: 0.5rem; + background-color: rgba(var(--text-color), 0.06); +} + +tags-input { + font-size: 0.9rem; +} +.torrent-upload-section { + display: grid; + place-items: center; + flex: 1; + padding: 0 0 2rem 0; +} +#torrent_form { + display: grid; + padding: 0 1rem; + margin-bottom: 3rem; } .loader { - height: 1.6rem; - width: 1.6rem; - stroke-width: 8; - overflow: visible; - stroke: var(--accent-color); - fill: none; - stroke-dashoffset: 180; - stroke-dasharray: 180; - animation: load 3.6s linear infinite, spin 1s linear infinite; + height: 1.6rem; + width: 1.6rem; + stroke-width: 8; + overflow: visible; + stroke: var(--accent-color); + fill: none; + stroke-dashoffset: 180; + stroke-dasharray: 180; + animation: load 3.6s linear infinite, spin 1s linear infinite; } @keyframes load { - 50% { - stroke-dashoffset: 0; - } - 100%{ - stroke-dashoffset: -180; - } + 50% { + stroke-dashoffset: 0; + } + 100% { + stroke-dashoffset: -180; + } } @keyframes spin { - 100% { - transform: rotate(360deg); - } + 100% { + transform: rotate(360deg); + } } -.progress-bar{ - position: relative; - display: flex; - width: 100%; - align-items: center; - height: 0.5rem; - border-radius: 2rem; +.progress-bar { + position: relative; + display: flex; + width: 100%; + align-items: center; + height: 0.5rem; + border-radius: 2rem; } -.progress{ - position: absolute; - left: 0; - height: 100%; - border-radius: 2rem; - transition: width 0.3s; - background-color: var(--accent-color); +.progress { + position: absolute; + left: 0; + height: 100%; + border-radius: 2rem; + transition: width 0.3s; + background-color: var(--accent-color); } #overlay_content, -#overlay_content > *{ - display: grid; - gap: 1.5rem; - justify-content: center; - justify-items: center; - text-align: center; +#overlay_content > * { + display: grid; + gap: 1.5rem; + justify-content: center; + justify-items: center; + text-align: center; } -#upload_torrent_button{ - width: 100%; +#upload_torrent_button { + width: 100%; } -sm-select{ - --max-height: 40vh; +sm-select { + --max-height: 40vh; } -file-input{ - font-size: 0.9rem; - --button-color: var(--background-color); - .icon{ - height: 1.2rem; - width: 1.2rem; - fill: var(--background-color); - } +file-input { + font-size: 0.9rem; + --button-color: rgba(var(--background-color), 1); + .icon { + height: 1.2rem; + width: 1.2rem; + fill: rgba(var(--background-color), 1); + } } -summary{ - user-select: none; - cursor: pointer; - justify-self: center; - margin-bottom: 1.5rem; +summary { + user-select: none; + cursor: pointer; + justify-self: center; + margin-bottom: 1.5rem; } -.page-footer{ - display: grid; - gap: 1.5rem; - padding: 2rem 1.5rem; - text-align: center; - justify-items: center; - background-color: rgba(var(--text-color), 0.06); - .icon{ - height: 1.6rem; - width: 1.6rem; - margin-left: -0.4rem; - margin-right: 0.1rem; - } - h5{ - font-weight: 400; - } - h4{ - font-weight: 600; - } +.page-footer { + display: grid; + gap: 1.5rem; + padding: 2rem 1.5rem; + text-align: center; + justify-items: center; + background-color: rgba(var(--text-color), 0.06); + .icon { + height: 1.6rem; + width: 1.6rem; + margin-left: -0.4rem; + margin-right: 0.1rem; + } + h5 { + font-weight: 400; + } + h4 { + font-weight: 600; + } } @media screen and (min-width: 640px) { - #main_header{ - padding: 1.5rem 2rem; - } - #torrent_form{ - width: 32rem; - } + #main_header { + padding: 1.5rem 2rem; + } + #torrent_form { + width: 32rem; + } } -@media (any-hover: hover){ - ::-webkit-scrollbar{ - width: 0.5rem; - height: 0.5rem; +@media (any-hover: hover) { + ::-webkit-scrollbar { + width: 0.5rem; + height: 0.5rem; + } + + ::-webkit-scrollbar-thumb { + background: rgba(var(--text-color), 0.3); + border-radius: 1rem; + &:hover { + background: rgba(var(--text-color), 0.5); } - - ::-webkit-scrollbar-thumb{ - background: rgba(var(--text-color), 0.3); - border-radius: 1rem; - &:hover{ - background: rgba(var(--text-color), 0.5); - } - } -} \ No newline at end of file + } +} diff --git a/index.html b/index.html index 1675b6f..a1ad9c3 100644 --- a/index.html +++ b/index.html @@ -15,21 +15,23 @@ - - + +

-
- Cancel - OK +
+ +
@@ -43,7 +45,7 @@
- +
@@ -51,22 +53,10 @@ - RanchiMall + RanchiMall
- How it works? - + How it works? +
@@ -79,7 +69,7 @@

FLO Torrent

Getting torrents from FLO blockchain

-
+ -
+ -

Linking the chunks

- The transaction ID of the last segment is the entry point to the full data stream and is published as a torrent ID. + The transaction ID of the last segment is the entry point to the full data stream and is + published as a torrent ID.

-
+

Discoverability

- Transactions from a global FLO Address will list all Torrent IDs, and other details like the name of the torrent, description, etc. + Transactions from a global FLO Address will list all Torrent IDs, and other details like the + name of the torrent, description, etc.

- This global FLO Address will be a trusted address and will list only trusted and good quality torrents. + This global FLO Address will be a trusted address and will list only trusted and good quality + torrents.

-
+
@@ -261,43 +264,50 @@ FLO torrent will first read the global FLO Address, find all the torrent details and, list it.

- When you select a torrent to download. Its entry transaction ID is retrieved, and the last segment of the torrent file is downloaded. The previous transaction ID is also retrieved, and data in that ID is downloaded. + When you select a torrent to download. Its entry transaction ID is retrieved, and the last + segment of the torrent file is downloaded. The previous transaction ID is also retrieved, and + data in that ID is downloaded.

- Finally, all segments are downloaded until we reach the first segment which has no further linkages. + Finally, all segments are downloaded until we reach the first segment which has no further + linkages.

-
+

Putting everything back

- Thus, all segments of the torrent can be downloaded from the blockchain. + Thus, all segments of the torrent can be downloaded from the blockchain.

- Now, all the browser has to do is reassemble them in the correct order, and we have our torrent file. + Now, all the browser has to do is reassemble them in the correct order, and we have our torrent + file.

-
+

But why?

- This solution decentralizes the storage of Torrent files which was the last missing piece in the decentralization of the torrent ecosystem. After this the entire chain of the torrent ecosystem is decentralized. + This solution decentralizes the storage of Torrent files which was the last missing piece in the + decentralization of the torrent ecosystem. After this the entire chain of the torrent ecosystem + is decentralized.

-
+

What if we get blocked?

- No worries, this app is completely contained within a single HTML file so even if the site URL is blocked if you saved this webpage as an HTML file it will work seamlessly. + No worries, this app is completely contained within a single HTML file so even if the site URL + is blocked if you saved this webpage as an HTML file it will work seamlessly.

-
+