mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-02 08:19:07 +02:00
refactor: better external link icon positioning (#6994)
This commit is contained in:
parent
87592bca03
commit
e606e62a6a
3 changed files with 14 additions and 7 deletions
|
@ -250,6 +250,7 @@ function DocSidebarItemLink({
|
|||
}: Props & {item: PropSidebarItemLink}) {
|
||||
const {href, label, className} = item;
|
||||
const isActive = isActiveSidebarItem(item, activePath);
|
||||
const isInternalLink = isInternalUrl(href);
|
||||
return (
|
||||
<li
|
||||
className={clsx(
|
||||
|
@ -260,17 +261,21 @@ function DocSidebarItemLink({
|
|||
)}
|
||||
key={label}>
|
||||
<Link
|
||||
className={clsx('menu__link', {
|
||||
'menu__link--active': isActive,
|
||||
})}
|
||||
className={clsx(
|
||||
'menu__link',
|
||||
!isInternalLink && styles.menuExternalLink,
|
||||
{
|
||||
'menu__link--active': isActive,
|
||||
},
|
||||
)}
|
||||
aria-current={isActive ? 'page' : undefined}
|
||||
to={href}
|
||||
{...(isInternalUrl(href) && {
|
||||
{...(isInternalLink && {
|
||||
onClick: onItemClick ? () => onItemClick(item) : undefined,
|
||||
})}
|
||||
{...props}>
|
||||
{label}
|
||||
{!isInternalUrl(href) && <IconExternalLink />}
|
||||
{!isInternalLink && <IconExternalLink />}
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
|
|
|
@ -11,3 +11,7 @@
|
|||
var(--ifm-menu-link-padding-horizontal);
|
||||
}
|
||||
}
|
||||
|
||||
.menuExternalLink {
|
||||
align-items: center;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,4 @@
|
|||
|
||||
.iconExternalLink {
|
||||
margin-left: 0.3rem;
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue