Skip to content

Commit

Permalink
fix: snap location
Browse files Browse the repository at this point in the history
  • Loading branch information
TorstenDittmann committed Sep 28, 2023
1 parent 3bf15f3 commit a927ffb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/markdoc/nodes/Heading.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
export let level: number;
export let id: string | undefined = undefined;
export let step: number | undefined = undefined;
export let inReferences = false;
const tag = `h${level + 1}`;
const ctx = hasContext('headings') ? getContext<LayoutContext>('headings') : undefined;
Expand Down Expand Up @@ -53,7 +54,8 @@
this={tag}
{id}
bind:this={element}
class:aw-snap-location={id}
class:aw-snap-location={id && !inReferences}
class:aw-snap-location-references={id && inReferences}
class="{classList[level]} aw-u-color-text-primary"
>
<slot />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
<section class="aw-article-content-grid-6-4">
<div class="aw-article-content-grid-6-4-column-1 u-flex-vertical u-gap-32">
<header class="aw-article-content-header">
<Heading id={method.id} level={2}>{method.title}</Heading>
<Heading id={method.id} level={2} inReferences>{method.title}</Heading>
</header>
<p class="aw-sub-body-400">
{@html parse(method.description)}
Expand Down
6 changes: 6 additions & 0 deletions src/scss/6-elements/_snap-location.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@
.#{$p}-snap-location {
scroll-snap-align: start;
scroll-margin-top: 7.5rem;
}

.#{$p}-snap-location-references {
scroll-snap-align: start;
scroll-margin-top: 7.5rem;
@media #{$break2open} { scroll-margin-top: 12.5rem; }
}

0 comments on commit a927ffb

Please sign in to comment.