Skip to content

Commit 21af551

Browse files
committed
Merge #116: remove vertical scroll bar
5078729 Applied changes from TGlide's PR consistently across the website (TGlide) 59a10b8 remove PagesWrapper 100vh, make Toc sticky on desktop up (Graeme Byrne) a39f573 remove vertical scroll bar (Graeme Byrne) Pull request description: * Remove vertical scroll bar on all `routes/(pages)` as mentioned [here](#113 (review)) using the following: ``` .content-preview { overflow-y: scroll; scrollbar-width: none; -ms-overflow-style: none; padding-top: 0rem; } ``` * Edit lists on all `routes/(pages)` to ensure style consistency. ACKs for top commit: josecelano: ACK 5078729 Tree-SHA512: df3e02cded2f2b4a36a0cf542051c05f8aff21ded49d607ab33c6434f21fa01198d160200086adc6b9e4a9660b2a629f4d010892fe17e6832c1caae62ed3628a
2 parents 6b90d44 + 5078729 commit 21af551

File tree

12 files changed

+1205
-1120
lines changed

12 files changed

+1205
-1120
lines changed

package-lock.json

Lines changed: 8 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"dependencies": {
5555
"@fontsource-variable/roboto-mono": "^5.0.19",
5656
"@fontsource-variable/roboto-slab": "^5.0.20",
57+
"@sveltejs/vite-plugin-svelte": "^3.1.2",
5758
"@tailwindcss/typography": "^0.5.15",
5859
"autoprefixer": "^10.4.20",
5960
"feather-icons": "^4.29.2",

src/lib/components/atoms/PagesWrapper.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
3737
@include for-desktop-up {
3838
.layout {
39-
height: 100vh;
39+
height: 100%;
4040
flex-direction: row;
4141
gap: 4rem;
4242
}
Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,57 @@
11
<script lang="ts">
2-
import { onMount } from 'svelte'; // ✨ Import Svelte onMount
32
import Tree from './Tree.svelte';
43
import { createTableOfContents } from '@melt-ui/svelte';
54
import { pushState } from '$app/navigation';
65
7-
let isMobileScreen = false;
8-
9-
onMount(() => {
10-
isMobileScreen = window.innerWidth <= 1200;
11-
12-
const handleResize = () => {
13-
isMobileScreen = window.innerWidth <= 1024;
14-
};
15-
window.addEventListener('resize', handleResize);
16-
return () => window.removeEventListener('resize', handleResize); // ✨ Clean up
17-
});
6+
let classes: string;
7+
export { classes as class };
8+
export let selector = '#toc-contents';
189
1910
const {
2011
elements: { item },
2112
states: { activeHeadingIdxs, headingsTree }
2213
} = createTableOfContents({
23-
selector: '#toc-builder-preview',
14+
selector,
2415
exclude: [],
2516
activeType: 'highest',
2617
pushStateFn: pushState,
2718
headingFilterFn: (heading) => !heading.hasAttribute('data-toc-ignore'),
2819
2920
scrollFn: (id) => {
30-
const container = document.getElementById('toc-builder-preview');
3121
const element = document.getElementById(id);
3222
33-
if (container && element) {
34-
const containerTopOffset = container.offsetTop;
35-
const elementTopOffset = element.offsetTop;
36-
37-
if (isMobileScreen) {
38-
element.scrollIntoView({
39-
behavior: 'smooth',
40-
block: 'start'
41-
});
42-
} else {
43-
container.scrollTo({
44-
top: elementTopOffset - containerTopOffset,
45-
behavior: 'smooth'
46-
});
47-
}
48-
}
23+
if (!element) return;
24+
const prevScrollMargin = element.style.scrollMarginTop;
25+
element.style.scrollMarginTop = '16px';
26+
27+
// trigger reflow
28+
getComputedStyle(element);
29+
element?.scrollIntoView({
30+
behavior: 'smooth',
31+
block: 'start'
32+
});
33+
element.style.scrollMarginTop = prevScrollMargin;
4934
}
5035
});
5136
</script>
5237

53-
<div class="lg:overflow-y-auto rounded-lg text-white">
38+
<div class="lg:overflow-y-auto rounded-lg text-white {classes}">
5439
<nav>
5540
{#key $headingsTree}
5641
<Tree tree={$headingsTree} activeHeadingIdxs={$activeHeadingIdxs} {item} />
5742
{/key}
5843
</nav>
5944
</div>
45+
46+
<style lang="scss">
47+
@import '$lib/scss/breakpoints.scss';
48+
49+
@include for-desktop-up {
50+
nav {
51+
position: sticky;
52+
top: 0;
53+
z-index: 100;
54+
background-color: inherit;
55+
}
56+
}
57+
</style>

src/lib/components/atoms/Tree.svelte

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
href="#{heading.id}"
1616
use:melt={$item(heading.id)}
1717
class="inline-flex items-center justify-center gap-1 text-white no-underline transition-colors
18-
hover:text-[rgba(255,_49,_0,_1)] data-[active]:text-[rgba(255,_49,_0,_1)]"
18+
hover:text-[rgba(255,_49,_0,_1)] data-[active]:text-[rgba(255,_49,_0,_1)] break-keep"
1919
>
20-
<!--
21-
Along with the heading title, the original heading node
20+
<!-- Along with the heading title, the original heading node
2221
is also passed down, so you can display headings
23-
however you want.
24-
-->
22+
however you want. -->
2523
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
2624
{@html heading.node.innerHTML}
2725
</a>
@@ -32,9 +30,3 @@
3230
{/each}
3331
{/if}
3432
</ul>
35-
36-
<style>
37-
a {
38-
word-break: keep-all;
39-
}
40-
</style>

0 commit comments

Comments
 (0)