Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 777acd06a5 | |||
| 0d90a7ae7f | |||
| 0b366b360d |
10
changelog.md
10
changelog.md
@@ -1,5 +1,15 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-11-30 - 2.0.0 - BREAKING CHANGE(elements)
|
||||||
|
Migrate web components to @design.estate/dees-element, introduce shared theme colors and cssManager, and update imports/usages across ts_web.
|
||||||
|
|
||||||
|
- Replaced direct lit usage with @design.estate/dees-element across the project (imports and base classes).
|
||||||
|
- Added cssManager export and a Shadcn-inspired color palette (colors) in ts_web/elements/shared.ts to centralize theming.
|
||||||
|
- Updated all components to extend DeesElement and include cssManager.defaultStyles in their static styles.
|
||||||
|
- Adjusted lifecycle and event typings (firstUpdated signatures, pointer/mouse event typing) and minor behaviour refinements in consentsoftware-toggle (drag handling, sync logic).
|
||||||
|
- Updated package.json dependencies to remove 'lit' and add '@design.estate/dees-element'.
|
||||||
|
- Updated page imports (ts_web/pages/page1.ts) to use the new html export from @design.estate/dees-element.
|
||||||
|
|
||||||
## 2025-11-30 - 1.6.1 - fix(build)
|
## 2025-11-30 - 1.6.1 - fix(build)
|
||||||
Update TypeScript config and build tooling; use accessor for Lit properties; bump deps and adjust package metadata
|
Update TypeScript config and build tooling; use accessor for Lit properties; bump deps and adjust package metadata
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@consent.software/catalog",
|
"name": "@consent.software/catalog",
|
||||||
"version": "1.6.1",
|
"version": "2.0.0",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "A library of web components designed to integrate robust consent management capabilities into web applications, ensuring compliance with privacy regulations.",
|
"description": "A library of web components designed to integrate robust consent management capabilities into web applications, ensuring compliance with privacy regulations.",
|
||||||
"exports": {
|
"exports": {
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@consent.software/interfaces": "^1.0.14",
|
"@consent.software/interfaces": "^1.0.14",
|
||||||
"@consent.software/webclient": "^1.1.0",
|
"@consent.software/webclient": "^1.1.0",
|
||||||
"@push.rocks/smartdelay": "^3.0.5",
|
"@design.estate/dees-element": "^2.1.3",
|
||||||
"lit": "^3.3.1"
|
"@push.rocks/smartdelay": "^3.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@design.estate/dees-wcctools": "^1.2.1",
|
"@design.estate/dees-wcctools": "^1.2.1",
|
||||||
|
|||||||
69
pnpm-lock.yaml
generated
69
pnpm-lock.yaml
generated
@@ -14,12 +14,12 @@ importers:
|
|||||||
'@consent.software/webclient':
|
'@consent.software/webclient':
|
||||||
specifier: ^1.1.0
|
specifier: ^1.1.0
|
||||||
version: 1.1.0
|
version: 1.1.0
|
||||||
|
'@design.estate/dees-element':
|
||||||
|
specifier: ^2.1.3
|
||||||
|
version: 2.1.3
|
||||||
'@push.rocks/smartdelay':
|
'@push.rocks/smartdelay':
|
||||||
specifier: ^3.0.5
|
specifier: ^3.0.5
|
||||||
version: 3.0.5
|
version: 3.0.5
|
||||||
lit:
|
|
||||||
specifier: ^3.3.1
|
|
||||||
version: 3.3.1
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@design.estate/dees-wcctools':
|
'@design.estate/dees-wcctools':
|
||||||
specifier: ^1.2.1
|
specifier: ^1.2.1
|
||||||
@@ -236,15 +236,9 @@ packages:
|
|||||||
'@design.estate/dees-comms@1.0.27':
|
'@design.estate/dees-comms@1.0.27':
|
||||||
resolution: {integrity: sha512-GvzTUwkV442LD60T08iqSoqvhA02Mou5lFvvqBPc4yBUiU7cZISqBx+76xvMgMIEI9Dx9JfTl4/2nW8MoVAanw==}
|
resolution: {integrity: sha512-GvzTUwkV442LD60T08iqSoqvhA02Mou5lFvvqBPc4yBUiU7cZISqBx+76xvMgMIEI9Dx9JfTl4/2nW8MoVAanw==}
|
||||||
|
|
||||||
'@design.estate/dees-domtools@2.1.1':
|
|
||||||
resolution: {integrity: sha512-ZYe7rt2pOWZ6av4YDc88i+Li9WquOHuvE4Xyf+Wo9jAZ37XyTw53wzzviaW3zDG77ggX2VlCLFkAs8Tm5Lf4gg==}
|
|
||||||
|
|
||||||
'@design.estate/dees-domtools@2.3.6':
|
'@design.estate/dees-domtools@2.3.6':
|
||||||
resolution: {integrity: sha512-cKaPNtSpp/ZuuXVx2dXO3K2FU3/HjC4ZkqtXb8Kl6yy9rNDbgtjcI4PuOk9Ux1SJzw7FgcxqVh7OSEV60htbmg==}
|
resolution: {integrity: sha512-cKaPNtSpp/ZuuXVx2dXO3K2FU3/HjC4ZkqtXb8Kl6yy9rNDbgtjcI4PuOk9Ux1SJzw7FgcxqVh7OSEV60htbmg==}
|
||||||
|
|
||||||
'@design.estate/dees-element@2.0.39':
|
|
||||||
resolution: {integrity: sha512-AQdGU/+GmWmU5M5pDf+GWT7GU8UN073WZvtIkfqQZemxd35HYU1vpi629m8/PjKd5dIHAU7QN2mKb6IQ8anPgw==}
|
|
||||||
|
|
||||||
'@design.estate/dees-element@2.1.3':
|
'@design.estate/dees-element@2.1.3':
|
||||||
resolution: {integrity: sha512-TjXWxVcdSPaT1IOk31ckfxvAZnJLuTxhFGsNCKoh63/UE2FVf6slp8//UFvN+ADigiA9ZsY0azkY99XbJCwDDA==}
|
resolution: {integrity: sha512-TjXWxVcdSPaT1IOk31ckfxvAZnJLuTxhFGsNCKoh63/UE2FVf6slp8//UFvN+ADigiA9ZsY0azkY99XbJCwDDA==}
|
||||||
|
|
||||||
@@ -820,9 +814,6 @@ packages:
|
|||||||
'@push.rocks/smartrequest@4.4.2':
|
'@push.rocks/smartrequest@4.4.2':
|
||||||
resolution: {integrity: sha512-Om4y1Ce4YdSu8VoXREz2SgFz9pDxcFEm0+SC1YYa3RXd0AH2Mknaj/1XfvfMqojnK9L7N2z1fY4xX8tO1IwqFQ==}
|
resolution: {integrity: sha512-Om4y1Ce4YdSu8VoXREz2SgFz9pDxcFEm0+SC1YYa3RXd0AH2Mknaj/1XfvfMqojnK9L7N2z1fY4xX8tO1IwqFQ==}
|
||||||
|
|
||||||
'@push.rocks/smartrouter@1.3.2':
|
|
||||||
resolution: {integrity: sha512-JtkxClN4CaHXMSeLDNvfWPwiVEPdEoQVSX2ee3gLgbXNO9dt9hvXdIhFrnFeLwyeA6M8nJdb9SqjrjZroYJsxw==}
|
|
||||||
|
|
||||||
'@push.rocks/smartrouter@1.3.3':
|
'@push.rocks/smartrouter@1.3.3':
|
||||||
resolution: {integrity: sha512-1+xZEnWlhzqLWAaJ1zFNhQ0zgbfCWQl1DBT72LygLxTs+P0K8AwJKgqo/IX6CT55kGCFnPAZIYSbVJlGsgrB0w==}
|
resolution: {integrity: sha512-1+xZEnWlhzqLWAaJ1zFNhQ0zgbfCWQl1DBT72LygLxTs+P0K8AwJKgqo/IX6CT55kGCFnPAZIYSbVJlGsgrB0w==}
|
||||||
|
|
||||||
@@ -847,9 +838,6 @@ packages:
|
|||||||
'@push.rocks/smartspawn@3.0.3':
|
'@push.rocks/smartspawn@3.0.3':
|
||||||
resolution: {integrity: sha512-DyrGPV69wwOiJgKkyruk5hS3UEGZ99xFAqBE9O2nM8VXCRLbbty3xt1Ug5Z092ZZmJYaaGMSnMw3ijyZJFCT0Q==}
|
resolution: {integrity: sha512-DyrGPV69wwOiJgKkyruk5hS3UEGZ99xFAqBE9O2nM8VXCRLbbty3xt1Ug5Z092ZZmJYaaGMSnMw3ijyZJFCT0Q==}
|
||||||
|
|
||||||
'@push.rocks/smartstate@2.0.19':
|
|
||||||
resolution: {integrity: sha512-Rx2/2n8YaSBW6b4Ww+lYceq5dwkD+QzcnRwAjQDXlsEe8K+KU2T6revTZyf9PchBoC9pNFaAJofIZNebEGMzYA==}
|
|
||||||
|
|
||||||
'@push.rocks/smartstate@2.0.27':
|
'@push.rocks/smartstate@2.0.27':
|
||||||
resolution: {integrity: sha512-q4UKir7GV3hakJWXQR4DoA4tUVwT5GRkJ/MtanHYF0wZLHfS19+nGmyO9y974zk3eT9hmy3+Lq5cKtU2W6+Y3w==}
|
resolution: {integrity: sha512-q4UKir7GV3hakJWXQR4DoA4tUVwT5GRkJ/MtanHYF0wZLHfS19+nGmyO9y974zk3eT9hmy3+Lq5cKtU2W6+Y3w==}
|
||||||
|
|
||||||
@@ -3774,28 +3762,6 @@ snapshots:
|
|||||||
'@push.rocks/smartdelay': 3.0.5
|
'@push.rocks/smartdelay': 3.0.5
|
||||||
broadcast-channel: 7.0.0
|
broadcast-channel: 7.0.0
|
||||||
|
|
||||||
'@design.estate/dees-domtools@2.1.1':
|
|
||||||
dependencies:
|
|
||||||
'@api.global/typedrequest': 3.1.10
|
|
||||||
'@design.estate/dees-comms': 1.0.27
|
|
||||||
'@push.rocks/lik': 6.2.2
|
|
||||||
'@push.rocks/smartdelay': 3.0.5
|
|
||||||
'@push.rocks/smartjson': 5.2.0
|
|
||||||
'@push.rocks/smartmarkdown': 3.0.3
|
|
||||||
'@push.rocks/smartpromise': 4.2.3
|
|
||||||
'@push.rocks/smartrouter': 1.3.2
|
|
||||||
'@push.rocks/smartrx': 3.0.10
|
|
||||||
'@push.rocks/smartstate': 2.0.19
|
|
||||||
'@push.rocks/smartstring': 4.0.15
|
|
||||||
'@push.rocks/smarturl': 3.1.0
|
|
||||||
'@push.rocks/webrequest': 3.0.37
|
|
||||||
'@push.rocks/websetup': 3.0.19
|
|
||||||
'@push.rocks/webstore': 2.0.20
|
|
||||||
lit: 3.3.1
|
|
||||||
sweet-scroll: 4.0.0
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- supports-color
|
|
||||||
|
|
||||||
'@design.estate/dees-domtools@2.3.6':
|
'@design.estate/dees-domtools@2.3.6':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@api.global/typedrequest': 3.1.10
|
'@api.global/typedrequest': 3.1.10
|
||||||
@@ -3822,15 +3788,6 @@ snapshots:
|
|||||||
- supports-color
|
- supports-color
|
||||||
- vue
|
- vue
|
||||||
|
|
||||||
'@design.estate/dees-element@2.0.39':
|
|
||||||
dependencies:
|
|
||||||
'@design.estate/dees-domtools': 2.1.1
|
|
||||||
'@push.rocks/isounique': 1.0.5
|
|
||||||
'@push.rocks/smartrx': 3.0.10
|
|
||||||
lit: 3.3.1
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- supports-color
|
|
||||||
|
|
||||||
'@design.estate/dees-element@2.1.3':
|
'@design.estate/dees-element@2.1.3':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@design.estate/dees-domtools': 2.3.6
|
'@design.estate/dees-domtools': 2.3.6
|
||||||
@@ -4547,12 +4504,15 @@ snapshots:
|
|||||||
|
|
||||||
'@push.rocks/smartntml@2.0.8':
|
'@push.rocks/smartntml@2.0.8':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@design.estate/dees-element': 2.0.39
|
'@design.estate/dees-element': 2.1.3
|
||||||
'@happy-dom/global-registrator': 15.11.7
|
'@happy-dom/global-registrator': 15.11.7
|
||||||
'@push.rocks/smartpromise': 4.2.3
|
'@push.rocks/smartpromise': 4.2.3
|
||||||
fake-indexeddb: 6.0.0
|
fake-indexeddb: 6.0.0
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@nuxt/kit'
|
||||||
|
- react
|
||||||
- supports-color
|
- supports-color
|
||||||
|
- vue
|
||||||
|
|
||||||
'@push.rocks/smartobject@1.0.12':
|
'@push.rocks/smartobject@1.0.12':
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -4598,12 +4558,6 @@ snapshots:
|
|||||||
agentkeepalive: 4.6.0
|
agentkeepalive: 4.6.0
|
||||||
form-data: 4.0.5
|
form-data: 4.0.5
|
||||||
|
|
||||||
'@push.rocks/smartrouter@1.3.2':
|
|
||||||
dependencies:
|
|
||||||
'@push.rocks/lik': 6.2.2
|
|
||||||
'@push.rocks/smartrx': 3.0.10
|
|
||||||
path-to-regexp: 8.2.0
|
|
||||||
|
|
||||||
'@push.rocks/smartrouter@1.3.3':
|
'@push.rocks/smartrouter@1.3.3':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@push.rocks/lik': 6.2.2
|
'@push.rocks/lik': 6.2.2
|
||||||
@@ -4677,15 +4631,6 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@push.rocks/smartstate@2.0.19':
|
|
||||||
dependencies:
|
|
||||||
'@push.rocks/isohash': 2.0.1
|
|
||||||
'@push.rocks/lik': 6.2.2
|
|
||||||
'@push.rocks/smartjson': 5.2.0
|
|
||||||
'@push.rocks/smartpromise': 4.2.3
|
|
||||||
'@push.rocks/smartrx': 3.0.10
|
|
||||||
'@push.rocks/webstore': 2.0.20
|
|
||||||
|
|
||||||
'@push.rocks/smartstate@2.0.27':
|
'@push.rocks/smartstate@2.0.27':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@push.rocks/lik': 6.2.2
|
'@push.rocks/lik': 6.2.2
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@consent.software/catalog',
|
name: '@consent.software/catalog',
|
||||||
version: '1.6.1',
|
version: '2.0.0',
|
||||||
description: 'A library of web components designed to integrate robust consent management capabilities into web applications, ensuring compliance with privacy regulations.'
|
description: 'A library of web components designed to integrate robust consent management capabilities into web applications, ensuring compliance with privacy regulations.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
import * as shared from './shared.js';
|
import { cssManager, colors } from './shared.js';
|
||||||
|
|
||||||
import { LitElement, html, css, type TemplateResult } from 'lit';
|
import {
|
||||||
import { customElement } from 'lit/decorators.js';
|
DeesElement,
|
||||||
import { property } from 'lit/decorators/property.js';
|
customElement,
|
||||||
|
html,
|
||||||
|
css,
|
||||||
|
type TemplateResult,
|
||||||
|
property,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
import * as csInterfaces from '@consent.software/interfaces';
|
import * as csInterfaces from '@consent.software/interfaces';
|
||||||
import * as csWebclient from '@consent.software/webclient';
|
import * as csWebclient from '@consent.software/webclient';
|
||||||
@@ -15,211 +20,158 @@ declare global {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@customElement('consentsoftware-cookieconsent')
|
@customElement('consentsoftware-cookieconsent')
|
||||||
export class ConsentsoftwareCookieconsent extends LitElement {
|
export class ConsentsoftwareCookieconsent extends DeesElement {
|
||||||
public static demo = () => html`<consentsoftware-cookieconsent></consentsoftware-cookieconsent>`;
|
public static demo = () => html`<consentsoftware-cookieconsent></consentsoftware-cookieconsent>`;
|
||||||
|
|
||||||
public csWebclientInstance = new csWebclient.CsWebclient();
|
public csWebclientInstance = new csWebclient.CsWebclient();
|
||||||
public csWebclientRan = false;
|
public csWebclientRan = false;
|
||||||
|
|
||||||
// Reflects the current theme ('light' or 'dark')
|
public static styles = [
|
||||||
@property({ type: String, reflect: true })
|
cssManager.defaultStyles,
|
||||||
public accessor theme: 'light' | 'dark' = 'light';
|
css`
|
||||||
|
|
||||||
/**
|
|
||||||
* Define component styles with CSS variables that adjust based on theme.
|
|
||||||
* The default variables serve as baseline for the light theme.
|
|
||||||
* Theme-specific overrides modify these for dark mode.
|
|
||||||
*/
|
|
||||||
public static styles = css`
|
|
||||||
:host {
|
:host {
|
||||||
font-family: ${shared.fontStack};
|
font-size: 14px;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
/* Default variables for Light Theme */
|
|
||||||
--text-color: #333;
|
|
||||||
--background-color: #eeeeee;
|
|
||||||
--accent-color: #333333;
|
|
||||||
--button-bg: #ffffff;
|
|
||||||
--button-hover-bg: #f2f2f2;
|
|
||||||
--icon-color: #4496f5;
|
|
||||||
--link-color: #333;
|
|
||||||
--padding-sides: 16px;
|
|
||||||
/* Additional variables for modal and info container styling */
|
|
||||||
--info-bg: rgba(0, 0, 0, 0.1);
|
|
||||||
--info-text: rgba(255, 255, 255, 0.5);
|
|
||||||
--modal-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dark Theme Overrides:
|
|
||||||
When theme attribute is 'dark', override variables accordingly. */
|
|
||||||
:host([theme='dark']) {
|
|
||||||
--text-color: #fff;
|
|
||||||
--background-color: #111;
|
|
||||||
--accent-color: #333333;
|
|
||||||
--button-bg: #252525;
|
|
||||||
--button-hover-bg: #222222;
|
|
||||||
--icon-color: #4496f5;
|
|
||||||
--link-color: #fff;
|
|
||||||
--info-bg: rgba(0, 0, 0, 0.1);
|
|
||||||
--info-text: rgba(255, 255, 255, 0.5);
|
|
||||||
--modal-box-shadow: 0px 0px 8px rgba(255, 255, 255, 0.6);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Light Theme Overrides:
|
|
||||||
Explicit light theme settings, currently matching defaults.
|
|
||||||
Can be customized independently if desired. */
|
|
||||||
:host([theme='light']) {
|
|
||||||
--text-color: #333;
|
|
||||||
--background-color: #eeeeee;
|
|
||||||
--accent-color: #333333;
|
|
||||||
--button-bg: #ffffff;
|
|
||||||
--button-hover-bg: #f2f2f2;
|
|
||||||
--icon-color: #4496f5;
|
|
||||||
--link-color: #333;
|
|
||||||
--info-bg: rgba(0, 0, 0, 0.1);
|
|
||||||
--info-text: rgba(0, 0, 0, 0.5);
|
|
||||||
--modal-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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: ${cssManager.bdTheme(colors.light.foreground, colors.dark.foreground)};
|
||||||
background: var(--background-color);
|
background: ${cssManager.bdTheme(colors.light.background, colors.dark.background)};
|
||||||
box-shadow: var(--modal-box-shadow);
|
box-shadow:
|
||||||
|
0 0 0 1px ${cssManager.bdTheme(colors.light.border, colors.dark.border)},
|
||||||
|
0 16px 70px ${cssManager.bdTheme('rgba(0, 0, 0, 0.15)', 'rgba(0, 0, 0, 0.35)')};
|
||||||
position: relative;
|
position: relative;
|
||||||
border: 1px dotted rgba(255, 255, 255, 0.1);
|
border-radius: 8px;
|
||||||
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: ${cssManager.bdTheme(colors.light.mutedForeground, colors.dark.mutedForeground)};
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-container a {
|
.text-container a {
|
||||||
color: var(--link-color);
|
color: ${cssManager.bdTheme(colors.light.foreground, colors.dark.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: 6px;
|
||||||
background: var(--button-bg);
|
background: ${cssManager.bdTheme(colors.light.secondary, colors.dark.secondary)};
|
||||||
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2);
|
border: 1px solid ${cssManager.bdTheme(colors.light.border, colors.dark.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: ${cssManager.bdTheme(colors.light.secondaryForeground, colors.dark.secondaryForeground)};
|
||||||
}
|
}
|
||||||
|
|
||||||
.consent-button:hover {
|
.consent-button:hover {
|
||||||
background: var(--button-hover-bg);
|
background: ${cssManager.bdTheme(colors.light.accent, colors.dark.accent)};
|
||||||
|
border-color: ${cssManager.bdTheme(colors.light.ring, colors.dark.ring)};
|
||||||
|
}
|
||||||
|
|
||||||
|
.consent-button:last-child {
|
||||||
|
background: ${cssManager.bdTheme(colors.light.primary, colors.dark.primary)};
|
||||||
|
color: ${cssManager.bdTheme(colors.light.primaryForeground, colors.dark.primaryForeground)};
|
||||||
|
border-color: ${cssManager.bdTheme(colors.light.primary, colors.dark.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: ${cssManager.bdTheme(colors.light.muted, colors.dark.muted)};
|
||||||
border-top: 1px dotted rgba(255, 255, 255, 0.1);
|
border-top: 1px solid ${cssManager.bdTheme(colors.light.border, colors.dark.border)};
|
||||||
font-size: 0.8em;
|
font-size: 0.75em;
|
||||||
color: var(--info-text);
|
color: ${cssManager.bdTheme(colors.light.mutedForeground, colors.dark.mutedForeground)};
|
||||||
}
|
}
|
||||||
|
|
||||||
.info-container a {
|
.info-container a {
|
||||||
text-decoration: underline;
|
color: ${cssManager.bdTheme(colors.light.foreground, colors.dark.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;
|
||||||
}
|
}
|
||||||
`;
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@@ -234,11 +186,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>
|
||||||
@@ -277,23 +229,22 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Lifecycle method called when the element is connected to the DOM.
|
* Lifecycle method called when the element is connected to the DOM.
|
||||||
* It sets up the theme and displays the consent banner if no cookie levels are set.
|
* Displays the consent banner if no cookie levels are set.
|
||||||
*/
|
*/
|
||||||
public async connectedCallback() {
|
public async connectedCallback() {
|
||||||
super.connectedCallback();
|
await super.connectedCallback();
|
||||||
this.updateTheme(); // Initialize theme based on system preference
|
|
||||||
|
|
||||||
const cookieLevel = await this.csWebclientInstance.getCookieLevels();
|
const cookieLevel = await this.csWebclientInstance.getCookieLevels();
|
||||||
if (!cookieLevel) {
|
if (!cookieLevel) {
|
||||||
// Show consent banner if cookie levels haven't been set yet
|
// Show consent banner if cookie levels haven't been set yet
|
||||||
this.setAttribute('show', 'true');
|
this.setAttribute('show', 'true');
|
||||||
requestAnimationFrame(async () => {
|
requestAnimationFrame(async () => {
|
||||||
await this.updated();
|
await this.updateComplete;
|
||||||
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) {
|
||||||
@@ -309,14 +260,7 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async firstUpdated() {
|
public async firstUpdated() {
|
||||||
// Placeholder for any logic needed after first render
|
// Run consent scripts if levels are already set
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called after updates. Logs banner height and runs consent scripts if necessary.
|
|
||||||
*/
|
|
||||||
public async updated() {
|
|
||||||
console.log(`The height of the cookie banner is ${this.shadowRoot?.host?.clientHeight}px`);
|
|
||||||
const acceptedCookieLevels = await this.csWebclientInstance.getCookieLevels();
|
const acceptedCookieLevels = await this.csWebclientInstance.getCookieLevels();
|
||||||
if (!this.csWebclientRan && acceptedCookieLevels) {
|
if (!this.csWebclientRan && acceptedCookieLevels) {
|
||||||
this.csWebclientRan = true;
|
this.csWebclientRan = true;
|
||||||
@@ -326,7 +270,6 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles consent button clicks, sets cookie levels, and hides the banner.
|
* Handles consent button clicks, sets cookie levels, and hides the banner.
|
||||||
* Uses theme variables for styling transitions.
|
|
||||||
*/
|
*/
|
||||||
private async handleConsentButtonClick(
|
private async handleConsentButtonClick(
|
||||||
event: MouseEvent,
|
event: MouseEvent,
|
||||||
@@ -335,8 +278,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');
|
||||||
@@ -349,7 +291,12 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|||||||
await this.csWebclientInstance.setCookieLevels(levelsArg);
|
await this.csWebclientInstance.setCookieLevels(levelsArg);
|
||||||
await delayFor(300);
|
await delayFor(300);
|
||||||
this.setAttribute('show', 'false'); // Hide the consent banner
|
this.setAttribute('show', 'false'); // Hide the consent banner
|
||||||
this.updated(); // Trigger any post-consent actions
|
|
||||||
|
// Run consent scripts
|
||||||
|
if (!this.csWebclientRan) {
|
||||||
|
this.csWebclientRan = true;
|
||||||
|
await this.csWebclientInstance.getAndRunConsentTuples();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -369,19 +316,4 @@ export class ConsentsoftwareCookieconsent extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Dynamically switches the theme between light and dark.
|
|
||||||
* Listens for system theme changes to update the component's theme.
|
|
||||||
*/
|
|
||||||
private updateTheme() {
|
|
||||||
// Check the initial system preference for dark mode
|
|
||||||
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
||||||
this.theme = prefersDark ? 'dark' : 'light';
|
|
||||||
|
|
||||||
// Listen for changes in the system color scheme preference
|
|
||||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
|
|
||||||
this.theme = e.matches ? 'dark' : 'light';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +1,52 @@
|
|||||||
import * as shared from './shared.js';
|
import { cssManager, colors } from './shared.js';
|
||||||
|
|
||||||
import { LitElement, html, css, type TemplateResult } from 'lit';
|
import {
|
||||||
import { customElement } from 'lit/decorators.js';
|
DeesElement,
|
||||||
import { property } from 'lit/decorators/property.js';
|
customElement,
|
||||||
|
html,
|
||||||
|
css,
|
||||||
|
type TemplateResult,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
@customElement('consentsoftware-header')
|
@customElement('consentsoftware-header')
|
||||||
export class ConsentsoftwareHeader extends LitElement {
|
export class ConsentsoftwareHeader extends DeesElement {
|
||||||
public static demo = () => html`<consentsoftware-tabs></consentsoftware-tabs>`;
|
public static demo = () => html`<consentsoftware-header></consentsoftware-header>`;
|
||||||
|
|
||||||
public static styles = css`
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
line-height: 3em;
|
padding: 14px 16px;
|
||||||
text-align: center;
|
border-bottom: 1px solid ${cssManager.bdTheme(colors.light.border, colors.dark.border)};
|
||||||
font-family: ${shared.fontStack};
|
|
||||||
border-bottom: 1px dotted rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.heading {
|
.heading {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
font-size: 0.95em;
|
||||||
|
font-weight: 600;
|
||||||
|
color: ${cssManager.bdTheme(colors.light.foreground, colors.dark.foreground)};
|
||||||
}
|
}
|
||||||
`;
|
|
||||||
|
|
||||||
constructor() {
|
.icon {
|
||||||
super();
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
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>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
import { LitElement, html, css, type TemplateResult } from 'lit';
|
import { cssManager, colors } from './shared.js';
|
||||||
import { customElement } from 'lit/decorators.js';
|
|
||||||
import { property } from 'lit/decorators/property.js';
|
import {
|
||||||
|
DeesElement,
|
||||||
|
customElement,
|
||||||
|
html,
|
||||||
|
css,
|
||||||
|
type TemplateResult,
|
||||||
|
property,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
@customElement('consentsoftware-mainselection')
|
@customElement('consentsoftware-mainselection')
|
||||||
export class ConsentsoftwareMainSelection extends LitElement {
|
export class ConsentsoftwareMainSelection extends DeesElement {
|
||||||
public static demo = () => html`<consentsoftware-mainselection></consentsoftware-mainselection>`;
|
public static demo = () => html`<consentsoftware-mainselection></consentsoftware-mainselection>`;
|
||||||
|
|
||||||
@property({ type: Boolean })
|
@property({ type: Boolean })
|
||||||
@@ -12,7 +19,9 @@ export class ConsentsoftwareMainSelection extends LitElement {
|
|||||||
@property({ type: Boolean })
|
@property({ type: Boolean })
|
||||||
public accessor selected = false;
|
public accessor selected = false;
|
||||||
|
|
||||||
public static styles = css`
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -21,23 +30,44 @@ 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 ${cssManager.bdTheme(colors.light.border, colors.dark.border)};
|
||||||
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;
|
||||||
}
|
}
|
||||||
`;
|
|
||||||
|
|
||||||
constructor() {
|
@media (max-width: 560px) {
|
||||||
super();
|
.itemBox {
|
||||||
|
padding: 10px 8px;
|
||||||
|
border-right: none;
|
||||||
|
border-bottom: 1px solid ${cssManager.bdTheme(colors.light.border, colors.dark.border)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.itemBox:nth-child(odd) {
|
||||||
|
border-right: 1px solid ${cssManager.bdTheme(colors.light.border, colors.dark.border)};
|
||||||
|
}
|
||||||
|
|
||||||
|
.itemBox:nth-last-child(-n+2) {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
public render(): TemplateResult {
|
public render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<div class="maincontainer">
|
<div class="maincontainer">
|
||||||
@@ -57,5 +87,5 @@ export class ConsentsoftwareMainSelection extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getResults(mouseEvent) {}
|
public async getResults() {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,24 @@
|
|||||||
import { LitElement, html, css, type TemplateResult } from 'lit';
|
import { cssManager, colors } from './shared.js';
|
||||||
import { customElement } from 'lit/decorators.js';
|
|
||||||
import { property } from 'lit/decorators/property.js';
|
import {
|
||||||
|
DeesElement,
|
||||||
|
customElement,
|
||||||
|
html,
|
||||||
|
css,
|
||||||
|
type TemplateResult,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
@customElement('consentsoftware-tabs')
|
@customElement('consentsoftware-tabs')
|
||||||
export class ConsentsoftwareTabs extends LitElement {
|
export class ConsentsoftwareTabs extends DeesElement {
|
||||||
public static demo = () => html`<consentsoftware-tabs></consentsoftware-tabs>`;
|
public static demo = () => html`<consentsoftware-tabs></consentsoftware-tabs>`;
|
||||||
|
|
||||||
public static styles = css`
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
position: relative;
|
position: relative;
|
||||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
background: ${cssManager.bdTheme(colors.light.muted, colors.dark.muted)};
|
||||||
}
|
}
|
||||||
|
|
||||||
.tabs {
|
.tabs {
|
||||||
@@ -20,31 +28,37 @@ 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: ${cssManager.bdTheme(colors.light.mutedForeground, colors.dark.mutedForeground)};
|
||||||
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: ${cssManager.bdTheme(colors.light.foreground, colors.dark.foreground)};
|
||||||
|
}
|
||||||
|
|
||||||
|
@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: ${cssManager.bdTheme(colors.light.foreground, colors.dark.foreground)};
|
||||||
transition: all 0.2s;
|
transition: all 0.2s ease-out;
|
||||||
}
|
border-radius: 1px;
|
||||||
`;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
}
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
public render(): TemplateResult {
|
public render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
@@ -57,7 +71,7 @@ export class ConsentsoftwareTabs extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async handleClick(mouseEvent) {
|
public async handleClick(mouseEvent: MouseEvent) {
|
||||||
const target = mouseEvent.target as HTMLElement;
|
const target = mouseEvent.target as HTMLElement;
|
||||||
const tab: HTMLDivElement = target.closest('.tab');
|
const tab: HTMLDivElement = target.closest('.tab');
|
||||||
if (tab) {
|
if (tab) {
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
import { LitElement, html, css, type TemplateResult } from 'lit';
|
import { cssManager, colors } from './shared.js';
|
||||||
import { customElement } from 'lit/decorators.js';
|
|
||||||
import { property } from 'lit/decorators/property.js';
|
import {
|
||||||
|
DeesElement,
|
||||||
|
customElement,
|
||||||
|
html,
|
||||||
|
css,
|
||||||
|
type TemplateResult,
|
||||||
|
property,
|
||||||
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
import { delayFor } from '@push.rocks/smartdelay';
|
import { delayFor } from '@push.rocks/smartdelay';
|
||||||
|
|
||||||
@customElement('consentsoftware-toggle')
|
@customElement('consentsoftware-toggle')
|
||||||
export class ConsentsoftwareToggle extends LitElement {
|
export class ConsentsoftwareToggle extends DeesElement {
|
||||||
@property({ type: Boolean })
|
@property({ type: Boolean })
|
||||||
public accessor required = false;
|
public accessor required = false;
|
||||||
|
|
||||||
@@ -12,9 +20,9 @@ export class ConsentsoftwareToggle extends LitElement {
|
|||||||
public accessor selected = false;
|
public accessor selected = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We always track the knob’s 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,39 +31,54 @@ 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;
|
|
||||||
|
|
||||||
public static styles = css`
|
// Toggle dimensions (with border-box, 1px border reduces inner by 2px)
|
||||||
|
private readonly trackWidth = 36; // outer width
|
||||||
|
private readonly trackHeight = 20; // outer height
|
||||||
|
private readonly knobSize = 14;
|
||||||
|
private readonly padding = 2; // padding from inner edge to knob
|
||||||
|
private readonly maxTravel = 16; // (36 - 2) - 14 - (2 * 2) = 34 - 14 - 4 = 16
|
||||||
|
|
||||||
|
public static styles = [
|
||||||
|
cssManager.defaultStyles,
|
||||||
|
css`
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 8px;
|
||||||
|
font-size: 0.8em;
|
||||||
|
font-weight: 500;
|
||||||
|
color: ${cssManager.bdTheme(colors.light.mutedForeground, colors.dark.mutedForeground)};
|
||||||
}
|
}
|
||||||
|
|
||||||
.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: ${cssManager.bdTheme(colors.light.input, colors.dark.input)};
|
||||||
border: 1px solid rgba(255, 255, 255, 0);
|
border: 1px solid ${cssManager.bdTheme(colors.light.border, colors.dark.border)};
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
transition: background 0.2s ease;
|
transition: all 0.15s ease;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.toggleKnobArea:hover {
|
||||||
|
border-color: ${cssManager.bdTheme(colors.light.ring, colors.dark.ring)};
|
||||||
|
}
|
||||||
|
|
||||||
:host([selected]) .toggleKnobArea {
|
:host([selected]) .toggleKnobArea {
|
||||||
background: green;
|
background: ${cssManager.bdTheme(colors.light.primary, colors.dark.primary)};
|
||||||
|
border-color: ${cssManager.bdTheme(colors.light.primary, colors.dark.primary)};
|
||||||
}
|
}
|
||||||
|
|
||||||
.toggleKnobMover {
|
.toggleKnobMover {
|
||||||
@@ -66,39 +89,37 @@ export class ConsentsoftwareToggle extends LitElement {
|
|||||||
|
|
||||||
.toggleKnobInner {
|
.toggleKnobInner {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 2px;
|
||||||
left: 0;
|
width: 14px;
|
||||||
width: 30px;
|
height: 14px;
|
||||||
height: 30px;
|
border-radius: 7px;
|
||||||
border-radius: 15px;
|
background: ${cssManager.bdTheme(colors.light.mutedForeground, colors.dark.mutedForeground)};
|
||||||
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: ${cssManager.bdTheme(colors.light.primaryForeground, colors.dark.primaryForeground)};
|
||||||
}
|
}
|
||||||
|
|
||||||
:host([required]) .toggleKnobArea {
|
:host([required]) .toggleKnobArea {
|
||||||
background: none;
|
cursor: not-allowed;
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:host([required]) .toggleKnobInner {
|
:host([required][selected]) .toggleKnobArea {
|
||||||
background: rgba(255, 255, 255, 0.1);
|
background: ${cssManager.bdTheme(colors.light.ring, colors.dark.ring)};
|
||||||
|
border-color: ${cssManager.bdTheme(colors.light.ring, colors.dark.ring)};
|
||||||
}
|
}
|
||||||
`;
|
|
||||||
|
|
||||||
constructor() {
|
:host([required][selected]) .toggleKnobInner {
|
||||||
super();
|
background: ${cssManager.bdTheme(colors.light.muted, colors.dark.muted)};
|
||||||
}
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
public render(): TemplateResult {
|
public render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
@@ -110,7 +131,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}
|
||||||
@@ -125,15 +146,14 @@ export class ConsentsoftwareToggle extends LitElement {
|
|||||||
/**
|
/**
|
||||||
* If required = true on first render, auto-select and set the knob to the right.
|
* If required = true on first render, auto-select and set the knob to the right.
|
||||||
*/
|
*/
|
||||||
public async firstUpdated() {
|
public async firstUpdated(_changedProperties: Map<PropertyKey, unknown>) {
|
||||||
|
await super.firstUpdated(_changedProperties);
|
||||||
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 +162,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 +169,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 } }));
|
||||||
@@ -189,7 +205,7 @@ export class ConsentsoftwareToggle extends LitElement {
|
|||||||
|
|
||||||
// Start dragging
|
// Start dragging
|
||||||
this.isDragging = true;
|
this.isDragging = true;
|
||||||
// The difference between the pointer’s X and the knob’s current position
|
// The difference between the pointer's X and the knob's current position
|
||||||
this.startX = event.clientX - this.currentX;
|
this.startX = event.clientX - this.currentX;
|
||||||
|
|
||||||
// capture pointer so we keep receiving pointermove/pointerup
|
// capture pointer so we keep receiving pointermove/pointerup
|
||||||
@@ -203,8 +219,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 +229,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 didn’t 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 +259,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);
|
||||||
|
|||||||
@@ -1,3 +1,39 @@
|
|||||||
import { unsafeCSS } from 'lit'
|
import { unsafeCSS, cssManager } from '@design.estate/dees-element';
|
||||||
|
|
||||||
|
export { cssManager };
|
||||||
|
|
||||||
export const fontStack = unsafeCSS('system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif');
|
export const fontStack = unsafeCSS('system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif');
|
||||||
|
|
||||||
|
// Shadcn-inspired color palette
|
||||||
|
export const colors = {
|
||||||
|
light: {
|
||||||
|
background: '#ffffff',
|
||||||
|
foreground: '#09090b',
|
||||||
|
muted: '#f4f4f5',
|
||||||
|
mutedForeground: '#71717a',
|
||||||
|
border: '#e4e4e7',
|
||||||
|
input: '#e4e4e7',
|
||||||
|
primary: '#18181b',
|
||||||
|
primaryForeground: '#fafafa',
|
||||||
|
secondary: '#f4f4f5',
|
||||||
|
secondaryForeground: '#18181b',
|
||||||
|
accent: '#f4f4f5',
|
||||||
|
accentForeground: '#18181b',
|
||||||
|
ring: '#a1a1aa',
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
background: '#09090b',
|
||||||
|
foreground: '#fafafa',
|
||||||
|
muted: '#27272a',
|
||||||
|
mutedForeground: '#a1a1aa',
|
||||||
|
border: '#27272a',
|
||||||
|
input: '#27272a',
|
||||||
|
primary: '#fafafa',
|
||||||
|
primaryForeground: '#18181b',
|
||||||
|
secondary: '#27272a',
|
||||||
|
secondaryForeground: '#fafafa',
|
||||||
|
accent: '#27272a',
|
||||||
|
accentForeground: '#fafafa',
|
||||||
|
ring: '#52525b',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
import { html } from 'lit';
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
export const page1 = () => html``;
|
export const page1 = () => html``;
|
||||||
Reference in New Issue
Block a user