diff --git a/public/components.js b/public/components.js new file mode 100644 index 0000000..03baa75 --- /dev/null +++ b/public/components.js @@ -0,0 +1,2611 @@ +/*jshint esversion: 6 */ +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)); + } + static get observedAttributes() { + return ['disabled']; + } + + get disabled() { + return this.hasAttribute('disabled'); + } + + set disabled(value) { + if (value) { + this.setAttribute('disabled', ''); + } else { + this.removeAttribute('disabled'); + } + } + + handleKeyDown(e) { + if (!this.hasAttribute('disabled') && (e.key === 'Enter' || e.code === 'Space')) { + e.preventDefault(); + this.click(); + } + } + + connectedCallback() { + if (!this.hasAttribute('disabled')) { + this.setAttribute('tabindex', '0'); + } + this.setAttribute('role', 'button'); + this.addEventListener('keydown', this.handleKeyDown); + } + attributeChangedCallback(name) { + if (name === 'disabled') { + this.removeAttribute('tabindex'); + this.setAttribute('aria-disabled', 'true'); + } + else { + this.setAttribute('tabindex', '0'); + this.setAttribute('aria-disabled', 'false'); + } + } + }) +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; + + 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) + } + debounce(callback, wait) { + let timeoutId = null; + return (...args) => { + window.clearTimeout(timeoutId); + timeoutId = window.setTimeout(() => { + callback.apply(null, args); + }, wait); + }; + } + _checkValidity() { + this.allRequiredValid = this.requiredElements.every(elem => elem.isValid) + if (!this.submitButton) return; + if (this.allRequiredValid) { + this.submitButton.disabled = false; + } + else { + this.submitButton.disabled = true; + } + } + handleKeydown(e) { + if (e.key === 'Enter' && e.target.tagName !== 'SM-TEXTAREA') { + if (this.allRequiredValid) { + if (this.submitButton && this.submitButton.tagName === 'SM-BUTTON') { + this.submitButton.click() + } + this.dispatchEvent(new CustomEvent('submit', { + bubbles: true, + composed: true, + })) + } + else { + this.requiredElements.find(elem => !elem.isValid).vibrate() + } + } + } + reset() { + this.formElements.forEach(elem => elem.reset()) + } + elementsChanged() { + this.formElements = [...this.querySelectorAll('sm-input, sm-textarea, sm-checkbox, tags-input, file-input, sm-switch, sm-radio')] + this.requiredElements = this.formElements.filter(elem => elem.hasAttribute('required')); + this.submitButton = this.querySelector('[variant="primary"], [type="submit"]'); + this.resetButton = this.querySelector('[type="reset"]'); + if (this.resetButton) { + this.resetButton.addEventListener('click', this.reset); + } + this._checkValidity() + } + connectedCallback() { + const slot = this.shadowRoot.querySelector('slot') + slot.addEventListener('slotchange', this.elementsChanged) + this.addEventListener('input', this.debounce(this._checkValidity, 100)); + this.addEventListener('keydown', this.debounce(this.handleKeydown, 100)); + } + disconnectedCallback() { + this.removeEventListener('input', this.debounce(this._checkValidity, 100)); + this.removeEventListener('keydown', this.debounce(this.handleKeydown, 100)); + } +}) + +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.outerContainer = this.shadowRoot.querySelector('.outer-container'); + this._helperText = ''; + this._errorText = ''; + this.isRequired = false; + this.hideRequired = false; + this.validationFunction = undefined; + this.reflectedAttributes = ['value', 'required', 'disabled', 'type', 'inputmode', 'readonly', 'min', 'max', 'pattern', 'minlength', 'maxlength', 'step']; + + this.reset = this.reset.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.vibrate = this.vibrate.bind(this); + } + + static get observedAttributes() { + return ['value', 'placeholder', 'required', 'disabled', 'type', 'inputmode', 'readonly', 'min', 'max', 'pattern', 'minlength', 'maxlength', 'step', 'helper-text', 'error-text', 'hiderequired']; + } + + 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 validity() { + return this.input.validity; + } + + get disabled() { + return this.hasAttribute('disabled'); + } + set disabled(value) { + if (value) + this.inputParent.classList.add('disabled'); + else + this.inputParent.classList.remove('disabled'); + } + get readOnly() { + return this.hasAttribute('readonly'); + } + set readOnly(value) { + if (value) { + this.setAttribute('readonly', ''); + } else { + this.removeAttribute('readonly'); + } + } + set customValidation(val) { + this.validationFunction = val; + } + set errorText(val) { + this._errorText = val; + } + set helperText(val) { + this._helperText = val; + } + get isValid() { + if (this.input.value !== '') { + const _isValid = this.input.checkValidity(); + let _customValid = true; + if (this.validationFunction) { + _customValid = Boolean(this.validationFunction(this.input.value)); + } + if (_isValid && _customValid) { + this.feedbackText.classList.remove('error'); + this.feedbackText.classList.add('success'); + this.feedbackText.textContent = ''; + } else { + if (this._errorText) { + this.feedbackText.classList.add('error'); + this.feedbackText.classList.remove('success'); + this.feedbackText.innerHTML = ` + + ${this._errorText} + `; + } + } + return (_isValid && _customValid); + } + } + reset() { + this.value = ''; + } + + 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.trim() !== '') { + this.clearBtn.classList.remove('hide'); + } else { + this.clearBtn.classList.add('hide'); + if (this.isRequired && !this.hideRequired) { + this.feedbackText.textContent = '*required'; + } + } + } + if (!this.hasAttribute('placeholder') || this.getAttribute('placeholder').trim() === '') 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'); + } + } + vibrate() { + this.outerContainer.animate([ + { transform: 'translateX(-1rem)' }, + { transform: 'translateX(1rem)' }, + { transform: 'translateX(-0.5rem)' }, + { transform: 'translateX(0.5rem)' }, + { transform: 'translateX(0)' }, + ], { + duration: 300, + easing: 'ease' + }); + } + + + connectedCallback() { + this.animate = this.hasAttribute('animate'); + this.setAttribute('role', 'textbox'); + this.input.addEventListener('input', this.checkInput); + this.clearBtn.addEventListener('click', this.reset); + } + + attributeChangedCallback(name, oldValue, newValue) { + if (oldValue !== newValue) { + if (this.reflectedAttributes.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 (this.hasAttribute('value')) { + this.checkInput(); + } + else if (name === 'type') { + if (this.hasAttribute('type') && this.getAttribute('type') === 'number') { + this.input.setAttribute('inputmode', 'numeric'); + } + } + else if (name === 'helper-text') { + this._helperText = this.getAttribute('helper-text'); + } + else if (name === 'error-text') { + this._errorText = this.getAttribute('error-text'); + } + else if (name === 'required') { + this.isRequired = this.hasAttribute('required'); + if (this.isRequired && !this.hideRequired) { + this.feedbackText.textContent = ''; + } else { + this.feedbackText.textContent = '*required'; + } + if (this.isRequired) { + this.setAttribute('aria-required', 'true'); + } + else { + this.setAttribute('aria-required', 'false'); + } + } + else if (name === 'hiderequired') { + this.hideRequired = this.hasAttribute('hiderequired') + } + 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'); + } + } + } + } + disconnectedCallback() { + this.input.removeEventListener('input', this.checkInput); + this.clearBtn.removeEventListener('click', this.reset); + } + }) +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)) + + 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) + + } + + randString(length) { + let result = ''; + const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + for (let i = 0; i < length; i++) + result += characters.charAt(Math.floor(Math.random() * characters.length)); + return result; + } + + createNotification(message, options) { + const { pinned = false, icon = '' } = options + const notification = document.createElement('div') + notification.id = this.randString(8) + notification.classList.add('notification'); + let composition = ``; + composition += ` +
${icon}
+

${message}

+ `; + if (pinned) { + notification.classList.add('pinned'); + composition += ` + + `; + } + notification.innerHTML = composition; + return notification; + } + + push(message, options = {}) { + const notification = this.createNotification(message, options); + this.notificationPanel.append(notification); + notification.animate([ + { + transform: `translateY(1rem)`, + opacity: '0' + }, + { + transform: `none`, + opacity: '1' + }, + ], this.animationOptions); + return notification.id; + } + + removeNotification(notification) { + notification.animate([ + { + transform: `none`, + opacity: '1' + }, + { + transform: `translateY(0.5rem)`, + opacity: '0' + } + ], this.animationOptions).onfinish = () => { + notification.remove(); + }; + } + + clearAll() { + Array.from(this.notificationPanel.children).forEach(child => { + this.removeNotification(child); + }); + } + + connectedCallback() { + 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 && !mutation.addedNodes[0].classList.contains('pinned')) { + setTimeout(() => { + this.removeNotification(mutation.addedNodes[0]); + }, 5000); + } + } + }); + }); + observer.observe(this.notificationPanel, { + childList: true, + }); + } +}); +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; + this.pinned = false; + this.popupStack = undefined; + this.offset = 0; + this.touchStartY = 0; + this.touchEndY = 0; + this.touchStartTime = 0; + this.touchEndTime = 0; + this.touchEndAnimataion = undefined; + + this.popupContainer = this.shadowRoot.querySelector('.popup-container'); + this.popup = 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.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.movePopup = this.movePopup.bind(this); + } + + static get observedAttributes() { + return ['open']; + } + + 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(options = {}) { + const { pinned = false, popupStack } = options; + 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.forms.length) { + setTimeout(() => { + this.forms.forEach(form => form.reset()); + }, 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()); + } + } + + 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.popupBodySlot.addEventListener('slotchange', () => { + this.forms = this.querySelectorAll('sm-form'); + }); + this.popupContainer.addEventListener('mousedown', e => { + if (e.target === this.popupContainer && !this.pinned) { + if (this.pinned) { + this.show(); + } else + this.hide(); + } + }); + + const resizeObserver = new ResizeObserver(entries => { + for (let entry of entries) { + 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.threshold = contentBoxSize.blockSize.height * 0.3; + } else { + this.threshold = entry.contentRect.height * 0.3; + } + } + }); + resizeObserver.observe(this); + + + this.popupHeader.addEventListener('touchstart', this.handleTouchStart, { passive: true }); + this.popupHeader.addEventListener('touchmove', this.handleTouchMove, { passive: true }); + this.popupHeader.addEventListener('touchend', this.handleTouchEnd, { 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 }); + resizeObserver.unobserve(); + } + attributeChangedCallback(name) { + if (name === 'open') { + if (this.hasAttribute('open')) { + this.show(); + } + } + } +}); +const spinner = document.createElement('template'); +spinner.innerHTML = ` + + + +`; +class SquareLoader extends HTMLElement { + constructor() { + super(); + this.attachShadow({ + mode: 'open' + }).append(spinner.content.cloneNode(true)); + } +} +window.customElements.define('sm-spinner', SquareLoader); + +const themeToggle = document.createElement('template'); +themeToggle.innerHTML = ` + + +`; + +class ThemeToggle extends HTMLElement { + constructor() { + super(); + + this.attachShadow({ + mode: 'open' + }).append(themeToggle.content.cloneNode(true)); + + this.isChecked = false; + 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) { + if (e.code === 'Space') { + this.toggleState(); + } + } + handleThemeChange(e) { + if (e.detail.theme !== this.hasTheme) { + if (e.detail.theme === 'dark') { + this.setAttribute('checked', ''); + } + else { + this.removeAttribute('checked'); + } + } + } + + fireEvent() { + this.dispatchEvent( + new CustomEvent('themechange', { + bubbles: true, + composed: true, + detail: { + theme: this.hasTheme + } + }) + ); + } + + connectedCallback() { + this.setAttribute('role', 'switch'); + this.setAttribute('aria-label', 'theme toggle'); + if (localStorage.getItem(`${window.location.hostname}-theme`) === "dark") { + this.nightlight(); + this.setAttribute('checked', ''); + } else if (localStorage.getItem(`${window.location.hostname}-theme`) === "light") { + this.daylight(); + this.removeAttribute('checked'); + } + else { + if (window.matchMedia(`(prefers-color-scheme: dark)`).matches) { + this.nightlight(); + this.setAttribute('checked', ''); + } else { + 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(name, oldVal, newVal) { + if (name === 'checked') { + if (this.hasAttribute('checked')) { + this.nightlight(); + localStorage.setItem(`${window.location.hostname}-theme`, "dark"); + } else { + this.daylight(); + localStorage.setItem(`${window.location.hostname}-theme`, "light"); + } + } + } +} + +window.customElements.define('theme-toggle', ThemeToggle); + +const smCopy = document.createElement('template'); +smCopy.innerHTML = ` + +
+

+ +
+`; +customElements.define('sm-copy', + class extends HTMLElement { + constructor() { + super(); + this.attachShadow({ + mode: 'open' + }).append(smCopy.content.cloneNode(true)); + + this.copyContent = this.shadowRoot.querySelector('.copy-content'); + this.copyButton = this.shadowRoot.querySelector('.copy-button'); + + this.copy = this.copy.bind(this); + } + static get observedAttributes() { + return ['value']; + } + set value(val) { + this.setAttribute('value', val); + } + get value() { + return this.getAttribute('value'); + } + fireEvent() { + this.dispatchEvent( + new CustomEvent('copy', { + composed: true, + bubbles: true, + cancelable: true, + }) + ); + } + copy() { + navigator.clipboard.writeText(this.copyContent.textContent) + .then(res => this.fireEvent()) + .catch(err => console.error(err)); + } + connectedCallback() { + this.copyButton.addEventListener('click', this.copy); + } + attributeChangedCallback(name, oldValue, newValue) { + if (name === 'value') { + this.copyContent.textContent = newValue; + } + } + disconnectedCallback() { + this.copyButton.removeEventListener('click', this.copy); + } + }); +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 = undefined; + this._value = undefined; + this.scrollDistance = 0; + + this.scrollLeft = this.scrollLeft.bind(this); + this.scrollRight = this.scrollRight.bind(this); + this.fireEvent = this.fireEvent.bind(this); + } + 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() { + this.setAttribute('role', 'listbox'); + + 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 (!this.hasAttribute('multiline')) { + 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); + } + disconnectedCallback() { + navButtonLeft.removeEventListener('click', this.scrollLeft); + navButtonRight.removeEventListener('click', this.scrollRight); + } +}); + +//Strip option +const stripOption = document.createElement('template'); +stripOption.innerHTML = ` + + +`; +customElements.define('strip-option', class extends HTMLElement { + constructor() { + super(); + this.attachShadow({ + mode: 'open' + }).append(stripOption.content.cloneNode(true)); + this._value = undefined; + 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: true, + composed: true, + detail: { + value: this._value + } + }) + ); + } + handleKeyDown(e) { + if (e.key === 'Enter' || e.key === 'Space') { + 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 slideButton = document.createElement('template') +slideButton.innerHTML = ` + +
+
+ + + +
+

