Improved JSX factory typings

This commit is contained in:
squidfunk 2020-02-02 16:33:09 +01:00
parent a074005b41
commit c1f0d4ab9a
6 changed files with 12 additions and 30 deletions

View File

@ -102,21 +102,13 @@ export function h(
return el
}
/**
* JSX factory wrapper
*
* @param el - JSX element
*
* @return HTML element
*/
export function toHTMLElement(el: JSXInternal.Element): HTMLElement {
return el as any // Hack: if you have a better idea, PR!
}
/* ----------------------------------------------------------------------------
* Namespace
* ------------------------------------------------------------------------- */
export declare namespace h {
export import JSX = JSXInternal
namespace JSX {
type Element = HTMLElement
type IntrinsicElements = JSXInternal.IntrinsicElements
}
}

View File

@ -473,16 +473,6 @@ export function initialize(config: unknown) {
filter(ev => !(ev.metaKey || ev.ctrlKey))
)
// search mode is active!
key$.pipe(
takeIf(searchActive$)
// switchMapIf(searchActive$, x => {
// console.log("search mode!", x)
// return EMPTY
// })
)
.subscribe(x => console.log("search mode", x))
// filter arrow keys if search is active!
searchActive$.subscribe(console.log)

View File

@ -20,7 +20,7 @@
* IN THE SOFTWARE.
*/
import { h, toHTMLElement } from "extensions"
import { h } from "extensions"
import { SearchResult } from "modules"
import { renderArticleDocument } from "../article"
@ -51,7 +51,7 @@ const css = {
export function renderSearchResult(
{ article, sections }: SearchResult
): HTMLElement {
return toHTMLElement(
return (
<li class={css.item}>
{renderArticleDocument(article)}
{...sections.map(renderSectionDocument)}

View File

@ -20,7 +20,7 @@
* IN THE SOFTWARE.
*/
import { h, toHTMLElement } from "extensions"
import { h } from "extensions"
import { ArticleDocument } from "modules"
import { truncate } from "utilities"
@ -52,7 +52,7 @@ const css = {
export function renderArticleDocument(
{ location, title, text }: ArticleDocument
): HTMLElement {
return toHTMLElement(
return (
<a href={location} title={title} class={css.link} tabIndex={-1}>
<article class={css.article}>
<h1 class={css.title}>{title}</h1>

View File

@ -20,7 +20,7 @@
* IN THE SOFTWARE.
*/
import { h, toHTMLElement } from "extensions"
import { h } from "extensions"
import { SectionDocument } from "modules"
import { truncate } from "utilities"
@ -52,7 +52,7 @@ const css = {
export function renderSectionDocument(
{ location, title, text }: SectionDocument
): HTMLElement {
return toHTMLElement(
return (
<a href={location} title={title} class={css.link} tabIndex={-1}>
<article class={css.article}>
<h1 class={css.title}>{title}</h1>

View File

@ -20,7 +20,7 @@
* IN THE SOFTWARE.
*/
import { h, toHTMLElement } from "extensions"
import { h } from "extensions"
/* ----------------------------------------------------------------------------
* Data
@ -48,7 +48,7 @@ const css = {
export function renderSource(
facts: any // TODO: add typings
): HTMLElement {
return toHTMLElement(
return (
<ul class={css.facts}>
{facts.map((fact: any) => <li class={css.fact}>{fact}</li>)}
</ul>