Skip to content

Commit 111d46f

Browse files
committed
code adjustments and tests
1 parent a6aa461 commit 111d46f

File tree

3 files changed

+74
-9
lines changed

3 files changed

+74
-9
lines changed

packages/uui-scroll-container/lib/uui-scroll-container.element.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,41 @@ import { LitElement, html, css } from 'lit';
88
export class UUIScrollContainerElement extends LitElement {
99
static styles = [
1010
css`
11-
:host {
12-
--uui-overflow-container-height: 180px;
13-
}
14-
1511
:host {
1612
display: block;
1713
scrollbar-width: thin;
1814
scrollbar-color: var(--uui-interface-contrast-disabled)
1915
var(--uui-interface-background-alt);
2016
overflow-y: scroll;
21-
max-height: var(--uui-overflow-container-height);
2217
}
2318
19+
/*
20+
:host(:focus) {
21+
outline-width: thin;
22+
outline-color: var(--uui-interface-border);
23+
}
24+
*/
25+
2426
:host::-webkit-scrollbar {
25-
width: 5px;
27+
width: 6px;
28+
height: 6px; /* needed for horizontal scrollbar */
2629
}
2730
2831
:host::-webkit-scrollbar-track {
2932
background: var(--uui-interface-background-alt);
30-
border-radius: 12px;
33+
border-radius: 3px;
3134
}
3235
:host::-webkit-scrollbar-thumb {
3336
background-color: var(--uui-interface-contrast-disabled);
34-
border-radius: 12px;
37+
border-radius: 3px;
3538
}
3639
`,
3740
];
3841

42+
connectedCallback() {
43+
super.connectedCallback();
44+
this.setAttribute('tabindex', '0');
45+
}
3946
render() {
4047
return html`<slot></slot>`;
4148
}

packages/uui-scroll-container/lib/uui-scroll-container.story.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,18 @@ export const Overview: Story = () =>
126126
<p>and now I have transitions</p>
127127
</uui-scroll-container>
128128
`;
129+
130+
export const NotEnoughContent: Story = () =>
131+
html`
132+
<uui-scroll-container style="width:400px; height:400px;">
133+
Very little text, no Scrollbar appearing
134+
</uui-scroll-container>
135+
`;
136+
137+
export const VeryWideContent: Story = () =>
138+
html`
139+
<uui-scroll-container style="width:400px; height:400px;">
140+
line is way toooo long
141+
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY<br />
142+
</uui-scroll-container>
143+
`;

packages/uui-scroll-container/lib/uui-scroll-container.test.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,54 @@ describe('UUIScrollContainerElement', () => {
77

88
beforeEach(async () => {
99
element = await fixture(
10-
html` <uui-scroll-container></uui-scroll-container> `
10+
html`<uui-scroll-container style="width:200px; height:200px;">
11+
initial line is way toooo long
12+
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY<br />
13+
1 line<br />
14+
2 line<br />
15+
3 line<br />
16+
4 line<br />
17+
5 line<br />
18+
6 line<br />
19+
7 line<br />
20+
8 line<br />
21+
9 line<br />
22+
10 line<br />
23+
11 line<br />
24+
12 line<br />
25+
13 line<br />
26+
14 line<br />
27+
15 line<br />
28+
16 line<br />
29+
17 line<br />
30+
18 line<br />
31+
19 line<br />
32+
20 line
33+
</uui-scroll-container>`
1134
);
1235
});
1336

1437
it('passes the a11y audit', async () => {
1538
await expect(element).shadowDom.to.be.accessible();
1639
});
40+
41+
it('can scroll', async () => {
42+
element.scrollTop = 42;
43+
await expect(element.scrollTop).to.be.equal(42);
44+
});
45+
46+
it('cant scroll to far', async () => {
47+
element.scrollTop = 9999;
48+
await expect(element.scrollTop).not.to.be.equal(9999);
49+
});
50+
51+
it('cant scroll to less than zero', async () => {
52+
element.scrollTop = -100;
53+
await expect(element.scrollTop).to.be.equal(0);
54+
});
55+
56+
it('can scroll sideways if content enforces it', async () => {
57+
element.scrollLeft = 42;
58+
await expect(element.scrollLeft).to.be.equal(42);
59+
});
1760
});

0 commit comments

Comments
 (0)