Skip to content

Commit

Permalink
Merge of Insiders features tied to 'Black Pearl' funding goal
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Mar 29, 2021
1 parent 8677190 commit ca3da9e
Show file tree
Hide file tree
Showing 51 changed files with 867 additions and 194 deletions.
32 changes: 0 additions & 32 deletions material/assets/javascripts/bundle.65ce87ac.min.js

This file was deleted.

32 changes: 32 additions & 0 deletions material/assets/javascripts/bundle.d892486b.min.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions material/assets/stylesheets/main.33e2939f.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions material/assets/stylesheets/main.33e2939f.min.css.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions material/assets/stylesheets/main.c772ddf0.min.css

This file was deleted.

1 change: 0 additions & 1 deletion material/assets/stylesheets/main.c772ddf0.min.css.map

This file was deleted.

1 change: 0 additions & 1 deletion material/assets/stylesheets/palette.7fa14f5b.min.css.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions material/assets/stylesheets/palette.ef6f36e2.min.css.map

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions material/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
{% endif %}
{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.c772ddf0.min.css' | url }}">
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.33e2939f.min.css' | url }}">
{% if config.theme.palette %}
{% set palette = config.theme.palette %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.7fa14f5b.min.css' | url }}">
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.ef6f36e2.min.css' | url }}">
{% if palette.primary %}
{% import "partials/palette.html" as map %}
{% set primary = map.primary(
Expand Down Expand Up @@ -87,13 +87,14 @@
{% set primary = palette.primary | replace(" ", "-") | lower %}
{% set accent = palette.accent | replace(" ", "-") | lower %}
<body dir="{{ direction }}" data-md-color-scheme="{{ scheme }}" data-md-color-primary="{{ primary }}" data-md-color-accent="{{ accent }}">
{% if "preference" == scheme %}
<script>matchMedia("(prefers-color-scheme: dark)").matches&&document.body.setAttribute("data-md-color-scheme","slate")</script>
{% endif %}
{% else %}
<body dir="{{ direction }}">
{% endif %}
{% set features = config.theme.features or [] %}
{% include "partials/javascripts/base.html" %}
{% if not config.theme.palette is mapping %}
{% include "partials/javascripts/palette.html" %}
{% endif %}
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" for="__drawer"></label>
Expand Down Expand Up @@ -178,6 +179,11 @@ <h1>{{ page.title | d(config.site_name, true)}}</h1>
</article>
</div>
</div>
{% if "navigation.top" in features %}
<a href="#" class="md-top md-icon" data-md-component="top" data-md-state="hidden">
{% include ".icons/material/arrow-up.svg" %}
</a>
{% endif %}
</main>
{% block footer %}
{% include "partials/footer.html" %}
Expand Down Expand Up @@ -217,7 +223,7 @@ <h1>{{ page.title | d(config.site_name, true)}}</h1>
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.65ce87ac.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.d892486b.min.js' | url }}"></script>
{% for path in config["extra_javascript"] %}
<script src="{{ path | url }}"></script>
{% endfor %}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion material/overrides/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
{% endblock %}
{% block scripts %}
{{ super() }}
<script src="{{ 'overrides/assets/javascripts/bundle.afdf7228.min.js' | url }}"></script>
<script src="{{ 'overrides/assets/javascripts/bundle.3b3ca511.min.js' | url }}"></script>
{% endblock %}
20 changes: 16 additions & 4 deletions material/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,20 @@
</div>
</div>
</div>
<div class="md-header__options">
{% if config.extra.alternate %}
{% if not config.theme.palette is mapping %}
<form class="md-header__option" data-md-component="palette">
{% for option in config.theme.palette %}
{% set primary = option.primary | replace(" ", "-") | lower %}
{% set accent = option.accent | replace(" ", "-") | lower %}
<input class="md-option" data-md-color-media="{{ option.media }}" data-md-color-scheme="{{ option.scheme }}" data-md-color-primary="{{ primary }}" data-md-color-accent="{{ accent }}" type="radio" name="__palette" id="__palette_{{ loop.index }}">
<label class="md-header__button md-icon" title="{{ option.toggle.name }}" for="__palette_{{ loop.index0 or loop.length }}" hidden>
{% include ".icons/" ~ option.toggle.icon ~ ".svg" %}
</label>
{% endfor %}
</form>
{% endif %}
{% if config.extra.alternate %}
<div class="md-header__option">
<div class="md-select">
{% set icon = config.theme.icon.alternate or "material/translate" %}
<span class="md-header__button md-icon">
Expand All @@ -46,8 +58,8 @@
</ul>
</div>
</div>
{% endif %}
</div>
</div>
{% endif %}
{% if "search" in config["plugins"] %}
<label class="md-header__button md-icon" for="__search">
{% include ".icons/material/magnify.svg" %}
Expand Down
4 changes: 4 additions & 0 deletions material/partials/javascripts/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{#-
This file was automatically generated - do not edit
-#}
<script>function __prefix(e){return new URL("{{ base_url }}",location).pathname+"."+e}function __get(e,t=localStorage){return JSON.parse(t.getItem(__prefix(e)))}</script>
4 changes: 4 additions & 0 deletions material/partials/javascripts/palette.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{#-
This file was automatically generated - do not edit
-#}
<script>var palette=__get("__palette");if(null!==palette&&"object"==typeof palette.color)for(var key in palette.color)document.body.setAttribute("data-md-color-"+key,palette.color[key])</script>
17 changes: 14 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,20 @@ theme:
- navigation.sections
- navigation.tabs
palette:
scheme: default
primary: indigo
accent: indigo
- media: "(prefers-color-scheme: light)"
scheme: default
primary: indigo
accent: indigo
toggle:
icon: material/toggle-switch-off-outline
name: Switch to dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: red
accent: red
toggle:
icon: material/toggle-switch
name: Switch to light mode
font:
text: Roboto
code: Roboto Mono
Expand Down
1 change: 1 addition & 0 deletions src/assets/javascripts/_/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type Flag =
| "navigation.instant" /* Instant loading */
| "navigation.sections" /* Sections navigation */
| "navigation.tabs" /* Tabs navigation */
| "navigation.top" /* Back-to-top button */
| "toc.integrate" /* Integrated table of contents */

/* ------------------------------------------------------------------------- */
Expand Down
1 change: 1 addition & 0 deletions src/assets/javascripts/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ export * from "./search"
export * from "./sidebar"
export * from "./source"
export * from "./tabs"
export * from "./top"
48 changes: 48 additions & 0 deletions src/assets/javascripts/actions/top/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2016-2021 Martin Donath <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/

/* ----------------------------------------------------------------------------
* Functions
* ------------------------------------------------------------------------- */

/**
* Set back-to-top state
*
* @param el - Back-to-top element
* @param state - Back-to-top state
*/
export function setBackToTopState(
el: HTMLElement, state: "hidden"
): void {
el.setAttribute("data-md-state", state)
}

/**
* Reset back-to-top state
*
* @param el - Back-to-top element
*/
export function resetBackToTopState(
el: HTMLElement
): void {
el.removeAttribute("data-md-state")
}
2 changes: 1 addition & 1 deletion src/assets/javascripts/browser/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
export function request(
url: URL | string, options: RequestInit = { credentials: "same-origin" }
): Observable<Response> {
return from(fetch(url.toString(), options))
return from(fetch(`${url}`, options))
.pipe(
filter(res => res.status === 200),
)
Expand Down
20 changes: 15 additions & 5 deletions src/assets/javascripts/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ import {
import {
getComponentElement,
getComponentElements,
mountBackToTop,
mountContent,
mountDialog,
mountHeader,
mountHeaderTitle,
mountPalette,
mountSearch,
mountSidebar,
mountSource,
Expand Down Expand Up @@ -173,17 +175,17 @@ const control$ = merge(
...getComponentElements("header")
.map(el => mountHeader(el, { viewport$, header$, main$ })),

/* Color palette */
...getComponentElements("palette")
.map(el => mountPalette(el)),

/* Search */
...getComponentElements("search")
.map(el => mountSearch(el, { index$, keyboard$ })),

/* Repository information */
...getComponentElements("source")
.map(el => mountSource(el)),

/* Navigation tabs */
...getComponentElements("tabs")
.map(el => mountTabs(el, { viewport$, header$ })),
.map(el => mountSource(el))
)

/* Set up content component observables */
Expand All @@ -204,9 +206,17 @@ const content$ = defer(() => merge(
: at(tablet$, () => mountSidebar(el, { viewport$, header$, main$ }))
),

/* Navigation tabs */
...getComponentElements("tabs")
.map(el => mountTabs(el, { viewport$, header$ })),

/* Table of contents */
...getComponentElements("toc")
.map(el => mountTableOfContents(el, { viewport$, header$ })),

/* Back-to-top button */
...getComponentElements("top")
.map(el => mountBackToTop(el, { viewport$, main$ }))
))

/* Set up component observables */
Expand Down
4 changes: 4 additions & 0 deletions src/assets/javascripts/components/_/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type ComponentType =
| "header-title" /* Header title */
| "header-topic" /* Header topic */
| "main" /* Main area */
| "palette" /* Color palette */
| "search" /* Search */
| "search-query" /* Search input */
| "search-result" /* Search results */
Expand All @@ -46,6 +47,7 @@ export type ComponentType =
| "source" /* Repository information */
| "tabs" /* Navigation tabs */
| "toc" /* Table of contents */
| "top" /* Back-to-top button */

/**
* A component
Expand Down Expand Up @@ -77,6 +79,7 @@ interface ComponentTypeMap {
"header-title": HTMLElement /* Header title */
"header-topic": HTMLElement /* Header topic */
"main": HTMLElement /* Main area */
"palette": HTMLElement /* Color palette */
"search": HTMLElement /* Search */
"search-query": HTMLInputElement /* Search input */
"search-result": HTMLElement /* Search results */
Expand All @@ -85,6 +88,7 @@ interface ComponentTypeMap {
"source": HTMLAnchorElement /* Repository information */
"tabs": HTMLElement /* Navigation tabs */
"toc": HTMLElement /* Table of contents */
"top": HTMLAnchorElement /* Back-to-top button */
}

/* ----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/assets/javascripts/components/content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@

export * from "./_"
export * from "./code"
export * from "./details"
export * from "./table"
2 changes: 1 addition & 1 deletion src/assets/javascripts/components/header/_/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function isHidden({ viewport$ }: WatchOptions): Observable<boolean> {
distinctUntilChanged()
)

/* Compute threshold for autohiding */
/* Compute threshold for hiding */
const search$ = watchToggle("search")
return combineLatest([viewport$, search$])
.pipe(
Expand Down
2 changes: 2 additions & 0 deletions src/assets/javascripts/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ export * from "./content"
export * from "./dialog"
export * from "./header"
export * from "./main"
export * from "./palette"
export * from "./search"
export * from "./sidebar"
export * from "./source"
export * from "./tabs"
export * from "./toc"
export * from "./top"
Loading

0 comments on commit ca3da9e

Please sign in to comment.