Add Partials (#1824)
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { Partial } from "$fresh/runtime.ts";
|
||||
import CounterA from "../../islands/CounterA.tsx";
|
||||
import { Fader } from "../../islands/Fader.tsx";
|
||||
|
||||
export default function SlotDemo() {
|
||||
return (
|
||||
<div>
|
||||
<Partial name="slot-1">
|
||||
<Fader>
|
||||
<p>Initial content</p>
|
||||
<CounterA />
|
||||
</Fader>
|
||||
</Partial>
|
||||
<p>
|
||||
<a
|
||||
class="update-link"
|
||||
href="/island_instance/injected"
|
||||
fh-partial="/island_instance/partial"
|
||||
>
|
||||
Update
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<a
|
||||
class="remove-link"
|
||||
href="/island_instance/injected"
|
||||
fh-partial="/island_instance/partial_remove"
|
||||
>
|
||||
Remove
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<a
|
||||
class="replace-link"
|
||||
href="/island_instance/injected"
|
||||
fh-partial="/island_instance/partial_replace"
|
||||
>
|
||||
Replace
|
||||
</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",
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -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 CounterA from "../../islands/CounterA.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>
|
||||
<h1>Another page</h1>
|
||||
<p class="status">updated content</p>
|
||||
<CounterA />
|
||||
</Fader>
|
||||
</Partial>
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { defineRoute } from "$fresh/src/server/defines.ts";
|
||||
import { RouteConfig } from "$fresh/server.ts";
|
||||
import { Partial } from "$fresh/runtime.ts";
|
||||
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">no islands</p>
|
||||
</Fader>
|
||||
</Partial>
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import { defineRoute } from "$fresh/src/server/defines.ts";
|
||||
import { RouteConfig } from "$fresh/server.ts";
|
||||
import { Partial } from "$fresh/runtime.ts";
|
||||
import { Fader } from "../../islands/Fader.tsx";
|
||||
import Other from "../../islands/Other.tsx";
|
||||
|
||||
export const config: RouteConfig = {
|
||||
skipAppWrapper: true,
|
||||
skipInheritedLayouts: true,
|
||||
};
|
||||
|
||||
export default defineRoute((req, ctx) => {
|
||||
return (
|
||||
<Partial name="slot-1">
|
||||
<Fader>
|
||||
<p class="status-replaced">replaced content</p>
|
||||
<Other />
|
||||
</Fader>
|
||||
</Partial>
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user