Skip to content

Commit 5a0207a

Browse files
authored
example using ct-autolayout and aside (commontoolsinc#1808)
1 parent db5ce84 commit 5a0207a

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

packages/patterns/aside.tsx

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/// <cts-enable />
2+
import {
3+
Cell,
4+
cell,
5+
Default,
6+
derive,
7+
h,
8+
handler,
9+
ifElse,
10+
lift,
11+
NAME,
12+
navigateTo,
13+
recipe,
14+
toSchema,
15+
UI,
16+
} from "commontools";
17+
18+
// note: you may need to zoom in our out in the browser to see the
19+
// content and/or tabs
20+
export default recipe(
21+
"Aside",
22+
() => {
23+
return {
24+
[NAME]: "Aside",
25+
[UI]: (
26+
// ct-screen provides a full-height layout with header/main/footer areas
27+
<ct-screen>
28+
{/* Header slot - fixed at top */}
29+
<div slot="header">
30+
<h2>Header Section</h2>
31+
</div>
32+
33+
{/* ct-autolayout creates responsive multi-panel layout with optional sidebars */}
34+
{/* tabNames: Labels for main content panels (shown as tabs on mobile) */}
35+
{/* Shows all panels side-by-side in a grid */}
36+
<ct-autolayout tabNames={["Main", "Second"]}>
37+
{/* Left sidebar - use slot="left" */}
38+
<aside slot="left">
39+
<h3>Left Sidebar</h3>
40+
<p>Left content</p>
41+
<ct-button>Left Button</ct-button>
42+
</aside>
43+
44+
{/* Main content panels - no slot attribute needed */}
45+
{/* Number of divs should match number of tabNames */}
46+
<div>
47+
<h1>Main Content Area</h1>
48+
<p>This is the main content with sidebars</p>
49+
<ct-button>Main Button</ct-button>
50+
</div>
51+
52+
<div>
53+
<h1>Second Content Area</h1>
54+
<p>This is the second content with sidebars</p>
55+
<ct-button>Second Button</ct-button>
56+
</div>
57+
58+
{/* Right sidebar - use slot="right" */}
59+
<aside slot="right">
60+
<h3>Right Sidebar</h3>
61+
<p>Right content</p>
62+
<ct-button>Right Button</ct-button>
63+
</aside>
64+
</ct-autolayout>
65+
66+
{/* Footer slot - fixed at bottom */}
67+
<div slot="footer">
68+
<p>Footer Section</p>
69+
</div>
70+
</ct-screen>
71+
),
72+
};
73+
},
74+
);

0 commit comments

Comments
 (0)