mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Improved JSX factory typings
This commit is contained in:
parent
a074005b41
commit
c1f0d4ab9a
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)}
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user