@vaadin/grid
Version:
A free, flexible and high-quality Web Component for showing large amounts of tabular data
82 lines (68 loc) • 2.02 kB
JavaScript
import '@vaadin/vaadin-lumo-styles/color.js';
import '@vaadin/vaadin-lumo-styles/spacing.js';
import '@vaadin/vaadin-lumo-styles/style.js';
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
registerStyles(
'vaadin-grid-tree-toggle',
css`
:host {
--vaadin-grid-tree-toggle-level-offset: 2em;
align-items: center;
vertical-align: middle;
transform: translateX(calc(var(--lumo-space-s) * -1));
-webkit-tap-highlight-color: transparent;
}
:host(:not([leaf])) {
cursor: default;
}
[part='toggle'] {
display: inline-block;
font-size: 1.5em;
line-height: 1;
width: 1em;
height: 1em;
text-align: center;
color: var(--lumo-contrast-50pct);
cursor: var(--lumo-clickable-cursor);
/* Increase touch target area */
padding: calc(1em / 3);
margin: calc(1em / -3);
}
:host(:not([dir='rtl'])) [part='toggle'] {
margin-right: 0;
}
@media (hover: hover) {
:host(:hover) [part='toggle'] {
color: var(--lumo-contrast-80pct);
}
}
[part='toggle']::before {
font-family: 'lumo-icons';
display: inline-block;
height: 100%;
}
:host(:not([expanded])) [part='toggle']::before {
content: var(--lumo-icons-angle-right);
}
:host([expanded]) [part='toggle']::before {
content: var(--lumo-icons-angle-right);
transform: rotate(90deg);
}
/* RTL specific styles */
:host([dir='rtl']) {
margin-left: 0;
margin-right: calc(var(--lumo-space-s) * -1);
}
:host([dir='rtl']) [part='toggle'] {
margin-left: 0;
}
:host([dir='rtl'][expanded]) [part='toggle']::before {
transform: rotate(-90deg);
}
:host([dir='rtl']:not([expanded])) [part='toggle']::before,
:host([dir='rtl'][expanded]) [part='toggle']::before {
content: var(--lumo-icons-angle-left);
}
`,
{ moduleId: 'lumo-grid-tree-toggle' },
);