diff --git a/demo/index.html b/demo/index.html index bf93682..be2ab63 100644 --- a/demo/index.html +++ b/demo/index.html @@ -5,6 +5,7 @@ vcf-toggle-button demo + - - -`; - -document.head.appendChild(template.content); - -const theme = document.createElement('dom-module'); -theme.id = 'vcf-toggle-button-lumo'; -theme.setAttribute('theme-for', 'vcf-toggle-button'); -theme.innerHTML = ` - - `; -theme.register(theme.id); +import { css, registerStyles } from '@vaadin/vaadin-themable-mixin'; + +registerStyles( + 'vaadin-checkbox', + css` + :host(.toggle-button) [part='checkbox'] { + width: calc(1.5em * 2 - 12px); + height: 1.5em; + border-radius: 0.75em; + background-color: var(--lumo-contrast-40pct); + margin: 0; + } + + :host(.toggle-button[disabled]) [part='checkbox'] { + background-color: var(--lumo-contrast-20pct); + } + + :host(.toggle-button) [part='checkbox']::after { + border-radius: 50%; + content: ''; + width: calc(1.5rem - 4px); + height: calc(1.5rem - 4px); + top: 2px; + left: 2px; + background-color: var(--lumo-primary-contrast-color); + border: none; + transform: none; + opacity: 1; + transition: transform 0.2s ease; + } + + :host(.toggle-button[checked]) [part='checkbox'] { + background-color: var(--lumo-primary-color); + } + + :host(.toggle-button[checked][disabled]) [part='checkbox'] { + background-color: var(--lumo-primary-color-50pct); + } + + :host(.toggle-button[active]) [part='checkbox'] { + transform: none; + } + + :host(.toggle-button[checked]) [part='checkbox']::after { + transform: translate(calc(100% - 8px)); + } + ` +);