fix: Embed disabled state should persist (#3407)

* Normalize code around localStorage
Persist disabled embed state

* fix: Cannot view more than 10 starred items on load

* More tidying of sidebar state
This commit is contained in:
Tom Moor
2022-04-17 10:24:40 -07:00
committed by GitHub
parent 1e1a57d246
commit e4e98286f4
11 changed files with 267 additions and 192 deletions

View File

@@ -24,6 +24,7 @@ type Props = Omit<NavLinkProps, "to"> & {
label?: React.ReactNode;
menu?: React.ReactNode;
showActions?: boolean;
disabled?: boolean;
active?: boolean;
/* If set, a disclosure will be rendered to the left of any icon */
expanded?: boolean;
@@ -55,6 +56,7 @@ function SidebarLink(
className,
expanded,
onDisclosureClick,
disabled,
...rest
}: Props,
ref: React.RefObject<HTMLAnchorElement>
@@ -82,6 +84,7 @@ function SidebarLink(
<Link
$isActiveDrop={isActiveDrop}
$isDraft={isDraft}
$disabled={disabled}
activeStyle={isActiveDrop ? activeDropStyle : activeStyle}
style={active ? activeStyle : style}
onClick={onClick}
@@ -158,7 +161,11 @@ const Actions = styled(EventBoundary)<{ showActions?: boolean }>`
}
`;
const Link = styled(NavLink)<{ $isActiveDrop?: boolean; $isDraft?: boolean }>`
const Link = styled(NavLink)<{
$isActiveDrop?: boolean;
$isDraft?: boolean;
$disabled?: boolean;
}>`
display: flex;
position: relative;
text-overflow: ellipsis;
@@ -174,6 +181,13 @@ const Link = styled(NavLink)<{ $isActiveDrop?: boolean; $isDraft?: boolean }>`
cursor: pointer;
overflow: hidden;
${(props) =>
props.$disabled &&
css`
pointer-events: none;
opacity: 0.75;
`}
${(props) =>
props.$isDraft &&
css`