Skip to content

Commit

Permalink
Add toggle buttons to show/hide class names
Browse files Browse the repository at this point in the history
  • Loading branch information
daizutabi committed Sep 19, 2024
1 parent cf040c6 commit 2cfd5ae
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
6 changes: 4 additions & 2 deletions docs/usage/object.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ by its qualified name.
The heading of a method's documentation
contains a tooltip displaying the full name of the method
along with the class to which the method belongs.
You can also click the prefix *method* to display the
qualified names of all methods on the current page.
You can also click the
<i class="fa-solid fa-square-plus"></i>
button to display the qualified names of all methods
on the current page.

## Source Code

Expand Down
5 changes: 1 addition & 4 deletions src/mkapi/css/mkapi-common.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,12 @@ ul.mkapi-item-list {
}

.mkapi-document-toggle,
.mkapi-parent-toggle,
.mkapi-section-toggle {
cursor: pointer;
color: var(--mkapi-punctuation-color);
}

.mkapi-parent-toggle {
cursor: pointer;
}

.mkapi-page-object {
margin-block-end: 0px;
border-bottom: 1px solid var(--mkapi-object-border-color);
Expand Down
10 changes: 10 additions & 0 deletions src/mkapi/javascript/mkapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,15 @@ parentButtons.forEach((button) => {
elements.forEach((element) => {
element.style.display = isVisible ? "none" : "inline";
});

const buttons = document.querySelectorAll(".mkapi-parent-toggle");
buttons.forEach((button) => {
const icon = button.querySelector("i");
if (icon) {
icon.className = isVisible
? "fa-solid fa-square-plus"
: "fa-solid fa-square-xmark";
}
});
});
});
4 changes: 2 additions & 2 deletions src/mkapi/templates/object.jinja2
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<p class="mkapi-object mkapi-page-{{ namespace }}" id="{{ id }}" markdown="1">
<span class="mkapi-object-link">
[{{ namespace }}][__mkapi__.__{{ namespace }}__.{{ obj_id }}]
{% if parent -%}
<span class="mkapi-parent-toggle" title="Toggle class names">
<i class="fa-regular fa-square-minus"></i>
<i class="fa-solid fa-square-plus"></i>
</span>
{%- endif %}
[{{ namespace }}][__mkapi__.__{{ namespace }}__.{{ obj_id }}]
<span class="mkapi-document-toggle" title="Toggle all docs">
<i class="fa-regular fa-square-minus"></i>
</span>
Expand Down

0 comments on commit 2cfd5ae

Please sign in to comment.