Skip to content

Commit

Permalink
Merge pull request #201 from daizutabi/198-add-show-class-buttons
Browse files Browse the repository at this point in the history
Add toggle buttons to show/hide class names
  • Loading branch information
daizutabi authored Sep 19, 2024
2 parents 8659764 + 2cfd5ae commit f7c736e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 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";
}
});
});
});
9 changes: 6 additions & 3 deletions src/mkapi/templates/object.jinja2
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<p class="mkapi-object mkapi-page-{{ namespace }}" id="{{ id }}" markdown="1">
<span class="mkapi-object-link">
{% if parent -%}
<span class="mkapi-parent-toggle" title="Toggle class names">
<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>
</span>
{%- if kind -%}
<span class="mkapi-object-kind{% if parent %} mkapi-parent-toggle{% endif %}"
{%- if parent %} title="Toggle class names"{% endif -%}
>{{ kind }}</span>
<span class="mkapi-object-kind">{{ kind }}</span>
{%- endif %}
{% if parent -%}
<span class="mkapi-object-parent">
Expand Down

0 comments on commit f7c736e

Please sign in to comment.