This commit is contained in:
Tom Moor committed 2022-02-21 17:06:24 -08:00
1 parent 382002d1e4
commit 792c841fda
8 files changed
+85 -40

No files matched your search

@@ -16,7 +16,6 @@ import useStores from "~/hooks/useStores";
import CollectionMenu from "~/menus/CollectionMenu";
import CollectionSortMenu from "~/menus/CollectionSortMenu";
import { NavigationNode } from "~/types";
import Disclosure from "./Disclosure";
import DocumentLink from "./DocumentLink";
import DropCursor from "./DropCursor";
import DropToImport from "./DropToImport";
@@ -316,14 +315,6 @@ function CollectionLink({
const Draggable = styled("div")<{ $isDragging: boolean; $isMoving: boolean }>`
opacity: ${(props) => (props.$isDragging || props.$isMoving ? 0.5 : 1)};
pointer-events: ${(props) => (props.$isMoving ? "none" : "auto")};
${Disclosure} {
opacity: 0;
}
&:hover ${Disclosure} {
opacity: 1;
}
`;
export default observer(CollectionLink);
@@ -1,18 +0,0 @@
import { CollapsedIcon } from "outline-icons";
import styled from "styled-components";
const Disclosure = styled(CollapsedIcon).attrs(() => ({
color: "currentColor",
}))<{
expanded?: boolean;
}>`
transition: opacity 100ms ease, transform 100ms ease, fill 50ms !important;
color: ${(props) => props.theme.textTertiary};
flex-shrink: 0;
position: absolute;
left: -20px;
${(props) => !props.expanded && "transform: rotate(-90deg);"};
`;
export default Disclosure;
@@ -0,0 +1,54 @@
import { CollapsedIcon } from "outline-icons";
import * as React from "react";
import styled, { css } from "styled-components";
import NudeButton from "~/components/NudeButton";
type Props = {
onClick?: React.MouseEventHandler<HTMLButtonElement>;
expanded: boolean;
root: boolean;
};
function Disclosure({ onClick, root, expanded, ...rest }: Props) {
return (
<Button size={20} onClick={onClick} $root={root} {...rest}>
<StyledCollapsedIcon expanded={expanded} size={20} color="currentColor" />
</Button>
);
}
const Button = styled(NudeButton)<{ $root: boolean }>`
position: absolute;
left: -24px;
flex-shrink: 0;
/* color: ${(props) => props.theme.textTertiary}; */
&:hover {
color: ${(props) => props.theme.sidebarText};
background: ${(props) => props.theme.sidebarControlHoverBackground};
}
${(props) =>
props.$root &&
css`
opacity: 0;
left: -16px;
&:hover {
opacity: 1;
background: none;
}
`}
`;
const StyledCollapsedIcon = styled(CollapsedIcon)<{
expanded?: boolean;
}>`
transition: opacity 100ms ease, transform 100ms ease, fill 50ms !important;
${(props) => !props.expanded && "transform: rotate(-90deg);"};
`;
// Enables identifying this component within styled components
const StyledDisclosure = styled(Disclosure)``;
export default StyledDisclosure;
+6 -4
View File
@@ -13,7 +13,9 @@ export function Header({ onClick, expanded, children }: Props) {
<H3>
<Button onClick={onClick} disabled={!onClick}>
{children}
{onClick && <Disclosure expanded={expanded} color="currentColor" />}
{onClick && (
<Disclosure expanded={expanded} color="currentColor" size={20} />
)}
</Button>
</H3>
);
@@ -27,18 +29,18 @@ const Button = styled.button`
user-select: none;
color: ${(props) => props.theme.textTertiary};
letter-spacing: 0.03em;
margin: 0 8px;
padding: 4px 0 4px 4px;
margin: 0;
padding: 4px 2px 4px 12px;
height: 22px;
border: 0;
background: none;
border-radius: 4px;
-webkit-appearance: none;
transition: all 100ms ease;
cursor: pointer;
&:not(:disabled):hover,
&:not(:disabled):active {
background: ${(props) => props.theme.sidebarItemBackground};
color: ${(props) => props.theme.textSecondary};
}
`;
@@ -19,7 +19,7 @@ type Props = Omit<NavLinkProps, "to"> & {
innerRef?: (arg0: HTMLElement | null | undefined) => void;
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
onDisclosureClick?: React.MouseEventHandler<HTMLOrSVGElement>;
onDisclosureClick?: React.MouseEventHandler<HTMLButtonElement>;
icon?: React.ReactNode;
label?: React.ReactNode;
menu?: React.ReactNode;
@@ -71,10 +71,10 @@ function SidebarLink(
() => ({
fontWeight: 600,
color: theme.text,
background: theme.sidebarItemBackground,
background: theme.sidebarActiveBackground,
...style,
}),
[theme.text, theme.sidebarItemBackground, style]
[theme.text, theme.sidebarActiveBackground, style]
);
return (
@@ -97,7 +97,11 @@ function SidebarLink(
>
<Content>
{expanded !== undefined && (
<Disclosure expanded={expanded} onClick={onDisclosureClick} />
<Disclosure
expanded={expanded}
onClick={onDisclosureClick}
root={depth === 0}
/>
)}
{icon && <IconWrapper>{icon}</IconWrapper>}
<Label>{label}</Label>
@@ -110,6 +114,7 @@ function SidebarLink(
const Content = styled.span`
display: flex;
align-items: center;
position: relative;
width: 100%;
`;
@@ -187,7 +192,7 @@ const Link = styled(NavLink)<{ $isActiveDrop?: boolean; $isDraft?: boolean }>`
&[aria-current="page"] + ${Actions} {
${NudeButton} {
background: ${(props) => props.theme.sidebarItemBackground};
background: ${(props) => props.theme.sidebarActiveBackground};
}
}
@@ -210,6 +215,13 @@ const Link = styled(NavLink)<{ $isActiveDrop?: boolean; $isDraft?: boolean }>`
props.$isActiveDrop ? props.theme.white : props.theme.text};
}
}
&:hover {
${Disclosure} {
opacity: 1;
color: ${(props) => props.theme.text};
}
}
`;
const Label = styled.div`
@@ -217,6 +229,7 @@ const Label = styled.div`
width: 100%;
max-height: 4.8em;
line-height: 1.6;
* {
unicode-bidi: plaintext;
}
@@ -85,7 +85,7 @@ const Header = styled.button`
&:active,
&:hover {
transition: background 100ms ease-in-out;
background: ${(props) => props.theme.sidebarItemBackground};
background: ${(props) => props.theme.sidebarActiveBackground};
}
`;
+2 -1
View File
@@ -150,7 +150,8 @@ declare module "styled-components" {
textTertiary: string;
placeholder: string;
sidebarBackground: string;
sidebarItemBackground: string;
sidebarActiveBackground: string;
sidebarControlHoverBackground: string;
sidebarDraftBorder: string;
sidebarText: string;
backdrop: string;
+4 -2
View File
@@ -134,7 +134,8 @@ export const light = {
textTertiary: colors.slate,
placeholder: "#a2b2c3",
sidebarBackground: colors.warmGrey,
sidebarItemBackground: "#d7e0ea",
sidebarActiveBackground: "#d7e0ea",
sidebarControlHoverBackground: "rgba(0,0,0,0.1)",
sidebarDraftBorder: darken("0.25", colors.warmGrey),
sidebarText: "rgb(78, 92, 110)",
backdrop: "rgba(0, 0, 0, 0.2)",
@@ -184,7 +185,8 @@ export const dark = {
textTertiary: colors.slate,
placeholder: colors.slateDark,
sidebarBackground: colors.veryDarkBlue,
sidebarItemBackground: lighten(0.015, colors.almostBlack),
sidebarActiveBackground: lighten(0.015, colors.almostBlack),
sidebarControlHoverBackground: "rgba(255,255,255,0.1)",
sidebarDraftBorder: darken("0.35", colors.slate),
sidebarText: colors.slate,
backdrop: "rgba(255, 255, 255, 0.3)",