mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
* feat: add dotenv to dev dep * chore: jest use env * feat * feat: command palette navigation
22 lines
569 B
TypeScript
22 lines
569 B
TypeScript
import React from "react"
|
|
|
|
export type HTMLAttributes = React.HTMLAttributes<HTMLElement> & {
|
|
[key: string]: any
|
|
}
|
|
|
|
export type HTMLLikeElement = {
|
|
tag: keyof JSX.IntrinsicElements
|
|
attributes?: HTMLAttributes
|
|
children?: (HTMLLikeElement | string)[]
|
|
}
|
|
|
|
export const renderHTMLLikeElement = (element: HTMLLikeElement | string): React.ReactNode => {
|
|
if (typeof element === "string") {
|
|
return element
|
|
}
|
|
|
|
const { tag, attributes = {}, children = [] } = element
|
|
|
|
return React.createElement(tag, attributes, ...children.map(child => renderHTMLLikeElement(child)))
|
|
}
|