Unified components and observable structure

This commit is contained in:
squidfunk 2020-03-05 17:17:15 +01:00
parent 6e6868b8cd
commit 9738c12cc9
149 changed files with 11475 additions and 1095 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 KiB

After

Width:  |  Height:  |  Size: 291 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,10 @@
{ {
"assets/javascripts/bundle.js": "assets/javascripts/bundle.8ceb0d66.min.js", "assets/javascripts/bundle.js": "assets/javascripts/bundle.js",
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.8ceb0d66.min.js.map", "assets/javascripts/bundle.js.map": "assets/javascripts/bundle.js.map",
"assets/javascripts/vendor.js": "assets/javascripts/vendor.000c9aa0.min.js", "assets/javascripts/vendor.js": "assets/javascripts/vendor.js",
"assets/javascripts/vendor.js.map": "assets/javascripts/vendor.000c9aa0.min.js.map", "assets/javascripts/vendor.js.map": "assets/javascripts/vendor.js.map",
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.926ffd9e.min.js", "assets/javascripts/worker/search.js": "assets/javascripts/worker/search.js",
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.926ffd9e.min.js.map", "assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.js.map",
"assets/stylesheets/main.css": "assets/stylesheets/main.c05f2dae.min.css", "assets/stylesheets/main.css": "assets/stylesheets/main.css",
"assets/stylesheets/palette.css": "assets/stylesheets/palette.f5f04e6f.min.css" "assets/stylesheets/palette.css": "assets/stylesheets/palette.css"
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,6 @@
This file was automatically generated - do not edit This file was automatically generated - do not edit
-#} -#}
{% import "partials/language.html" as lang with context %} {% import "partials/language.html" as lang with context %}
{% set feature = config.theme.feature %}
{% set palette = config.theme.palette %} {% set palette = config.theme.palette %}
{% set font = config.theme.font %} {% set font = config.theme.font %}
<!doctype html> <!doctype html>
@ -43,7 +42,7 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block styles %} {% block styles %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.c05f2dae.min.css' | url }}"> <link rel="stylesheet" href="{{ 'assets/stylesheets/main.14bb5ffa.min.css' | url }}">
{% if palette.primary or palette.accent %} {% if palette.primary or palette.accent %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.f5f04e6f.min.css' | url }}"> <link rel="stylesheet" href="{{ 'assets/stylesheets/palette.f5f04e6f.min.css' | url }}">
{% endif %} {% endif %}
@ -79,18 +78,20 @@
{% endblock %} {% endblock %}
{% block extrahead %}{% endblock %} {% block extrahead %}{% endblock %}
</head> </head>
{% set direction = config.theme.direction | default(lang.t('direction')) %}
{% if palette.primary or palette.accent %} {% if palette.primary or palette.accent %}
{% set primary = palette.primary | replace(" ", "-") | lower %} {% set primary = palette.primary | replace(" ", "-") | lower %}
{% set accent = palette.accent | replace(" ", "-") | lower %} {% set accent = palette.accent | replace(" ", "-") | lower %}
<body dir="{{ lang.t('direction') }}" data-md-color-primary="{{ primary }}" data-md-color-accent="{{ accent }}"> <body dir="{{ direction }}" data-md-color-primary="{{ primary }}" data-md-color-accent="{{ accent }}">
{% else %} {% else %}
<body dir="{{ lang.t('direction') }}"> <body dir="{{ direction }}">
{% endif %} {% endif %}
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off"> <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"> <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" for="__drawer"></label> <label class="md-overlay" for="__drawer"></label>
{% if page.toc | first is defined %} {% if page.toc | first is defined %}
<a href="{{ (page.toc | first).url }}" class="md-skip"> {% set skip = page.toc | first %}
<a href="{{ skip.url | url }}" class="md-skip" data-md-component="skip">
{{ lang.t('skip.link.title') }} {{ lang.t('skip.link.title') }}
</a> </a>
{% endif %} {% endif %}
@ -111,7 +112,7 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block tabs %} {% block tabs %}
{% if feature.tabs %} {% if "tabs" in config.theme.features %}
{% include "partials/tabs.html" %} {% include "partials/tabs.html" %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}
@ -147,40 +148,19 @@
{% endif %} {% endif %}
{% block source %} {% block source %}
{% if page and page.meta and page.meta.source %} {% if page and page.meta and page.meta.source %}
{% set repo = config.repo_url %} {% include "partials/source-link.html" %}
{% if repo | last == "/" %}
{% set repo = repo[:-1] %}
{% endif %}
{% set path = page.meta.path | default([""]) %}
{% set file = page.meta.source %}
{% set repo_icon = config.extra.repo_icon | default(
"fontawesome/brands/git-alt"
) %}
<a href="{{ [repo, path, page.meta.source] | join('/') }}" title="{{ file }}" class="md-content__button md-icon">
{{ lang.t("meta.source") }}
{% include ".icons/" ~ repo_icon ~ ".svg" %}
</a>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% if not "\x3ch1" in page.content %} {% if not "\x3ch1" in page.content %}
<h1>{{ page.title | default(config.site_name, true)}}</h1> <h1>{{ page.title | default(config.site_name, true)}}</h1>
{% endif %} {% endif %}
{{ page.content }} {{ page.content }}
{% if page and page.meta and ( {% if page and page.meta %}
page.meta.git_revision_date_localized or {% if page.meta.git_revision_date_localized or
page.meta.revision_date page.meta.revision_date
) %} %}
{% set label = lang.t("source.revision.date") %} {% include "partials/source-date.html" %}
<hr> {% endif %}
<div class="md-source-date">
<small>
{% if page.meta.git_revision_date_localized %}
{{ label }}: {{ page.meta.git_revision_date_localized }}
{% elif page.meta.revision_date %}
{{ label }}: {{ page.meta.revision_date }}
{% endif %}
</small>
</div>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block disqus %} {% block disqus %}
@ -194,21 +174,23 @@
{% include "partials/footer.html" %} {% include "partials/footer.html" %}
{% endblock %} {% endblock %}
</div> </div>
{% block config %}
<script>var __config={}</script>
{% endblock %}
{% block scripts %} {% block scripts %}
<script src="{{ 'assets/javascripts/vendor.000c9aa0.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/vendor.31a2e7b9.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.8ceb0d66.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/bundle.9330522f.min.js' | url }}"></script>
{%- set translations = {} -%} {%- set translations = {} -%}
{%- for key in [ {%- for key in [
"clipboard.copy", "clipboard.copy",
"clipboard.copied", "clipboard.copied",
"search.language", "search.config.lang",
"search.pipeline.stopwords", "search.config.pipeline",
"search.pipeline.trimmer", "search.config.separator",
"search.result.placeholder", "search.result.placeholder",
"search.result.none", "search.result.none",
"search.result.one", "search.result.one",
"search.result.other", "search.result.other"
"search.tokenizer"
] -%} ] -%}
{%- set _ = translations.update({ key: lang.t(key) }) -%} {%- set _ = translations.update({ key: lang.t(key) }) -%}
{%- endfor -%} {%- endfor -%}
@ -216,15 +198,15 @@
{{ translations | tojson }} {{ translations | tojson }}
</script> </script>
<script> <script>
app = initialize({ __material = initialize(Object.assign({
base: "{{ base_url }}", url: {
worker: { base: "{{ base_url }}",
search: "{{ 'assets/javascripts/worker/search.926ffd9e.min.js' | url }}" worker: {
search: "{{ 'assets/javascripts/worker/search.edc88caf.min.js' | url }}"
}
}, },
feature: { features: {{ config.theme.features | tojson }}
instant: {{ "true" if feature and feature.instant else "false" }} }, __config))
}
});
</script> </script>
{% for path in config["extra_javascript"] %} {% for path in config["extra_javascript"] %}
<script src="{{ path | url }}"></script> <script src="{{ path | url }}"></script>

