feat(elements): Revamp consent components with improved theming, layout, and accessibility

This commit is contained in:
2025-11-30 21:43:36 +00:00
parent 8a26378689
commit 0b366b360d
5 changed files with 243 additions and 185 deletions

View File

@@ -33,191 +33,192 @@ export class ConsentsoftwareCookieconsent extends LitElement {
public static styles = css` public static styles = css`
:host { :host {
font-family: ${shared.fontStack}; font-family: ${shared.fontStack};
font-size: 14px;
user-select: none; user-select: none;
/* Default variables for Light Theme */ /* Shadcn-inspired Dark Theme (default) */
--text-color: #333; --background: hsl(0 0% 7%);
--background-color: #eeeeee; --foreground: hsl(0 0% 95%);
--accent-color: #333333; --muted: hsl(0 0% 15%);
--button-bg: #ffffff; --muted-foreground: hsl(0 0% 64%);
--button-hover-bg: #f2f2f2; --border: hsl(0 0% 18%);
--icon-color: #4496f5; --input: hsl(0 0% 15%);
--link-color: #333; --primary: hsl(0 0% 98%);
--padding-sides: 16px; --primary-foreground: hsl(0 0% 9%);
/* Additional variables for modal and info container styling */ --secondary: hsl(0 0% 15%);
--info-bg: rgba(0, 0, 0, 0.1); --secondary-foreground: hsl(0 0% 98%);
--info-text: rgba(255, 255, 255, 0.5); --accent: hsl(0 0% 15%);
--modal-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.2); --accent-foreground: hsl(0 0% 98%);
--ring: hsl(0 0% 30%);
--radius: 8px;
} }
/* Dark Theme Overrides:
When theme attribute is 'dark', override variables accordingly. */
:host([theme='dark']) { :host([theme='dark']) {
--text-color: #fff; --background: hsl(0 0% 7%);
--background-color: #111; --foreground: hsl(0 0% 95%);
--accent-color: #333333; --muted: hsl(0 0% 15%);
--button-bg: #252525; --muted-foreground: hsl(0 0% 64%);
--button-hover-bg: #222222; --border: hsl(0 0% 18%);
--icon-color: #4496f5; --input: hsl(0 0% 15%);
--link-color: #fff; --primary: hsl(0 0% 98%);
--info-bg: rgba(0, 0, 0, 0.1); --primary-foreground: hsl(0 0% 9%);
--info-text: rgba(255, 255, 255, 0.5); --secondary: hsl(0 0% 15%);
--modal-box-shadow: 0px 0px 8px rgba(255, 255, 255, 0.6); --secondary-foreground: hsl(0 0% 98%);
--accent: hsl(0 0% 15%);
--accent-foreground: hsl(0 0% 98%);
--ring: hsl(0 0% 30%);
} }
/* Light Theme Overrides:
Explicit light theme settings, currently matching defaults.
Can be customized independently if desired. */
:host([theme='light']) { :host([theme='light']) {
--text-color: #333; --background: hsl(0 0% 100%);
--background-color: #eeeeee; --foreground: hsl(0 0% 9%);
--accent-color: #333333; --muted: hsl(0 0% 96%);
--button-bg: #ffffff; --muted-foreground: hsl(0 0% 45%);
--button-hover-bg: #f2f2f2; --border: hsl(0 0% 90%);
--icon-color: #4496f5; --input: hsl(0 0% 90%);
--link-color: #333; --primary: hsl(0 0% 9%);
--info-bg: rgba(0, 0, 0, 0.1); --primary-foreground: hsl(0 0% 98%);
--info-text: rgba(0, 0, 0, 0.5); --secondary: hsl(0 0% 96%);
--modal-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.2); --secondary-foreground: hsl(0 0% 9%);
--accent: hsl(0 0% 96%);
--accent-foreground: hsl(0 0% 9%);
--ring: hsl(0 0% 64%);
} }
/* Overlay covering the page behind the modal */
.pageOverlay { .pageOverlay {
position: fixed; position: fixed;
top: 0; inset: 0;
bottom: 0;
right: 0;
left: 0;
display: grid; display: grid;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
z-index: 1000; /* Ensures the overlay is on top of other elements */ z-index: 1000;
background: rgba(255, 255, 255, 0); background: rgba(0, 0, 0, 0);
backdrop-filter: blur(0px); backdrop-filter: blur(0px);
transition: all 0.2s; transition: all 0.2s ease-out;
} }
/* Shake animation for overlay when clicked */
.pageOverlay.shake { .pageOverlay.shake {
background: rgba(0, 0, 0, 0.5) !important; background: rgba(0, 0, 0, 0.6) !important;
} }
/* Modal box styling using theme variables for colors and shadows */
.modalBox { .modalBox {
display: block; display: block;
color: var(--text-color); color: var(--foreground);
background: var(--background-color); background: var(--background);
box-shadow: var(--modal-box-shadow); box-shadow:
0 0 0 1px var(--border),
0 16px 70px rgba(0, 0, 0, 0.35);
position: relative; position: relative;
border: 1px dotted rgba(255, 255, 255, 0.1); border-radius: var(--radius);
border-top: 1px solid var(--accent-color); max-width: 520px;
border-radius: 16px; min-width: 320px;
max-width: 1100px;
min-width: calc(100vw / 3);
box-sizing: border-box; box-sizing: border-box;
overflow: hidden; overflow: hidden;
will-change: transform; will-change: transform;
transition: all 0.3s; transition: all 0.2s ease-out;
transform: scale(0.95); transform: scale(0.96);
opacity: 0; opacity: 0;
} }
/* Media query for mobile devices: stack buttons vertically */ @media (max-width: 560px) {
@media (max-width: 600px) {
.modalBox { .modalBox {
max-width: 100%;
min-width: 100%;
height: 100vh; height: 100vh;
box-shadow: none; border-radius: 0;
border-radius: 0px;
} }
} }
/* Shake animation for modal box */
.modalBox.shake { .modalBox.shake {
animation: shake 150ms 2 linear; animation: shake 120ms 2 linear;
} }
@keyframes shake { @keyframes shake {
0% { 0% { transform: translateX(3px); }
transform: translate(3px, 0); 50% { transform: translateX(-3px); }
} 100% { transform: translateX(0); }
50% {
transform: translate(-3px, 0);
}
100% {
transform: translate(0, 0);
}
} }
/* Toggle display based on [show] attribute */ :host([show='false']) { display: none; }
:host([show='false']) { :host([show='true']) { display: block; }
display: none;
}
:host([show='true']) {
display: block;
}
.content { .content {
margin: auto; margin: auto;
} }
.text-container { .text-container {
padding-left: var(--padding-sides); padding: 12px 16px;
padding-right: var(--padding-sides); font-size: 0.9em;
display: grid; line-height: 1.5;
grid-template-columns: auto; color: var(--muted-foreground);
} }
.text-container a { .text-container a {
color: var(--link-color); color: var(--foreground);
text-decoration: none; text-decoration: underline;
text-underline-offset: 2px;
}
.text-container a:hover {
opacity: 0.8;
} }
.button-container { .button-container {
padding: var(--padding-sides); padding: 12px 16px 16px;
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(3, 1fr);
gap: 16px; gap: 8px;
} }
/* Media query for mobile devices: stack buttons vertically */ @media (max-width: 560px) {
@media (max-width: 600px) {
.button-container { .button-container {
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
} }
/* Consent button styling using theme variables */
.consent-button { .consent-button {
border-radius: 3px; border-radius: calc(var(--radius) - 2px);
background: var(--button-bg); background: var(--secondary);
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2); border: 1px solid var(--border);
padding: 10px; padding: 8px 16px;
line-height: 30px; font-size: 0.85em;
font-weight: 500;
text-align: center; text-align: center;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.15s ease;
color: var(--secondary-foreground);
} }
.consent-button:hover { .consent-button:hover {
background: var(--button-hover-bg); background: var(--accent);
border-color: var(--ring);
}
.consent-button:last-child {
background: var(--primary);
color: var(--primary-foreground);
border-color: var(--primary);
}
.consent-button:last-child:hover {
opacity: 0.9;
} }
/* Use theme variables for info container background and text */
.info-container { .info-container {
text-align: center; text-align: center;
line-height: 3em; padding: 10px 16px;
background: var(--info-bg); background: var(--muted);
border-top: 1px dotted rgba(255, 255, 255, 0.1); border-top: 1px solid var(--border);
font-size: 0.8em; font-size: 0.75em;
color: var(--info-text); color: var(--muted-foreground);
} }
.info-container a { .info-container a {
text-decoration: underline; color: var(--foreground);
color: var(--link-color); text-decoration: none;
transition: color 0.2s;
} }
.info-container a:hover { .info-container a:hover {
color: #ffffff; text-decoration: underline;
} }
`; `;
@@ -234,11 +235,11 @@ export class ConsentsoftwareCookieconsent extends LitElement {
<div class="content"> <div class="content">
<consentsoftware-header></consentsoftware-header> <consentsoftware-header></consentsoftware-header>
<consentsoftware-tabs></consentsoftware-tabs> <consentsoftware-tabs></consentsoftware-tabs>
<div class="text-container" style="padding: 16px;"> <div class="text-container">
<div class="toptext"> <div class="toptext">
This page uses cookies. Please review our We use cookies to enhance your experience. Review our
<a href="https://lossless.gmbh/cookie" target="_blank">cookie policy</a> <a href="https://lossless.gmbh/cookie" target="_blank">cookie policy</a>
and choose which cookie level you are willing to accept. and select your preferences.
</div> </div>
</div> </div>
<consentsoftware-mainselection></consentsoftware-mainselection> <consentsoftware-mainselection></consentsoftware-mainselection>
@@ -291,9 +292,9 @@ export class ConsentsoftwareCookieconsent extends LitElement {
await this.updated(); await this.updated();
const pageOverlay: HTMLDivElement = this.shadowRoot?.querySelector('.pageOverlay'); const pageOverlay: HTMLDivElement = this.shadowRoot?.querySelector('.pageOverlay');
if (pageOverlay) { if (pageOverlay) {
// Apply dark overlay styling when modal appears // Apply subtle backdrop blur when modal appears
pageOverlay.style.background = 'rgba(0,0,0, 0.5)'; pageOverlay.style.background = 'rgba(0,0,0, 0.6)';
pageOverlay.style.backdropFilter = 'blur(20px)'; pageOverlay.style.backdropFilter = 'blur(4px)';
} }
const modalBox: HTMLDivElement = this.shadowRoot?.querySelector('.modalBox'); const modalBox: HTMLDivElement = this.shadowRoot?.querySelector('.modalBox');
if (modalBox) { if (modalBox) {
@@ -335,8 +336,7 @@ export class ConsentsoftwareCookieconsent extends LitElement {
console.log(`Set level to ${levelsArg}`); console.log(`Set level to ${levelsArg}`);
const pageOverlay: HTMLDivElement = this.shadowRoot?.querySelector('.pageOverlay'); const pageOverlay: HTMLDivElement = this.shadowRoot?.querySelector('.pageOverlay');
if (pageOverlay) { if (pageOverlay) {
// Fade out overlay effect using inline styles for transition pageOverlay.style.background = 'rgba(0,0,0, 0)';
pageOverlay.style.background = 'rgba(255,255,255, 0)';
pageOverlay.style.backdropFilter = 'blur(0px)'; pageOverlay.style.backdropFilter = 'blur(0px)';
} }
const modalBox: HTMLDivElement = this.shadowRoot?.querySelector('.modalBox'); const modalBox: HTMLDivElement = this.shadowRoot?.querySelector('.modalBox');

View File

@@ -11,14 +11,24 @@ export class ConsentsoftwareHeader extends LitElement {
public static styles = css` public static styles = css`
:host { :host {
display: block; display: block;
line-height: 3em; padding: 14px 16px;
text-align: center;
font-family: ${shared.fontStack}; font-family: ${shared.fontStack};
border-bottom: 1px dotted rgba(255, 255, 255, 0.1); border-bottom: 1px solid var(--border, hsl(0 0% 18%));
} }
.heading { .heading {
display: flex;
align-items: center;
gap: 8px;
font-size: 0.95em;
font-weight: 600;
color: var(--foreground, hsl(0 0% 95%));
}
.icon {
width: 18px;
height: 18px;
opacity: 0.7;
} }
`; `;
@@ -29,7 +39,12 @@ export class ConsentsoftwareHeader extends LitElement {
public render(): TemplateResult { public render(): TemplateResult {
return html` return html`
<div class="heading"> <div class="heading">
What about cookies? <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"/>
<path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/>
<path d="M12 17h.01"/>
</svg>
Cookie Preferences
</div> </div>
`; `;
} }

View File

@@ -21,17 +21,41 @@ export class ConsentsoftwareMainSelection extends LitElement {
.maincontainer { .maincontainer {
display: grid; display: grid;
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(4, 1fr);
padding: 8px 0;
}
@media (max-width: 560px) {
.maincontainer {
grid-template-columns: repeat(2, 1fr);
gap: 4px;
}
} }
.itemBox { .itemBox {
padding: 16px; padding: 12px 8px;
text-align: center; text-align: center;
border-right: 1px solid; border-right: 1px solid var(--border, hsl(0 0% 18%));
border-image: radial-gradient(circle, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 100%) 1;
} }
.itemBox:last-child { .itemBox:last-child {
border-right: none; border-right: none;
} }
@media (max-width: 560px) {
.itemBox {
padding: 10px 8px;
border-right: none;
border-bottom: 1px solid var(--border, hsl(0 0% 18%));
}
.itemBox:nth-child(odd) {
border-right: 1px solid var(--border, hsl(0 0% 18%));
}
.itemBox:nth-last-child(-n+2) {
border-bottom: none;
}
}
`; `;
constructor() { constructor() {

View File

@@ -10,7 +10,7 @@ export class ConsentsoftwareTabs extends LitElement {
:host { :host {
display: block; display: block;
position: relative; position: relative;
border-bottom: 1px solid rgba(255, 255, 255, 0.1); background: var(--muted, hsl(0 0% 15%));
} }
.tabs { .tabs {
@@ -20,25 +20,34 @@ export class ConsentsoftwareTabs extends LitElement {
.tabs .tab { .tabs .tab {
text-align: center; text-align: center;
line-height: 3em; padding: 8px 0;
font-size: 0.8em;
font-weight: 500;
color: var(--muted-foreground, hsl(0 0% 64%));
cursor: pointer; cursor: pointer;
transition: color 0.15s ease;
} }
/* Media query for mobile devices: stack buttons vertically */ .tabs .tab:hover {
@media (max-width: 600px) { color: var(--foreground, hsl(0 0% 95%));
}
@media (max-width: 560px) {
.tabs .tab { .tabs .tab {
font-size: 0.8em; font-size: 0.75em;
padding: 6px 0;
} }
} }
.selector { .selector {
position: absolute; position: absolute;
width: calc(100% / 3); width: calc(100% / 3);
height: 1px; height: 2px;
left: 0; left: 0;
bottom: 0px; bottom: 0;
background: orange; background: var(--foreground, hsl(0 0% 95%));
transition: all 0.2s; transition: all 0.2s ease-out;
border-radius: 1px;
} }
`; `;

View File

@@ -12,9 +12,9 @@ export class ConsentsoftwareToggle extends LitElement {
public accessor selected = false; public accessor selected = false;
/** /**
* We always track the knobs left offset in `currentX`. * Knob position tracking (0 = off, maxTravel = on)
* - 0 => fully left * This is the travel distance, not absolute left position.
* - 30 => fully right * Actual left = padding + currentX
*/ */
private currentX = 0; private currentX = 0;
@@ -23,9 +23,14 @@ export class ConsentsoftwareToggle extends LitElement {
*/ */
private isDragging = false; private isDragging = false;
private hasDragged = false; private hasDragged = false;
private startX = 0; // pointerdown offset private startX = 0;
private readonly knobWidth = 30;
private readonly trackWidth = 60; // Toggle dimensions
private readonly trackWidth = 36;
private readonly trackHeight = 20;
private readonly knobSize = 14;
private readonly padding = 3; // padding from track edge to knob
private readonly maxTravel = 16; // trackWidth - knobSize - (2 * padding) = 36 - 14 - 6 = 16
public static styles = css` public static styles = css`
:host { :host {
@@ -34,28 +39,36 @@ export class ConsentsoftwareToggle extends LitElement {
} }
.label { .label {
margin-bottom: 16px; margin-bottom: 8px;
font-size: 0.8em;
font-weight: 500;
color: var(--muted-foreground, hsl(0 0% 64%));
} }
.toggle { .toggle {
user-select: none; /* helps avoid text selection on drag */ user-select: none;
} }
.toggleKnobArea { .toggleKnobArea {
position: relative; position: relative;
margin: auto; margin: auto;
height: 30px; height: 20px;
width: 60px; width: 36px;
border-radius: 20px; border-radius: 10px;
background: rgba(255, 255, 255, 0.1); background: var(--input, hsl(0 0% 15%));
border: 1px solid rgba(255, 255, 255, 0); border: 1px solid var(--border, hsl(0 0% 18%));
overflow: hidden; overflow: hidden;
transition: background 0.2s ease; transition: all 0.15s ease;
cursor: pointer; cursor: pointer;
} }
.toggleKnobArea:hover {
border-color: var(--ring, hsl(0 0% 30%));
}
:host([selected]) .toggleKnobArea { :host([selected]) .toggleKnobArea {
background: green; background: var(--primary, hsl(0 0% 98%));
border-color: var(--primary, hsl(0 0% 98%));
} }
.toggleKnobMover { .toggleKnobMover {
@@ -66,33 +79,36 @@ export class ConsentsoftwareToggle extends LitElement {
.toggleKnobInner { .toggleKnobInner {
position: absolute; position: absolute;
top: 0; top: 3px;
left: 0; width: 14px;
width: 30px; height: 14px;
height: 30px; border-radius: 7px;
border-radius: 15px; background: var(--muted-foreground, hsl(0 0% 64%));
background: rgba(255, 255, 255, 0.5); transition: left 0.15s ease, background 0.15s ease;
transition: left 0.2s ease, background 0.2s ease;
transform: scale(0.7);
/* Prevent scroll gestures on mobile */
touch-action: none; touch-action: none;
} }
.toggleKnobInner.dragging { .toggleKnobInner.dragging {
transition: background 0.2s ease; transition: background 0.15s ease;
} }
:host([selected]) .toggleKnobInner { :host([selected]) .toggleKnobInner {
background: white; background: var(--primary-foreground, hsl(0 0% 9%));
} }
:host([required]) .toggleKnobArea { :host([required]) .toggleKnobArea {
background: none; background: var(--muted, hsl(0 0% 15%));
border: 1px solid rgba(255, 255, 255, 0.1); border-color: var(--border, hsl(0 0% 18%));
opacity: 0.6;
cursor: not-allowed;
} }
:host([required]) .toggleKnobInner { :host([required]) .toggleKnobInner {
background: rgba(255, 255, 255, 0.1); background: var(--muted-foreground, hsl(0 0% 45%));
}
:host([required][selected]) .toggleKnobArea {
background: var(--muted-foreground, hsl(0 0% 45%));
} }
`; `;
@@ -110,7 +126,7 @@ export class ConsentsoftwareToggle extends LitElement {
<!-- The knob itself, with pointer events for dragging. --> <!-- The knob itself, with pointer events for dragging. -->
<div <div
class="toggleKnobInner" class="toggleKnobInner"
style="left: ${this.currentX}px;" style="left: ${this.padding + this.currentX}px;"
@pointerdown=${this.onPointerDown} @pointerdown=${this.onPointerDown}
@pointermove=${this.onPointerMove} @pointermove=${this.onPointerMove}
@pointerup=${this.onPointerUp} @pointerup=${this.onPointerUp}
@@ -127,13 +143,11 @@ export class ConsentsoftwareToggle extends LitElement {
*/ */
public async firstUpdated() { public async firstUpdated() {
if (this.required) { if (this.required) {
// If "required" => always selected
this.selected = true; this.selected = true;
this.currentX = this.knobWidth; // 30 this.currentX = this.maxTravel;
this.requestUpdate(); this.requestUpdate();
} else { } else {
// If not required, set knob to 0 or 30 depending on `selected` this.currentX = this.selected ? this.maxTravel : 0;
this.currentX = this.selected ? this.knobWidth : 0;
this.requestUpdate(); this.requestUpdate();
} }
} }
@@ -142,7 +156,6 @@ export class ConsentsoftwareToggle extends LitElement {
* CLICK HANDLER * CLICK HANDLER
*/ */
public async handleClick(event: MouseEvent) { public async handleClick(event: MouseEvent) {
// If the user truly dragged the knob, skip the normal click toggle.
if (this.isDragging || this.hasDragged) { if (this.isDragging || this.hasDragged) {
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
@@ -150,26 +163,23 @@ export class ConsentsoftwareToggle extends LitElement {
} }
if (this.required) { if (this.required) {
// small bounce from 30 -> 20 -> 30 // Small bounce animation for required toggles
this.currentX = this.knobWidth; // ensure at 30 this.currentX = this.maxTravel;
this.requestUpdate(); this.requestUpdate();
await new Promise((r) => setTimeout(r, 10)); await new Promise((r) => setTimeout(r, 10));
this.currentX = this.maxTravel - 3;
this.currentX = 20; // small bounce left
this.requestUpdate(); this.requestUpdate();
await delayFor(200); await delayFor(150);
this.currentX = this.maxTravel;
this.currentX = this.knobWidth; // back to 30
this.requestUpdate(); this.requestUpdate();
return; return;
} }
// Normal toggle if no drag & not required
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
this.selected = !this.selected; this.selected = !this.selected;
this.currentX = this.selected ? this.knobWidth : 0; // snap knob left(0) or right(30) this.currentX = this.selected ? this.maxTravel : 0;
this.requestUpdate(); this.requestUpdate();
this.dispatchEvent(new CustomEvent('toggle', { detail: { selected: this.selected } })); this.dispatchEvent(new CustomEvent('toggle', { detail: { selected: this.selected } }));
@@ -203,8 +213,8 @@ export class ConsentsoftwareToggle extends LitElement {
const toggleKnobInner: HTMLDivElement = this.shadowRoot.querySelector('.toggleKnobInner'); const toggleKnobInner: HTMLDivElement = this.shadowRoot.querySelector('.toggleKnobInner');
toggleKnobInner.classList.add('dragging'); toggleKnobInner.classList.add('dragging');
// Clamp // Clamp to valid travel range (0 to maxTravel)
this.currentX = Math.max(0, Math.min(newX, this.trackWidth - this.knobWidth)); this.currentX = Math.max(0, Math.min(newX, this.maxTravel));
this.requestUpdate(); this.requestUpdate();
} }
@@ -213,17 +223,17 @@ export class ConsentsoftwareToggle extends LitElement {
(event.target as HTMLElement).releasePointerCapture(event.pointerId); (event.target as HTMLElement).releasePointerCapture(event.pointerId);
this.isDragging = false; this.isDragging = false;
// If we didnt truly drag, pointerup does nothing; click handler handles toggling. // If we didn't truly drag, pointerup does nothing; click handler handles toggling.
if (!this.hasDragged) { if (!this.hasDragged) {
return; return;
} }
const toggleKnobInner: HTMLDivElement = this.shadowRoot.querySelector('.toggleKnobInner'); const toggleKnobInner: HTMLDivElement = this.shadowRoot.querySelector('.toggleKnobInner');
toggleKnobInner.classList.remove('dragging'); toggleKnobInner.classList.remove('dragging');
// Real drag => decide final side // Real drag => decide final side based on midpoint
const midpoint = (this.trackWidth - this.knobWidth) / 2; // 15 const midpoint = this.maxTravel / 2;
this.selected = this.currentX > midpoint; this.selected = this.currentX > midpoint;
this.currentX = this.selected ? this.knobWidth : 0; // snap to edge this.currentX = this.selected ? this.maxTravel : 0; // snap to edge
this.requestUpdate(); this.requestUpdate();
// Dispatch toggle event // Dispatch toggle event
@@ -243,7 +253,7 @@ export class ConsentsoftwareToggle extends LitElement {
!this.hasDragged && !this.hasDragged &&
!this.required !this.required
) { ) {
this.currentX = this.selected ? this.knobWidth : 0; this.currentX = this.selected ? this.maxTravel : 0;
this.requestUpdate(); this.requestUpdate();
} }
super.updated(changedProperties); super.updated(changedProperties);