feat: allow passing JSX children to island + nested islands (#1285)

This commit is contained in:
Marvin Hagemeister
2023-06-15 10:08:48 +02:00
committed by GitHub
parent 372d0dfffb
commit ce0eda7654
24 changed files with 873 additions and 67 deletions
@@ -0,0 +1,3 @@
export default function Home() {
return <div />;
}
@@ -0,0 +1,13 @@
import Island from "../islands/Island.tsx";
export default function Home() {
return (
<div id="page">
<Island>
<Island>
<p>it works</p>
</Island>
</Island>
</div>
);
}
@@ -0,0 +1,11 @@
import Island from "../islands/Island.tsx";
export default function Home() {
return (
<div id="page">
<Island>
<p>it works</p>
</Island>
</div>
);
}
@@ -0,0 +1,12 @@
import Island from "../islands/Island.tsx";
export default function Home() {
return (
<div id="page">
<Island>
<p>it{" "}</p>
<p>works</p>
</Island>
</div>
);
}
@@ -0,0 +1,26 @@
import { ComponentChildren } from "preact";
import Island from "../islands/Island.tsx";
function Foo(props: { children?: ComponentChildren }) {
return (
<div class="server">
{props.children}
</div>
);
}
export default function Home() {
return (
<div id="page">
<Island>
<Foo>
<Island>
<Foo>
<p>it works</p>
</Foo>
</Island>
</Foo>
</Island>
</div>
);
}
@@ -0,0 +1,11 @@
import Island from "../islands/Island.tsx";
export default function Home() {
return (
<div id="page">
<Island>
{"it"} {"works"}
</Island>
</div>
);
}
@@ -0,0 +1,12 @@
import IslandWithProps from "../islands/IslandWithProps.tsx";
import Island from "../islands/Island.tsx";
export default function Home() {
return (
<div id="page">
<Island>
<IslandWithProps foo={{ bar: "it works" }} />
</Island>
</div>
);
}
@@ -0,0 +1,14 @@
import Island from "../islands/Island.tsx";
export default function Home() {
return (
<div id="page">
<Island>
<p class="a">it works</p>
</Island>
<Island>
<p class="b">it works</p>
</Island>
</div>
);
}