mirror of
https://github.com/linsa-io/linsa.git
synced 2026-03-28 11:51:59 +01:00
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:
21
web/lib/utils/htmlLikeElementUtil.ts
Normal file
21
web/lib/utils/htmlLikeElementUtil.ts
Normal 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)))
|
||||
}
|
||||
Reference in New Issue
Block a user