From 792c841fda46616b1de60cda9553dcae877fa1b2 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 21 Feb 2022 17:06:24 -0800 Subject: [PATCH] wip wip --- .../Sidebar/components/CollectionLink.tsx | 9 ---- .../Sidebar/components/Disclosure.ts | 18 ------- .../Sidebar/components/Disclosure.tsx | 54 +++++++++++++++++++ app/components/Sidebar/components/Header.tsx | 10 ++-- .../Sidebar/components/SidebarLink.tsx | 23 ++++++-- .../Sidebar/components/TeamButton.tsx | 2 +- app/typings/styled-components.d.ts | 3 +- shared/theme.ts | 6 ++- 8 files changed, 85 insertions(+), 40 deletions(-) delete mode 100644 app/components/Sidebar/components/Disclosure.ts create mode 100644 app/components/Sidebar/components/Disclosure.tsx diff --git a/app/components/Sidebar/components/CollectionLink.tsx b/app/components/Sidebar/components/CollectionLink.tsx index f6a480377d..952cda0cca 100644 --- a/app/components/Sidebar/components/CollectionLink.tsx +++ b/app/components/Sidebar/components/CollectionLink.tsx @@ -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); diff --git a/app/components/Sidebar/components/Disclosure.ts b/app/components/Sidebar/components/Disclosure.ts deleted file mode 100644 index 69496389b1..0000000000 --- a/app/components/Sidebar/components/Disclosure.ts +++ /dev/null @@ -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; diff --git a/app/components/Sidebar/components/Disclosure.tsx b/app/components/Sidebar/components/Disclosure.tsx new file mode 100644 index 0000000000..96b7149317 --- /dev/null +++ b/app/components/Sidebar/components/Disclosure.tsx @@ -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; + expanded: boolean; + root: boolean; +}; + +function Disclosure({ onClick, root, expanded, ...rest }: Props) { + return ( + + ); +} + +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; diff --git a/app/components/Sidebar/components/Header.tsx b/app/components/Sidebar/components/Header.tsx index ddb8ed09ca..8c468b8c9f 100644 --- a/app/components/Sidebar/components/Header.tsx +++ b/app/components/Sidebar/components/Header.tsx @@ -13,7 +13,9 @@ export function Header({ onClick, expanded, children }: Props) {

); @@ -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}; } `; diff --git a/app/components/Sidebar/components/SidebarLink.tsx b/app/components/Sidebar/components/SidebarLink.tsx index e1e7d9cb0d..a725cb4b99 100644 --- a/app/components/Sidebar/components/SidebarLink.tsx +++ b/app/components/Sidebar/components/SidebarLink.tsx @@ -19,7 +19,7 @@ type Props = Omit & { innerRef?: (arg0: HTMLElement | null | undefined) => void; onClick?: React.MouseEventHandler; onMouseEnter?: React.MouseEventHandler; - onDisclosureClick?: React.MouseEventHandler; + onDisclosureClick?: React.MouseEventHandler; 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( > {expanded !== undefined && ( - + )} {icon && {icon}} @@ -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; } diff --git a/app/components/Sidebar/components/TeamButton.tsx b/app/components/Sidebar/components/TeamButton.tsx index bc2723b774..154e1007e6 100644 --- a/app/components/Sidebar/components/TeamButton.tsx +++ b/app/components/Sidebar/components/TeamButton.tsx @@ -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}; } `; diff --git a/app/typings/styled-components.d.ts b/app/typings/styled-components.d.ts index c04a744139..51fe0effe7 100644 --- a/app/typings/styled-components.d.ts +++ b/app/typings/styled-components.d.ts @@ -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; diff --git a/shared/theme.ts b/shared/theme.ts index f1c0298520..b5f89fa5af 100644 --- a/shared/theme.ts +++ b/shared/theme.ts @@ -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)",