Skip to content

Commit

Permalink
Switched annotation markers to + signs in non-print contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Dec 9, 2021
1 parent 16939c1 commit 1ddf872
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 42 deletions.

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions material/assets/javascripts/bundle.17f42bbf.min.js.map

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions material/assets/javascripts/bundle.a5f8ea78.min.js.map

This file was deleted.

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

This file was deleted.

4 changes: 2 additions & 2 deletions material/base.html
Expand Up @@ -34,7 +34,7 @@
{% endif %}
{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.52c8dc4b.min.css' | url }}">
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.2d264350.min.css' | url }}">
{% if config.theme.palette %}
{% set palette = config.theme.palette %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.9204c3b2.min.css' | url }}">
Expand Down Expand Up @@ -213,7 +213,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.a5f8ea78.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.17f42bbf.min.js' | url }}"></script>
{% for path in config["extra_javascript"] %}
<script src="{{ path | url }}"></script>
{% endfor %}
Expand Down
18 changes: 18 additions & 0 deletions material/overrides/assets/javascripts/bundle.05395296.min.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

18 changes: 0 additions & 18 deletions material/overrides/assets/javascripts/bundle.ab1cf86a.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion material/overrides/main.html
Expand Up @@ -16,5 +16,5 @@
{% endblock %}
{% block scripts %}
{{ super() }}
<script src="{{ 'overrides/assets/javascripts/bundle.ab1cf86a.min.js' | url }}"></script>
<script src="{{ 'overrides/assets/javascripts/bundle.05395296.min.js' | url }}"></script>
{% endblock %}
5 changes: 5 additions & 0 deletions src/assets/javascripts/browser/element/focus/index.ts
Expand Up @@ -22,6 +22,7 @@

import {
Observable,
debounceTime,
distinctUntilChanged,
fromEvent,
map,
Expand All @@ -43,6 +44,9 @@ import { getActiveElement } from "../_"
* within the elements itself. A better solutions are `focusin` and `focusout`
* events, which bubble up the tree and allow for more fine-grained control.
*
* `debounceTime` is necessary, because when a focus change happens inside an
* element, the observable would first emit `false` and then `true` again.
*
* @param el - Element
*
* @returns Element focus observable
Expand All @@ -55,6 +59,7 @@ export function watchElementFocus(
fromEvent(document.body, "focusout")
)
.pipe(
debounceTime(1),
map(() => {
const active = getActiveElement()
return typeof active !== "undefined"
Expand Down
4 changes: 3 additions & 1 deletion src/assets/javascripts/templates/annotation/index.tsx
Expand Up @@ -39,7 +39,9 @@ export function renderAnnotation(id: number): HTMLElement {
<div class="md-annotation__inner md-tooltip">
<div class="md-tooltip__inner md-typeset"></div>
</div>
<span class="md-annotation__index">{id}</span>
<span class="md-annotation__index">
<span data-md-annotation-id={id}></span>
</span>
</aside>
)
}
18 changes: 18 additions & 0 deletions src/assets/stylesheets/main/layout/_tooltip.scss
Expand Up @@ -214,6 +214,24 @@
}
}

// Annotation marker content
[data-md-annotation-id]::before {
display: inline-block;
transition: transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1);
content: attr(data-md-annotation-id);

// [not print]: if we're not in print mode, show a `+` sign instead of
// the original numbers, as context is already given by the position.
@media not print {
content: "+";

// Annotation marker content on focus
:focus-within > & {
transform: rotate(45deg);
}
}
}

// Annotation index on focus/hover
:is(:focus-within, :hover) > & {
color: var(--md-accent-bg-color);
Expand Down

0 comments on commit 1ddf872

Please sign in to comment.