Skip to content

Commit 77836f6

Browse files
committed
Stop using container units
...Unfortunately they do not work across slot boundaries. The container unit is sized by the light dom container, not the shadow dom container. See w3c/csswg-drafts#5984 Solution: use percentage units instead. Oddly enough, these do work across shadow boundaries.
1 parent 9808639 commit 77836f6

File tree

5 files changed

+41
-7
lines changed

5 files changed

+41
-7
lines changed

typescript/packages/lookslike-sagas/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<body class="theme">
1111
<common-screen>
1212
<common-app>
13-
<common-vstack pad="md" gap="md">
13+
<common-list>
1414
<common-media src="example/mitchell-orr-jQqR2xGkesc-unsplash.jpg">
1515
Hello!
1616
</common-media>
@@ -29,7 +29,7 @@
2929
<common-media src="example/mitchell-orr-jQqR2xGkesc-unsplash.jpg">
3030
Hello!
3131
</common-media>
32-
</common-vstack>
32+
</common-list>
3333
<div slot="secondary">
3434
<common-suggestion>
3535
Buy milk

typescript/packages/lookslike-sagas/src/components/app.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ export class AppElement extends LitElement {
99
css`
1010
:host {
1111
display: block;
12+
height: 100%;
13+
width: 100%;
1214
}
1315
1416
.app {
15-
height: 100cqh;
1617
display: grid;
18+
height: 100%;
19+
width: 100%;
1720
grid-template-columns: 1fr;
1821
grid-template-rows: 1fr min-content min-content;
1922
grid-template-areas:
@@ -32,10 +35,12 @@ export class AppElement extends LitElement {
3235
3336
.app-secondary {
3437
grid-area: secondary;
38+
container-type: inline-size;
3539
}
3640
3741
.app-search {
3842
grid-area: search;
43+
container-type: inline-size;
3944
background-color: var(--secondary-background);
4045
display: block;
4146
padding: var(--gap);
@@ -47,9 +52,7 @@ export class AppElement extends LitElement {
4752
return html`
4853
<div class="app">
4954
<main class="app-primary">
50-
<common-scroll>
51-
<slot></slot>
52-
</common-scroll>
55+
<slot></slot>
5356
</main>
5457
<nav class="app-secondary">
5558
<slot name="secondary"></slot>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { LitElement, html, css } from "lit";
2+
import { customElement } from "lit/decorators.js";
3+
import { baseStyles } from "../style.js";
4+
5+
@customElement("common-list")
6+
export class CommonListElement extends LitElement {
7+
static override styles = [
8+
baseStyles,
9+
css`
10+
:host {
11+
display: block;
12+
height: 100%;
13+
width: 100%;
14+
}
15+
`
16+
];
17+
18+
override render() {
19+
return html`
20+
<common-scroll>
21+
<common-vstack gap="md" pad="md">
22+
<slot></slot>
23+
</common-vstack>
24+
</common-scroll>
25+
`;
26+
}
27+
}

typescript/packages/lookslike-sagas/src/components/layout/scroll.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ export class ScrollElement extends LitElement {
99
css`
1010
:host {
1111
display: block;
12+
height: 100%;
13+
width: 100%;
1214
}
1315
1416
.scroll {
1517
overflow-y: auto;
1618
overflow-x: hidden;
17-
height: 100cqh;
19+
height: 100%;
20+
width: 100%;
1821
container-type: size;
1922
container-name: scroll;
2023
}

typescript/packages/lookslike-sagas/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export { ScrollElement } from './components/layout/scroll.js';
22
export { ScreenElement } from './components/layout/screen.js';
33
export { VstackElement } from './components/layout/vstack.js';
44
export { HstackElement } from './components/layout/hstack.js';
5+
export { CommonListElement } from './components/layout/list.js';
56
export { MediaElement } from './components/common/media.js';
67
export { ImgElement } from './components/common/img.js';
78
export { ButtonElement } from './components/common/button.js';

0 commit comments

Comments
 (0)