code improvement
This commit is contained in:
parent
535634e390
commit
c5659f0cb9
8
components/dist/chips.js
vendored
8
components/dist/chips.js
vendored
@ -181,7 +181,7 @@ customElements.define('sm-chips', class extends HTMLElement {
|
|||||||
this._value = value;
|
this._value = value;
|
||||||
this.assignedElements.forEach(elem => {
|
this.assignedElements.forEach(elem => {
|
||||||
if (elem.value == value) {
|
if (elem.value == value) {
|
||||||
elem.setAttribute('selected', '');
|
elem.setAttribute('selected', 'true');
|
||||||
elem.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "center" });
|
elem.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "center" });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -213,7 +213,7 @@ customElements.define('sm-chips', class extends HTMLElement {
|
|||||||
this.slotChangeTimeout = setTimeout(() => {
|
this.slotChangeTimeout = setTimeout(() => {
|
||||||
this.assignedElements = slot.assignedElements();
|
this.assignedElements = slot.assignedElements();
|
||||||
this.assignedElements.forEach(elem => {
|
this.assignedElements.forEach(elem => {
|
||||||
if (elem.hasAttribute('selected')) {
|
if (elem.hasAttribute('selected') && elem.getAttribute('selected') === 'true') {
|
||||||
this._value = elem.value;
|
this._value = elem.value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -304,7 +304,7 @@ smChip.innerHTML = `
|
|||||||
:host(:focus-within) .sm-chip{
|
:host(:focus-within) .sm-chip{
|
||||||
box-shadow: 0 0 0 0.1rem var(--accent-color,teal) inset;
|
box-shadow: 0 0 0 0.1rem var(--accent-color,teal) inset;
|
||||||
}
|
}
|
||||||
:host(:hover:not([selected])) .sm-chip{
|
:host(:hover:not([selected="true"])) .sm-chip{
|
||||||
background-color: rgba(var(--text-color,(17,17,17)), 0.06);
|
background-color: rgba(var(--text-color,(17,17,17)), 0.06);
|
||||||
}
|
}
|
||||||
.sm-chip{
|
.sm-chip{
|
||||||
@ -318,7 +318,7 @@ smChip.innerHTML = `
|
|||||||
-webkit-tap-highlight-color: transparent;
|
-webkit-tap-highlight-color: transparent;
|
||||||
background: var(--background,inherit);
|
background: var(--background,inherit);
|
||||||
}
|
}
|
||||||
.sm-chip[selected]{
|
.sm-chip[selected="true"]{
|
||||||
background-color: var(--accent-color,teal);
|
background-color: var(--accent-color,teal);
|
||||||
color: rgba(var(--background-color, (255,255,255)), 1);
|
color: rgba(var(--background-color, (255,255,255)), 1);
|
||||||
}
|
}
|
||||||
|
|||||||
2
components/dist/chips.min.js
vendored
2
components/dist/chips.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user