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

229 overhaul menu html structure #810

Merged
merged 7 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions packages/typo3-docs-theme/assets/js/menu-expandable.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,31 @@
if (link.nextSibling) {
var expand = document.createElement('span');
expand.classList.add('toctree-expand');
expand.setAttribute('tabindex', '0');
expand.addEventListener('click', toggleCurrent, true);
expand.addEventListener('keydown', (e) => {
if (e.key === "Enter") {
toggleCurrent(e)
}
}, true);
link.prepend(expand);
}
});
});
}

// Adds the EventListener for the toggle Button of the complete menu (mobile)
function makeTocMenuExpandable() {
const tocToggle = document.getElementById('toc-toggle');
tocToggle.addEventListener('click', () => toggleNavigation(tocToggle), true);
}

function toggleNavigation(tocToggle) {
const tocCollapse = document.getElementById('toc-collapse');
tocCollapse.classList.toggle('show');
tocToggle.setAttribute('aria-expanded', tocCollapse.classList.contains('show'));
}

makeTocMenuExpandable();
makeMenuExpandable();
})();
9 changes: 7 additions & 2 deletions packages/typo3-docs-theme/assets/js/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
if (!isNaN(versionAsFloat) && Number(versionTrimmed) === versionAsFloat) {
// make each number part have the same digit count, allowing to
// properly sort as a string
version = version.split('.').map(n => +n+VERSION_SORT_BASE).join('.')
version = version.split('.').map(n => +n + VERSION_SORT_BASE).join('.')
versionType = '2_numeric';
}
}
Expand Down Expand Up @@ -197,7 +197,7 @@

if (versionType === '2_numeric') {
// restore version string from before sorting
parsedVersion = version.split('.').map(n => +n-VERSION_SORT_BASE).join('.')
parsedVersion = version.split('.').map(n => +n - VERSION_SORT_BASE).join('.')
}

html += '<dd><a href="' + sortedOutput[baseIndexKey][language][versionType][version] + '">' + parsedVersion + '</a></dd>';
Expand Down Expand Up @@ -251,4 +251,9 @@
}

versionElement.addEventListener('click', addListOfVersions);
versionElement.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
addListOfVersions()
}
});
})();
Original file line number Diff line number Diff line change
@@ -1,155 +1,164 @@
.toc-checkbox {
display: none;
}
.toc-collapse {
display: none;
@include media-breakpoint-up(lg) {
display: block;
}
}
.toc-checkbox:checked ~ .toc-collapse {
display: block;
}
.toc-toggle {
margin: 0;
@extend .btn;
@extend .btn-light;
@include media-breakpoint-up(lg) {
.page-main-navigation {

#toc-collapse {
display: none;
}
}
.toc-header {
display: flex;
justify-content: space-between;
padding-left: calc(#{$spacer} / 1.5) ;
}
.main_menu {
margin: $spacer 0;
display: block;
.caption {
font-weight: bold;
margin: 0;
}
a {
position: relative;
display: block;
color: inherit;
line-height: 1.25;
padding: calc(#{$spacer} / 4) 0;
padding-right: 1.5em;
text-decoration: none;
&:hover {
text-decoration: underline;
@include media-breakpoint-up(lg) {
display: block;
}

&.show {
display: block;
}
}
ul {
padding-left: calc(#{$spacer} / 2);
list-style-type: none;

#toc-toggle {
margin: 0;
}
> ul {
> li {
&.active {
border-left: 1px solid rgba(0, 0, 0, .15);
border-radius: 0;

.toc-header {
display: flex;
justify-content: space-between;
padding-left: calc(#{$spacer} / 1.5);

a.toc-title-project {
display: block;
position: relative;
font-size: 1.2em;
font-weight: 700;
line-height: 1.25;
color: $secondary;
text-decoration: none;

&:before {
content: '';
width: 0.2em;
height: 100%;
background: $primary;
position: absolute;
top: 0;
left: -0.6em;
}

&:hover {
text-decoration: .1em underline;
}
}
}
li {
border-radius: $border-radius;
overflow: hidden;
padding-left: calc(#{$spacer} / 2) ;
&.current {
border-left: none;
}
@include media-breakpoint-up(lg) {
font-size: 1rem;
}

.toc-search {
margin-top: $spacer;
margin-bottom: ($spacer * 2);
}
.toctree-expand {
position: absolute;

.main_menu {
margin: $spacer 0;
display: block;
top: calc((#{$spacer} / 4) + (#{$font-size-base} * 1.25 / 2));
right: 0;
transform: translate(0, -50%);
height: 1em;
width: 1em;
background-color: $light;
border-radius: 50%;
&:after,
&:before {
position: absolute;
content: '';
top: 50%;
left: 50%;

.caption {
font-weight: bold;
margin: 0;
}
&:after {
width: 10px;
height: 0;
border-top: 2px solid;
transform: translate(-50%, -50%);

a {
position: relative;
display: block;
color: inherit;
line-height: 1.25;
padding: calc(#{$spacer} / 4) 0;
padding-right: 1.5em;
text-decoration: none;

&:hover {
text-decoration: underline;
}
}
&:before {
width: 0;
height: 10px;
border-left: 2px solid;
transform: translate(-50%, -50%);

ul {
padding-left: calc(#{$spacer} / 2);
list-style-type: none;
}
}
.active > a {
font-weight: bold;
> .toctree-expand {
&:before {
display: none;

> ul {
padding-left: 0;

.active {
> ul {
display: block !important;
}
}

&:not(:last-child) {
padding-bottom: $spacer;
border-bottom: 1px solid rgba(0, 0, 0, .15);
}

> li {
&.active {
border-left: 1px solid rgba(0, 0, 0, .15);
border-radius: 0;
}

ul {
display: none;
}
}
}
}
> ul {
padding-left: 0;
.active {
> ul {
display: block !important;

li {
border-radius: $border-radius;
overflow: hidden;
padding-left: calc(#{$spacer} / 2);

&.current {
border-left: none;
}

@include media-breakpoint-up(lg) {
font-size: 1rem;
}
}
> li ul {
display: none;

.toctree-expand {
position: absolute;
display: block;
top: calc((#{$spacer} / 4) + (#{$font-size-base} * 1.25 / 2));
right: 0;
transform: translate(0, -50%);
height: 1em;
width: 1em;
background-color: $light;
border-radius: 50%;

&:after,
&:before {
position: absolute;
content: '';
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

&:after {
width: 10px;
height: 0;
border-top: 2px solid;
}

&:before {
width: 0;
height: 10px;
border-left: 2px solid;
}
}
}
> ul:not(:last-child) {
padding-bottom: $spacer;
border-bottom: 1px solid rgba(0, 0, 0, .15);
}
}
a.toc-title-project {
display: block;
position: relative;
font-size: 1.2em;
font-weight: 700;
line-height: 1.25;
color: $secondary;
text-decoration: none;

&:before {
content: '';
width: 0.2em;
height: 100%;
background: $primary;
position: absolute;
top: 0;
left: -0.6em;
}

&:hover {
text-decoration: .1em underline;
}
}
.toc-search {
margin-top: $spacer;
margin-bottom: ($spacer * 2);
}
.toc-backref {
color: inherit;
&:hover {
color: inherit;
text-decoration: none;
.active > a {
font-weight: bold;

> .toctree-expand {
&:before {
display: none;
}
}
}
}
}
Loading
Loading