View File

@ -26,15 +26,7 @@ direction:
# Feature flags for functionality that alters behavior significantly, and thus # Feature flags for functionality that alters behavior significantly, and thus
# may be a matter of taste # may be a matter of taste
feature: features: []
# Another layer on top of the main navigation for larger screens in the form
# of tabs, especially useful for larger documentation projects
tabs: false
# Instant loading will instruct the application to intercept all internal
# links, load and inject the HTML into the page and rebind all handlers
instant: false
# Sets the primary and accent color palettes as defined in the Material Design # Sets the primary and accent color palettes as defined in the Material Design
# documentation - possible values can be looked up in the getting started guide # documentation - possible values can be looked up in the getting started guide
@ -61,10 +53,10 @@ font:
icon: icon:
# Shown if no logo is set # Shown if no logo is set
logo: .icons/material/book-open-variant logo: material/library
# Repository icon # Repository icon
repo: .icons/fontawesome/git-alt repo: fontawesome/brands/git-alt
# Favicon to be rendered # Favicon to be rendered
favicon: assets/images/favicon.png favicon: assets/images/favicon.png

View File

@ -1,9 +1,8 @@
{#- {#-
This file was automatically generated - do not edit This file was automatically generated - do not edit
-#} -#}
{% set feature = config.theme.feature %}
{% set class = "md-hero" %} {% set class = "md-hero" %}
{% if not feature.tabs %} {% if "tabs" not in config.theme.features %}
{% set class = "md-hero md-hero--expand" %} {% set class = "md-hero md-hero--expand" %}
{% endif %} {% endif %}
<div class="{{ class }}" data-md-component="hero"> <div class="{{ class }}" data-md-component="hero">

View File

@ -3,6 +3,4 @@
-#} -#}
{% import "partials/language/" + config.theme.language + ".html" as lang %} {% import "partials/language/" + config.theme.language + ".html" as lang %}
{% import "partials/language/en.html" as fallback %} {% import "partials/language/en.html" as fallback %}
{% macro t(key) %}{{ { {% macro t(key) %}{{ lang.t(key) | default(fallback.t(key)) }}{% endmacro %}
"direction": config.theme.direction
}[key] or lang.t(key) or fallback.t(key) }}{% endmacro %}

View File

@ -10,7 +10,7 @@
"footer.next": "Volgende", "footer.next": "Volgende",
"meta.comments": "Kommentaar", "meta.comments": "Kommentaar",
"meta.source": "Bron", "meta.source": "Bron",
"search.language": "nl", "search.config.lang": "nl",
"search.placeholder": "Soek", "search.placeholder": "Soek",
"search.result.placeholder": "Tik om te begin soek", "search.result.placeholder": "Tik om te begin soek",
"search.result.none": "Geen ooreenstemmende dokumente", "search.result.none": "Geen ooreenstemmende dokumente",

View File

@ -11,9 +11,7 @@
"footer.next": "التالية", "footer.next": "التالية",
"meta.comments": "التعليقات", "meta.comments": "التعليقات",
"meta.source": "المصدر", "meta.source": "المصدر",
"search.language": "", "search.config.pipeline": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.placeholder": "بحث", "search.placeholder": "بحث",
"search.result.placeholder": "اكتب لبدء البحث", "search.result.placeholder": "اكتب لبدء البحث",
"search.result.none": "لا توجد نتائج", "search.result.none": "لا توجد نتائج",

View File

@ -10,7 +10,6 @@
"footer.next": "Següent", "footer.next": "Següent",
"meta.comments": "Comentaris", "meta.comments": "Comentaris",
"meta.source": "Codi font", "meta.source": "Codi font",
"search.language": "",
"search.placeholder": "Cerca", "search.placeholder": "Cerca",
"search.result.placeholder": "Escriu per a començar a cercar", "search.result.placeholder": "Escriu per a començar a cercar",
"search.result.none": "Cap document coincideix", "search.result.none": "Cap document coincideix",

View File

@ -10,7 +10,7 @@
"footer.next": "Další", "footer.next": "Další",
"meta.comments": "Komentáře", "meta.comments": "Komentáře",
"meta.source": "Zdroj", "meta.source": "Zdroj",
"search.language": "ro", "search.config.lang": "ro",
"search.placeholder": "Hledat", "search.placeholder": "Hledat",
"search.result.placeholder": "Pište co se má vyhledat", "search.result.placeholder": "Pište co se má vyhledat",
"search.result.none": "Nenalezeny žádné dokumenty", "search.result.none": "Nenalezeny žádné dokumenty",

View File

@ -10,7 +10,7 @@
"footer.next": "Næste", "footer.next": "Næste",
"meta.comments": "Kommentarer", "meta.comments": "Kommentarer",
"meta.source": "Kilde", "meta.source": "Kilde",
"search.language": "da", "search.config.lang": "da",
"search.placeholder": "Søg", "search.placeholder": "Søg",
"search.result.placeholder": "Indtast søgeord", "search.result.placeholder": "Indtast søgeord",
"search.result.none": "Ingen resultater fundet", "search.result.none": "Ingen resultater fundet",

View File

@ -10,7 +10,7 @@
"footer.next": "Weiter", "footer.next": "Weiter",
"meta.comments": "Kommentare", "meta.comments": "Kommentare",
"meta.source": "Quellcode", "meta.source": "Quellcode",
"search.language": "de", "search.config.lang": "de",
"search.placeholder": "Suche", "search.placeholder": "Suche",
"search.result.placeholder": "Suchbegriff eingeben", "search.result.placeholder": "Suchbegriff eingeben",
"search.result.none": "Keine Suchergebnisse", "search.result.none": "Keine Suchergebnisse",

View File

@ -11,15 +11,14 @@
"footer.next": "Next", "footer.next": "Next",
"meta.comments": "Comments", "meta.comments": "Comments",
"meta.source": "Source", "meta.source": "Source",
"search.language": "en", "search.config.lang": "en",
"search.pipeline.stopwords": true, "search.config.pipeline": "trimmer, stopWordFilter",
"search.pipeline.trimmer": true, "search.config.separator": "[\s\-]+",
"search.placeholder": "Search", "search.placeholder": "Search",
"search.result.placeholder": "Type to start searching", "search.result.placeholder": "Type to start searching",
"search.result.none": "No matching documents", "search.result.none": "No matching documents",
"search.result.one": "1 matching document", "search.result.one": "1 matching document",
"search.result.other": "# matching documents", "search.result.other": "# matching documents",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Skip to content", "skip.link.title": "Skip to content",
"source.link.title": "Go to repository", "source.link.title": "Go to repository",
"source.revision.date": "Last update", "source.revision.date": "Last update",

View File

@ -10,7 +10,7 @@
"footer.next": "Siguiente", "footer.next": "Siguiente",
"meta.comments": "Comentarios", "meta.comments": "Comentarios",
"meta.source": "Fuente", "meta.source": "Fuente",
"search.language": "es", "search.config.lang": "es",
"search.placeholder": "Búsqueda", "search.placeholder": "Búsqueda",
"search.result.placeholder": "Teclee para comenzar búsqueda", "search.result.placeholder": "Teclee para comenzar búsqueda",
"search.result.none": "No se encontraron documentos", "search.result.none": "No se encontraron documentos",

View File

@ -10,9 +10,7 @@
"footer.next": "Järgmine", "footer.next": "Järgmine",
"meta.comments": "Kommentaarid", "meta.comments": "Kommentaarid",
"meta.source": "Lähtekood", "meta.source": "Lähtekood",
"search.language": "", "search.config.pipeline": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.placeholder": "Otsi", "search.placeholder": "Otsi",
"search.result.placeholder": "Otsimiseks kirjuta siia", "search.result.placeholder": "Otsimiseks kirjuta siia",
"search.result.none": "Otsingule ei leitud ühtegi vastet", "search.result.none": "Otsingule ei leitud ühtegi vastet",

View File

@ -11,9 +11,7 @@
"footer.next": "بعدی", "footer.next": "بعدی",
"meta.comments": "نظرات", "meta.comments": "نظرات",
"meta.source": "منبع", "meta.source": "منبع",
"search.language": "", "search.config.pipeline": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.placeholder": "جستجو", "search.placeholder": "جستجو",
"search.result.placeholder": "برای شروع جستجو تایپ کنید", "search.result.placeholder": "برای شروع جستجو تایپ کنید",
"search.result.none": "سندی یافت نشد", "search.result.none": "سندی یافت نشد",

View File

@ -10,7 +10,7 @@
"footer.next": "Seuraava", "footer.next": "Seuraava",
"meta.comments": "Kommentit", "meta.comments": "Kommentit",
"meta.source": "Lähdekodi", "meta.source": "Lähdekodi",
"search.language": "fi", "search.config.lang": "fi",
"search.placeholder": "Hae", "search.placeholder": "Hae",
"search.result.placeholder": "Kirjoita aloittaaksesi haun", "search.result.placeholder": "Kirjoita aloittaaksesi haun",
"search.result.none": "Ei täsmääviä dokumentteja", "search.result.none": "Ei täsmääviä dokumentteja",

View File

@ -10,12 +10,13 @@
"footer.next": "Suivant", "footer.next": "Suivant",
"meta.comments": "Commentaires", "meta.comments": "Commentaires",
"meta.source": "Source", "meta.source": "Source",
"search.language": "fr", "search.config.lang": "fr",
"search.placeholder": "Rechercher", "search.placeholder": "Rechercher",
"search.result.placeholder": "Taper pour démarrer la recherche", "search.result.placeholder": "Taper pour démarrer la recherche",
"search.result.none": "Aucun document trouvé", "search.result.none": "Aucun document trouvé",
"search.result.one": "1 document trouvé", "search.result.one": "1 document trouvé",
"search.result.other": "# documents trouvés", "search.result.other": "# documents trouvés",
"skip.link.title": "Aller au contenu",
"source.link.title": "Aller au dépôt", "source.link.title": "Aller au dépôt",
"source.revision.date": "Dernière mise à jour", "source.revision.date": "Dernière mise à jour",
"toc.title": "Table des matières" "toc.title": "Table des matières"

View File

@ -10,7 +10,7 @@
"footer.next": "Seguinte", "footer.next": "Seguinte",
"meta.comments": "Comentarios", "meta.comments": "Comentarios",
"meta.source": "Fonte", "meta.source": "Fonte",
"search.language": "es", "search.config.lang": "es",
"search.placeholder": "Busca", "search.placeholder": "Busca",
"search.result.placeholder": "Insira un termo", "search.result.placeholder": "Insira un termo",
"search.result.none": "Sen resultados", "search.result.none": "Sen resultados",

View File

@ -10,9 +10,7 @@
"footer.next": "Προηγούμενη", "footer.next": "Προηγούμενη",
"meta.comments": "Σχόλια", "meta.comments": "Σχόλια",
"meta.source": "Πηγή", "meta.source": "Πηγή",
"search.language": "", "search.config.pipeline": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.placeholder": "Αναζήτηση", "search.placeholder": "Αναζήτηση",
"search.result.placeholder": "Πληκτρολογήστε για να αρχίσει η αναζήτηση", "search.result.placeholder": "Πληκτρολογήστε για να αρχίσει η αναζήτηση",
"search.result.none": "Δε βρέθηκαν αντίστοιχα αρχεία", "search.result.none": "Δε βρέθηκαν αντίστοιχα αρχεία",

View File

@ -11,9 +11,7 @@
"footer.next": "הַבָּא", "footer.next": "הַבָּא",
"meta.comments": "הערות", "meta.comments": "הערות",
"meta.source": "מָקוֹר", "meta.source": "מָקוֹר",
"search.language": "", "search.config.pipeline": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.placeholder": "לחפש", "search.placeholder": "לחפש",
"search.result.placeholder": "הקלד כדי להתחיל לחפש", "search.result.placeholder": "הקלד כדי להתחיל לחפש",
"search.result.none": "אין מסמכים תואמים", "search.result.none": "אין מסמכים תואמים",

View File

@ -10,9 +10,7 @@
"footer.next": "आगामी", "footer.next": "आगामी",
"meta.comments": "टिप्पणियाँ", "meta.comments": "टिप्पणियाँ",
"meta.source": "स्रोत", "meta.source": "स्रोत",
"search.language": "", "search.config.pipeline": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.placeholder": "खोज", "search.placeholder": "खोज",
"search.result.placeholder": "खोज शुरू करने के लिए टाइप करें", "search.result.placeholder": "खोज शुरू करने के लिए टाइप करें",
"search.result.none": "कोई मिलान डॉक्यूमेंट नहीं", "search.result.none": "कोई मिलान डॉक्यूमेंट नहीं",

View File

@ -10,9 +10,7 @@
"footer.next": "Sljedeće", "footer.next": "Sljedeće",
"meta.comments": "Komentari", "meta.comments": "Komentari",
"meta.source": "Izvor", "meta.source": "Izvor",
"search.language": "", "search.config.pipeline": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.placeholder": "Pretraživanje", "search.placeholder": "Pretraživanje",
"search.result.placeholder": "Unesite pojam pretraživanja", "search.result.placeholder": "Unesite pojam pretraživanja",
"search.result.none": "Ništa nije pronađeno", "search.result.none": "Ništa nije pronađeno",

View File

@ -10,7 +10,7 @@
"footer.next": "Következő", "footer.next": "Következő",
"meta.comments": "Hozzászólások", "meta.comments": "Hozzászólások",
"meta.source": "Forrás", "meta.source": "Forrás",
"search.language": "hu", "search.config.lang": "hu",
"search.placeholder": "Keresés", "search.placeholder": "Keresés",
"search.result.placeholder": "Kereséshez írj ide valamit", "search.result.placeholder": "Kereséshez írj ide valamit",
"search.result.none": "Nincs találat", "search.result.none": "Nincs találat",

View File

@ -10,9 +10,7 @@
"footer.next": "Selanjutnya", "footer.next": "Selanjutnya",
"meta.comments": "Komentar", "meta.comments": "Komentar",
"meta.source": "Sumber", "meta.source": "Sumber",
"search.language": "", "search.config.pipeline": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.placeholder": "Cari", "search.placeholder": "Cari",
"search.result.placeholder": "Ketik untuk mulai pencarian", "search.result.placeholder": "Ketik untuk mulai pencarian",
"search.result.none": "Tidak ada dokumen yang sesuai", "search.result.none": "Tidak ada dokumen yang sesuai",

View File

@ -10,7 +10,7 @@
"footer.next": "Prossimo", "footer.next": "Prossimo",
"meta.comments": "Commenti", "meta.comments": "Commenti",
"meta.source": "Sorgente", "meta.source": "Sorgente",
"search.language": "it", "search.config.lang": "it",
"search.placeholder": "Cerca", "search.placeholder": "Cerca",
"search.result.placeholder": "Scrivi per iniziare a cercare", "search.result.placeholder": "Scrivi per iniziare a cercare",
"search.result.none": "Nessun documento trovato", "search.result.none": "Nessun documento trovato",

View File

@ -10,13 +10,13 @@
"footer.next": "次", "footer.next": "次",
"meta.comments": "コメント", "meta.comments": "コメント",
"meta.source": "ソース", "meta.source": "ソース",
"search.language": "ja", "search.config.lang": "ja",
"search.config.separator": "[\s\- 、。,.]+",
"search.placeholder": "検索", "search.placeholder": "検索",
"search.result.placeholder": "検索キーワードを入力してください", "search.result.placeholder": "検索キーワードを入力してください",
"search.result.none": "何も見つかりませんでした", "search.result.none": "何も見つかりませんでした",
"search.result.one": "1件見つかりました", "search.result.one": "1件見つかりました",
"search.result.other": "#件見つかりました", "search.result.other": "#件見つかりました",
"search.tokenizer": "[\s\- 、。,.]+",
"source.link.title": "リポジトリへ", "source.link.title": "リポジトリへ",
"source.revision.date": "最終更新日", "source.revision.date": "最終更新日",
"toc.title": "目次" "toc.title": "目次"

View File

@ -10,7 +10,7 @@
"footer.next": "다음", "footer.next": "다음",
"meta.comments": "댓글", "meta.comments": "댓글",
"meta.source": "출처", "meta.source": "출처",
"search.language": "ja", "search.config.lang": "ja",
"search.placeholder": "검색", "search.placeholder": "검색",
"search.result.placeholder": "검색어를 입력하세요", "search.result.placeholder": "검색어를 입력하세요",
"search.result.none": "검색어와 일치하는 문서가 없습니다", "search.result.none": "검색어와 일치하는 문서가 없습니다",

View File

@ -10,7 +10,7 @@
"footer.next": "Volgende", "footer.next": "Volgende",
"meta.comments": "Reacties", "meta.comments": "Reacties",
"meta.source": "Bron", "meta.source": "Bron",
"search.language": "nl", "search.config.lang": "nl",
"search.placeholder": "Zoeken", "search.placeholder": "Zoeken",
"search.result.placeholder": "Typ om te beginnen met zoeken", "search.result.placeholder": "Typ om te beginnen met zoeken",
"search.result.none": "Geen overeenkomende documenten", "search.result.none": "Geen overeenkomende documenten",

View File

@ -10,7 +10,7 @@
"footer.next": "Neste", "footer.next": "Neste",
"meta.comments": "Kommentarar", "meta.comments": "Kommentarar",
"meta.source": "Kjelde", "meta.source": "Kjelde",
"search.language": "no", "search.config.lang": "no",
"search.placeholder": "Søk", "search.placeholder": "Søk",
"search.result.placeholder": "Skriv søkeord", "search.result.placeholder": "Skriv søkeord",
"search.result.none": "Ingen treff", "search.result.none": "Ingen treff",

View File

@ -10,7 +10,7 @@
"footer.next": "Neste", "footer.next": "Neste",
"meta.comments": "Kommentarer", "meta.comments": "Kommentarer",
"meta.source": "Kilde", "meta.source": "Kilde",
"search.language": "no", "search.config.lang": "no",
"search.placeholder": "Søk", "search.placeholder": "Søk",
"search.result.placeholder": "Skriv søkeord", "search.result.placeholder": "Skriv søkeord",
"search.result.none": "Ingen treff", "search.result.none": "Ingen treff",

View File

@ -10,9 +10,7 @@
"footer.next": "Następna strona", "footer.next": "Następna strona",
"meta.comments": "Komentarze", "meta.comments": "Komentarze",
"meta.source": "Kod źródłowy", "meta.source": "Kod źródłowy",
"search.language": "", "search.config.pipeline": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.placeholder": "Szukaj", "search.placeholder": "Szukaj",
"search.result.placeholder": "Zacznij pisać, aby szukać", "search.result.placeholder": "Zacznij pisać, aby szukać",
"search.result.none": "Brak wyników wyszukiwania", "search.result.none": "Brak wyników wyszukiwania",

View File

@ -10,7 +10,7 @@
"footer.next": "Próximo", "footer.next": "Próximo",
"meta.comments": "Comentários", "meta.comments": "Comentários",
"meta.source": "Fonte", "meta.source": "Fonte",
"search.language": "pt", "search.config.lang": "pt",
"search.placeholder": "Buscar", "search.placeholder": "Buscar",
"search.result.placeholder": "Digite para iniciar a busca", "search.result.placeholder": "Digite para iniciar a busca",
"search.result.none": "Nenhum resultado encontrado", "search.result.none": "Nenhum resultado encontrado",

View File

@ -10,7 +10,7 @@
"footer.next": "Următor", "footer.next": "Următor",
"meta.comments": "Comentarii", "meta.comments": "Comentarii",
"meta.source": "Sursă", "meta.source": "Sursă",
"search.language": "ro", "search.config.lang": "ro",
"search.placeholder": "Căutare", "search.placeholder": "Căutare",
"search.result.placeholder": "Tastează pentru a începe căutarea", "search.result.placeholder": "Tastează pentru a începe căutarea",
"search.result.none": "Nu a fost găsit niciun document", "search.result.none": "Nu a fost găsit niciun document",

View File

@ -10,7 +10,7 @@
"footer.next": "Вперед", "footer.next": "Вперед",
"meta.comments": "Комментарии", "meta.comments": "Комментарии",
"meta.source": "Исходный код", "meta.source": "Исходный код",
"search.language": "ru", "search.config.lang": "ru",
"search.placeholder": "Поиск", "search.placeholder": "Поиск",
"search.result.placeholder": "Начните печатать для поиска", "search.result.placeholder": "Начните печатать для поиска",
"search.result.none": "Совпадений не найдено", "search.result.none": "Совпадений не найдено",

View File

@ -10,7 +10,7 @@
"footer.next": "Sledeće", "footer.next": "Sledeće",
"meta.comments": "Komentari", "meta.comments": "Komentari",
"meta.source": "Izvor", "meta.source": "Izvor",
"search.language": "ro", "search.config.lang": "ro",
"search.placeholder": "Pretraga", "search.placeholder": "Pretraga",
"search.result.placeholder": "Unesite pojam pretrage", "search.result.placeholder": "Unesite pojam pretrage",
"search.result.none": "Ništa nije pronađeno", "search.result.none": "Ništa nije pronađeno",

View File

@ -10,7 +10,6 @@
"footer.next": "Naslednja stran", "footer.next": "Naslednja stran",
"meta.comments": "Komentarji", "meta.comments": "Komentarji",
"meta.source": "Izvorna koda", "meta.source": "Izvorna koda",
"search.language": "",
"search.placeholder": "Išči", "search.placeholder": "Išči",
"search.result.placeholder": "Vpiši iskalni niz", "search.result.placeholder": "Vpiši iskalni niz",
"search.result.none": "Ni zadetkov", "search.result.none": "Ni zadetkov",

View File

@ -10,7 +10,6 @@
"footer.next": "Ďalej", "footer.next": "Ďalej",
"meta.comments": "Komentáre", "meta.comments": "Komentáre",
"meta.source": "Zdroj", "meta.source": "Zdroj",
"search.language": "",
"search.placeholder": "Hľadať", "search.placeholder": "Hľadať",
"search.result.placeholder": "Pre vyhľadávanie začni písať", "search.result.placeholder": "Pre vyhľadávanie začni písať",
"search.result.none": "Žiadne vyhovujúce dokumenty", "search.result.none": "Žiadne vyhovujúce dokumenty",

View File

@ -10,9 +10,7 @@
"footer.next": "Следеће", "footer.next": "Следеће",
"meta.comments": "Коментари", "meta.comments": "Коментари",
"meta.source": "Извор", "meta.source": "Извор",
"search.language": "", "search.config.pipeline": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.placeholder": "Претрага", "search.placeholder": "Претрага",
"search.result.placeholder": "Унесите појам претраге", "search.result.placeholder": "Унесите појам претраге",
"search.result.none": "Нису пронађени документи", "search.result.none": "Нису пронађени документи",

View File

@ -10,7 +10,7 @@
"footer.next": "Nästa", "footer.next": "Nästa",
"meta.comments": "Kommentarer", "meta.comments": "Kommentarer",
"meta.source": "Källa", "meta.source": "Källa",
"search.language": "sv", "search.config.lang": "sv",
"search.placeholder": "Sök", "search.placeholder": "Sök",
"search.result.placeholder": "Skriv sökord", "search.result.placeholder": "Skriv sökord",
"search.result.none": "Inga sökresultat", "search.result.none": "Inga sökresultat",

View File

@ -10,13 +10,11 @@
"footer.next": "ต่อไป", "footer.next": "ต่อไป",
"meta.comments": "ความคิดเห็น", "meta.comments": "ความคิดเห็น",
"meta.source": "แหล่งที่มา", "meta.source": "แหล่งที่มา",
"search.language": "th",
"search.placeholder": "ค้นหา", "search.placeholder": "ค้นหา",
"search.result.placeholder": "พิมพ์เพื่อเริ่มค้นหา", "search.result.placeholder": "พิมพ์เพื่อเริ่มค้นหา",
"search.result.none": "ไม่พบเอกสารที่ตรงกัน", "search.result.none": "ไม่พบเอกสารที่ตรงกัน",
"search.result.one": "พบเอกสารที่ตรงกัน", "search.result.one": "พบเอกสารที่ตรงกัน",
"search.result.other": "พบ # เอกสารที่ตรงกัน", "search.result.other": "พบ # เอกสารที่ตรงกัน",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "ข้ามไปที่เนื้อหา", "skip.link.title": "ข้ามไปที่เนื้อหา",
"source.link.title": "ไปที่ Repository", "source.link.title": "ไปที่ Repository",
"toc.title": "สารบัญ" "toc.title": "สารบัญ"

View File

@ -10,12 +10,13 @@
"footer.next": "Sonraki", "footer.next": "Sonraki",
"meta.comments": "Yorumlar", "meta.comments": "Yorumlar",
"meta.source": "Kaynak", "meta.source": "Kaynak",
"search.language": "tr", "search.config.lang": "tr",
"search.placeholder": "Ara", "search.placeholder": "Ara",
"search.result.placeholder": "Aramaya başlamak için yazın", "search.result.placeholder": "Aramaya başlamak için yazın",
"search.result.none": "Eşleşen doküman bulunamadı", "search.result.none": "Eşleşen doküman bulunamadı",
"search.result.one": "1 doküman bulundu", "search.result.one": "1 doküman bulundu",
"search.result.other": "# doküman bulundu", "search.result.other": "# doküman bulundu",
"skip.link.title": "Ana içeriğe geç",
"source.link.title": "Depoya git", "source.link.title": "Depoya git",
"source.revision.date": "Son Güncelleme", "source.revision.date": "Son Güncelleme",
"toc.title": "İçindekiler" "toc.title": "İçindekiler"

View File

@ -10,7 +10,7 @@
"footer.next": "Вперед", "footer.next": "Вперед",
"meta.comments": "Коментарі", "meta.comments": "Коментарі",
"meta.source": "Вихідний код", "meta.source": "Вихідний код",
"search.language": "ru", "search.config.lang": "ru",
"search.placeholder": "Пошук", "search.placeholder": "Пошук",
"search.result.placeholder": "Розпочніть писати для пошуку", "search.result.placeholder": "Розпочніть писати для пошуку",
"search.result.none": "Збігів не знайдено", "search.result.none": "Збігів не знайдено",

View File

@ -10,13 +10,13 @@
"footer.next": "下一頁", "footer.next": "下一頁",
"meta.comments": "評論", "meta.comments": "評論",
"meta.source": "來源", "meta.source": "來源",
"search.language": "ja", "search.config.lang": "ja",
"search.config.separator": "[\\。]+",
"search.placeholder": "搜尋", "search.placeholder": "搜尋",
"search.result.placeholder": "鍵入以開始檢索", "search.result.placeholder": "鍵入以開始檢索",
"search.result.none": "沒有找到符合條件的結果", "search.result.none": "沒有找到符合條件的結果",
"search.result.one": "找到 1 个符合條件的結果", "search.result.one": "找到 1 个符合條件的結果",
"search.result.other": "# 個符合條件的結果", "search.result.other": "# 個符合條件的結果",
"search.tokenizer": "[\\。]+",
"skip.link.title": "跳轉至", "skip.link.title": "跳轉至",
"source.link.title": "前往 Github 倉庫", "source.link.title": "前往 Github 倉庫",
"source.revision.date": "最後更新", "source.revision.date": "最後更新",

View File

@ -10,13 +10,13 @@
"footer.next": "下一頁", "footer.next": "下一頁",
"meta.comments": "留言", "meta.comments": "留言",
"meta.source": "來源", "meta.source": "來源",
"search.language": "ja", "search.config.lang": "ja",
"search.config.separator": "[\\。]+",
"search.placeholder": "搜尋", "search.placeholder": "搜尋",
"search.result.placeholder": "打字進行搜尋", "search.result.placeholder": "打字進行搜尋",
"search.result.none": "沒有符合的項目", "search.result.none": "沒有符合的項目",
"search.result.one": "找到 1 個符合的項目", "search.result.one": "找到 1 個符合的項目",
"search.result.other": "找到 # 個符合的項目", "search.result.other": "找到 # 個符合的項目",
"search.tokenizer": "[\\。]+",
"skip.link.title": "跳轉到", "skip.link.title": "跳轉到",
"source.link.title": "前往倉庫", "source.link.title": "前往倉庫",
"toc.title": "本頁目錄" "toc.title": "本頁目錄"

View File

@ -10,13 +10,13 @@
"footer.next": "下一页", "footer.next": "下一页",
"meta.comments": "评论", "meta.comments": "评论",
"meta.source": "来源", "meta.source": "来源",
"search.language": "ja", "search.config.lang": "ja",
"search.config.separator": "[\\。]+",
"search.placeholder": "搜索", "search.placeholder": "搜索",
"search.result.placeholder": "键入以开始搜索", "search.result.placeholder": "键入以开始搜索",
"search.result.none": "没有找到符合条件的结果", "search.result.none": "没有找到符合条件的结果",
"search.result.one": "找到 1 个符合条件的结果", "search.result.one": "找到 1 个符合条件的结果",
"search.result.other": "# 个符合条件的结果", "search.result.other": "# 个符合条件的结果",
"search.tokenizer": "[\\。]+",
"skip.link.title": "跳转至", "skip.link.title": "跳转至",
"source.link.title": "前往 Github 仓库", "source.link.title": "前往 Github 仓库",
"source.revision.date": "最后更新", "source.revision.date": "最后更新",

View File

@ -4,10 +4,10 @@
<nav class="md-nav md-nav--primary" data-md-level="0"> <nav class="md-nav md-nav--primary" data-md-level="0">
<label class="md-nav__title" for="__drawer"> <label class="md-nav__title" for="__drawer">
<a href="{{ config.site_url | default(nav.homepage.url, true) | url }}" title="{{ config.site_name }}" aria-label="{{ config.site_name }}" class="md-nav__button md-logo"> <a href="{{ config.site_url | default(nav.homepage.url, true) | url }}" title="{{ config.site_name }}" aria-label="{{ config.site_name }}" class="md-nav__button md-logo">
{% if config.theme.logo.icon %} {% if config.theme.logo %}
{% include ".icons/" ~ config.theme.logo.icon ~ ".svg" %}
{% else %}
<img src="{{ config.theme.logo | url }}" alt="logo"> <img src="{{ config.theme.logo | url }}" alt="logo">
{% else %}
{% include ".icons/" ~ config.theme.icon.logo ~ ".svg" %}
{% endif %} {% endif %}
</a> </a>
{{ config.site_name }} {{ config.site_name }}

View File

@ -0,0 +1,15 @@
{#-
This file was automatically generated - do not edit
-#}
{% import "partials/language.html" as lang with context %}
{% set label = lang.t("source.revision.date") %}
<hr>
<div class="md-source-date">
<small>
{% if page.meta.git_revision_date_localized %}
{{ label }}: {{ page.meta.git_revision_date_localized }}
{% elif page.meta.revision_date %}
{{ label }}: {{ page.meta.revision_date }}
{% endif %}
</small>
</div>

View File

@ -0,0 +1,17 @@
{#-
This file was automatically generated - do not edit
-#}
{% import "partials/language.html" as lang with context %}
{% set repo = config.repo_url %}
{% if repo | last == "/" %}
{% set repo = repo[:-1] %}
{% endif %}
{% set path = page.meta.path | default([""]) %}
{% set file = page.meta.source %}
{% set repo_icon = config.extra.repo_icon | default(
"fontawesome/brands/git-alt"
) %}
<a href="{{ [repo, path, page.meta.source] | join('/') }}" title="{{ file }}" class="md-content__button md-icon">
{{ lang.t("meta.source") }}
{% include ".icons/" ~ repo_icon ~ ".svg" %}
</a>

View File

@ -3,11 +3,11 @@
-#} -#}
{% import "partials/language.html" as lang with context %} {% import "partials/language.html" as lang with context %}
<nav class="md-nav md-nav--secondary"> <nav class="md-nav md-nav--secondary">
{% set toc_ = page.toc %} {% set toc = page.toc %}
{% if toc_ | first is defined and "\x3ch1 id=" in page.content %} {% if toc | first is defined and "\x3ch1 id=" in page.content %}
{% set toc_ = (toc_ | first).children %} {% set toc = (toc | first).children %}
{% endif %} {% endif %}
{% if toc_ | first is defined %} {% if toc | first is defined %}
<label class="md-nav__title" for="__toc"> <label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"> <span class="md-nav__icon md-icon">
{% include ".icons/material/arrow-left.svg" %} {% include ".icons/material/arrow-left.svg" %}
@ -15,7 +15,7 @@
{{ lang.t("toc.title") }} {{ lang.t("toc.title") }}
</label> </label>
<ul class="md-nav__list" data-md-scrollfix> <ul class="md-nav__list" data-md-scrollfix>
{% for toc_item in toc_ %} {% for toc_item in toc %}
{% include "partials/toc-item.html" %} {% include "partials/toc-item.html" %}
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -19,7 +19,7 @@
# IN THE SOFTWARE. # IN THE SOFTWARE.
# Direct dependencies # Direct dependencies
mkdocs>=1.0 mkdocs>=1.1
Pygments>=2.4 Pygments>=2.4
markdown>=3.2 markdown>=3.2
pymdown-extensions>=7.0b2 pymdown-extensions>=7.0b2

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -60,7 +60,7 @@ interface WatchOptions {
* *
* @param options - Options * @param options - Options
* *
* @return Document switch observable * @return Document observable
*/ */
export function watchDocumentSwitch( export function watchDocumentSwitch(
{ location$ }: WatchOptions { location$ }: WatchOptions

View File

@ -64,7 +64,7 @@ export function getElementOrThrow<T extends HTMLElement>(
/** /**
* Retrieve the currently active element * Retrieve the currently active element
* *
* @return Element * @return Element or nothing
*/ */
export function getActiveElement(): HTMLElement | undefined { export function getActiveElement(): HTMLElement | undefined {
return document.activeElement instanceof HTMLElement return document.activeElement instanceof HTMLElement

View File

@ -34,11 +34,9 @@ import { getActiveElement } from "../_"
* *
* @param el - Element * @param el - Element
* @param value - Whether the element should be focused * @param value - Whether the element should be focused
*
* @return Element offset
*/ */
export function setElementFocus( export function setElementFocus(
el: HTMLElement, value: boolean = true el: HTMLElement, value: boolean = true
): void { ): void {
if (value) if (value)
el.focus() el.focus()

View File

@ -25,5 +25,6 @@ export * from "./element"
export * from "./keyboard" export * from "./keyboard"
export * from "./location" export * from "./location"
export * from "./media" export * from "./media"
export * from "./toggle"
export * from "./viewport" export * from "./viewport"
export * from "./worker" export * from "./worker"

View File

@ -46,7 +46,7 @@ export interface Key {
* *
* @return Test result * @return Test result
*/ */
export function isSusceptibleToKeyboard(el: HTMLElement) { export function isSusceptibleToKeyboard(el: HTMLElement): boolean {
switch (el.tagName) { switch (el.tagName) {
/* Form elements */ /* Form elements */

View File

@ -51,6 +51,40 @@ export function setLocation(url: URL): void {
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/**
* Check whether a URL is an internal link or a file (except `.html`)
*
* @param url - URL or HTML anchor element
* @param ref - Reference URL
*
* @return Test result
*/
export function isLocationInternal(
url: URL | HTMLAnchorElement,
ref: URL | Location = location
): boolean {
return url.host === ref.host
&& /^(?:\/[\w-]+)*(?:\/?|\.html)$/i.test(url.pathname)
}
/**
* Check whether a URL is an anchor link on the current page
*
* @param url - URL or HTML anchor element
* @param ref - Reference URL
*
* @return Test result
*/
export function isLocationAnchor(
url: URL | HTMLAnchorElement,
ref: URL | Location = location
): boolean {
return url.pathname === ref.pathname
&& url.hash.length > 0
}
/* ------------------------------------------------------------------------- */
/** /**
* Watch location * Watch location
* *

View File

@ -36,6 +36,22 @@ export function getLocationHash(): string {
return location.hash.substring(1) return location.hash.substring(1)
} }
/**
* Set location hash
*
* Setting a new fragment identifier via `location.hash` will have no effect
* if the value doesn't change. However, when a new fragment identifier is set,
* we want the browser to target the respective element at all times, which is
* why we use this dirty little trick.
*
* @param hash - Location hash
*/
export function setLocationHash(hash: string): void {
const el = document.createElement("a")
el.href = hash
el.click()
}
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/** /**

View File

@ -20,17 +20,10 @@
* IN THE SOFTWARE. * IN THE SOFTWARE.
*/ */
import { NEVER, Observable, fromEvent, of } from "rxjs" import { Observable, fromEvent } from "rxjs"
import { import { map, startWith } from "rxjs/operators"
distinctUntilChanged,
map,
shareReplay,
startWith,
switchMap,
take
} from "rxjs/operators"
import { getElement } from "../agent" import { getElementOrThrow } from "../element"
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Types * Types
@ -43,92 +36,33 @@ export type Toggle =
| "drawer" /* Toggle for drawer */ | "drawer" /* Toggle for drawer */
| "search" /* Toggle for search */ | "search" /* Toggle for search */
/**
* Toggle map
*/
export type ToggleMap = {
[P in Toggle]?: HTMLInputElement
}
/* ----------------------------------------------------------------------------
* Helper types
* ------------------------------------------------------------------------- */
/**
* Watch options
*/
interface WatchOptions {
document$: Observable<Document> /* Document observable */
}
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Data * Data
* ------------------------------------------------------------------------- */ * ------------------------------------------------------------------------- */
/** /**
* Toggle map observable * Toggle map
*/ */
let toggles$: Observable<ToggleMap> const toggles: Record<Toggle, HTMLInputElement> = {
drawer: getElementOrThrow(`[data-md-toggle=drawer]`),
search: getElementOrThrow(`[data-md-toggle=search]`)
}
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Functions * Functions
* ------------------------------------------------------------------------- */ * ------------------------------------------------------------------------- */
/** /**
* Setup bindings to toggles with given names * Retrieve the value of a toggle
* *
* @param names - Toggle names * @param name - Toggle
* @param options - Options *
* @return Toggle value
*/ */
export function setupToggles( export function getToggle(name: Toggle): boolean {
names: Toggle[], { document$ }: WatchOptions return toggles[name].checked
): void {
toggles$ = document$
.pipe(
/* Ignore document switches */
take(1),
/* Build toggle map */
map(document => names.reduce<ToggleMap>((toggles, name) => {
const el = getElement(`[data-md-toggle=${name}]`, document)
return {
...toggles,
...typeof el !== "undefined" ? { [name]: el } : {}
}
}, {})),
/* Convert to hot observable */
shareReplay(1)
)
} }
/**
* Retrieve a toggle
*
* The returned observable will only re-emit if the element changed, i.e. if
* it was replaced from a document which was switched to.
*
* @param name - Toggle name
*
* @return Element observable
*/
export function useToggle(
name: Toggle
): Observable<HTMLInputElement> {
return toggles$
.pipe(
switchMap(toggles => (
typeof toggles[name] !== "undefined"
? of(toggles[name]!)
: NEVER
)),
distinctUntilChanged()
)
}
/* ------------------------------------------------------------------------- */
/** /**
* Set toggle * Set toggle
* *
@ -137,14 +71,12 @@ export function useToggle(
* used `CustomEvent` to programmatically change the value of a toggle, but this * used `CustomEvent` to programmatically change the value of a toggle, but this
* is a much simpler and cleaner solution which doesn't require a polyfill. * is a much simpler and cleaner solution which doesn't require a polyfill.
* *
* @param el - Toggle element * @param name - Toggle
* @param value - Toggle value * @param value - Toggle value
*/ */
export function setToggle( export function setToggle(name: Toggle, value: boolean): void {
el: HTMLInputElement, value: boolean if (toggles[name].checked !== value)
): void { toggles[name].click()
if (el.checked !== value)
el.click()
} }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
@ -152,13 +84,12 @@ export function setToggle(
/** /**
* Watch toggle * Watch toggle
* *
* @param el - Toggle element * @param name - Toggle
* *
* @return Toggle observable * @return Toggle value observable
*/ */
export function watchToggle( export function watchToggle(name: Toggle): Observable<boolean> {
el: HTMLInputElement const el = toggles[name]
): Observable<boolean> {
return fromEvent(el, "change") return fromEvent(el, "change")
.pipe( .pipe(
map(() => el.checked), map(() => el.checked),

View File

@ -27,7 +27,8 @@ import {
shareReplay shareReplay
} from "rxjs/operators" } from "rxjs/operators"
import { Header } from "../../../header" import { Header } from "components"
import { import {
ViewportOffset, ViewportOffset,
watchViewportOffset watchViewportOffset
@ -54,9 +55,9 @@ export interface Viewport {
* ------------------------------------------------------------------------- */ * ------------------------------------------------------------------------- */
/** /**
* Watch relative options * Watch at options
*/ */
interface WatchRelativeOptions { interface WatchAtOptions {
header$: Observable<Header> /* Header observable */ header$: Observable<Header> /* Header observable */
viewport$: Observable<Viewport> /* Viewport observable */ viewport$: Observable<Viewport> /* Viewport observable */
} }
@ -90,7 +91,7 @@ export function watchViewport(): Observable<Viewport> {
* @return Viewport observable * @return Viewport observable
*/ */
export function watchViewportAt( export function watchViewportAt(
el: HTMLElement, { header$, viewport$ }: WatchRelativeOptions el: HTMLElement, { header$, viewport$ }: WatchAtOptions
): Observable<Viewport> { ): Observable<Viewport> {
const offset$ = viewport$ const offset$ = viewport$
.pipe( .pipe(

View File

@ -29,7 +29,7 @@ import {
switchMap switchMap
} from "rxjs/operators" } from "rxjs/operators"
import { getElement } from "observables" import { getElement } from "browser"
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Types * Types

View File

@ -35,11 +35,13 @@ import {
Viewport, Viewport,
getElement, getElement,
watchViewportAt watchViewportAt
} from "observables" } from "browser"
import { useComponent } from "../../_" import { useComponent } from "../../_"
import { paintHeaderType } from "../paint" import {
import { watchHeader } from "../watch" applyHeaderType,
watchHeader
} from "../react"
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Types * Types
@ -104,7 +106,7 @@ export function mountHeader(
return y >= hx.offsetHeight ? "page" : "site" return y >= hx.offsetHeight ? "page" : "site"
}), }),
distinctUntilChanged(), distinctUntilChanged(),
paintHeaderType(title) applyHeaderType(title)
) )
), ),
startWith<HeaderType>("site") startWith<HeaderType>("site")

View File

@ -21,6 +21,5 @@
*/ */
export * from "./_" export * from "./_"
export * from "./apply" export * from "./react"
export * from "./paint" export * from "./set"
export * from "./watch"

View File

@ -1,63 +0,0 @@
/*
* Copyright (c) 2016-2020 Martin Donath <martin.donath@squidfunk.com>
*
* 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.
*/
import {
MonoTypeOperatorFunction,
animationFrameScheduler,
pipe
} from "rxjs"
import { finalize, observeOn, tap } from "rxjs/operators"
import { HeaderType } from "../_"
import {
resetHeaderTitleActive,
setHeaderTitleActive
} from "../apply"
/* ----------------------------------------------------------------------------
* Functions
* ------------------------------------------------------------------------- */
/**
* Paint header title type
*
* @param el - Header title element
*
* @return Operator function
*/
export function paintHeaderType(
el: HTMLElement
): MonoTypeOperatorFunction<HeaderType> {
return pipe(
/* Defer repaint to next animation frame */
observeOn(animationFrameScheduler),
tap(type => {
setHeaderTitleActive(el, type === "page")
}),
/* Reset on complete or error */
finalize(() => {
resetHeaderTitleActive(el)
})
)
}

View File

@ -20,12 +20,28 @@
* IN THE SOFTWARE. * IN THE SOFTWARE.
*/ */
import { Observable, of } from "rxjs" import {
import { distinctUntilKeyChanged, switchMap } from "rxjs/operators" MonoTypeOperatorFunction,
Observable,
animationFrameScheduler,
of,
pipe
} from "rxjs"
import {
distinctUntilKeyChanged,
finalize,
observeOn,
switchMap,
tap
} from "rxjs/operators"
import { Viewport } from "observables" import { Viewport } from "browser"
import { Header } from "../_" import { Header, HeaderType } from "../_"
import {
resetHeaderTitleActive,
setHeaderTitleActive
} from "../set"
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Helper types * Helper types
@ -72,3 +88,30 @@ export function watchHeader(
}) })
) )
} }
/* ------------------------------------------------------------------------- */
/**
* Apply header title type
*
* @param el - Header title element
*
* @return Operator function
*/
export function applyHeaderType(
el: HTMLElement
): MonoTypeOperatorFunction<HeaderType> {
return pipe(
/* Defer repaint to next animation frame */
observeOn(animationFrameScheduler),
tap(type => {
setHeaderTitleActive(el, type === "page")
}),
/* Reset on complete or error */
finalize(() => {
resetHeaderTitleActive(el)
})
)
}

View File

@ -23,10 +23,10 @@
import { Observable, OperatorFunction, pipe } from "rxjs" import { Observable, OperatorFunction, pipe } from "rxjs"
import { distinctUntilChanged, map, switchMap } from "rxjs/operators" import { distinctUntilChanged, map, switchMap } from "rxjs/operators"
import { Viewport, watchViewportAt } from "observables" import { Viewport, watchViewportAt } from "browser"
import { Header } from "../../header" import { Header } from "../../header"
import { paintHero } from "../paint" import { applyHero } from "../react"
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Types * Types
@ -70,7 +70,7 @@ export function mountHero(
.pipe( .pipe(
map(({ offset: { y } }) => ({ hidden: y >= 20 })), map(({ offset: { y } }) => ({ hidden: y >= 20 })),
distinctUntilChanged(), distinctUntilChanged(),
paintHero(el) applyHero(el)
) )
) )
) )

View File

@ -21,5 +21,5 @@
*/ */
export * from "./_" export * from "./_"
export * from "./apply" export * from "./react"
export * from "./paint" export * from "./set"

View File

@ -31,20 +31,20 @@ import { Hero } from "../_"
import { import {
resetHeroHidden, resetHeroHidden,
setHeroHidden setHeroHidden
} from "../apply" } from "../set"
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Functions * Functions
* ------------------------------------------------------------------------- */ * ------------------------------------------------------------------------- */
/** /**
* Paint hero * Apply hero
* *
* @param el - Hero element * @param el - Hero element
* *
* @return Operator function * @return Operator function
*/ */
export function paintHero( export function applyHero(
el: HTMLElement el: HTMLElement
): MonoTypeOperatorFunction<Hero> { ): MonoTypeOperatorFunction<Hero> {
return pipe( return pipe(

View File

@ -23,12 +23,14 @@
import { Observable, OperatorFunction, Subject, pipe } from "rxjs" import { Observable, OperatorFunction, Subject, pipe } from "rxjs"
import { distinctUntilKeyChanged, switchMap, tap } from "rxjs/operators" import { distinctUntilKeyChanged, switchMap, tap } from "rxjs/operators"
import { Viewport } from "observables" import { Viewport } from "browser"
import { useComponent } from "../../_" import { useComponent } from "../../_"
import { Header } from "../../header" import { Header } from "../../header"
import { paintHeaderShadow } from "../paint" import {
import { watchMain } from "../watch" applyHeaderShadow,
watchMain
} from "../react"
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Types * Types
@ -82,7 +84,7 @@ export function mountMain(
switchMap(header => main$ switchMap(header => main$
.pipe( .pipe(
distinctUntilKeyChanged("active"), distinctUntilKeyChanged("active"),
paintHeaderShadow(header) applyHeaderShadow(header)
) )
) )
) )

Some files were not shown because too many files have changed in this diff Show More