-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4eed8d2
commit 0527528
Showing
2 changed files
with
34 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,32 @@ | ||
import { ComponentChildren } from "preact"; | ||
import { ComponentChildren, JSX } from "preact"; | ||
import { Head } from "$fresh/runtime.ts"; | ||
|
||
export type PageProps = { | ||
children: ComponentChildren; | ||
export type PageProps = JSX.HTMLAttributes<HTMLBodyElement> & { | ||
title?: string; | ||
}; | ||
|
||
export default function Page({ children, title }: PageProps) { | ||
export default function Page( | ||
{ class: extraClass = "", title, ...props }: PageProps, | ||
) { | ||
const commonClassNames = [ | ||
"bg-white", | ||
"text-gray-900", | ||
"dark:(bg-gray-900 text-white)", | ||
]; | ||
const classNames = commonClassNames.concat(extraClass); | ||
|
||
const head = title | ||
? ( | ||
<Head> | ||
<title>{title}</title> | ||
</Head> | ||
) | ||
: null; | ||
|
||
return ( | ||
<> | ||
{title | ||
? ( | ||
<Head> | ||
<title>{title}</title> | ||
</Head> | ||
) | ||
: null} | ||
|
||
<body class="bg-white text-gray-900 dark:(bg-gray-900 text-white)"> | ||
{children} | ||
</body> | ||
{head} | ||
<body {...props} class={classNames.join(" ")} /> | ||
</> | ||
); | ||
} |