Skip to content

Commit d198daf

Browse files
committed
fix: improve TOC sidebar appearance and fix word-break issues
- Remove aggressive word-break: break-all from global a and li styles, keeping only overflow-wrap: break-word to prevent mid-word breaks in narrow containers like the TOC sidebar - TOC links: smaller font (text-sm), muted default color (text-gray-400), softer active highlight (text-red-400), left-aligned text - Fix TOC nested item over-indentation caused by global ul margin-left: 40px bleeding into the nav; reset margin to 0 and apply a modest 0.75rem padding-left only on nested lists via a scoped .nested class - Reduce Toc nav max-width from 250px to 220px
1 parent 7536720 commit d198daf

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/lib/components/atoms/Toc.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
top: 0;
5858
z-index: 100;
5959
background-color: inherit;
60-
max-width: 250px;
60+
max-width: 220px;
6161
}
6262
}
6363
</style>

src/lib/components/atoms/Tree.svelte

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
let { tree = [], activeHeadingIdxs, item, level = 1 }: Props = $props();
1313
</script>
1414

15-
<ul class="mt-0 list-none {level !== 1 ? 'pl-4' : ''}">
15+
<ul class="mt-0 list-none {level !== 1 ? 'nested' : ''}">
1616
{#if tree && tree.length}
1717
{#each tree as heading, i (i)}
18-
<li class="mt-0 pt-2 list-none">
18+
<li class="mt-0 pt-1.5 list-none">
1919
<!-- Tailwind: Removes bullets -->
2020
<a
2121
href="#{heading.id}"
2222
use:melt={$item(heading.id)}
23-
class="inline-flex items-center justify-center gap-1 text-white no-underline transition-colors
24-
hover:text-red-500 data-[active]:text-red-500 break-keep"
23+
class="inline-flex items-start justify-start gap-1 text-sm text-gray-400 no-underline transition-colors
24+
hover:text-gray-100 data-[active]:text-red-400 break-keep leading-snug"
2525
>
2626
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
2727
{@html heading.node.innerHTML}
@@ -38,6 +38,11 @@
3838
ul {
3939
list-style: none !important;
4040
padding-left: 0 !important;
41+
margin: 0 !important;
42+
}
43+
44+
ul.nested {
45+
padding-left: 0.75rem !important;
4146
}
4247
4348
li {

src/lib/scss/_base.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ ol {
55

66
li {
77
margin: 6px 0;
8-
word-wrap: break-word;
9-
word-break: break-all;
108
overflow-wrap: break-word;
119
white-space: normal;
1210

src/lib/scss/global.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ body {
3232

3333
a {
3434
color: rgba(255, 49, 0, 0.96);
35-
word-wrap: break-word;
36-
word-break: break-all;
3735
overflow-wrap: break-word;
3836
white-space: normal;
3937
}

0 commit comments

Comments
 (0)