feat: navigation for command palette (#150)

* feat: add dotenv to dev dep

* chore: jest use env

* feat

* feat: command palette navigation
This commit is contained in:
Aslam
2024-09-08 05:43:44 +07:00
committed by GitHub
parent a87c27d91f
commit f005101d91
8 changed files with 185 additions and 13 deletions

View File

@@ -0,0 +1,21 @@
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)))
}