Skip to content

Commit 677d228

Browse files
authored
Improve examples menu (#106)
* Migrate to pnpm catalogs * Switch from catalogs to syncpack * Attemp to fix CI script * Another CI fix * Improve examples menu UI
1 parent 56450f9 commit 677d228

6 files changed

Lines changed: 357 additions & 69 deletions

File tree

apps/website/app/demos/[demoname]/Dev.tsx

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,26 @@ export function Dev({ demoname }: { demoname: string }) {
1313
<Style
1414
css={`
1515
@scope {
16+
:scope {
17+
width: min(100%, 46rem);
18+
}
19+
20+
.content {
21+
display: grid;
22+
gap: 1rem;
23+
justify-items: start;
24+
}
25+
26+
p {
27+
margin: 0;
28+
}
29+
1630
pre {
1731
background: rgb(13, 13, 13);
1832
padding: 1rem;
1933
border-radius: 0.35rem;
34+
margin: 0;
35+
width: 100%;
2036
}
2137
code {
2238
color: white;
@@ -41,18 +57,20 @@ export function Dev({ demoname }: { demoname: string }) {
4157
`}
4258
/>
4359

44-
<p>Start this demo with :</p>
45-
<pre
46-
onClick={(e) => {
47-
navigator.clipboard.writeText(cmd);
48-
}}
49-
>
50-
<code>{cmd}</code>
51-
<a>copy</a>
52-
</pre>
53-
<p>
54-
Then <a onClick={(e) => refresh()}>refresh</a>
55-
</p>
60+
<div className="content">
61+
<p>Start this demo with :</p>
62+
<pre
63+
onClick={(e) => {
64+
navigator.clipboard.writeText(cmd);
65+
}}
66+
>
67+
<code>{cmd}</code>
68+
<a>copy</a>
69+
</pre>
70+
<p>
71+
Then <a onClick={(e) => refresh()}>refresh</a>
72+
</p>
73+
</div>
5674
</div>
5775
);
5876
}

apps/website/app/demos/[demoname]/layout.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ export default function Layout({
1818
css={`
1919
@scope {
2020
:scope {
21+
width: 100%;
2122
height: 100%;
22-
display: flex;
23-
align-items: center;
24-
justify-content: center;
25-
> * {
26-
max-width: 100%;
27-
}
23+
min-width: 0;
24+
min-height: 0;
25+
display: grid;
2826
}
2927
}
3028
`}

apps/website/app/demos/[demoname]/page.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { notFound } from "next/navigation";
22

3+
import { ScaledDemoFrame } from "@/components/ScaledDemoFrame";
34
import { getDemos } from "@/lib/helper";
45
import { Dev } from "./Dev";
56
import { Style } from "@/components/Style";
@@ -77,11 +78,17 @@ export default async function Page(props: Props) {
7778
css={`
7879
@scope {
7980
.Dev {
80-
padding-inline: 1rem;
81+
width: 100%;
82+
height: 100%;
83+
display: grid;
84+
place-items: center;
85+
padding: 1rem;
8186
}
82-
iframe {
87+
.Frame {
8388
width: 100%;
84-
min-height: 100dvh;
89+
height: 100%;
90+
min-width: 0;
91+
min-height: 0;
8592
}
8693
.Social {
8794
position: fixed;
@@ -101,7 +108,9 @@ export default async function Page(props: Props) {
101108
<Dev demoname={demoname} />
102109
) : (
103110
<>
104-
<iframe src={embed_url} />
111+
<div className="Frame">
112+
<ScaledDemoFrame src={embed_url} title={demoname} />
113+
</div>
105114

106115
<Social demoname={demoname} embed_url={embed_url} />
107116
</>

apps/website/app/layout.tsx

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,54 @@ export default function RootLayout({
2525
css={`
2626
@scope {
2727
:scope {
28+
--sidebar-w: 260px;
29+
--motion-curve: linear(
30+
0.00, 0.00780, 0.0340, 0.0738, 0.116, 0.160, 0.203, 0.244,
31+
0.284, 0.322, 0.357, 0.391, 0.422, 0.453, 0.483, 0.510,
32+
0.536, 0.561, 0.583, 0.606, 0.627, 0.646, 0.665, 0.683,
33+
0.700, 0.716, 0.731, 0.745, 0.759, 0.771, 0.784, 0.795,
34+
0.806, 0.816, 0.826, 0.835, 0.844, 0.852, 0.859, 0.867,
35+
0.874, 0.881, 0.887, 0.893, 0.899, 0.904, 0.909, 0.914,
36+
0.919, 0.923, 0.927, 0.931, 0.935, 0.938, 0.941, 0.944,
37+
0.947, 0.950, 0.953, 0.955, 0.958, 0.960, 0.962, 0.964,
38+
0.966, 0.968, 0.969, 0.971, 0.973, 0.974, 0.975, 0.977,
39+
0.978, 0.979, 0.980, 0.981, 0.982, 0.983, 0.984, 0.985,
40+
0.986, 0.987, 0.987, 0.988, 0.989, 0.989, 0.990, 0.990,
41+
0.991, 0.991, 0.992, 0.992, 0.993, 0.993, 0.993, 0.994,
42+
0.994, 0.994, 0.995, 0.995, 0.995, 0.995, 0.996, 0.996,
43+
0.996, 0.996, 0.997, 0.997, 0.997, 0.997, 0.997, 0.997,
44+
0.998, 0.998, 0.998, 0.998, 0.998, 0.998, 0.998, 0.998,
45+
0.998, 0.998, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999,
46+
0.999, 0.999, 1.00
47+
);
48+
2849
background: #eee;
50+
display: grid;
51+
grid-template-columns: var(--sidebar-w) 1fr;
52+
height: 100dvh;
53+
transition: grid-template-columns 1078ms var(--motion-curve);
2954
}
3055
31-
main {
32-
position: fixed;
33-
width: 100%;
34-
height: 100dvh;
56+
:scope:has(.Nav[data-collapsed]) {
57+
grid-template-columns: 0px 1fr;
3558
}
3659
37-
.Nav {
38-
position: fixed;
39-
bottom: 0;
60+
main {
4061
width: 100%;
41-
overflow: auto;
42-
43-
@media (min-aspect-ratio: 1/1) {
44-
display: inline-block;
45-
position: static;
46-
}
62+
height: 100dvh;
63+
overflow: hidden;
64+
display: grid;
65+
place-items: center;
66+
padding: 1.5rem;
67+
min-width: 0;
68+
min-height: 0;
4769
}
4870
}
4971
`}
5072
/>
5173

52-
<main>{children}</main>
5374
<Nav demos={demos} />
75+
<main>{children}</main>
5476
</body>
5577
</html>
5678
);

0 commit comments

Comments
 (0)