-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(website): add fragment links to scroll to component headlines (#444
) resolves #426
- Loading branch information
1 parent
83cb9b6
commit 3f3b5c1
Showing
7 changed files
with
46 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
--- | ||
import { fragmentLinkScrollMargin } from '../layouts/base/header/headerConstants'; | ||
interface Props { | ||
title: string; | ||
} | ||
const { title } = Astro.props; | ||
const fragmentId = title.toLowerCase().replace(/ /g, '-'); | ||
--- | ||
|
||
<h2 class='font-bold'> | ||
<slot /> | ||
<h2 class={`font-bold ${fragmentLinkScrollMargin} `} id={fragmentId}> | ||
<a href={`#${fragmentId}`} class='group flex items-center gap-1'> | ||
{title} | ||
<span class='iconify font-normal opacity-0 mdi--link-variant group-hover:opacity-100'></span> | ||
</a> | ||
</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
import type { LapisFilter } from '@genspectrum/dashboard-components/util'; | ||
import ComponentHeadline from '../ComponentHeadline.astro'; | ||
interface Props { | ||
numeratorFilter: LapisFilter; | ||
denominatorFilter: LapisFilter; | ||
} | ||
const { numeratorFilter, denominatorFilter } = Astro.props; | ||
--- | ||
|
||
<div class='h-56 sm:h-32'> | ||
<ComponentHeadline title='Stats' /> | ||
<gs-statistics | ||
numeratorFilter={JSON.stringify(numeratorFilter)} | ||
denominatorFilter={JSON.stringify(denominatorFilter)} | ||
width='100%' | ||
height='100%'></gs-statistics> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
export const headerHeight = 'h-16'; | ||
|
||
/** | ||
* Account for the header when scrolling to a fragment link (href="#my-fragment"). | ||
* Otherwise, the fragment that we scroll to will be hidden behind the header. | ||
* The height must match the header height (plus a little extra spacing). | ||
*/ | ||
export const fragmentLinkScrollMargin = 'scroll-mt-20'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters