Skip to content

Commit

Permalink
feat(theme-default): display complete content of toc in aside component
Browse files Browse the repository at this point in the history
  • Loading branch information
shulaoda committed Sep 6, 2024
1 parent a1df311 commit 4d4bc86
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
30 changes: 14 additions & 16 deletions packages/theme-default/src/components/Aside/index.scss
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
.aside-link {
padding-bottom: 1px;
}

.aside-link-text {
padding: 0px 12px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding: 0.25rem 0;
margin-bottom: 1px;
border-radius: var(--rp-radius-small) 0 0 var(--rp-radius-small);
font-size: 13px;
line-height: 1.75rem;

&:hover {
background-color: var(--rp-c-bg-mute);
}
}

.aside-active {
&,
&:hover {
color: var(--rp-c-link);
background-color: var(--rp-c-brand-tint);
&.aside-active {
&,
&:hover {
color: var(--rp-c-link);
background-color: var(--rp-c-brand-tint);
}
}
}

.aside-link-text {
padding: 0px 12px;
font-size: 0.8125rem;
line-height: 1.25rem;
}
2 changes: 1 addition & 1 deletion packages/theme-default/src/components/Aside/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function Aside(props: { headers: Header[]; outlineTitle: string }) {
title={parseInlineMarkdownText(header.text)}
className="aside-link transition-all duration-300 hover:text-text-1 text-text-2 block"
style={{
paddingLeft: (header.depth - baseHeaderLevel) * 12,
marginLeft: (header.depth - baseHeaderLevel) * 12,
fontWeight: 'semibold',
}}
onClick={e => {
Expand Down
4 changes: 1 addition & 3 deletions packages/theme-default/src/logic/sideEffects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ export function bindingAsideScroll() {
const activate = (links: HTMLAnchorElement[], index: number) => {
if (links[index]) {
const id = links[index].getAttribute('href');
const currentLink = aside?.querySelector(
`a[href="#${id?.slice(1)}"] > span`,
);
const currentLink = aside?.querySelector(`a[href="#${id?.slice(1)}"]`);
if (currentLink) {
if (prevActiveLink) {
prevActiveLink.classList.remove('aside-active');
Expand Down

0 comments on commit 4d4bc86

Please sign in to comment.