Skip to content

Commit

Permalink
Merge pull request #13980 from ethereum/shadcn-wave-idanchor
Browse files Browse the repository at this point in the history
refactor: migrate IdAnchor to tw
  • Loading branch information
pettinarip authored Sep 27, 2024
2 parents be880e3 + c4e3ee9 commit a044f32
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/components/Glossary/GlossaryDefinition/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const GlossaryDefinition = ({
return (
<Stack className="mb-8 items-stretch gap-4 text-start">
<h4
className={term ? "relative scroll-mt-28" : ""}
className={term ? "group relative scroll-mt-28" : ""}
{...(term ? { "data-group": true, id: term } : {})}
>
<IdAnchor id={term} />
Expand Down
15 changes: 5 additions & 10 deletions src/components/IdAnchor.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import { CiLink } from "react-icons/ci"

import Link from "@/components/Link"
import { BaseLink } from "@/components/ui/Link"

const IdAnchor = ({ id }: { id?: string }) => {
if (!id) return null
return (
<Link
href={"#" + id}
position="absolute"
insetInlineEnd="100%"
<BaseLink
className="absolute end-full flex h-full items-center opacity-0 transition-opacity duration-100 ease-in-out focus:opacity-100 group-hover:opacity-100"
aria-label={id.replaceAll("-", " ") + " permalink"}
opacity={0}
_groupHover={{ opacity: 1 }}
_focus={{ opacity: 1 }}
transition="opacity 0.1s ease-in-out"
href={"#" + id}
>
<CiLink className="me-1 text-xl" />
</Link>
</BaseLink>
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/MdComponents/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const commonHeadingAttributes = (className: string, id?: string) => ({
id,
className: cn(
"font-bold leading-xs my-8",
id && "scroll-mt-28 relative",
id && "scroll-mt-28 relative group",
className
),
"data-group": !!id || undefined,
Expand Down

0 comments on commit a044f32

Please sign in to comment.