feat: Add types for partial attributes (#1862)

This commit is contained in:
Marvin Hagemeister
2023-10-05 11:02:47 +02:00
committed by GitHub
parent fd235e877c
commit fd4a2b99ef
5 changed files with 25 additions and 2 deletions
+1
View File
@@ -1,3 +1,4 @@
import "./src/types.ts";
export * from "./src/runtime/utils.ts";
export * from "./src/runtime/head.ts";
export * from "./src/runtime/csp.ts";
+1
View File
@@ -1 +1,2 @@
import "./src/types.ts";
export * from "./src/server/mod.ts";
+21
View File
@@ -0,0 +1,21 @@
export interface SignalLike<T> {
value: T;
peek(): T;
subscribe(fn: (value: T) => void): () => void;
}
declare global {
namespace preact.createElement.JSX {
interface HTMLAttributes {
/**
* Alternative url to fetch partials from on `<a>` or `<form>` tags
*/
"f-partial"?: string | SignalLike<string>;
/**
* Enable or disable client side navigation and partials for this
* particular node and its children.
*/
"f-client-nav"?: boolean | SignalLike<boolean>;
}
}
}
@@ -10,7 +10,7 @@ export default function AppLayout({ Component }: AppProps) {
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>fresh title</title>
</head>
<body f-client-nav="true">
<body f-client-nav>
<Partial name="body">
<Fader>
<Component />
@@ -10,7 +10,7 @@ export default function AppLayout({ Component }: AppProps) {
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>fresh title</title>
</head>
<body f-client-nav="false">
<body f-client-nav={false}>
<Partial name="body">
<Fader>
<Component />