Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add ids to headings in the pricing page #396

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/lib/utils/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ export const createScrollInfo = () => {
let lastDirChange = 0;

onMount(() => {
const handleInitialAnchor = () => {
if (window.location.hash) {
const anchorElement = document.querySelector(window.location.hash);
if (anchorElement) {
return window.pageYOffset + anchorElement.getBoundingClientRect().top;
}
}
return 0;
};

const initialTop = handleInitialAnchor();
scrollInfo.set({ direction: 'down', top: initialTop, deltaDirChange: 0 });
lastDirChange = initialTop;

const handleScroll = () => {
scrollInfo.update((p) => {
const top = window.scrollY;
Expand Down
10 changes: 5 additions & 5 deletions src/routes/pricing/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
>
<div class="aw-pricing-cards-item">
<header class="aw-pricing-cards-header">
<h2 class="aw-label">Starter</h2>
<h2 id="starter" class="aw-label">Starter</h2>
<div
class="aw-title aw-u-color-text-primary u-margin-block-start-8"
>
Expand Down Expand Up @@ -112,7 +112,7 @@
>
<div class="aw-pricing-cards-item">
<header class="aw-pricing-cards-header">
<h2 class="aw-label">Pro</h2>
<h2 id="pro" class="aw-label">Pro</h2>
<div
class="aw-title aw-u-color-text-primary u-margin-block-start-8"
>
Expand Down Expand Up @@ -159,7 +159,7 @@
>
<div class="aw-pricing-cards-item">
<header class="aw-pricing-cards-header">
<h2 class="aw-label">Scale</h2>
<h2 id="scale" class="aw-label">Scale</h2>
<div
class="aw-title aw-u-color-text-primary u-margin-block-start-8"
>
Expand Down Expand Up @@ -205,7 +205,7 @@
style="background:rgba(35, 35, 37, 0.90);"
>
<header class="u-flex u-gap-12">
<h3 class="aw-main-body-500 aw-u-color-text-primary">
<h3 id="enterprises" class="aw-main-body-500 aw-u-color-text-primary">
Enterprises
</h3>
<div class="aw-inline-tag is-pink">Coming Soon</div>
Expand All @@ -228,7 +228,7 @@
style="background:rgba(35, 35, 37, 0.90);"
>
<header class="u-flex u-gap-12">
<h3 class="aw-main-body-500 aw-u-color-text-primary">
<h3 id="open-source-teams" class="aw-main-body-500 aw-u-color-text-primary">
Open-source teams
</h3>
</header>
Expand Down