Slide to confirm

+
+`; +class SlideButton extends HTMLElement { + constructor() { + super(); + this.attachShadow({ + mode: 'open' + }).append(slideButton.content.cloneNode(true)); + + this.handleTouchStart = this.handleTouchStart.bind(this); + this.handleTouchMove = this.handleTouchMove.bind(this); + this.handleTouchEnd = this.handleTouchEnd.bind(this); + this.reset = this.reset.bind(this); + this.fireEvent = this.fireEvent.bind(this); + this.thumb = this.shadowRoot.querySelector('.slide-thumb'); + + this.startX = 0; + this.threshold = 0; + this.bound = 0; + } + get disabled() { + return this.hasAttribute('disabled'); + } + + set disabled(value) { + if (value) { + this.setAttribute('disabled', ''); + } else { + this.removeAttribute('disabled'); + } + } + + reset() { + this.thumb.setAttribute('style', `transform: translateX(0)`); + } + + fireEvent() { + this.dispatchEvent(new CustomEvent('confirmed', { + bubbles: true, + composed: true, + })); + } + + handleTouchStart(e) { + this.thumb.classList.remove('transition') + const thumbDimensions = this.thumb.getBoundingClientRect(); + const buttonDimensions = this.getBoundingClientRect(); + this.bound = buttonDimensions.width - thumbDimensions.width; + this.startX = e.clientX; + this.threshold = this.bound / 2; + this.thumb.setPointerCapture(e.pointerId); + this.thumb.addEventListener('pointermove', this.handleTouchMove); + this.thumb.addEventListener('pointerup', this.handleTouchEnd); + } + handleTouchMove(e) { + requestAnimationFrame(() => { + this.thumb.setAttribute('style', `transform: translateX(${Math.max(0, Math.min((this.bound), e.clientX - this.startX))}px)`); + }) + } + handleTouchEnd(e) { + this.thumb.classList.add('transition'); + if (e.clientX > this.threshold) { + this.fireEvent(); + this.thumb.setAttribute('style', `transform: translateX(${this.bound}px)`); + } else { + this.reset(); + } + this.thumb.releasePointerCapture(e.pointerId); + this.thumb.removeEventListener('pointermove', this.handleTouchMove); + this.thumb.removeEventListener('pointerup', this.handleTouchEnd); + } + + connectedCallback() { + this.thumb.addEventListener('pointerdown', this.handleTouchStart); + } + + disconnectedCallback() { + this.thumb.removeEventListener('pointerdown', this.handleTouchStart); + } +} + +window.customElements.define('slide-button', SlideButton); + +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)) + + 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.availableOptions + this.previousOption + this.isOpen = 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' + } + + this.optionList = this.shadowRoot.querySelector('.options') + this.chevron = this.shadowRoot.querySelector('.toggle') + this.selection = this.shadowRoot.querySelector('.selection') + this.selectedOptionText = this.shadowRoot.querySelector('.selected-option-text') + } + static get observedAttributes() { + return ['value', 'disabled'] + } + get value() { + return this.getAttribute('value') + } + set value(val) { + this.setAttribute('value', val) + } + + reset(fire = true) { + if (this.availableOptions[0] && this.previousOption !== this.availableOptions[0]) { + const firstElement = this.availableOptions[0]; + if (this.previousOption) { + this.previousOption.classList.remove('check-selected') + } + firstElement.classList.add('check-selected') + this.value = firstElement.getAttribute('value') + this.selectedOptionText.textContent = firstElement.textContent + this.previousOption = firstElement; + if (fire) { + this.fireEvent() + } + } + } + + open() { + this.optionList.classList.remove('hide') + this.optionList.animate(this.slideDown, this.animationOptions) + this.chevron.classList.add('rotate') + this.isOpen = true + } + collapse() { + this.chevron.classList.remove('rotate') + this.optionList.animate(this.slideUp, this.animationOptions) + .onfinish = () => { + this.optionList.classList.add('hide') + this.isOpen = false + } + } + toggle() { + if (!this.isOpen && !this.hasAttribute('disabled')) { + this.open() + } else { + this.collapse() + } + } + + fireEvent() { + this.dispatchEvent(new CustomEvent('change', { + bubbles: true, + composed: true, + detail: { + value: this.value + } + })) + } + + handleOptionsNavigation(e) { + if (e.code === 'ArrowUp') { + e.preventDefault() + if (document.activeElement.previousElementSibling) { + document.activeElement.previousElementSibling.focus() + } else { + this.availableOptions[this.availableOptions.length - 1].focus() + } + } + else if (e.code === 'ArrowDown') { + e.preventDefault() + if (document.activeElement.nextElementSibling) { + document.activeElement.nextElementSibling.focus() + } else { + this.availableOptions[0].focus() + } + } + } + handleOptionSelection(e) { + if (this.previousOption !== document.activeElement) { + this.value = document.activeElement.getAttribute('value') + this.selectedOptionText.textContent = document.activeElement.textContent; + this.fireEvent() + if (this.previousOption) { + this.previousOption.classList.remove('check-selected') + } + document.activeElement.classList.add('check-selected') + this.previousOption = document.activeElement + } + } + handleClick(e) { + if (e.target === this) { + this.toggle() + } + else { + this.handleOptionSelection() + this.collapse() + } + } + handleKeydown(e) { + if (e.target === this) { + if (this.isOpen && e.code === 'ArrowDown') { + e.preventDefault() + this.availableOptions[0].focus() + this.handleOptionSelection(e) + } + else if (e.code === 'Enter' || e.code === 'Space') { + e.preventDefault() + this.toggle() + } + } + else { + this.handleOptionsNavigation(e) + this.handleOptionSelection(e) + if (e.code === 'Enter' || e.code === 'Space') { + e.preventDefault() + this.collapse() + } + } + } + handleClickOutside(e) { + if (this.isOpen && !this.contains(e.target)) { + this.collapse() + } + } + connectedCallback() { + this.setAttribute('role', 'listbox') + if (!this.hasAttribute('disabled')) { + this.selection.setAttribute('tabindex', '0') + } + let slot = this.shadowRoot.querySelector('slot') + slot.addEventListener('slotchange', e => { + this.availableOptions = slot.assignedElements() + this.reset(false) + }); + this.addEventListener('click', this.handleClick) + this.addEventListener('keydown', this.handleKeydown) + document.addEventListener('mousedown', this.handleClickOutside) + } + disconnectedCallback() { + this.removeEventListener('click', this.toggle) + this.removeEventListener('keydown', this.handleKeydown) + document.removeEventListener('mousedown', this.handleClickOutside) + } + attributeChangedCallback(name) { + if (name === "disabled") { + if (this.hasAttribute('disabled')) { + this.selection.removeAttribute('tabindex') + } else { + this.selection.setAttribute('tabindex', '0') + } + } + } +}) + +// 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)) + } + + connectedCallback() { + this.setAttribute('role', 'option') + this.setAttribute('tabindex', '0') + } +}) diff --git a/public/css/main.css b/public/css/main.css new file mode 100644 index 0000000..ae87c2c --- /dev/null +++ b/public/css/main.css @@ -0,0 +1,831 @@ +* { + padding: 0; + margin: 0; + -webkit-box-sizing: border-box; + box-sizing: border-box; + font-family: "Roboto", sans-serif; +} + +:root { + font-size: clamp(1rem, 1.2vmax, 1.2rem); +} + +html, +body { + height: 100%; + scroll-behavior: smooth; +} + +body { + color: rgba(var(--text-color), 1); + background: rgba(var(--background-color), 1); +} +body, +body * { + --accent-color: #504dff; + --accent-color--light: #f4f4ff; + --text-color: 36, 36, 36; + --background-color: 255, 255, 255; + --foreground-color: rgb(250, 252, 255); + --danger-color: rgb(255, 75, 75); + --green: #1cad59; + --yellow: #f3a600; + --loan-color: rgb(255, 171, 93); + scrollbar-width: thin; +} + +body[data-theme=dark], +body[data-theme=dark] * { + --accent-color: #a3a1ff; + --accent-color--light: rgba(142, 140, 255, 0.06); + --text-color: 230, 230, 230; + --text-color-light: 170, 170, 170; + --background-color: 10, 10, 10; + --foreground-color: rgb(20, 20, 20); + --danger-color: rgb(255, 106, 106); + --green: #00e676; + --yellow: #ffd13a; + --loan-color: rgb(255, 232, 170); +} + +p, +strong { + font-size: 0.9rem; + max-width: 70ch; + line-height: 1.7; + color: rgba(var(--text-color), 0.8); +} +p:not(:last-of-type), +strong:not(:last-of-type) { + margin-bottom: 1.5rem; +} + +a:where([class]) { + color: inherit; + text-decoration: none; +} +a:where([class]):focus-visible { + -webkit-box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset; + box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset; +} + +a { + color: var(--accent-color); +} + +button, +.button { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + position: relative; + display: -webkit-inline-box; + display: -ms-inline-flexbox; + display: inline-flex; + border: none; + background-color: transparent; + overflow: hidden; + color: inherit; + cursor: pointer; + -webkit-transition: -webkit-transform 0.3s; + transition: -webkit-transform 0.3s; + transition: transform 0.3s; + transition: transform 0.3s, -webkit-transform 0.3s; + -webkit-tap-highlight-color: transparent; +} + +.button { + white-space: nowrap; + padding: 0.6rem 1rem; + border-radius: 0.3rem; + font-weight: 500; + font-size: 0.8rem; + background-color: var(--accent-color--light); + color: var(--accent-color); + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; +} +.button--primary { + background-color: var(--accent-color); + color: rgba(var(--background-color), 1); +} + +button:disabled { + opacity: 0.5; +} + +a:-webkit-any-link:focus-visible { + outline: rgba(var(--text-color), 1) 0.1rem solid; +} + +a:-moz-any-link:focus-visible { + outline: rgba(var(--text-color), 1) 0.1rem solid; +} + +a:any-link:focus-visible { + outline: rgba(var(--text-color), 1) 0.1rem solid; +} + +sm-input { + --border-radius: 0.5rem; + --background: var(--accent-color--light); +} + +sm-button { + --padding: 0.7rem 1rem; +} +sm-button[variant=primary] .icon { + fill: rgba(var(--background-color), 1); +} +sm-button[disabled] .icon { + fill: rgba(var(--text-color), 0.6); +} + +ul { + list-style: none; +} + +.flex { + display: -webkit-box; + display: -ms-flexbox; + display: flex; +} + +.grid { + display: grid; +} + +.hide { + opacity: 0; + pointer-events: none; +} + +.hide-completely { + display: 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; + -webkit-hyphens: auto; + hyphens: auto; +} + +.full-bleed { + grid-column: 1/4; +} + +.h1 { + font-size: 1.5rem; +} + +.h2 { + font-size: 1.2rem; +} + +.h3 { + font-size: 1rem; +} + +.h4 { + font-size: 0.9rem; +} + +.h5 { + font-size: 0.8rem; +} + +.uppercase { + text-transform: uppercase; +} + +.capitalize { + text-transform: capitalize; +} + +.flex { + display: -webkit-box; + display: -ms-flexbox; + display: flex; +} + +.grid { + display: grid; +} + +.grid-3 { + grid-template-columns: 1fr auto auto; +} + +.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 { + -webkit-box-align: start; + -ms-flex-align: start; + align-items: flex-start; +} + +.align-center { + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.text-center { + text-align: center; +} + +.justify-start { + -webkit-box-pack: start; + -ms-flex-pack: start; + justify-content: start; +} + +.justify-center { + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; +} + +.justify-right { + margin-left: auto; +} + +.align-self-center { + -ms-flex-item-align: center; + align-self: center; +} + +.justify-self-center { + justify-self: center; +} + +.justify-self-start { + justify-self: start; +} + +.justify-self-end { + justify-self: end; +} + +.direction-column { + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; +} + +.space-between { + -webkit-box-pack: justify; + -ms-flex-pack: justify; + justify-content: space-between; +} + +.stretch { + -webkit-box-pack: stretch; + -ms-flex-pack: stretch; + justify-content: stretch; + justify-items: stretch; +} +.stretch > * { + width: 100%; +} + +.interact { + position: relative; + cursor: pointer; + -webkit-transition: -webkit-transform 0.3s; + transition: -webkit-transform 0.3s; + transition: transform 0.3s; + transition: transform 0.3s, -webkit-transform 0.3s; + -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.8); +} + +.button__icon { + height: 1.2rem; + width: 1.2rem; +} +.button__icon--left { + margin-right: 0.5rem; +} +.button__icon--right { + margin-left: 0.5rem; +} + +.icon-button { + padding: 0.6rem; + border-radius: 0.8rem; + background-color: var(--accent-color--light); + height: -webkit-max-content; + height: -moz-max-content; + height: max-content; +} +.icon-button .icon { + fill: var(--accent-color); +} + +#confirmation_popup, +#prompt_popup { + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; +} +#confirmation_popup h4, +#prompt_popup h4 { + font-weight: 500; + margin-bottom: 0.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: 0.6rem; + margin-left: auto; +} + +button:active, +.button:active, +.interact:active { + -webkit-transform: scale(0.96); + transform: scale(0.96); +} + +.popup__header { + display: grid; + gap: 0.5rem; + width: 100%; + padding: 0 1.5rem 0 0.5rem; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + grid-template-columns: auto 1fr auto; +} + +.popup__header__close { + padding: 0.5rem; + cursor: pointer; +} + +#main_page { + padding: 1.5rem; +} +#main_page > section:nth-of-type(1) { + -ms-flex-line-pack: start; + align-content: flex-start; +} + +.logo { + display: grid; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + width: 100%; + grid-template-columns: auto 1fr; + gap: 0 0.3rem; + margin-right: 1rem; +} +.logo h4 { + text-transform: capitalize; + font-size: 0.9rem; + font-weight: 600; +} +.logo .main-logo { + height: 1.4rem; + width: 1.4rem; + fill: rgba(var(--text-color), 1); + stroke: none; +} + +details summary { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-pack: justify; + -ms-flex-pack: justify; + justify-content: space-between; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + cursor: pointer; +} +details[open] > summary { + margin-bottom: 1rem; +} +details[open] > summary .icon { + -webkit-transform: rotate(180deg); + transform: rotate(180deg); +} + +strip-select { + --gap: 0; + background-color: var(--accent-color--light); + border-radius: 0.3rem; +} + +strip-option { + text-transform: uppercase; + font-weight: 500; + letter-spacing: 0.05em; + font-size: 0.8rem; + --border-radius: 0; + --active-option-color: rgba(var(--background-color), 1); + --active-option-background-color: var(--accent-color); +} +strip-option:first-of-type { + --border-radius: 0.3rem 0 0 0.3rem; +} +strip-option:last-of-type { + --border-radius: 0 0.3rem 0.3rem 0; +} + +.warning { + background-color: khaki; + color: rgba(0, 0, 0, 0.7); + padding: 1rem; + border-radius: 0.5rem; + line-height: 1.5; +} + +.page-layout { + display: grid; + grid-template-columns: 1.5rem minmax(0, 1fr) 1.5rem; +} +.page-layout > * { + grid-column: 2/3; +} + +.page { + height: 100%; +} + +.table__row { + display: grid; + grid-template-columns: repeat(var(--table-columns), auto); +} +.table__header { + color: rgba(var(--text-color), 0.8); + font-size: 0.8rem; +} + +#landing { + grid-template-rows: auto 1fr; +} +#landing header { + padding: 1.5rem 0; +} +#landing > .grid { + -ms-flex-line-pack: start; + align-content: flex-start; + text-align: center; + gap: 1rem; +} + +#sign_in, +#sign_up { + grid-template-rows: auto 1fr; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} +#sign_in section, +#sign_up section { + margin-top: -6rem; + justify-self: center; + width: min(24rem, 100%); +} +#sign_in sm-form, +#sign_up sm-form { + margin: 2rem 0; +} +#sign_in header, +#sign_up header { + padding: 1.5rem 0; +} + +#sign_up sm-copy { + font-size: 0.9rem; + --button-border-radius: 0.5rem; +} +#sign_up .h2 { + margin-bottom: 0.5rem; +} +#sign_up .card { + margin: 1.5rem 0; +} +#sign_up h5 { + font-weight: 500; + color: rgba(var(--text-color), 0.8); +} +#sign_up .warning { + margin-top: 2rem; +} + +#loading { + place-content: center; + text-align: center; +} +#loading sm-spinner { + margin-bottom: 1.5rem; +} + +#home { + height: 100%; + display: grid; + grid-template-columns: minmax(0, 1fr); +} + +#main_header { + padding: 1.8rem 1.5rem; + display: grid; + gap: 1rem; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + grid-template-columns: 1fr auto; +} + +#trade_form { + --width: min(24rem, 100%); + -ms-flex-item-align: start; + align-self: flex-start; + padding: 1rem 1.5rem; +} + +#quantity_selector .button { + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1; + padding: 0.5rem 0.6rem; + margin-left: 0.5rem; +} + +#quantity_type { + font-size: 0.8rem; + padding-right: 0.5rem; + border-right: thin solid rgba(var(--text-color), 0.3); + margin-right: auto; + color: rgba(var(--text-color), 0.8); + line-height: 1.5; + font-weight: 500; + min-width: 8ch; +} + +#orders_section { + padding: 1.5rem; +} + +#user_section { + gap: 1.5rem; + padding: 1.5rem; + -ms-flex-line-pack: start; + align-content: flex-start; +} + +.wallet_actions__wrapper { + grid-column: span 3; + gap: 0.5rem; + margin-top: 0.5rem; +} +.wallet_actions__wrapper .button { + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1; +} + +.balance-card { + display: grid; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + gap: 0.3rem 1rem; + padding: 0.5rem 0; + border-radius: 0.5rem; +} +.balance-card.is-locked { + grid-template-columns: auto 1fr; + gap: 1rem; +} +.balance-card.is-locked .label { + font-size: 0.8rem; + color: rgba(var(--text-color), 0.8); +} +.balance-card:not(.is-locked) { + grid-template-columns: auto 1fr auto; +} +.balance-card__icon { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -ms-flex-line-pack: center; + align-content: center; + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; + padding: 0.6rem; + border-radius: 0.8rem; + background-color: var(--accent-color--light); +} +.balance-card__icon .icon { + height: 1.3rem; + width: 1.3rem; + fill: var(--accent-color); +} +.balance-card__token { + font-size: 0.9rem; + font-weight: 500; +} +.balance-card__amount-wrapper { + grid-column: span 2; + gap: 0.3rem 1rem; + grid-template-columns: 1fr 1fr; +} +.balance-card__amount-wrapper > :nth-child(even) { + text-align: right; +} + +.loader-button-wrapper { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + position: relative; + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} +.loader-button-wrapper sm-button, +.loader-button-wrapper slide-button { + width: 100%; + z-index: 1; + -webkit-transition: -webkit-clip-path 0.3s; + transition: -webkit-clip-path 0.3s; + transition: clip-path 0.3s; + transition: clip-path 0.3s, -webkit-clip-path 0.3s; + -webkit-clip-path: circle(100%); + clip-path: circle(100%); +} +.loader-button-wrapper sm-button.clip, +.loader-button-wrapper slide-button.clip { + pointer-events: none; + -webkit-clip-path: circle(0); + clip-path: circle(0); +} +.loader-button-wrapper sm-spinner { + position: absolute; +} + +@media screen and (max-width: 40rem) { + sm-button { + --padding: 0.9rem 1.6rem; + } +} +@media screen and (min-width: 40rem) { + sm-popup { + --width: 24rem; + } + + .h1 { + font-size: 2rem; + } + + .h2 { + font-size: 1.8rem; + } + + .h3 { + font-size: 1.3rem; + } + + .h4 { + font-size: 1rem; + } + + .popup__header { + padding: 1rem 1.5rem 0 0.5rem; + } + + #confirmation_popup { + --width: 24rem; + } + + .page-layout { + grid-template-columns: 1fr 90vw 1fr; + } +} +@media screen and (min-width: 64rem) { + .page-layout { + grid-template-columns: 1fr 80vw 1fr; + } + + #home { + -webkit-box-align: start; + -ms-flex-align: start; + align-items: flex-start; + padding: 1.5vmax 3vmax; + grid-template-columns: 24rem minmax(0, 1fr) 20rem; + gap: 1rem; + } + #home > * { + border-radius: 0.5rem; + background-color: var(--foreground-color); + border: solid thin rgba(var(--text-color), 0.1); + } + + .hide-on-desktop { + display: none; + } +} +@media screen and (min-width: 120rem) { + .page-layout { + grid-template-columns: 1fr 70vw 1fr; + } +} +@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; + } + ::-webkit-scrollbar-thumb:hover { + background: rgba(var(--text-color), 0.5); + } + + .nav-item, +.interact { + -webkit-transition: background-color 0.3s, -webkit-transform 0.3s; + transition: background-color 0.3s, -webkit-transform 0.3s; + transition: background-color 0.3s, transform 0.3s; + transition: background-color 0.3s, transform 0.3s, -webkit-transform 0.3s; + } + .nav-item:hover, +.interact:hover { + background-color: var(--accent-color--light); + } +} \ No newline at end of file diff --git a/public/css/main.min.css b/public/css/main.min.css new file mode 100644 index 0000000..c14dcc3 --- /dev/null +++ b/public/css/main.min.css @@ -0,0 +1 @@ +*{padding:0;margin:0;-webkit-box-sizing:border-box;box-sizing:border-box;font-family:"Roboto",sans-serif}:root{font-size:clamp(1rem, 1.2vmax, 1.2rem)}html,body{height:100%;scroll-behavior:smooth}body{color:rgba(var(--text-color), 1);background:rgba(var(--background-color), 1)}body,body *{--accent-color: #504dff;--accent-color--light: #f4f4ff;--text-color: 36, 36, 36;--background-color: 255, 255, 255;--foreground-color: rgb(250, 252, 255);--danger-color: rgb(255, 75, 75);--green: #1cad59;--yellow: #f3a600;--loan-color: rgb(255, 171, 93);scrollbar-width:thin}body[data-theme=dark],body[data-theme=dark] *{--accent-color: #a3a1ff;--accent-color--light: rgba(142, 140, 255, 0.06);--text-color: 230, 230, 230;--text-color-light: 170, 170, 170;--background-color: 10, 10, 10;--foreground-color: rgb(20, 20, 20);--danger-color: rgb(255, 106, 106);--green: #00e676;--yellow: #ffd13a;--loan-color: rgb(255, 232, 170)}p,strong{font-size:.9rem;max-width:70ch;line-height:1.7;color:rgba(var(--text-color), 0.8)}p:not(:last-of-type),strong:not(:last-of-type){margin-bottom:1.5rem}a:where([class]){color:inherit;text-decoration:none}a:where([class]):focus-visible{-webkit-box-shadow:0 0 0 .1rem rgba(var(--text-color), 1) inset;box-shadow:0 0 0 .1rem rgba(var(--text-color), 1) inset}a{color:var(--accent-color)}button,.button{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;position:relative;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;border:none;background-color:transparent;overflow:hidden;color:inherit;cursor:pointer;-webkit-transition:-webkit-transform .3s;transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s, -webkit-transform .3s;-webkit-tap-highlight-color:transparent}.button{white-space:nowrap;padding:.6rem 1rem;border-radius:.3rem;font-weight:500;font-size:.8rem;background-color:var(--accent-color--light);color:var(--accent-color);-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.button--primary{background-color:var(--accent-color);color:rgba(var(--background-color), 1)}button:disabled{opacity:.5}a:-webkit-any-link:focus-visible{outline:rgba(var(--text-color), 1) .1rem solid}a:-moz-any-link:focus-visible{outline:rgba(var(--text-color), 1) .1rem solid}a:any-link:focus-visible{outline:rgba(var(--text-color), 1) .1rem solid}sm-input{--border-radius: 0.5rem;--background: var(--accent-color--light)}sm-button{--padding: 0.7rem 1rem}sm-button[variant=primary] .icon{fill:rgba(var(--background-color), 1)}sm-button[disabled] .icon{fill:rgba(var(--text-color), 0.6)}ul{list-style:none}.flex{display:-webkit-box;display:-ms-flexbox;display:flex}.grid{display:grid}.hide{opacity:0;pointer-events:none}.hide-completely{display: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;-webkit-hyphens:auto;hyphens:auto}.full-bleed{grid-column:1/4}.h1{font-size:1.5rem}.h2{font-size:1.2rem}.h3{font-size:1rem}.h4{font-size:.9rem}.h5{font-size:.8rem}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.flex{display:-webkit-box;display:-ms-flexbox;display:flex}.grid{display:grid}.grid-3{grid-template-columns:1fr auto auto}.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{-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start}.align-center{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.text-center{text-align:center}.justify-start{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:start}.justify-center{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.justify-right{margin-left:auto}.align-self-center{-ms-flex-item-align:center;align-self:center}.justify-self-center{justify-self:center}.justify-self-start{justify-self:start}.justify-self-end{justify-self:end}.direction-column{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.space-between{-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.stretch{-webkit-box-pack:stretch;-ms-flex-pack:stretch;justify-content:stretch;justify-items:stretch}.stretch>*{width:100%}.interact{position:relative;cursor:pointer;-webkit-transition:-webkit-transform .3s;transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s, -webkit-transform .3s;-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.8)}.button__icon{height:1.2rem;width:1.2rem}.button__icon--left{margin-right:.5rem}.button__icon--right{margin-left:.5rem}.icon-button{padding:.6rem;border-radius:.8rem;background-color:var(--accent-color--light);height:-webkit-max-content;height:-moz-max-content;height:max-content}.icon-button .icon{fill:var(--accent-color)}#confirmation_popup,#prompt_popup{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;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}button:active,.button:active,.interact:active{-webkit-transform:scale(0.96);transform:scale(0.96)}.popup__header{display:grid;gap:.5rem;width:100%;padding:0 1.5rem 0 .5rem;-webkit-box-align:center;-ms-flex-align:center;align-items:center;grid-template-columns:auto 1fr auto}.popup__header__close{padding:.5rem;cursor:pointer}#main_page{padding:1.5rem}#main_page>section:nth-of-type(1){-ms-flex-line-pack:start;align-content:flex-start}.logo{display:grid;-webkit-box-align:center;-ms-flex-align:center;align-items:center;width:100%;grid-template-columns:auto 1fr;gap:0 .3rem;margin-right:1rem}.logo h4{text-transform:capitalize;font-size:.9rem;font-weight:600}.logo .main-logo{height:1.4rem;width:1.4rem;fill:rgba(var(--text-color), 1);stroke:none}details summary{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer}details[open]>summary{margin-bottom:1rem}details[open]>summary .icon{-webkit-transform:rotate(180deg);transform:rotate(180deg)}strip-select{--gap: 0;background-color:var(--accent-color--light);border-radius:.3rem}strip-option{text-transform:uppercase;font-weight:500;letter-spacing:.05em;font-size:.8rem;--border-radius: 0;--active-option-color: rgba(var(--background-color), 1);--active-option-background-color: var(--accent-color)}strip-option:first-of-type{--border-radius: 0.3rem 0 0 0.3rem}strip-option:last-of-type{--border-radius: 0 0.3rem 0.3rem 0}.warning{background-color:khaki;color:rgba(0,0,0,.7);padding:1rem;border-radius:.5rem;line-height:1.5}.page-layout{display:grid;grid-template-columns:1.5rem minmax(0, 1fr) 1.5rem}.page-layout>*{grid-column:2/3}.page{height:100%}.table__row{display:grid;grid-template-columns:repeat(var(--table-columns), auto)}.table__header{color:rgba(var(--text-color), 0.8);font-size:.8rem}#landing{grid-template-rows:auto 1fr}#landing header{padding:1.5rem 0}#landing>.grid{-ms-flex-line-pack:start;align-content:flex-start;text-align:center;gap:1rem}#sign_in,#sign_up{grid-template-rows:auto 1fr;-webkit-box-align:center;-ms-flex-align:center;align-items:center}#sign_in section,#sign_up section{margin-top:-6rem;justify-self:center;width:min(24rem, 100%)}#sign_in sm-form,#sign_up sm-form{margin:2rem 0}#sign_in header,#sign_up header{padding:1.5rem 0}#sign_up sm-copy{font-size:.9rem;--button-border-radius: 0.5rem}#sign_up .h2{margin-bottom:.5rem}#sign_up .card{margin:1.5rem 0}#sign_up h5{font-weight:500;color:rgba(var(--text-color), 0.8)}#sign_up .warning{margin-top:2rem}#loading{place-content:center;text-align:center}#loading sm-spinner{margin-bottom:1.5rem}#home{height:100%;display:grid;grid-template-columns:minmax(0, 1fr)}#main_header{padding:1.8rem 1.5rem;display:grid;gap:1rem;-webkit-box-align:center;-ms-flex-align:center;align-items:center;grid-template-columns:1fr auto}#trade_form{--width: min(24rem, 100%);-ms-flex-item-align:start;align-self:flex-start;padding:1rem 1.5rem}#quantity_selector .button{-webkit-box-flex:1;-ms-flex:1;flex:1;padding:.5rem .6rem;margin-left:.5rem}#quantity_type{font-size:.8rem;padding-right:.5rem;border-right:thin solid rgba(var(--text-color), 0.3);margin-right:auto;color:rgba(var(--text-color), 0.8);line-height:1.5;font-weight:500;min-width:8ch}#orders_section{padding:1.5rem}#user_section{gap:1.5rem;padding:1.5rem;-ms-flex-line-pack:start;align-content:flex-start}.wallet_actions__wrapper{grid-column:span 3;gap:.5rem;margin-top:.5rem}.wallet_actions__wrapper .button{-webkit-box-flex:1;-ms-flex:1;flex:1}.balance-card{display:grid;-webkit-box-align:center;-ms-flex-align:center;align-items:center;gap:.3rem 1rem;padding:.5rem 0;border-radius:.5rem}.balance-card.is-locked{grid-template-columns:auto 1fr;gap:1rem}.balance-card.is-locked .label{font-size:.8rem;color:rgba(var(--text-color), 0.8)}.balance-card:not(.is-locked){grid-template-columns:auto 1fr auto}.balance-card__icon{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-line-pack:center;align-content:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;padding:.6rem;border-radius:.8rem;background-color:var(--accent-color--light)}.balance-card__icon .icon{height:1.3rem;width:1.3rem;fill:var(--accent-color)}.balance-card__token{font-size:.9rem;font-weight:500}.balance-card__amount-wrapper{grid-column:span 2;gap:.3rem 1rem;grid-template-columns:1fr 1fr}.balance-card__amount-wrapper>:nth-child(even){text-align:right}.loader-button-wrapper{display:-webkit-box;display:-ms-flexbox;display:flex;position:relative;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.loader-button-wrapper sm-button,.loader-button-wrapper slide-button{width:100%;z-index:1;-webkit-transition:-webkit-clip-path .3s;transition:-webkit-clip-path .3s;transition:clip-path .3s;transition:clip-path .3s, -webkit-clip-path .3s;-webkit-clip-path:circle(100%);clip-path:circle(100%)}.loader-button-wrapper sm-button.clip,.loader-button-wrapper slide-button.clip{pointer-events:none;-webkit-clip-path:circle(0);clip-path:circle(0)}.loader-button-wrapper sm-spinner{position:absolute}@media screen and (max-width: 40rem){sm-button{--padding: 0.9rem 1.6rem}}@media screen and (min-width: 40rem){sm-popup{--width: 24rem}.h1{font-size:2rem}.h2{font-size:1.8rem}.h3{font-size:1.3rem}.h4{font-size:1rem}.popup__header{padding:1rem 1.5rem 0 .5rem}#confirmation_popup{--width: 24rem}.page-layout{grid-template-columns:1fr 90vw 1fr}}@media screen and (min-width: 64rem){.page-layout{grid-template-columns:1fr 80vw 1fr}#home{-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start;padding:1.5vmax 3vmax;grid-template-columns:24rem minmax(0, 1fr) 20rem;gap:1rem}#home>*{border-radius:.5rem;background-color:var(--foreground-color);border:solid thin rgba(var(--text-color), 0.1)}.hide-on-desktop{display:none}}@media screen and (min-width: 120rem){.page-layout{grid-template-columns:1fr 70vw 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)}.nav-item,.interact{-webkit-transition:background-color .3s,-webkit-transform .3s;transition:background-color .3s,-webkit-transform .3s;transition:background-color .3s,transform .3s;transition:background-color .3s,transform .3s,-webkit-transform .3s}.nav-item:hover,.interact:hover{background-color:var(--accent-color--light)}} \ No newline at end of file diff --git a/public/css/main.scss b/public/css/main.scss new file mode 100644 index 0000000..e1bcd63 --- /dev/null +++ b/public/css/main.scss @@ -0,0 +1,726 @@ +* { + padding: 0; + margin: 0; + box-sizing: border-box; + font-family: "Roboto", sans-serif; +} + +:root { + font-size: clamp(1rem, 1.2vmax, 1.2rem); +} + +html, +body { + height: 100%; + scroll-behavior: smooth; +} + +body { + &, + * { + --accent-color: #504dff; + --accent-color--light: #f4f4ff; + --text-color: 36, 36, 36; + --background-color: 255, 255, 255; + --foreground-color: rgb(250, 252, 255); + --danger-color: rgb(255, 75, 75); + --green: #1cad59; + --yellow: #f3a600; + --loan-color: rgb(255, 171, 93); + scrollbar-width: thin; + } + + color: rgba(var(--text-color), 1); + background: rgba(var(--background-color), 1); +} + +body[data-theme="dark"] { + &, + * { + --accent-color: #a3a1ff; + --accent-color--light: rgba(142, 140, 255, 0.06); + --text-color: 230, 230, 230; + --text-color-light: 170, 170, 170; + --background-color: 10, 10, 10; + --foreground-color: rgb(20, 20, 20); + --danger-color: rgb(255, 106, 106); + --green: #00e676; + --yellow: #ffd13a; + --loan-color: rgb(255, 232, 170); + } +} + +p, +strong { + font-size: 0.9rem; + max-width: 70ch; + line-height: 1.7; + color: rgba(var(--text-color), 0.8); + + &:not(:last-of-type) { + margin-bottom: 1.5rem; + } +} + +a:where([class]) { + color: inherit; + text-decoration: none; + + &:focus-visible { + box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset; + } +} + +a { + color: var(--accent-color); +} + +button, +.button { + user-select: none; + position: relative; + display: inline-flex; + border: none; + background-color: transparent; + overflow: hidden; + color: inherit; + cursor: pointer; + transition: transform 0.3s; + -webkit-tap-highlight-color: transparent; +} +.button { + white-space: nowrap; + padding: 0.6rem 1rem; + border-radius: 0.3rem; + font-weight: 500; + font-size: 0.8rem; + background-color: var(--accent-color--light); + color: var(--accent-color); + justify-content: center; + &--primary { + background-color: var(--accent-color); + color: rgba(var(--background-color), 1); + } +} + +button:disabled { + opacity: 0.5; +} + +a:any-link:focus-visible { + outline: rgba(var(--text-color), 1) 0.1rem solid; +} + +sm-input { + --border-radius: 0.5rem; + --background: var(--accent-color--light); +} +sm-button { + --padding: 0.7rem 1rem; + &[variant="primary"] { + .icon { + fill: rgba(var(--background-color), 1); + } + } + + &[disabled] { + .icon { + fill: rgba(var(--text-color), 0.6); + } + } +} + +ul { + list-style: none; +} + +.flex { + display: flex; +} + +.grid { + display: grid; +} + +.hide { + opacity: 0; + pointer-events: none; +} + +.hide-completely { + display: 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; +} + +.full-bleed { + grid-column: 1/4; +} + +.h1 { + font-size: 1.5rem; +} + +.h2 { + font-size: 1.2rem; +} + +.h3 { + font-size: 1rem; +} + +.h4 { + font-size: 0.9rem; +} + +.h5 { + font-size: 0.8rem; +} + +.uppercase { + text-transform: uppercase; +} + +.capitalize { + text-transform: capitalize; +} + +.flex { + display: flex; +} + +.grid { + display: grid; +} + +.grid-3 { + grid-template-columns: 1fr auto auto; +} + +.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; +} + +.stretch { + justify-content: stretch; + justify-items: stretch; + + & > * { + width: 100%; + } +} + +.interact { + position: relative; + cursor: pointer; + transition: transform 0.3s; + -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.8); +} + +.button__icon { + height: 1.2rem; + width: 1.2rem; + + &--left { + margin-right: 0.5rem; + } + + &--right { + margin-left: 0.5rem; + } +} + +.icon-button { + padding: 0.6rem; + border-radius: 0.8rem; + background-color: var(--accent-color--light); + height: max-content; + .icon { + fill: 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; + } + } +} + +button:active, +.button:active, +.interact:active { + transform: scale(0.96); +} + +.popup__header { + display: grid; + gap: 0.5rem; + width: 100%; + padding: 0 1.5rem 0 0.5rem; + align-items: center; + grid-template-columns: auto 1fr auto; +} + +.popup__header__close { + padding: 0.5rem; + cursor: pointer; +} + +#main_page { + padding: 1.5rem; + + & > section:nth-of-type(1) { + align-content: flex-start; + } +} +.logo { + display: grid; + align-items: center; + width: 100%; + grid-template-columns: auto 1fr; + gap: 0 0.3rem; + margin-right: 1rem; + + h4 { + text-transform: capitalize; + font-size: 0.9rem; + font-weight: 600; + } + + .main-logo { + height: 1.4rem; + width: 1.4rem; + fill: rgba(var(--text-color), 1); + stroke: none; + } +} +details { + summary { + display: flex; + justify-content: space-between; + user-select: none; + cursor: pointer; + } + + &[open] > summary { + margin-bottom: 1rem; + .icon { + transform: rotate(180deg); + } + } +} +strip-select { + --gap: 0; + background-color: var(--accent-color--light); + border-radius: 0.3rem; +} +strip-option { + text-transform: uppercase; + font-weight: 500; + letter-spacing: 0.05em; + font-size: 0.8rem; + --border-radius: 0; + --active-option-color: rgba(var(--background-color), 1); + --active-option-background-color: var(--accent-color); + &:first-of-type { + --border-radius: 0.3rem 0 0 0.3rem; + } + &:last-of-type { + --border-radius: 0 0.3rem 0.3rem 0; + } +} +.warning { + background-color: khaki; + color: rgba(0, 0, 0, 0.7); + padding: 1rem; + border-radius: 0.5rem; + line-height: 1.5; +} +.page-layout { + display: grid; + grid-template-columns: 1.5rem minmax(0, 1fr) 1.5rem; + & > * { + grid-column: 2/3; + } +} +.page { + height: 100%; +} +.table { + &__row { + display: grid; + grid-template-columns: repeat(var(--table-columns), auto); + } + &__header { + color: rgba(var(--text-color), 0.8); + font-size: 0.8rem; + } +} +#landing { + grid-template-rows: auto 1fr; + header { + padding: 1.5rem 0; + } + & > .grid { + align-content: flex-start; + text-align: center; + gap: 1rem; + } +} + +#sign_in, +#sign_up { + grid-template-rows: auto 1fr; + align-items: center; + section { + margin-top: -6rem; + justify-self: center; + width: min(24rem, 100%); + } + sm-form { + margin: 2rem 0; + } + header { + padding: 1.5rem 0; + } +} +#sign_up { + sm-copy { + font-size: 0.9rem; + --button-border-radius: 0.5rem; + } + .h2 { + margin-bottom: 0.5rem; + } + .card { + margin: 1.5rem 0; + } + h5 { + font-weight: 500; + color: rgba(var(--text-color), 0.8); + } + .warning { + margin-top: 2rem; + } +} +#loading { + place-content: center; + text-align: center; + sm-spinner { + margin-bottom: 1.5rem; + } +} +#home { + height: 100%; + display: grid; + grid-template-columns: minmax(0, 1fr); +} + +#main_header { + padding: 1.8rem 1.5rem; + display: grid; + gap: 1rem; + align-items: center; + grid-template-columns: 1fr auto; +} + +#trade_form { + --width: min(24rem, 100%); + align-self: flex-start; + padding: 1rem 1.5rem; +} +#quantity_selector { + .button { + flex: 1; + padding: 0.5rem 0.6rem; + margin-left: 0.5rem; + } +} +#quantity_type { + font-size: 0.8rem; + padding-right: 0.5rem; + border-right: thin solid rgba(var(--text-color), 0.3); + margin-right: auto; + color: rgba(var(--text-color), 0.8); + line-height: 1.5; + font-weight: 500; + min-width: 8ch; +} +#orders_section { + padding: 1.5rem; +} +#user_section { + gap: 1.5rem; + padding: 1.5rem; + align-content: flex-start; +} +.user_section__header { +} +.wallet_actions__wrapper { + grid-column: span 3; + gap: 0.5rem; + margin-top: 0.5rem; + .button { + flex: 1; + } +} +.balance-card { + display: grid; + align-items: center; + gap: 0.3rem 1rem; + padding: 0.5rem 0; + border-radius: 0.5rem; + &.is-locked { + grid-template-columns: auto 1fr; + gap: 1rem; + .label { + font-size: 0.8rem; + color: rgba(var(--text-color), 0.8); + } + } + &:not(.is-locked) { + grid-template-columns: auto 1fr auto; + } + &__icon { + display: flex; + align-content: center; + justify-content: center; + padding: 0.6rem; + border-radius: 0.8rem; + background-color: var(--accent-color--light); + .icon { + height: 1.3rem; + width: 1.3rem; + fill: var(--accent-color); + } + } + &__token { + font-size: 0.9rem; + font-weight: 500; + } + &__amount-wrapper { + grid-column: span 2; + gap: 0.3rem 1rem; + grid-template-columns: 1fr 1fr; + & > :nth-child(even) { + text-align: right; + } + } +} +.loader-button-wrapper { + display: flex; + position: relative; + justify-content: center; + align-items: center; + sm-button, + slide-button { + width: 100%; + z-index: 1; + transition: clip-path 0.3s; + clip-path: circle(100%); + &.clip { + pointer-events: none; + clip-path: circle(0); + } + } + sm-spinner { + position: absolute; + } +} +@media screen and (max-width: 40rem) { + sm-button { + --padding: 0.9rem 1.6rem; + } +} +@media screen and (min-width: 40rem) { + sm-popup { + --width: 24rem; + } + .h1 { + font-size: 2rem; + } + + .h2 { + font-size: 1.8rem; + } + + .h3 { + font-size: 1.3rem; + } + + .h4 { + font-size: 1rem; + } + .popup__header { + padding: 1rem 1.5rem 0 0.5rem; + } + #confirmation_popup { + --width: 24rem; + } + .page-layout { + grid-template-columns: 1fr 90vw 1fr; + } +} +@media screen and (max-width: 64rem) { +} +@media screen and (min-width: 64rem) { + .page-layout { + grid-template-columns: 1fr 80vw 1fr; + } + #home { + align-items: flex-start; + padding: 1.5vmax 3vmax; + grid-template-columns: 24rem minmax(0, 1fr) 20rem; + gap: 1rem; + & > * { + border-radius: 0.5rem; + background-color: var(--foreground-color); + border: solid thin rgba(var(--text-color), 0.1); + } + } + .hide-on-desktop { + display: none; + } +} +@media screen and (min-width: 120rem) { + .page-layout { + grid-template-columns: 1fr 70vw 1fr; + } +} +@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); + } + } + .nav-item, + .interact { + transition: background-color 0.3s, transform 0.3s; + &:hover { + background-color: var(--accent-color--light); + } + } +} diff --git a/public/home.html b/public/home.html index d98cf08..7a5694e 100644 --- a/public/home.html +++ b/public/home.html @@ -1,12 +1,15 @@ - + + - + + + + + RanchiMall market + + + @@ -56,7 +59,8 @@ - + @@ -169,7 +173,387 @@ + - + \ No newline at end of file diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..aaba03f --- /dev/null +++ b/public/index.html @@ -0,0 +1,1208 @@ + + + + + + + + RanchiMall market + + + + + + + + + + + + + + + + +

+

+
+ Cancel + OK +
+
+ +

+

+ +
+ Cancel + OK +
+
+
+
+ +
+ + Sign in +
+
+
+

Decentralized banking
made simple

+

*Interest rates are re-calculated with each new transaction done on network

+
+ +
+
+
+
+
+ +
+
+

Sign In

+

Welcome back, glad to see you again

+ + + Sign In + +

+ New here? get your FLO login credentials +

+
+
+
+
+ +
+
+

FLO credentials

+

Get your FLO credentials to use RanchiMall market and all RanchiMall FLO apps.

+
+
+
FLO ID
+ +
+
+
Private key
+ +
+
+ Sign in with these credentials + + Keep your private key secure and don't share with anyone. + Once lost there is no way to recover private key. + +
+
+
+ +

Loading RanchiMall Market

+
+
+
+
+ + +
+ +
+

Trade FLO

+ + Buy + Sell + +
+ + + + +
+ Rupee + + + + +
+ BUY +
+
+
+
+

My orders

+ + Open + Completed + +
+
+
+
+
Quantity
+
At price
+
Order placed
+
+
+
+
+

+ + + + + + My wallet +

+
+

Select asset

+ + FLO + Rupee + +
+ + +
+
+
+

Balance

+
+
+ + + +
+
FLO
+
+
+
+
+ + + +
+
Rupee
+
+
+
+
+
+ + + + + + + +
+ +
+
+
+
+
+ Login + + +
+ RememberMe
+ +
+
+
+
+ Profile +
+
+ + +
+
+
+ My Orders +
+ Buying + + + + + + + + + + +
SelectQuantityMax PriceOrder Placed
+
+
+ Selling + + + + + + + + + + +
SelectQuantityMin PriceOrder placed
+
+ +
+
+
+
+ My Transactions + + + + + + + + + + + +
Sold/BroughtTo/FromQuantityUnit ValueTime
+
+
+
+
+
+ + +
+
+
+ BuyOrders + + + + + + + + + + +
BuyerQuantityMax PriceOrder Placed
+
+
+
+
+ SellOrders + + + + + + + + + + +
SellerQuantityMin PriceOrder Placed
+
+
+
+
+ Transactions + + + + + + + + + + + +
SellerBuyerQuantityUnit ValueTime
+
+
+
+ + + + + + + + \ No newline at end of file