Improved documentation and fixed search reset

This commit is contained in:
squidfunk
2020-02-17 14:37:12 +01:00
parent fdffefd536
commit 7876148fbd
32 changed files with 106 additions and 68 deletions

View File

@@ -82,7 +82,7 @@ let components$: Observable<ComponentMap>
* Watch components with given names
*
* This function returns an observable that will maintain bindings to the given
* components in-between document switches and update the document in-place.
* components in-between document switches and update the components in-place.
*
* @param names - Component names
* @param options - Options

View File

@@ -40,14 +40,14 @@ import {
* ------------------------------------------------------------------------- */
/**
* Navigation below screen breakpoint
* Navigation for [screen -]
*/
export interface NavigationBelowScreen {
layer: NavigationLayer /* Active layer */
}
/**
* Navigation above screen breakpoint
* Navigation for [screen +]
*/
export interface NavigationAboveScreen {
sidebar: Sidebar /* Sidebar */
@@ -94,7 +94,7 @@ export function mountNavigation(
.pipe(
switchMap(screen => {
/* Mount navigation above screen breakpoint */
/* [screen +]: Mount navigation in sidebar */
if (screen) {
return watchSidebar(el, { main$, viewport$ })
.pipe(
@@ -102,7 +102,7 @@ export function mountNavigation(
map(sidebar => ({ sidebar }))
)
/* Mount navigation below screen breakpoint */
/* [screen -]: Mount navigation in drawer */
} else {
const els = getElements("nav", el)
return watchNavigationLayer(els)

View File

@@ -79,19 +79,19 @@ export function mountSearch(
return pipe(
switchMap(() => {
/* Mount search query */
const query$ = useComponent<HTMLInputElement>("search-query")
.pipe(
mountSearchQuery(handler),
shareReplay(1)
)
/* Mount search reset */
const reset$ = useComponent<HTMLInputElement>("search-reset")
.pipe(
mountSearchReset()
)
/* Mount search query */
const query$ = useComponent<HTMLInputElement>("search-query")
.pipe(
mountSearchQuery(handler, { reset$ }),
shareReplay(1)
)
/* Mount search result */
const result$ = useComponent("search-result")
.pipe(

View File

@@ -63,7 +63,6 @@ export function mountSearchQuery(
/* Subscribe worker to search query */
query$
.pipe(
distinctUntilKeyChanged("value"),
map<SearchQuery, SearchQueryMessage>(({ value }) => ({
type: SearchMessageType.QUERY,
data: value

View File

@@ -47,12 +47,12 @@ import {
* ------------------------------------------------------------------------- */
/**
* Table of contents below tablet breakpoint
* Table of contents for [tablet -]
*/
export interface TableOfContentsBelowTablet {} // tslint:disable-line
/**
* Table of contents above tablet breakpoint
* Table of contents for [tablet +]
*/
export interface TableOfContentsAboveTablet {
sidebar: Sidebar /* Sidebar */
@@ -101,7 +101,7 @@ export function mountTableOfContents(
.pipe(
switchMap(tablet => {
/* Mount table of contents above tablet breakpoint */
/* [tablet +]: Mount table of contents in sidebar */
if (tablet) {
const els = getElements<HTMLAnchorElement>(".md-nav__link", el)
@@ -123,7 +123,7 @@ export function mountTableOfContents(
map(([sidebar, anchors]) => ({ sidebar, anchors }))
)
/* Mount table of contents below tablet breakpoint */
/* [tablet -]: Unmount table of contents */
} else {
return of({})
}