-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,30 @@ | ||
import * as React from "react"; | ||
import { cookies } from "next/headers"; | ||
import { DEFAULT_ID } from "../../constants"; | ||
import type { ColorSchemePreference } from "../../hooks/use-theme"; | ||
|
||
interface ServerTargetProps { | ||
children?: React.ReactNode; | ||
tag?: keyof JSX.IntrinsicElements; | ||
targetId?: string; | ||
} | ||
|
||
/** | ||
* # ServerTarget | ||
* | ||
* --todo | ||
* update comments | ||
* create colorswitch | ||
* update examples | ||
*/ | ||
export function ServerTarget({ children }: ServerTargetProps) { | ||
return ( | ||
<div> | ||
<h1 data-testid="server-target-h1">server-target</h1> | ||
{children} | ||
</div> | ||
); | ||
export function ServerTarget({ tag, targetId }: ServerTargetProps) { | ||
const key = targetId || DEFAULT_ID; | ||
const [theme, csp, scs] = (cookies().get(key)?.value ?? ",system,light").split(",") as [ | ||
Check failure on line 20 in lib/nthul/src/server/server-target/server-target.tsx GitHub Actions / testsrc/server/server-target/server-target.test.tsx > server-target > check if h1 heading exists
Check failure on line 20 in lib/nthul/src/server/server-target/server-target.tsx GitHub Actions / generate-docssrc/server/server-target/server-target.test.tsx > server-target > check if h1 heading exists
Check failure on line 20 in lib/nthul/src/server/server-target/server-target.tsx GitHub Actions / generate-docssrc/server/server-target/server-target.test.tsx > server-target > check if h1 heading exists
Check failure on line 20 in lib/nthul/src/server/server-target/server-target.tsx GitHub Actions / testsrc/server/server-target/server-target.test.tsx > server-target > check if h1 heading exists
|
||
string, | ||
ColorSchemePreference, | ||
"dark" | "light", | ||
]; | ||
|
||
const cls = `th-${theme} ${csp === "system" ? scs : csp}`; | ||
|
||
const Tag = tag ?? "div"; | ||
return <Tag className={cls} data-nth="next" id={targetId ?? DEFAULT_ID} />; | ||
} |