From 14fffb94c07599cf761f1297549fc2b008e84d15 Mon Sep 17 00:00:00 2001 From: Saumya Pandey Date: Sat, 12 Feb 2022 17:48:52 +0530 Subject: [PATCH] fix: add disclosure and transition --- .../Sidebar/components/CollectionLink.tsx | 34 ++++++++++++++++--- .../Sidebar/components/DocumentLink.tsx | 14 ++++++-- .../Sidebar/components/SidebarLink.tsx | 6 +++- .../Sidebar/components/Transition.tsx | 8 +++++ 4 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 app/components/Sidebar/components/Transition.tsx diff --git a/app/components/Sidebar/components/CollectionLink.tsx b/app/components/Sidebar/components/CollectionLink.tsx index c942fc66cb..2f85f03b12 100644 --- a/app/components/Sidebar/components/CollectionLink.tsx +++ b/app/components/Sidebar/components/CollectionLink.tsx @@ -1,5 +1,6 @@ import fractionalIndex from "fractional-index"; import { observer } from "mobx-react"; +import { CollapsedIcon } from "outline-icons"; import * as React from "react"; import { useDrop, useDrag } from "react-dnd"; import { useTranslation } from "react-i18next"; @@ -21,6 +22,7 @@ import DropCursor from "./DropCursor"; import DropToImport from "./DropToImport"; import EditableTitle from "./EditableTitle"; import SidebarLink, { DragObject } from "./SidebarLink"; +import Transition from "./Transition"; type Props = { collection: Collection; @@ -229,7 +231,16 @@ function CollectionLink({ + <> + { + event.preventDefault(); + setExpanded((prev) => !prev); + }} + /> + + } showActions={menuOpen} isActiveDrop={isOver && canDrop} @@ -242,7 +253,7 @@ function CollectionLink({ /> } exact={false} - depth={0.5} + depth={0.6} menu={ !isEditing && ( <> @@ -274,8 +285,14 @@ function CollectionLink({ /> )} - {expanded && - collectionDocuments.map((node, index) => ( + + {collectionDocuments.map((node, index) => ( ))} + ` pointer-events: ${(props) => (props.$isMoving ? "none" : "auto")}; `; +const Disclosure = styled(CollapsedIcon)<{ expanded?: boolean }>` + transition: transform 100ms ease, fill 50ms !important; + position: absolute; + left: 0px; + ${({ expanded }) => !expanded && "transform: rotate(-90deg);"}; + display: none; +`; + const CollectionSortMenuWithMargin = styled(CollectionSortMenu)` margin-right: 4px; `; diff --git a/app/components/Sidebar/components/DocumentLink.tsx b/app/components/Sidebar/components/DocumentLink.tsx index 63aa5677cf..ee1eead99c 100644 --- a/app/components/Sidebar/components/DocumentLink.tsx +++ b/app/components/Sidebar/components/DocumentLink.tsx @@ -21,6 +21,7 @@ import DropCursor from "./DropCursor"; import DropToImport from "./DropToImport"; import EditableTitle from "./EditableTitle"; import SidebarLink, { DragObject } from "./SidebarLink"; +import Transition from "./Transition"; type Props = { node: NavigationNode; @@ -351,9 +352,15 @@ function DocumentLink( )} - {expanded && - !isDragging && - nodeChildren.map((childNode, index) => ( + + {nodeChildren.map((childNode, index) => ( ))} + ); } diff --git a/app/components/Sidebar/components/SidebarLink.tsx b/app/components/Sidebar/components/SidebarLink.tsx index 2d36a5be0c..61b8b39378 100644 --- a/app/components/Sidebar/components/SidebarLink.tsx +++ b/app/components/Sidebar/components/SidebarLink.tsx @@ -69,7 +69,7 @@ function SidebarLink( background: theme.sidebarItemBackground, ...style, }), - [theme, style] + [theme.text, theme.sidebarItemBackground, style] ); return ( @@ -158,6 +158,10 @@ const Link = styled(NavLink)<{ $isActiveDrop?: boolean; $isDraft?: boolean }>` transition: fill 50ms; } + &:hover svg { + display: inline-block; + } + &:focus { color: ${(props) => props.theme.text}; background: ${(props) => diff --git a/app/components/Sidebar/components/Transition.tsx b/app/components/Sidebar/components/Transition.tsx new file mode 100644 index 0000000000..022bcaaaba --- /dev/null +++ b/app/components/Sidebar/components/Transition.tsx @@ -0,0 +1,8 @@ +import styled from "styled-components"; + +const Transition = styled.div` + transition: max-height 400ms cubic-bezier(0.08, 0.17, 0.14, 0.87); + overflow: hidden; +`; + +export default Transition;