Add Partials (#1824)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { Partial } from "$fresh/runtime.ts";
|
||||
import { useSignal } from "@preact/signals";
|
||||
import Spinner from "../../islands/Spinner.tsx";
|
||||
import PartialTrigger from "../../islands/PartialTrigger.tsx";
|
||||
|
||||
export default function SlotDemo() {
|
||||
const sig = useSignal(false);
|
||||
return (
|
||||
<div>
|
||||
<div class="output">
|
||||
<Partial name="slot-1">
|
||||
<p class="status">Default content</p>
|
||||
<Spinner id="inner" show={sig} />
|
||||
</Partial>
|
||||
</div>
|
||||
<Spinner id="outer" show={sig} />
|
||||
<a
|
||||
class="update-link"
|
||||
href="/loading/injected"
|
||||
fh-partial="/loading/update"
|
||||
fh-loading={sig}
|
||||
>
|
||||
update
|
||||
</a>
|
||||
<br />
|
||||
<PartialTrigger
|
||||
class="trigger"
|
||||
href="/loading/injected"
|
||||
partial="/loading/update"
|
||||
loading={sig}
|
||||
>
|
||||
partial trigger
|
||||
</PartialTrigger>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { defineRoute } from "$fresh/src/server/defines.ts";
|
||||
|
||||
export default defineRoute(() => {
|
||||
return new Response("", {
|
||||
status: 302,
|
||||
headers: {
|
||||
Location: "/loading",
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import { defineRoute } from "$fresh/src/server/defines.ts";
|
||||
import { RouteConfig } from "$fresh/server.ts";
|
||||
import { Partial } from "$fresh/runtime.ts";
|
||||
import { delay } from "../../../deps.ts";
|
||||
|
||||
export const config: RouteConfig = {
|
||||
skipAppWrapper: true,
|
||||
skipInheritedLayouts: true,
|
||||
};
|
||||
|
||||
export default defineRoute(async (req, ctx) => {
|
||||
// A bit of artificial delay to show the loader
|
||||
await delay(200);
|
||||
|
||||
return (
|
||||
<Partial name="slot-1">
|
||||
<p class="status-updated">it works</p>
|
||||
</Partial>
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user