Skip to content

Commit a36b7da

Browse files
authored
experiment: add scroller base styles and visual tests (#9630)
1 parent 7ccc4e8 commit a36b7da

14 files changed

+159
-24
lines changed

packages/scroller/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
"type": "module",
2222
"files": [
2323
"src",
24+
"!src/styles/*-base-styles.d.ts",
25+
"!src/styles/*-base-styles.js",
2426
"theme",
2527
"vaadin-*.d.ts",
2628
"vaadin-*.js",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2020 - 2025 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import type { CSSResult } from 'lit';
7+
8+
export const scrollerStyles: CSSResult;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2020 - 2025 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import '@vaadin/component-base/src/style-props.js';
7+
import { css } from 'lit';
8+
9+
export const scrollerStyles = css`
10+
@layer base {
11+
:host {
12+
display: block;
13+
overflow: auto;
14+
outline: none;
15+
}
16+
17+
:host([focus-ring]) {
18+
outline: var(--vaadin-focus-ring-width) solid var(--vaadin-focus-ring-color);
19+
}
20+
21+
:host([hidden]) {
22+
display: none !important;
23+
}
24+
25+
:host([scroll-direction='vertical']) {
26+
overflow-x: hidden;
27+
}
28+
29+
:host([scroll-direction='horizontal']) {
30+
overflow-y: hidden;
31+
}
32+
33+
:host([scroll-direction='none']) {
34+
overflow: hidden;
35+
}
36+
37+
:host([theme~='overflow-indicators'])::before,
38+
:host([theme~='overflow-indicators'])::after {
39+
content: '';
40+
display: none;
41+
position: sticky;
42+
inset: 0;
43+
z-index: 9999;
44+
height: 1px;
45+
margin-bottom: -1px;
46+
background: var(--vaadin-scroller-border-color, var(--vaadin-border-color));
47+
}
48+
49+
:host([theme~='overflow-indicators'])::after {
50+
margin-bottom: 0;
51+
margin-top: -1px;
52+
}
53+
54+
:host([theme~='overflow-indicators'][overflow~='top'])::before,
55+
:host([theme~='overflow-indicators'][overflow~='bottom'])::after {
56+
display: block;
57+
}
58+
}
59+
`;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2020 - 2025 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import type { CSSResult } from 'lit';
7+
8+
export const scrollerStyles: CSSResult;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2020 - 2025 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import { css } from 'lit';
7+
8+
export const scrollerStyles = css`
9+
:host {
10+
display: block;
11+
overflow: auto;
12+
}
13+
14+
:host([hidden]) {
15+
display: none !important;
16+
}
17+
18+
:host([scroll-direction='vertical']) {
19+
overflow-x: hidden;
20+
}
21+
22+
:host([scroll-direction='horizontal']) {
23+
overflow-y: hidden;
24+
}
25+
26+
:host([scroll-direction='none']) {
27+
overflow: hidden;
28+
}
29+
`;

packages/scroller/src/vaadin-scroller.js

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
* Copyright (c) 2020 - 2025 Vaadin Ltd.
44
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
55
*/
6-
import { css, html, LitElement } from 'lit';
6+
import { html, LitElement } from 'lit';
77
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
88
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
99
import { OverflowController } from '@vaadin/component-base/src/overflow-controller.js';
1010
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
1111
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
1212
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13+
import { scrollerStyles } from './styles/vaadin-scroller-core-styles.js';
1314
import { ScrollerMixin } from './vaadin-scroller-mixin.js';
1415

1516
/**
@@ -40,28 +41,7 @@ class Scroller extends ScrollerMixin(ElementMixin(ThemableMixin(LumoInjectionMix
4041
}
4142

4243
static get styles() {
43-
return css`
44-
:host {
45-
display: block;
46-
overflow: auto;
47-
}
48-
49-
:host([hidden]) {
50-
display: none !important;
51-
}
52-
53-
:host([scroll-direction='vertical']) {
54-
overflow-x: hidden;
55-
}
56-
57-
:host([scroll-direction='horizontal']) {
58-
overflow-y: hidden;
59-
}
60-
61-
:host([scroll-direction='none']) {
62-
overflow: hidden;
63-
}
64-
`;
44+
return scrollerStyles;
6545
}
6646

6747
/** @protected */
7.16 KB
Loading
7.38 KB
Loading
6.65 KB
Loading
6.63 KB
Loading

0 commit comments

Comments
 (0)