Skip to content

Commit

Permalink
feat: add popper for MLink
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Apr 18, 2024
1 parent 4aac9b8 commit 2bcf16c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/components/layout/footer/FooterInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const PoweredBy: Component = ({ className }) => {
</StyledLink>{' '}
的开源版本。
{process.env.COMMIT_HASH && process.env.COMMIT_URL && (
<MLink href={process.env.COMMIT_URL}>
<MLink popper={false} href={process.env.COMMIT_URL}>
版本哈希:{process.env.COMMIT_HASH.slice(0, 8)}
</MLink>
)}
Expand Down
40 changes: 22 additions & 18 deletions src/components/ui/link/MLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export const MLink: FC<{
href: string
title?: string
children?: ReactNode
}> = memo(({ href, children, title }) => {
text?: string
popper?: boolean
}> = memo(({ href, children, title, popper = true }) => {
const router = useRouter()
const isSelfUrl = useMemo(() => {
if (isServerSide) return false
Expand Down Expand Up @@ -53,28 +55,30 @@ export const MLink: FC<{
[href, isSelfUrl, router],
)

const el = (
<span className="inline items-center font-sans">
{isSelfUrl ? <BizSelfFavicon /> : <Favicon href={href} />}
<a
className="shiro-link--underline"
href={href}
target="_blank"
onClick={handleRedirect}
title={title}
rel="noreferrer"
>
{children}
</a>

<i className="icon-[mingcute--arrow-right-up-line] translate-y-[2px] opacity-70" />
</span>
)
if (!popper) return el
return (
<FloatPopover
as="span"
wrapperClassName="!inline"
type="tooltip"
triggerElement={
<span className="inline-flex items-center font-sans">
{isSelfUrl ? <BizSelfFavicon /> : <Favicon href={href} />}
<a
className="shiro-link--underline"
href={href}
target="_blank"
onClick={handleRedirect}
title={title}
rel="noreferrer"
>
{children}
</a>

<i className="icon-[mingcute--arrow-right-up-line] translate-y-[2px] opacity-70" />
</span>
}
triggerElement={el}
>
<a href={href} target="_blank" rel="noreferrer">
<span>{href}</span>
Expand Down

0 comments on commit 2bcf16c

Please sign in to comment.