fix: No reserving space in sidebar for overflow (#2807)

* fix: No reserving space in sidebar for overflow
closes #2486

Co-authored-by: Charles Harries <charles@harries.me>
This commit is contained in:
Tom Moor
2021-11-30 05:56:04 -08:00
committed by GitHub
parent e2841aebcd
commit d13254b543
5 changed files with 42 additions and 8 deletions

View File

@@ -25,5 +25,17 @@
"@babel/plugin-transform-destructuring",
"@babel/plugin-transform-regenerator",
"transform-class-properties"
]
],
"env": {
"production": {
"plugins": [
[
"styled-components",
{
"displayName": false
}
]
]
}
}
}

View File

@@ -250,9 +250,8 @@ function DocumentLink(
/>
</>
}
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'match' implicitly has an 'any' type.
isActive={(match, location) =>
match && location.search !== "?starred"
!!match && location.search !== "?starred"
}
isActiveDrop={isOverReparent && canDropToReparent}
depth={depth}

View File

@@ -4,7 +4,11 @@
// it avoids recalculating the link match again.
import { Location, createLocation } from "history";
import * as React from "react";
import { __RouterContext as RouterContext, matchPath } from "react-router";
import {
__RouterContext as RouterContext,
matchPath,
match,
} from "react-router";
import { Link } from "react-router-dom";
import scrollIntoView from "smooth-scroll-into-view-if-needed";
@@ -32,7 +36,7 @@ export type Props = React.HTMLAttributes<HTMLAnchorElement> & {
className?: string;
scrollIntoViewIfNeeded?: boolean;
exact?: boolean;
isActive?: any;
isActive?: (match: match | null, location: Location) => boolean;
location?: Location;
strict?: boolean;
style?: React.CSSProperties;

View File

@@ -3,6 +3,7 @@ import * as React from "react";
import styled, { useTheme } from "styled-components";
import breakpoint from "styled-components-breakpoint";
import EventBoundary from "~/components/EventBoundary";
import NudeButton from "~/components/NudeButton";
import { NavigationNode } from "~/types";
import NavLink, { Props as NavLinkProps } from "./NavLink";
@@ -153,8 +154,27 @@ const Link = styled(NavLink)<{ $isActiveDrop?: boolean }>`
transparentize("0.25", props.theme.sidebarItemBackground)};
}
& + ${Actions} {
${NudeButton} {
background: ${(props) => props.theme.sidebarBackground};
}
}
&:focus + ${Actions} {
${NudeButton} {
background: ${(props) =>
transparentize("0.25", props.theme.sidebarItemBackground)};
}
}
&[aria-current="page"] + ${Actions} {
${NudeButton} {
background: ${(props) => props.theme.sidebarItemBackground};
}
}
${breakpoint("tablet")`
padding: 4px 32px 4px 16px;
padding: 4px 8px 4px 16px;
font-size: 15px;
`}

View File

@@ -75,9 +75,8 @@ function StarredLink({ depth, title, to, documentId, collectionId }: Props) {
<SidebarLink
depth={depth}
to={`${to}?starred`}
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'match' implicitly has an 'any' type.
isActive={(match, location) =>
match && location.search === "?starred"
!!match && location.search === "?starred"
}
label={
<>