-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract IdAnchor to new file
prevents circular reference issues from inside MdComponents
- Loading branch information
Showing
3 changed files
with
26 additions
and
23 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
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,24 @@ | ||
import { CiLink } from "react-icons/ci" | ||
import { Icon } from "@chakra-ui/react" | ||
|
||
import Link from "@/components/Link" | ||
|
||
const IdAnchor = ({ id }: { id?: string }) => { | ||
if (!id) return null | ||
return ( | ||
<Link | ||
href={"#" + id} | ||
position="absolute" | ||
insetInlineEnd="100%" | ||
aria-label={id.replaceAll("-", " ") + " permalink"} | ||
opacity={0} | ||
_groupHover={{ opacity: 1 }} | ||
_focus={{ opacity: 1 }} | ||
transition="opacity 0.1s ease-in-out" | ||
> | ||
<Icon as={CiLink} fontSize="xl" me="1" /> | ||
</Link> | ||
) | ||
} | ||
|
||
export default IdAnchor |
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