diff --git a/components.js b/components.js
index bbc5e33..9ff07ca 100644
--- a/components.js
+++ b/components.js
@@ -204,18 +204,19 @@ border: none;
.input {
display: flex;
align-items: center;
+ text-align: left;
position: relative;
gap: 1em;
padding: 0.7em 1em;
border-radius: 0.3em;
transition: opacity 0.3s;
- background: rgba(var(--text-color), 0.1);
+ background: rgba(var(--text-color), 0.06);
+ box-shadow: 0 0 0 0.1em rgba(var(--text-color), 0.2) inset;
font-family: var(--font-family);
width: 100%
outline: none;
min-width: 0;
}
-
input:focus{
caret-color: var(--accent-color);
}
@@ -281,6 +282,9 @@ input{
border: solid 1px rgba(var(--text-color), 0.2);
padding: 0.6em 1em;
}
+.helper-text:empty{
+ padding: 0;
+}
@media (any-hover: hover){
.icon:hover{
background: rgba(var(--text-color), 0.1);
@@ -288,19 +292,19 @@ input{
}
-
-
+
+
`;
customElements.define('sm-input',
@@ -339,22 +343,22 @@ customElements.define('sm-input',
return this.shadowRoot.querySelector('input').checkValidity()
}
- focusIn() {
+ focusIn = () => {
this.shadowRoot.querySelector('input').focus()
}
- focusOut() {
+ focusOut = () => {
this.shadowRoot.querySelector('input').blur()
}
- preventNonNumericalInput(e) {
+ preventNonNumericalInput = (e) => {
let keyCode = e.keyCode;
- if (!((keyCode > 47 && keyCode < 56) || (keyCode > 36 && keyCode < 39) || (keyCode > 95 && keyCode < 104) || keyCode === 110 || (keyCode > 7 && keyCode < 19))) {
+ if (!((keyCode > 47 && keyCode < 56) || (keyCode > 36 && keyCode < 39) || (keyCode > 95 && keyCode < 106) || keyCode === 110 || (keyCode > 7 && keyCode < 19))) {
e.preventDefault();
}
}
- fireEvent() {
+ fireEvent = () => {
let event = new Event('input', {
bubbles: true,
cancelable: true,
@@ -363,7 +367,7 @@ customElements.define('sm-input',
this.dispatchEvent(event);
}
- checkInput() {
+ checkInput = (e) => {
if (!this.hasAttribute('placeholder') || this.getAttribute('placeholder') === '')
return;
if (this.input.value !== '') {
@@ -392,6 +396,8 @@ customElements.define('sm-input',
this.helperText = this.shadowRoot.querySelector('.helper-text')
this.valueChanged = false;
this.readonly = false
+ this.min
+ this.max
this.animate = this.hasAttribute('animate')
this.input = this.shadowRoot.querySelector('input')
this.shadowRoot.querySelector('.label').textContent = this.getAttribute('placeholder')
@@ -402,6 +408,19 @@ customElements.define('sm-input',
if (this.hasAttribute('required')) {
this.input.setAttribute('required', '')
}
+ if (this.hasAttribute('min')) {
+ let minValue = this.getAttribute('min')
+ this.input.setAttribute('min', minValue)
+ this.min = parseInt(minValue)
+ }
+ if (this.hasAttribute('max')) {
+ let maxValue = this.getAttribute('max')
+ this.input.setAttribute('max', maxValue)
+ this.max = parseInt(maxValue)
+ }
+ if (this.hasAttribute('pattern')) {
+ this.input.setAttribute('pattern', this.getAttribute('pattern'))
+ }
if (this.hasAttribute('readonly')) {
this.input.setAttribute('readonly', '')
this.readonly = true
@@ -412,6 +431,7 @@ customElements.define('sm-input',
if (this.hasAttribute('type')) {
if (this.getAttribute('type') === 'number') {
this.input.setAttribute('inputmode', 'numeric')
+ this.input.setAttribute('type', 'number')
}
else
this.input.setAttribute('type', this.getAttribute('type'))
@@ -434,6 +454,7 @@ customElements.define('sm-input',
if (oldValue !== newValue) {
if (name === 'placeholder')
this.shadowRoot.querySelector('.label').textContent = newValue;
+ this.setAttribute('aria-label', newValue);
}
}
})
@@ -1488,7 +1509,7 @@ customElements.define('sm-strip-select', class extends HTMLElement {
set value(val) {
this.setAttribute('value', val)
}
- scrollLeft() {
+ scrollLeft = () => {
this.select.scrollBy({
top: 0,
left: -this.scrollDistance,
@@ -1496,7 +1517,7 @@ customElements.define('sm-strip-select', class extends HTMLElement {
})
}
- scrollRight() {
+ scrollRight = () => {
this.select.scrollBy({
top: 0,
left: this.scrollDistance,
@@ -1572,13 +1593,13 @@ customElements.define('sm-strip-select', class extends HTMLElement {
previousOption = firstElement;
}
});
- this.nextArrow.addEventListener('click', this.scrollRight.bind(this))
- this.previousArrow.addEventListener('click', this.scrollLeft.bind(this))
+ this.nextArrow.addEventListener('click', this.scrollRight)
+ this.previousArrow.addEventListener('click', this.scrollLeft)
}
disconnectedCallback() {
- this.nextArrow.removeEventListener('click', this.scrollRight.bind(this))
- this.previousArrow.removeEventListener('click', this.scrollLeft.bind(this))
+ this.nextArrow.removeEventListener('click', this.scrollRight)
+ this.previousArrow.removeEventListener('click', this.scrollLeft)
}
})
@@ -1660,73 +1681,80 @@ const smPopup = document.createElement('template')
smPopup.innerHTML = `
-
-
-
-
-
-
-
+
+
+
+
+
+
`;
@@ -2039,7 +2104,11 @@ customElements.define('sm-carousel', class extends HTMLElement {
this.attachShadow({ mode: 'open' }).append(smCarousel.content.cloneNode(true))
}
- scrollLeft() {
+ static get observedAttributes() {
+ return ['indicator']
+ }
+
+ scrollLeft = () => {
this.carousel.scrollBy({
top: 0,
left: -this.scrollDistance,
@@ -2047,7 +2116,7 @@ customElements.define('sm-carousel', class extends HTMLElement {
})
}
- scrollRight() {
+ scrollRight = () => {
this.carousel.scrollBy({
top: 0,
left: this.scrollDistance,
@@ -2061,32 +2130,50 @@ customElements.define('sm-carousel', class extends HTMLElement {
this.carouselSlot = this.shadowRoot.querySelector('slot')
this.nextArrow = this.shadowRoot.querySelector('.next-item')
this.previousArrow = this.shadowRoot.querySelector('.previous-item')
- this.nextGradient = this.shadowRoot.querySelector('.right')
- this.previousGradient = this.shadowRoot.querySelector('.left')
+ this.indicatorsContainer = this.shadowRoot.querySelector('.indicators')
this.carouselItems
+ this.indicators
+ this.showIndicator = false
this.scrollDistance = this.carouselContainer.getBoundingClientRect().width / 3
- const firstElementObserver = new IntersectionObserver(entries => {
- if (entries[0].isIntersecting) {
- this.previousArrow.classList.remove('expand')
- this.previousGradient.classList.add('hide')
- }
- else {
- this.previousArrow.classList.add('expand')
- this.previousGradient.classList.remove('hide')
- }
- }, {
- root: this.carouselContainer,
- threshold: 0.9
- })
- const lastElementObserver = new IntersectionObserver(entries => {
- if (entries[0].isIntersecting) {
- this.nextArrow.classList.remove('expand')
- this.nextGradient.classList.add('hide')
- }
- else {
- this.nextArrow.classList.add('expand')
- this.nextGradient.classList.remove('hide')
- }
+ let frag = document.createDocumentFragment();
+ if (this.hasAttribute('indicator'))
+ this.showIndicator = true
+
+
+ let firstVisible = false,
+ lastVisible = false
+ const allElementsObserver = new IntersectionObserver(entries => {
+ entries.forEach(entry => {
+ if(this.showIndicator)
+ if (entry.isIntersecting) {
+ this.indicators[parseInt(entry.target.attributes.rank.textContent)].classList.add('active')
+ }
+ else
+ this.indicators[parseInt(entry.target.attributes.rank.textContent)].classList.remove('active')
+ 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
@@ -2102,8 +2189,18 @@ customElements.define('sm-carousel', class extends HTMLElement {
this.carouselSlot.addEventListener('slotchange', e => {
this.carouselItems = this.carouselSlot.assignedElements()
- firstElementObserver.observe(this.carouselItems[0])
- lastElementObserver.observe(this.carouselItems[this.carouselItems.length - 1])
+ 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')
+ frag.append(dot)
+ item.setAttribute('rank', index)
+ })
+ this.indicatorsContainer.append(frag)
+ this.indicators = this.indicatorsContainer.children
+ }
})
this.addEventListener('keyup', e => {
@@ -2113,13 +2210,22 @@ customElements.define('sm-carousel', class extends HTMLElement {
this.scrollRight()
})
- this.nextArrow.addEventListener('click', this.scrollRight.bind(this))
- this.previousArrow.addEventListener('click', this.scrollLeft.bind(this))
+ this.nextArrow.addEventListener('click', this.scrollRight)
+ this.previousArrow.addEventListener('click', this.scrollLeft)
+ }
+
+ attributeChangedCallback(name, oldValue, newValue) {
+ if (name === 'indicator') {
+ if (this.hasAttribute('indicator'))
+ this.showIndicator = true
+ else
+ this.showIndicator = false
+ }
}
disconnectedCallback() {
- this.nextArrow.removeEventListener('click', this.scrollRight.bind(this))
- this.previousArrow.removeEventListener('click', this.scrollLeft.bind(this))
+ this.nextArrow.removeEventListener('click', this.scrollRight)
+ this.previousArrow.removeEventListener('click', this.scrollLeft)
}
})
@@ -2156,27 +2262,28 @@ transform: none;
opacity: 1;
}
.notification{
-display: flex;
-opacity: 0;
-padding: 1rem 1.5rem;
-transform: translateY(-1rem);
-position: relative;
-border-radius: 0.3rem;
-box-shadow: 0 0.1rem 0.2rem rgba(0, 0, 0, 0.1),
- 0.5rem 1rem 2rem rgba(0, 0, 0, 0.1);
-background: rgba(var(--foreground-color), 1);
-transition: height 0.3s, transform 0.3s, opacity 0.3s;
-overflow: hidden;
-overflow-wrap: break-word;
-word-wrap: break-word;
--ms-word-break: break-all;
-word-break: break-all;
-word-break: break-word;
--ms-hyphens: auto;
--moz-hyphens: auto;
--webkit-hyphens: auto;
-hyphens: auto;
-max-width: 100%;
+ display: flex;
+ opacity: 0;
+ padding: 1rem 1.5rem;
+ margin-bottom: 0.5rem;
+ transform: translateY(-1rem);
+ position: relative;
+ border-radius: 0.3rem;
+ box-shadow: 0 0.1rem 0.2rem rgba(0, 0, 0, 0.1),
+ 0.5rem 1rem 2rem rgba(0, 0, 0, 0.1);
+ background: rgba(var(--foreground-color), 1);
+ transition: height 0.3s, transform 0.3s, opacity 0.3s;
+ overflow: hidden;
+ overflow-wrap: break-word;
+ word-wrap: break-word;
+ -ms-word-break: break-all;
+ word-break: break-all;
+ word-break: break-word;
+ -ms-hyphens: auto;
+ -moz-hyphens: auto;
+ -webkit-hyphens: auto;
+ hyphens: auto;
+ max-width: 100%;
}
h4:first-letter,
p:first-letter{
@@ -2247,7 +2354,7 @@ stroke-width: 6;
transform: translateX(1rem);
}
}
-@media screen and (max-width: 640px){
+@media screen and (any-hover: none){
.close{
display: none
}
@@ -2263,14 +2370,14 @@ customElements.define('sm-notifications', class extends HTMLElement {
this.shadow = this.attachShadow({ mode: 'open' }).append(smNotifications.content.cloneNode(true))
}
- handleTouchStart(e) {
+ handleTouchStart =(e) => {
this.notification = e.target.closest('.notification')
this.touchStartX = e.changedTouches[0].clientX
this.notification.style.transition = 'initial'
this.touchStartTime = e.timeStamp
}
- handleTouchMove(e) {
+ handleTouchMove = (e) => {
e.preventDefault()
if (this.touchStartX < e.changedTouches[0].clientX) {
this.offset = e.changedTouches[0].clientX - this.touchStartX;
@@ -2282,7 +2389,7 @@ customElements.define('sm-notifications', class extends HTMLElement {
}
}
- handleTouchEnd(e) {
+ handleTouchEnd = (e) => {
this.notification.style.transition = 'transform 0.3s, opacity 0.3s'
this.touchEndTime = e.timeStamp
cancelAnimationFrame(this.touchEndAnimataion)
@@ -2312,11 +2419,11 @@ customElements.define('sm-notifications', class extends HTMLElement {
this.notification.style.transform = `translateX(${this.offset}px)`
}
- resetPosition() {
+ resetPosition = () => {
this.notification.style.transform = `translateX(0)`
}
- push(messageBody, type, pinned) {
+ push = (messageBody, type, pinned) => {
let notification = document.createElement('div'),
composition = ``
notification.classList.add('notification')
@@ -2362,12 +2469,12 @@ customElements.define('sm-notifications', class extends HTMLElement {
else {
notification.setAttribute('style', `transform: translateY(0); opacity: 1`)
}
- notification.addEventListener('touchstart', this.handleTouchStart.bind(this))
- notification.addEventListener('touchmove', this.handleTouchMove.bind(this))
- notification.addEventListener('touchend', this.handleTouchEnd.bind(this))
+ notification.addEventListener('touchstart', this.handleTouchStart)
+ notification.addEventListener('touchmove', this.handleTouchMove)
+ notification.addEventListener('touchend', this.handleTouchEnd)
}
- removeNotification(notification, toLeft) {
+ removeNotification = (notification, toLeft) => {
if (!this.offset)
this.offset = 0;
diff --git a/index.html b/index.html
index d73db9b..d8dccfa 100644
--- a/index.html
+++ b/index.html
@@ -5,7 +5,9 @@
Blockchain UPI
-
+
@@ -14,262 +16,287 @@
-