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

FIX: adjust mobile specificity #71

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Changes from 1 commit
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
Next Next commit
FIX: adjust mobile specificity
  • Loading branch information
awesomerobot committed Dec 11, 2023
commit 6d14d5d57cd3bd3d8998df945dbd362645dcb6f2
121 changes: 65 additions & 56 deletions common/common.scss
Original file line number Diff line number Diff line change
@@ -191,77 +191,79 @@ a.d-toc-close {
.d-toc-mini {
display: block;
}
// overlayed timeline (on mobile and narrow screens)
.topic-navigation.with-topic-progress {
.d-toc-wrapper {
position: fixed;
margin-top: 0.25em;
height: calc(100dvh - 50px - var(--header-offset));
opacity: 0.5;
right: -100vw;
top: var(--header-offset);

// core overrides when timeline is active
.timeline-container {
display: none;
}
.container.posts .topic-navigation.with-topic-progress {
align-self: start;
}
}

// overlayed timeline (on mobile and narrow screens)
.topic-navigation.with-topic-progress {
.d-toc-timeline-toggle {
display: none;
}
.d-toc-wrapper {
position: fixed;
margin-top: 0.25em;
height: calc(100dvh - 50px - var(--header-offset));
opacity: 0.5;
right: -100vw;
top: var(--header-offset);
width: 75vw;
max-width: 350px;
background-color: var(--secondary);
box-shadow: var(--shadow-dropdown);
z-index: z("modal", "overlay");
transition: all 0.2s ease-in-out;
.d-toc-main {
width: 100%;
padding: 0.5em;
height: 100%;
#d-toc {
max-height: calc(100% - 2.25em);
}
}
&.overlay {
right: 0;
width: 75vw;
max-width: 350px;
background-color: var(--secondary);
box-shadow: var(--shadow-dropdown);
z-index: z("modal", "overlay");
transition: all 0.2s ease-in-out;
opacity: 1;
.d-toc-main {
width: 100%;
padding: 0.5em;
height: 100%;
#d-toc {
max-height: calc(100% - 2.25em);
}
}
&.overlay {
right: 0;
width: 75vw;
opacity: 1;
.d-toc-main {
display: block;
#d-toc li.d-toc-item ul {
transition: none;
}
display: block;
#d-toc li.d-toc-item ul {
transition: none;
}
}
}

a.scroll-to-bottom {
margin-top: 0.33em;
}

a.scroll-to-bottom,
a.d-toc-close {
display: inline-block;
padding: 0.5em;
}
a.scroll-to-bottom {
margin-top: 0.33em;
}

.d-toc-icons {
position: absolute;
background: var(--secondary);
right: 1.5em;
top: 0.25em;
z-index: z("timeline");
}
a.scroll-to-bottom,
a.d-toc-close {
display: inline-block;
padding: 0.5em;
}
}

// core overrides when timeline is active
.timeline-container {
display: none;
}
.container.posts .topic-navigation.with-topic-progress {
align-self: start;
.d-toc-icons {
position: absolute;
background: var(--secondary);
right: 1.5em;
top: 0.25em;
z-index: z("timeline");
}
}
}

#topic-progress-wrapper {
align-items: stretch;
.d-toc-mini {
display: none;
.d-toc-timeline-visible & {
display: block;
}

height: 100%;
.btn {
height: 100%;
@@ -275,6 +277,13 @@ a.d-toc-close {
}
}

.d-toc-timeline-toggleable {
#topic-progress-wrapper .d-toc-mini {
display: block;
}
}


// core sets first child's top margin to 0
// ensure it's also 0 when TOC markup is first
.cooked > div[data-theme-toc]:first-child + * {
16 changes: 8 additions & 8 deletions javascripts/discourse/initializers/disco-toc-main.js
Original file line number Diff line number Diff line change
@@ -231,14 +231,6 @@ export default {
return false;
}

if (
!classNames.some((className) =>
document.body.classList.contains(className)
)
) {
return;
}

// link to each heading
if (
e.target.closest(".d-toc-item") &&
@@ -291,6 +283,14 @@ export default {
if (!e.target.closest(".d-toc-wrapper.overlay")) {
document.querySelector(".d-toc-wrapper").classList.remove("overlay");
}

if (
!classNames.some((className) =>
document.body.classList.contains(className)
)
) {
return;
}
},

buildTOC(headings) {