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

refactor: migrate IdAnchor to tw #13980

Merged
merged 1 commit into from
Sep 27, 2024
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
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
Loading