feat: style component with HTMLAttributes

This commit is contained in:
DIYgod
2024-01-17 17:14:24 +08:00
parent 251e183cd7
commit f4bdee31a8
2 changed files with 7 additions and 12 deletions
+6 -11
View File
@@ -1,19 +1,14 @@
import { memo } from "react"
import { HTMLAttributes, memo } from "react"
import { toGateway } from "~/lib/ipfs-parser"
const Style = memo(function Style({
content,
children,
}: {
content?: string
children?: React.ReactNode[]
}) {
let css = content
if (!css && typeof children?.[0] === "string") {
css = children[0].trim()
}
if (!css) {
}: HTMLAttributes<HTMLStyleElement>) {
let css: string | null = null
if (typeof children === "string") {
css = children.trim()
} else {
return null
}
+1 -1
View File
@@ -49,5 +49,5 @@ export const CustomSiteStyle: FC<{
}
}, [])
return <Style content={currentStyle} />
return <Style>{currentStyle}</Style>
}