Add Partials (#1824)

This commit is contained in:
Marvin Hagemeister
2023-09-27 13:34:30 +02:00
committed by GitHub
parent d9829e25e6
commit 665d35bbc2
92 changed files with 3271 additions and 116 deletions
@@ -0,0 +1,46 @@
import { Partial } from "$fresh/runtime.ts";
import CounterA from "../../islands/CounterA.tsx";
import CounterB from "../../islands/CounterB.tsx";
import { Fader } from "../../islands/Fader.tsx";
export default function SlotDemo() {
return (
<div>
<div id="output">
<Partial name="slot-1">
<Fader>
<p>Initial content slot 1</p>
<CounterA />
</Fader>
</Partial>
<hr />
<Partial name="slot-2">
<Fader>
<p>Initial content slot 2</p>
<CounterB />
</Fader>
</Partial>
<hr />
</div>
<p>
<a
class="update-second-link"
href="/island_instance_multiple/injected"
fh-partial="/island_instance_multiple/partial"
>
update second
</a>
</p>
<p>
<a
class="update-both-link"
href="/island_instance_multiple/injected"
fh-partial="/island_instance_multiple/partial_both"
>
update both
</a>
</p>
<pre id="logs" />
</div>
);
}
@@ -0,0 +1,10 @@
import { defineRoute } from "$fresh/src/server/defines.ts";
export default defineRoute(() => {
return new Response("", {
status: 302,
headers: {
Location: "/island_instance_multiple",
},
});
});
@@ -0,0 +1,22 @@
import { defineRoute } from "$fresh/src/server/defines.ts";
import { RouteConfig } from "$fresh/server.ts";
import { Partial } from "$fresh/runtime.ts";
import CounterB from "../../islands/CounterB.tsx";
import { Fader } from "../../islands/Fader.tsx";
export const config: RouteConfig = {
skipAppWrapper: true,
skipInheritedLayouts: true,
};
export default defineRoute((req, ctx) => {
return (
<Partial name="slot-2">
<Fader>
<h1>Another page</h1>
<p class="status-2">updated content {Math.random()}</p>
<CounterB />
</Fader>
</Partial>
);
});
@@ -0,0 +1,31 @@
import { defineRoute } from "$fresh/src/server/defines.ts";
import { RouteConfig } from "$fresh/server.ts";
import { Partial } from "$fresh/runtime.ts";
import CounterA from "../../islands/CounterA.tsx";
import CounterB from "../../islands/CounterB.tsx";
import { Fader } from "../../islands/Fader.tsx";
export const config: RouteConfig = {
skipAppWrapper: true,
skipInheritedLayouts: true,
};
export default defineRoute((req, ctx) => {
return (
<>
<Partial name="slot-1">
<Fader>
<p class="status-1">updated content {Math.random()}</p>
<CounterA />
</Fader>
</Partial>
<Partial name="slot-2">
<Fader>
<h1>Another page</h1>
<p class="status-2">updated content {Math.random()}</p>
<CounterB />
</Fader>
</Partial>
</>
);
});