import { customElement, DeesElement, property, html, type TemplateResult, cssManager, css } from '@design.estate/dees-element'; import * as domtools from '@design.estate/dees-domtools'; import '@design.estate/dees-catalog'; import * as csInterfaces from '@consent.software/interfaces'; import * as csWebclient from '@consent.software/webclient'; import { delayFor } from '@push.rocks/smartdelay'; @customElement('consentsoftware-cookieconsent') export class ConsentsoftwareCookieconsent extends DeesElement { public static demo = () => html``; public csWebclientInstance = new csWebclient.CsWebclient(); public csWebclientRan = false; constructor() { super(); domtools.elementBasic.setup(); // lets determine wether to show the cookieconsent dialog or not } public static styles = [ cssManager.defaultStyles, css` * { box-sizing: border-box; } .content { max-width: 1100px; margin: auto; line-height: var(--cookieconsent-height); padding-bottom: 20px; } .text-container { line-height: var(--cookieconsent-height); display: grid; grid-template-columns: 30px auto; } .text-container .icon-container { height: var(--cookieconsent-height); display: inline-block; color: #4496F5; } .text-container .toptext { } .text-container a { color: ${cssManager.bdTheme('#333', '#fff')}; } .button-container { display: grid; grid-template-columns: ${cssManager.cssGridColumns(4, 20)}; grid-column-gap: 20px; grid-row-gap: 20px; } .info-container { color: ${cssManager.bdTheme('#444', '#CCC')}; text-align: center; } .info-container a { text-decoration: underline; color: ${cssManager.bdTheme('#444', '#CCC')}; transition: color 0.2s; } .info-container a:hover { color: #ffffff; } .consent-button { border-radius: 3px; background: ${cssManager.bdTheme('#ffffff', '#252525')}; box-shadow: ${cssManager.bdTheme('0px 0px 5px rgba(0,0,0,0.2)', '0px 0px 5px rgba(0,0,0,0.4)')}; padding: 10px; line-height: 30px; text-align: center; cursor: pointer; transition: background 0.2s; } .consent-button:hover { background: ${cssManager.bdTheme('#f2f2f2', '#222222')}; } .consent-button:first-child { margin-left: 0px; } ${cssManager.cssForNotebook(css` .content { padding-left: 30px; padding-right: 30px; } `)} ${cssManager.cssForTablet(css` :host { text-align: center; } .content { padding-top: 20px; } .icon-container { margin-top: -10px; line-height: 50px; font-size: 40px; } .text-container { line-height: 20px; margin-bottom: 10px; grid-template-columns: 50px auto; } .button-container { grid-template-columns: ${cssManager.cssGridColumns(2, 20)}; } `)} ${cssManager.cssForPhablet(css` .button-container { grid-template-columns: 100%; } `)} ` ] public render(): TemplateResult { return html`
This page uses cookies. Please review our cookie policy and choose which cookie level you are willing to accept.
consent management powered by consent.software
`; } @property({type: Number}) public heightPixels: number = 60; public async connectedCallback() { super.connectedCallback(); this.setAttribute('gotIt', 'true'); const cookieLevel = await this.csWebclientInstance.getCookieLevels(); if(!cookieLevel) { delayFor(300).then(() => { this.setAttribute('show', 'true'); this.setAttribute('gotIt', 'false'); }); } else { this.setAttribute('show', 'false'); this.setAttribute('gotIt', 'true'); } } public firstUpdated() { this.heightPixels = this.shadowRoot.host.clientHeight; } public async updated() { console.log(`The height of the cookie banner is ${this.shadowRoot.host.clientHeight}px`); const acceptedCookieLevels = await this.csWebclientInstance.getCookieLevels(); if (!this.csWebclientRan && acceptedCookieLevels) { this.csWebclientRan = true; await this.csWebclientInstance.getAndRunConsentTuples(); } } private async setLevel (event: MouseEvent, levelsArg: csInterfaces.TCookieLevel[]) { console.log(`Set level to ${levelsArg}`); await this.csWebclientInstance.setCookieLevels(levelsArg); this.setAttribute('gotIt', 'true'); await delayFor(300); this.setAttribute('show', 'false'); this.updated(); } }