@haxtheweb/haxcms-nodejs
Version:
HAXcms single and multisite nodejs server, api, and administration
176 lines (150 loc) • 4.92 kB
JavaScript
import"../../../vaadin-lumo-styles/color.js";import"../../../vaadin-lumo-styles/style.js";import{html as e}from"../../../../@polymer/polymer/lib/utils/html-tag.js";const o=e`<dom-module id="lumo-checkbox" theme-for="vaadin-checkbox">
<template>
<style include="lumo-checkbox-style lumo-checkbox-effects">
/* IE11 only */
::-ms-backdrop,
[part="checkbox"] {
line-height: 1;
}
</style>
</template>
</dom-module><dom-module id="lumo-checkbox-style">
<template>
<style>
:host {
-webkit-tap-highlight-color: transparent;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
cursor: default;
outline: none;
}
[part="label"]:not([empty]) {
margin: 0.1875em 0.875em 0.1875em 0.375em;
}
[part="checkbox"] {
width: calc(1em + 2px);
height: calc(1em + 2px);
margin: 0.1875em;
position: relative;
border-radius: var(--lumo-border-radius-s);
background-color: var(--lumo-contrast-20pct);
transition: transform 0.2s cubic-bezier(.12, .32, .54, 2), background-color 0.15s;
pointer-events: none;
line-height: 1.2;
}
:host([indeterminate]) [part="checkbox"],
:host([checked]) [part="checkbox"] {
background-color: var(--lumo-primary-color);
}
/* Needed to align the checkbox nicely on the baseline */
[part="checkbox"]::before {
content: "\\2003";
}
/* Checkmark */
[part="checkbox"]::after {
content: "";
display: inline-block;
width: 0;
height: 0;
border: 0 solid var(--lumo-primary-contrast-color);
border-width: 0.1875em 0 0 0.1875em;
box-sizing: border-box;
transform-origin: 0 0;
position: absolute;
top: 0.8125em;
left: 0.5em;
transform: scale(0.55) rotate(-135deg);
opacity: 0;
}
:host([checked]) [part="checkbox"]::after {
opacity: 1;
width: 0.625em;
height: 1.0625em;
}
/* Indeterminate checkmark */
:host([indeterminate]) [part="checkbox"]::after {
transform: none;
opacity: 1;
top: 45%;
height: 10%;
left: 22%;
right: 22%;
width: auto;
border: 0;
background-color: var(--lumo-primary-contrast-color);
transition: opacity 0.25s;
}
/* Focus ring */
:host([focus-ring]) [part="checkbox"] {
box-shadow: 0 0 0 3px var(--lumo-primary-color-50pct);
}
/* Disabled */
:host([disabled]) {
pointer-events: none;
color: var(--lumo-disabled-text-color);
}
:host([disabled]) [part="label"] ::slotted(*) {
color: inherit;
}
:host([disabled]) [part="checkbox"] {
background-color: var(--lumo-contrast-10pct);
}
:host([disabled]) [part="checkbox"]::after {
border-color: var(--lumo-contrast-30pct);
}
:host([indeterminate][disabled]) [part="checkbox"]::after {
background-color: var(--lumo-contrast-30pct);
}
/* RTL specific styles */
:host([dir="rtl"]) [part="label"]:not([empty]) {
margin: 0.1875em 0.375em 0.1875em 0.875em;
}
</style>
</template>
</dom-module><dom-module id="lumo-checkbox-effects">
<template>
<style>
/* Transition the checkmark if activated with the mouse (disabled for grid select-all this way) */
:host(:hover) [part="checkbox"]::after {
transition: width 0.1s, height 0.25s;
}
/* Used for activation "halo" */
[part="checkbox"]::before {
color: transparent;
display: inline-block;
width: 100%;
height: 100%;
border-radius: inherit;
background-color: inherit;
transform: scale(1.4);
opacity: 0;
transition: transform 0.1s, opacity 0.8s;
}
/* Hover */
:host(:not([checked]):not([indeterminate]):not([disabled]):hover) [part="checkbox"] {
background-color: var(--lumo-contrast-30pct);
}
/* Disable hover for touch devices */
@media (pointer: coarse) {
:host(:not([checked]):not([indeterminate]):not([disabled]):hover) [part="checkbox"] {
background-color: var(--lumo-contrast-20pct);
}
}
/* Active */
:host([active]) [part="checkbox"] {
transform: scale(0.9);
transition-duration: 0.05s;
}
:host([active][checked]) [part="checkbox"] {
transform: scale(1.1);
}
:host([active]:not([checked])) [part="checkbox"]::before {
transition-duration: 0.01s, 0.01s;
transform: scale(0);
opacity: 0.4;
}
</style>
</template>
</dom-module>`;document.head.appendChild(o.content);