Skip to content

Commit 068b1db

Browse files
Add hscroll (#92)
...creates a horizontal scroller for many items
1 parent 27436d0 commit 068b1db

File tree

3 files changed

+96
-1
lines changed

3 files changed

+96
-1
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { LitElement, html, css } from "lit";
2+
import { customElement } from "lit/decorators.js";
3+
import { baseStyles } from "./style.js";
4+
import { view } from '../hyperscript/render.js';
5+
import { eventProps } from "../hyperscript/schema-helpers.js";
6+
7+
export const hscroll = view('common-hscroll', {
8+
...eventProps()
9+
});
10+
11+
@customElement("common-hscroll")
12+
export class CommonHscrollElement extends LitElement {
13+
static override styles = [
14+
baseStyles,
15+
css`
16+
:host {
17+
display: block;
18+
width: 100%;
19+
}
20+
21+
.scroll {
22+
overflow-x: auto;
23+
overflow-y: hidden;
24+
width: 100%;
25+
}
26+
27+
.scroll {
28+
scrollbar-width: none; /* Firefox */
29+
-ms-overflow-style: none; /* Internet Explorer 10+ */
30+
}
31+
32+
.scroll::-webkit-scrollbar {
33+
width: 0;
34+
height: 0;
35+
}
36+
37+
.scroll-body {
38+
display: flex;
39+
flex-direction: row;
40+
flex-wrap: nowrap;
41+
gap: var(--gap)
42+
}
43+
44+
:host([gap="none"]) .scroll-body {
45+
gap: 0;
46+
}
47+
48+
:host([gap="md"]) .scroll-body {
49+
gap: var(--gap);
50+
}
51+
52+
:host([pad="md"]) .scroll-body {
53+
padding: var(--gap);
54+
}
55+
`
56+
];
57+
58+
override render() {
59+
return html`
60+
<div class="scroll">
61+
<div class="scroll-body">
62+
<slot></slot>
63+
</div>
64+
</div>
65+
`;
66+
}
67+
}

typescript/packages/common-ui/src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ export * as CommonSystemLayout from './common-system-layout.js';
2020
export * as CommonNavstack from './common-navstack.js';
2121
export * as CommonTodo from './common-todo.js';
2222
export * as CommonPill from './common-pill.js';
23+
export * as CommonHscroll from './common-hscroll.js';
2324
export * as style from './style.js';

typescript/packages/lookslike-sagas/index.html

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,34 @@
1212
<common-system-layout>
1313
<common-list>
1414
<common-button>Bonk</common-button>
15-
<common-pill>Bonk</common-pill>
15+
<common-hscroll>
16+
<common-pill>Bonk</common-pill>
17+
<common-pill>Bonk</common-pill>
18+
<common-pill>Bonk</common-pill>
19+
<common-pill>Bonk</common-pill>
20+
<common-pill>Bonk</common-pill>
21+
<common-pill>Bonk</common-pill>
22+
<common-pill>Bonk</common-pill>
23+
<common-pill>Bonk</common-pill>
24+
<common-pill>Bonk</common-pill>
25+
<common-pill>Bonk</common-pill>
26+
<common-pill>Bonk</common-pill>
27+
<common-pill>Bonk</common-pill>
28+
<common-pill>Bonk</common-pill>
29+
<common-pill>Bonk</common-pill>
30+
<common-pill>Bonk</common-pill>
31+
<common-pill>Bonk</common-pill>
32+
<common-pill>Bonk</common-pill>
33+
<common-pill>Bonk</common-pill>
34+
<common-pill>Bonk</common-pill>
35+
<common-pill>Bonk</common-pill>
36+
<common-pill>Bonk</common-pill>
37+
<common-pill>Bonk</common-pill>
38+
<common-pill>Bonk</common-pill>
39+
<common-pill>Bonk</common-pill>
40+
<common-pill>Bonk</common-pill>
41+
<common-pill>Bonk</common-pill>
42+
</common-hscroll>
1643
<common-todo value="Buy milk" placeholder="Todo..."></common-todo>
1744
<common-media src="example/mitchell-orr-jQqR2xGkesc-unsplash.jpg">
1845
Hello!

0 commit comments

Comments
 (0)