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
|
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
|
* Namespace
|
||||||
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
export declare namespace h {
|
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))
|
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!
|
// filter arrow keys if search is active!
|
||||||
searchActive$.subscribe(console.log)
|
searchActive$.subscribe(console.log)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
* IN THE SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { h, toHTMLElement } from "extensions"
|
import { h } from "extensions"
|
||||||
import { SearchResult } from "modules"
|
import { SearchResult } from "modules"
|
||||||
|
|
||||||
import { renderArticleDocument } from "../article"
|
import { renderArticleDocument } from "../article"
|
||||||
@ -51,7 +51,7 @@ const css = {
|
|||||||
export function renderSearchResult(
|
export function renderSearchResult(
|
||||||
{ article, sections }: SearchResult
|
{ article, sections }: SearchResult
|
||||||
): HTMLElement {
|
): HTMLElement {
|
||||||
return toHTMLElement(
|
return (
|
||||||
<li class={css.item}>
|
<li class={css.item}>
|
||||||
{renderArticleDocument(article)}
|
{renderArticleDocument(article)}
|
||||||
{...sections.map(renderSectionDocument)}
|
{...sections.map(renderSectionDocument)}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
* IN THE SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { h, toHTMLElement } from "extensions"
|
import { h } from "extensions"
|
||||||
import { ArticleDocument } from "modules"
|
import { ArticleDocument } from "modules"
|
||||||
import { truncate } from "utilities"
|
import { truncate } from "utilities"
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ const css = {
|
|||||||
export function renderArticleDocument(
|
export function renderArticleDocument(
|
||||||
{ location, title, text }: ArticleDocument
|
{ location, title, text }: ArticleDocument
|
||||||
): HTMLElement {
|
): HTMLElement {
|
||||||
return toHTMLElement(
|
return (
|
||||||
<a href={location} title={title} class={css.link} tabIndex={-1}>
|
<a href={location} title={title} class={css.link} tabIndex={-1}>
|
||||||
<article class={css.article}>
|
<article class={css.article}>
|
||||||
<h1 class={css.title}>{title}</h1>
|
<h1 class={css.title}>{title}</h1>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
* IN THE SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { h, toHTMLElement } from "extensions"
|
import { h } from "extensions"
|
||||||
import { SectionDocument } from "modules"
|
import { SectionDocument } from "modules"
|
||||||
import { truncate } from "utilities"
|
import { truncate } from "utilities"
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ const css = {
|
|||||||
export function renderSectionDocument(
|
export function renderSectionDocument(
|
||||||
{ location, title, text }: SectionDocument
|
{ location, title, text }: SectionDocument
|
||||||
): HTMLElement {
|
): HTMLElement {
|
||||||
return toHTMLElement(
|
return (
|
||||||
<a href={location} title={title} class={css.link} tabIndex={-1}>
|
<a href={location} title={title} class={css.link} tabIndex={-1}>
|
||||||
<article class={css.article}>
|
<article class={css.article}>
|
||||||
<h1 class={css.title}>{title}</h1>
|
<h1 class={css.title}>{title}</h1>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
* IN THE SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { h, toHTMLElement } from "extensions"
|
import { h } from "extensions"
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
* Data
|
* Data
|
||||||
@ -48,7 +48,7 @@ const css = {
|
|||||||
export function renderSource(
|
export function renderSource(
|
||||||
facts: any // TODO: add typings
|
facts: any // TODO: add typings
|
||||||
): HTMLElement {
|
): HTMLElement {
|
||||||
return toHTMLElement(
|
return (
|
||||||
<ul class={css.facts}>
|
<ul class={css.facts}>
|
||||||
{facts.map((fact: any) => <li class={css.fact}>{fact}</li>)}
|
{facts.map((fact: any) => <li class={css.fact}>{fact}</li>)}
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
Reference in New Issue
Block a user