Skip to content

Commit

Permalink
Adds jumplink highlight on target
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonRomano committed Dec 19, 2024
1 parent ef4496a commit edd8f11
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/components/jumplink-header/JumplinkHeader.module.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.jumplinkHeader {
display: inline;
scroll-margin-top: var(--header-height);
&:target {
& .text {
animation: jumplink-highlight 1.5s ease-in-out;
border-radius: 8px;
}
}

& .content {
display: flex;
Expand Down Expand Up @@ -63,3 +69,16 @@
color: var(--gray-9);
}
}

@keyframes jumplink-highlight {
from {
background-color: color-mix(in srgb, var(--brand-color) 60%, transparent);
padding: 6px 16px;
margin: -6px -16px;
}
to {
background-color: transparent;
padding: 0px;
margin: 0px;
}
}
7 changes: 6 additions & 1 deletion src/components/jumplink-header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ export default function JumplinkHeader({
[s.h6]: as === "h6",
})}
>
<Text className={className} as={as} font="display" weight="medium">
<Text
className={classNames(className, s.text)}
as={as}
font="display"
weight="medium"
>
{children}
</Text>
<a href={`#${id}`} className={s.jumplinkCopy}>
Expand Down

0 comments on commit edd8f11

Please sign in to comment.