Skip to content

Commit 706beca

Browse files
authored
refactor: update scroller and virtual-list overflow-indicators (#10433)
1 parent a725c7f commit 706beca

File tree

23 files changed

+186
-45
lines changed

23 files changed

+186
-45
lines changed

packages/scroller/src/styles/vaadin-scroller-base-styles.js

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@ import { css } from 'lit';
88

99
export const scrollerStyles = css`
1010
:host {
11+
--_indicator-height: var(--vaadin-scroller-overflow-indicator-height, 1px);
12+
/* Don't let these properties inherit */
13+
--vaadin-scroller-padding-block: 0px;
14+
--vaadin-scroller-padding-inline: 0px;
15+
--vaadin-scroller-overflow-indicator-top-opacity: 0;
16+
--vaadin-scroller-overflow-indicator-bottom-opacity: 0;
1117
display: block;
1218
overflow: auto;
1319
outline: none;
20+
flex: 1;
21+
box-sizing: border-box;
22+
padding: 0 var(--vaadin-scroller-padding-inline);
1423
}
1524
1625
:host([focus-ring]) {
@@ -33,27 +42,44 @@ export const scrollerStyles = css`
3342
overflow: hidden;
3443
}
3544
36-
:host([theme*='overflow-indicator'])::before,
37-
:host([theme*='overflow-indicator'])::after {
45+
:host::before,
46+
:host::after {
3847
content: '';
39-
display: none;
48+
display: block;
49+
opacity: 0;
4050
position: sticky;
41-
inset: 0;
51+
inset: 0 calc(var(--vaadin-scroller-padding-inline) * -1);
4252
z-index: 9999;
43-
height: 1px;
44-
margin-bottom: -1px;
45-
background: var(--vaadin-scroller-border-color, var(--vaadin-border-color-secondary));
53+
pointer-events: none;
54+
box-sizing: border-box;
55+
height: var(--_indicator-height);
56+
margin-inline: calc(var(--vaadin-scroller-padding-inline) * -1);
57+
background: var(--vaadin-border-color-secondary);
4658
}
4759
48-
:host([theme*='overflow-indicator'])::after {
49-
margin-bottom: 0;
50-
margin-top: -1px;
60+
:host::before {
61+
margin-bottom: calc(var(--vaadin-scroller-padding-block) - var(--_indicator-height));
5162
}
5263
53-
:host([theme~='overflow-indicator-top'][overflow~='top'])::before,
54-
:host([theme~='overflow-indicators'][overflow~='top'])::before,
55-
:host([theme~='overflow-indicators'][overflow~='bottom'])::after,
56-
:host([theme~='overflow-indicator-bottom'][overflow~='bottom'])::after {
57-
display: block;
64+
:host::after {
65+
margin-top: calc(var(--vaadin-scroller-padding-block) - var(--_indicator-height));
66+
}
67+
68+
:host([overflow~='top'])::before {
69+
opacity: var(--vaadin-scroller-overflow-indicator-top-opacity);
70+
}
71+
72+
:host([overflow~='bottom'])::after {
73+
opacity: var(--vaadin-scroller-overflow-indicator-bottom-opacity);
74+
}
75+
76+
:host([theme~='overflow-indicator-top'][overflow~='top']),
77+
:host([theme~='overflow-indicators'][overflow~='top']) {
78+
--vaadin-scroller-overflow-indicator-top-opacity: 1;
79+
}
80+
81+
:host([theme~='overflow-indicators'][overflow~='bottom']),
82+
:host([theme~='overflow-indicator-bottom'][overflow~='bottom']) {
83+
--vaadin-scroller-overflow-indicator-bottom-opacity: 1;
5884
}
5985
`;

packages/scroller/src/vaadin-scroller.d.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,36 @@ import { ScrollerMixin } from './vaadin-scroller-mixin.js';
1616
* </vaadin-scroller>
1717
* ```
1818
*
19-
* The following attributes are exposed for styling:
19+
* ### Styling
20+
*
21+
* The following state attributes are available for styling:
2022
*
2123
* Attribute | Description
2224
* -------------| -----------
2325
* `focus-ring` | Set when the element is focused using the keyboard.
2426
* `focused` | Set when the element is focused.
2527
* `overflow` | Set to `top`, `bottom`, `start`, `end`, all of them, or none.
28+
*
29+
* ### Built-in Theme Variants
30+
*
31+
* `<vaadin-scroller>` supports the following theme variants:
32+
*
33+
* Theme variant | Description
34+
* -----------------------------------------|---------------
35+
* `theme="overflow-indicators"` | Shows visual indicators at the top and bottom when the content is scrolled
36+
* `theme="overflow-indicator-top"` | Shows the visual indicator at the top when the content is scrolled
37+
* `theme="overflow-indicator-top-bottom"` | Shows the visual indicator at the bottom when the content is scrolled
38+
*
39+
* ### Custom CSS Properties
40+
*
41+
* The following custom CSS properties are available for styling:
42+
*
43+
* Custom CSS property | Description
44+
* -----------------------------------|-------------
45+
* `--vaadin-scroller-padding-block` | The CSS padding applied to top and bottom edges
46+
* `--vaadin-scroller-padding-inline` | The CSS padding applied to left and right edges
47+
*
48+
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
2649
*/
2750
declare class Scroller extends ScrollerMixin(ThemableMixin(ElementMixin(HTMLElement))) {}
2851

packages/scroller/src/vaadin-scroller.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,37 @@ import { ScrollerMixin } from './vaadin-scroller-mixin.js';
2222
* </vaadin-scroller>
2323
* ```
2424
*
25-
* The following attributes are exposed for styling:
25+
* ### Styling
26+
*
27+
* The following state attributes are available for styling:
2628
*
2729
* Attribute | Description
2830
* -------------| -----------
2931
* `focus-ring` | Set when the element is focused using the keyboard.
3032
* `focused` | Set when the element is focused.
3133
* `overflow` | Set to `top`, `bottom`, `start`, `end`, all of them, or none.
3234
*
35+
* ### Built-in Theme Variants
36+
*
37+
* `<vaadin-scroller>` supports the following theme variants:
38+
*
39+
* Theme variant | Description
40+
* -----------------------------------------|---------------
41+
* `theme="overflow-indicators"` | Shows visual indicators at the top and bottom when the content is scrolled
42+
* `theme="overflow-indicator-top"` | Shows the visual indicator at the top when the content is scrolled
43+
* `theme="overflow-indicator-top-bottom"` | Shows the visual indicator at the bottom when the content is scrolled
44+
*
45+
* ### Custom CSS Properties
46+
*
47+
* The following custom CSS properties are available for styling:
48+
*
49+
* Custom CSS property | Description
50+
* -----------------------------------|-------------
51+
* `--vaadin-scroller-padding-block` | The CSS padding applied to top and bottom edges
52+
* `--vaadin-scroller-padding-inline` | The CSS padding applied to left and right edges
53+
*
54+
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
55+
*
3356
* @customElement
3457
* @extends HTMLElement
3558
* @mixes ThemableMixin
-3.68 KB
Loading
-3.74 KB
Loading

packages/tabsheet/src/styles/vaadin-tabsheet-base-styles.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ export const tabSheetStyles = [
4646
position: relative;
4747
flex: 1;
4848
box-sizing: border-box;
49-
padding: var(--vaadin-tabsheet-padding, var(--vaadin-padding-l));
50-
border-top: var(--vaadin-tabsheet-border-width, 1px) solid transparent;
51-
margin-top: calc(var(--vaadin-tabsheet-border-width, 1px) * -1);
49+
--vaadin-scroller-padding-block: var(--vaadin-tabsheet-padding, var(--vaadin-padding-m));
50+
--vaadin-scroller-padding-inline: var(--vaadin-tabsheet-padding, var(--vaadin-padding-m));
51+
--vaadin-scroller-overflow-indicator-top-opacity: 1;
5252
}
5353
5454
[part='content'][focus-ring] {
@@ -57,14 +57,12 @@ export const tabSheetStyles = [
5757
outline-offset: calc(var(--vaadin-focus-ring-width) * -1);
5858
}
5959
60-
[part='content'][overflow~='top'] {
61-
border-top-color: var(--vaadin-tabsheet-border-color, var(--vaadin-border-color-secondary));
60+
:host([loading]) [part='content'] {
61+
align-content: center;
6262
}
6363
64-
:host([loading]) [part='content'] {
65-
display: flex;
66-
align-items: center;
67-
justify-content: center;
64+
[part='loader'] {
65+
margin: auto;
6866
}
6967
7068
:host([theme~='no-border']) {
@@ -74,6 +72,8 @@ export const tabSheetStyles = [
7472
7573
:host([theme~='no-padding']) [part='content'] {
7674
padding: 0 !important;
75+
--vaadin-scroller-padding-block: 0px !important;
76+
--vaadin-scroller-padding-inline: 0px !important;
7777
}
7878
`,
7979
];
-55 Bytes
Loading
-61 Bytes
Loading
-74 Bytes
Loading
-1.29 KB
Loading

0 commit comments

Comments
 (0)