Skip to content

Commit fc53d7e

Browse files
authored
FIX: adjust mobile specificity (#71)
* FIX: adjust mobile specificity * prettier
1 parent 04acc4b commit fc53d7e

File tree

2 files changed

+72
-64
lines changed

2 files changed

+72
-64
lines changed

common/common.scss

Lines changed: 64 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -191,77 +191,79 @@ a.d-toc-close {
191191
.d-toc-mini {
192192
display: block;
193193
}
194-
// overlayed timeline (on mobile and narrow screens)
195-
.topic-navigation.with-topic-progress {
196-
.d-toc-wrapper {
197-
position: fixed;
198-
margin-top: 0.25em;
199-
height: calc(100dvh - 50px - var(--header-offset));
200-
opacity: 0.5;
201-
right: -100vw;
202-
top: var(--header-offset);
194+
195+
// core overrides when timeline is active
196+
.timeline-container {
197+
display: none;
198+
}
199+
.container.posts .topic-navigation.with-topic-progress {
200+
align-self: start;
201+
}
202+
}
203+
204+
// overlayed timeline (on mobile and narrow screens)
205+
.topic-navigation.with-topic-progress {
206+
.d-toc-timeline-toggle {
207+
display: none;
208+
}
209+
.d-toc-wrapper {
210+
position: fixed;
211+
margin-top: 0.25em;
212+
height: calc(100dvh - 50px - var(--header-offset));
213+
opacity: 0.5;
214+
right: -100vw;
215+
top: var(--header-offset);
216+
width: 75vw;
217+
max-width: 350px;
218+
background-color: var(--secondary);
219+
box-shadow: var(--shadow-dropdown);
220+
z-index: z("modal", "overlay");
221+
transition: all 0.2s ease-in-out;
222+
.d-toc-main {
223+
width: 100%;
224+
padding: 0.5em;
225+
height: 100%;
226+
#d-toc {
227+
max-height: calc(100% - 2.25em);
228+
}
229+
}
230+
&.overlay {
231+
right: 0;
203232
width: 75vw;
204-
max-width: 350px;
205-
background-color: var(--secondary);
206-
box-shadow: var(--shadow-dropdown);
207-
z-index: z("modal", "overlay");
208-
transition: all 0.2s ease-in-out;
233+
opacity: 1;
209234
.d-toc-main {
210-
width: 100%;
211-
padding: 0.5em;
212-
height: 100%;
213-
#d-toc {
214-
max-height: calc(100% - 2.25em);
215-
}
216-
}
217-
&.overlay {
218-
right: 0;
219-
width: 75vw;
220-
opacity: 1;
221-
.d-toc-main {
222-
display: block;
223-
#d-toc li.d-toc-item ul {
224-
transition: none;
225-
}
235+
display: block;
236+
#d-toc li.d-toc-item ul {
237+
transition: none;
226238
}
227239
}
240+
}
228241

229-
a.scroll-to-bottom {
230-
margin-top: 0.33em;
231-
}
232-
233-
a.scroll-to-bottom,
234-
a.d-toc-close {
235-
display: inline-block;
236-
padding: 0.5em;
237-
}
242+
a.scroll-to-bottom {
243+
margin-top: 0.33em;
244+
}
238245

239-
.d-toc-icons {
240-
position: absolute;
241-
background: var(--secondary);
242-
right: 1.5em;
243-
top: 0.25em;
244-
z-index: z("timeline");
245-
}
246+
a.scroll-to-bottom,
247+
a.d-toc-close {
248+
display: inline-block;
249+
padding: 0.5em;
246250
}
247-
}
248251

249-
// core overrides when timeline is active
250-
.timeline-container {
251-
display: none;
252-
}
253-
.container.posts .topic-navigation.with-topic-progress {
254-
align-self: start;
252+
.d-toc-icons {
253+
position: absolute;
254+
background: var(--secondary);
255+
right: 1.5em;
256+
top: 0.25em;
257+
z-index: z("timeline");
258+
}
255259
}
256260
}
257261

258262
#topic-progress-wrapper {
259263
align-items: stretch;
260264
.d-toc-mini {
261265
display: none;
262-
.d-toc-timeline-visible & {
263-
display: block;
264-
}
266+
265267
height: 100%;
266268
.btn {
267269
height: 100%;
@@ -275,6 +277,12 @@ a.d-toc-close {
275277
}
276278
}
277279

280+
.d-toc-timeline-toggleable {
281+
#topic-progress-wrapper .d-toc-mini {
282+
display: block;
283+
}
284+
}
285+
278286
// core sets first child's top margin to 0
279287
// ensure it's also 0 when TOC markup is first
280288
.cooked > div[data-theme-toc]:first-child + * {

javascripts/discourse/initializers/disco-toc-main.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,6 @@ export default {
231231
return false;
232232
}
233233

234-
if (
235-
!classNames.some((className) =>
236-
document.body.classList.contains(className)
237-
)
238-
) {
239-
return;
240-
}
241-
242234
// link to each heading
243235
if (
244236
e.target.closest(".d-toc-item") &&
@@ -291,6 +283,14 @@ export default {
291283
if (!e.target.closest(".d-toc-wrapper.overlay")) {
292284
document.querySelector(".d-toc-wrapper").classList.remove("overlay");
293285
}
286+
287+
if (
288+
!classNames.some((className) =>
289+
document.body.classList.contains(className)
290+
)
291+
) {
292+
return;
293+
}
294294
},
295295

296296
buildTOC(headings) {

0 commit comments

Comments
 (0)