Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "collapse/expand" functionality #2078

Merged
merged 30 commits into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b30b2e0
- added keyboard shortcut for search box
Hetarth02 Jan 29, 2023
ec10ac0
- Removed Jquery dependency
Hetarth02 Feb 4, 2023
7c101ea
- Removed Jquery dependency
Hetarth02 Feb 4, 2023
617d7ac
Merge branch 'master' of https://github.com/Hetarth02/Documenter.jl
Hetarth02 Feb 4, 2023
0e07875
Update src/html/HTMLWriter.jl
mortenpi Feb 5, 2023
95a9c86
Update CHANGELOG.md
mortenpi Feb 5, 2023
32875ac
Update CHANGELOG.md
mortenpi Feb 5, 2023
af0433d
Update src/html/HTMLWriter.jl
mortenpi Feb 6, 2023
f78953a
Merge branch 'master' into master
mortenpi Feb 12, 2023
c56c1c3
Update .gitignore
mortenpi Feb 12, 2023
5149391
Apply suggestions from code review
fredrikekre Feb 12, 2023
abde3c6
Merge branch 'JuliaDocs:master' into master
Hetarth02 Mar 1, 2023
f761e73
Merge branch 'JuliaDocs:master' into master
Hetarth02 Mar 12, 2023
18f018a
Merge branch 'JuliaDocs:master' into development
Hetarth02 Mar 12, 2023
a9ed840
Merge pull request #1 from Hetarth02/development
Hetarth02 Mar 12, 2023
3cf8450
- Adding padding to menu's element on-hover
Hetarth02 Mar 12, 2023
564301d
Merge pull request #2 from Hetarth02/development
Hetarth02 Mar 12, 2023
0788aad
Merge branch 'JuliaDocs:master' into master
Hetarth02 Mar 18, 2023
68c3a1c
- Issue #1393
Hetarth02 Mar 18, 2023
94784d0
Merge branch 'development' of https://github.com/Hetarth02/Documenter…
Hetarth02 Mar 18, 2023
37087e3
- Removed lingering code from PR #2065
Hetarth02 Mar 18, 2023
1123a9e
- Fixed navbar icon gap
Hetarth02 Mar 18, 2023
bcfcf5a
- Updated `fas` => `fa-solid` due to font awesome version bump
Hetarth02 Mar 18, 2023
0d7e97d
Merge branch 'issue-1393' of https://github.com/Hetarth02/Documenter.…
Hetarth02 Mar 29, 2023
90eaa92
Merge branch 'JuliaDocs:master' into issue-1393
Hetarth02 Apr 9, 2023
4c2516d
- Shifted toggle button at last position in navbar
Hetarth02 Apr 9, 2023
e8369cf
Merge branch 'JuliaDocs:master' into issue-1393
Hetarth02 Apr 15, 2023
d6e3114
- Add a CHANGELOG entry for this feature addition
Hetarth02 Apr 15, 2023
cad2602
- Minor title updates in generated toggle button
Hetarth02 Apr 15, 2023
c352fb6
Update CHANGELOG.md
mortenpi Apr 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions assets/html/js/collapse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// libraries: jquery
// arguments: $

var isExpanded = true;

$(document).on("click", ".docstring header", function () {
let articleToggleTitle = "Expand article";
Hetarth02 marked this conversation as resolved.
Show resolved Hide resolved

if ($(this).siblings("section").is(":visible")) {
$(this)
.find(".docstring-article-toggle-button")
.removeClass("fa-chevron-down")
.addClass("fa-chevron-right");
} else {
$(this)
.find(".docstring-article-toggle-button")
.removeClass("fa-chevron-right")
.addClass("fa-chevron-down");

articleToggleTitle = "Collapse article";
Hetarth02 marked this conversation as resolved.
Show resolved Hide resolved
}

$(this).find(".docstring-article-toggle-button").prop("title", articleToggleTitle);
$(this).siblings("section").slideToggle();
});

$(document).on("click", ".docs-article-toggle-button", function () {
let articleToggleTitle = "Expand article";
let navArticleToggleTitle = "Expand all Articles";
Hetarth02 marked this conversation as resolved.
Show resolved Hide resolved

if (isExpanded) {
$(this).removeClass("fa-chevron-up").addClass("fa-chevron-down");
$(".docstring-article-toggle-button")
.removeClass("fa-chevron-down")
.addClass("fa-chevron-right");

isExpanded = false;

$(".docstring section").slideUp();
} else {
$(this).removeClass("fa-chevron-down").addClass("fa-chevron-up");
$(".docstring-article-toggle-button")
.removeClass("fa-chevron-right")
.addClass("fa-chevron-down");

isExpanded = true;
articleToggleTitle = "Collapse article";
navArticleToggleTitle = "Collapse all Articles";
Hetarth02 marked this conversation as resolved.
Show resolved Hide resolved

$(".docstring section").slideDown();
}

$(this).prop("title", navArticleToggleTitle);
$(".docstring-article-toggle-button").prop("title", articleToggleTitle);
});
5 changes: 5 additions & 0 deletions assets/html/scss/documenter/components/_docstring.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
max-width: 100%;

> header {
cursor: pointer;
display: flex;
flex-grow: 1;
align-items: stretch;
Expand All @@ -21,6 +22,10 @@
background-color: transparent;
}

.docstring-article-toggle-button {
padding: 0.2rem 0.2rem 0.2rem 0;
Hetarth02 marked this conversation as resolved.
Show resolved Hide resolved
}

.docstring-binding {
margin-right: 0.3em;
}
Expand Down
2 changes: 2 additions & 0 deletions assets/html/scss/documenter/layout/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
display: inline-block;
}
white-space: nowrap;
gap: 1rem;
align-items: center;
.docs-label {
padding: 0;
margin-left: 0.3em;
Expand Down
7 changes: 6 additions & 1 deletion assets/html/themes/documenter-dark.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion assets/html/themes/documenter-light.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/html/HTMLWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,12 @@ function render_navbar(ctx, navnode, edit_page_link::Bool)
:href => "#", :title => "Settings",
])

# Collapse/Expand All articles toggle
push!(navbar_right.nodes, a[
"#documenter-article-toggle-button.docs-article-toggle-button.fa-solid.fa-chevron-up",
:href=>"javascript:;", :title=>"Collapse all Articles",
])

# Construct the main <header> node that should be the first element in div.docs-main
header[".docs-navbar"](navbar_left, breadcrumb, navbar_right)
end
Expand Down Expand Up @@ -1623,6 +1629,7 @@ function domify(dctx::DCtx, mdast_node::Node, node::Documenter.DocsNode)

article[".docstring"](
header(
a[".docstring-article-toggle-button.fa-solid.fa-chevron-down", :href=>"javascript:;", :title=>"Collapse article"],
a[".docstring-binding", :id=>node.anchor.id, :href=>"#$(node.anchor.id)"](code("$(node.object.binding)")),
" — ", # &mdash;
span[".docstring-category"]("$(Documenter.doccat(node.object))")
Expand Down