Fixed scroll snapping for 2nd+ level items using tabs

This commit is contained in:
squidfunk 2020-03-03 14:59:57 +01:00
parent 89d8d6c5ac
commit 301582cc76
14 changed files with 45430 additions and 44 deletions

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 it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,8 @@
{ {
"assets/javascripts/bundle.js": "assets/javascripts/bundle.b70c6ac3.min.js", "assets/javascripts/bundle.js": "assets/javascripts/bundle.js",
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.b70c6ac3.min.js.map", "assets/javascripts/bundle.js.map": "assets/javascripts/bundle.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.1e07d700.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

View File

@ -43,9 +43,9 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block styles %} {% block styles %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.1e07d700.min.css' | url }}"> <link rel="stylesheet" href="{{ 'assets/stylesheets/main.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.css' | url }}">
{% endif %} {% endif %}
{% if palette.primary %} {% if palette.primary %}
{% import "partials/palette.html" as map %} {% import "partials/palette.html" as map %}
@ -195,7 +195,7 @@
{% endblock %} {% endblock %}
</div> </div>
{% block scripts %} {% block scripts %}
<script src="{{ 'assets/javascripts/bundle.b70c6ac3.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/bundle.js' | url }}"></script>
{%- set translations = {} -%} {%- set translations = {} -%}
{%- for key in [ {%- for key in [
"clipboard.copy", "clipboard.copy",
@ -218,7 +218,7 @@
app = initialize({ app = initialize({
base: "{{ base_url }}", base: "{{ base_url }}",
worker: { worker: {
search: "{{ 'assets/javascripts/worker/search.926ffd9e.min.js' | url }}" search: "{{ 'assets/javascripts/worker/search.js' | url }}"
}, },
feature: { feature: {
instant: {{ "true" if feature and feature.instant else "false" }} instant: {{ "true" if feature and feature.instant else "false" }}

View File

@ -149,6 +149,12 @@ export function setupComponents(
* *
* @return Element observable * @return Element observable
*/ */
export function useComponent<T extends HTMLInputElement>(
name: "search-query"
): Observable<T>
export function useComponent<T extends HTMLElement>(
name: Component
): Observable<T>
export function useComponent<T extends HTMLElement>( export function useComponent<T extends HTMLElement>(
name: Component name: Component
): Observable<T> { ): Observable<T> {

View File

@ -181,7 +181,7 @@ export function initialize(config: unknown) {
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/* Mount search query */ /* Mount search query */
const query$ = useComponent<HTMLInputElement>("search-query") const query$ = useComponent("search-query")
.pipe( .pipe(
mountSearchQuery(worker), mountSearchQuery(worker),
shareReplay(1) // TODO: this must be put onto EVERY component! shareReplay(1) // TODO: this must be put onto EVERY component!

View File

@ -173,10 +173,11 @@ export function setupKeyboard(): Observable<Keyboard> {
.subscribe(([key, query]) => { .subscribe(([key, query]) => {
switch (key.type) { switch (key.type) {
/* Open search */ /* Open search and select query */
case "f": case "f":
case "s": case "s":
setElementFocus(query) setElementFocus(query)
query.select()
key.claim() key.claim()
break break

View File

@ -208,7 +208,7 @@
scroll-snap-type: y mandatory; scroll-snap-type: y mandatory;
// Remove border for first list item // Remove border for first list item
& > .md-nav__item:first-child { > .md-nav__item:first-child {
border-top: 0; border-top: 0;
} }
} }

View File

@ -64,6 +64,8 @@
font-size: px2rem(13px); font-size: px2rem(13px);
line-height: 1.2; line-height: 1.2;
white-space: nowrap; white-space: nowrap;
// Hack: reduce jitter
backface-visibility: hidden;
// Adjust for right-to-left languages // Adjust for right-to-left languages
[dir="rtl"] & { [dir="rtl"] & {

View File

@ -120,12 +120,9 @@
// [screen +]: Adjust main navigation styles // [screen +]: Adjust main navigation styles
@include break-from-device(screen) { @include break-from-device(screen) {
// Hide 1st level nested items, as they are listed in the tabs by setting // Hide 1st level nested items, as they are listed in the tabs
// font-size to zero, as we need to preserve bottom padding
~ .md-main .md-nav--primary > .md-nav__list > .md-nav__item--nested { ~ .md-main .md-nav--primary > .md-nav__list > .md-nav__item--nested {
max-height: 0; display: none;
font-size: 0;
visibility: hidden;
} }
// We're on the 2nd+ level // We're on the 2nd+ level
@ -137,54 +134,44 @@
// Show title and remove spacing // Show title and remove spacing
.md-nav__title { .md-nav__title {
display: block; display: block;
padding: 0; padding: 0 px2rem(12px);
pointer-events: none; pointer-events: none;
} scroll-snap-align: start;
// Hide site title // Hide site title
.md-nav__title[for="__drawer"] { &[for="__drawer"] {
display: none; display: none;
} }
// Show 1st level navigation always expanded
.no-js & > .md-nav {
display: block;
} }
// Hide 1st level normal items // Hide 1st level normal items
& > .md-nav__list > .md-nav__item { > .md-nav__list > .md-nav__item {
font-size: 0; display: none;
visibility: hidden;
// Reset font-size for nested items and induce margin collapse // Hide nested items
&--nested { &--nested {
display: none; display: none;
max-height: none; }
font-size: px2rem(14px);
overflow: auto; // Show 1st level active nested items
visibility: visible; &--active {
display: block;
padding: 0;
// Hide nested links // Hide nested links
> .md-nav__link { > .md-nav__link {
display: none; display: none;
} }
} }
// Show 1st level active nested items
&--active {
display: block;
}
} }
} }
// Always expand nested navigation on 2nd level // Always expand nested navigation on 2nd level
.md-nav[data-md-level="1"] { .md-nav[data-md-level="1"] {
max-height: initial;
overflow: visible;
// Remove spacing on 2nd level items // Remove spacing on 2nd level items
> .md-nav__list > .md-nav__item { > .md-nav__list > .md-nav__item {
padding: 0; padding: 0 px2rem(12px);
} }
// Hide titles from 2nd level on // Hide titles from 2nd level on