mirror of
https://github.com/outline/outline.git
synced 2026-12-06 11:12:32 +03:00
fix: add disclosure and transition
This commit is contained in:
1 parent
f4af702492
commit
14fffb94c0
4 files changed
+54
-8
No files matched your search
@@ -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({
|
||||
<SidebarLink
|
||||
to={collection.url}
|
||||
icon={
|
||||
<CollectionIcon collection={collection} expanded={expanded} />
|
||||
<>
|
||||
<Disclosure
|
||||
expanded={expanded}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
setExpanded((prev) => !prev);
|
||||
}}
|
||||
/>
|
||||
<CollectionIcon collection={collection} expanded={expanded} />
|
||||
</>
|
||||
}
|
||||
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({
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
{expanded &&
|
||||
collectionDocuments.map((node, index) => (
|
||||
<Transition
|
||||
style={{
|
||||
maxHeight: expanded
|
||||
? (collection?.documentIds?.length ?? 1) * 80 + "px"
|
||||
: "0px",
|
||||
}}
|
||||
>
|
||||
{collectionDocuments.map((node, index) => (
|
||||
<DocumentLink
|
||||
key={node.id}
|
||||
node={node}
|
||||
@@ -288,6 +305,7 @@ function CollectionLink({
|
||||
index={index}
|
||||
/>
|
||||
))}
|
||||
</Transition>
|
||||
<Modal
|
||||
title={t("Move document")}
|
||||
onRequestClose={handlePermissionClose}
|
||||
@@ -311,6 +329,14 @@ const Draggable = styled("div")<{ $isDragging: boolean; $isMoving: boolean }>`
|
||||
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;
|
||||
`;
|
||||
|
||||
@@ -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(
|
||||
<DropCursor isActiveDrop={isOverReorder} innerRef={dropToReorder} />
|
||||
)}
|
||||
</Relative>
|
||||
{expanded &&
|
||||
!isDragging &&
|
||||
nodeChildren.map((childNode, index) => (
|
||||
<Transition
|
||||
style={{
|
||||
maxHeight:
|
||||
expanded && !isDragging
|
||||
? (collection?.documentIds?.length ?? 1) * 80 + "px"
|
||||
: "0px",
|
||||
}}
|
||||
>
|
||||
{nodeChildren.map((childNode, index) => (
|
||||
<ObservedDocumentLink
|
||||
key={childNode.id}
|
||||
collection={collection}
|
||||
@@ -367,6 +374,7 @@ function DocumentLink(
|
||||
parentId={node.id}
|
||||
/>
|
||||
))}
|
||||
</Transition>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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) =>
|
||||
|
||||
@@ -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;
|
||||
Reference in new issue
Block a user