feat: Add ability to star collection (#3327)
* Migrations, models, commands * ui * Move starred hint to location state * lint * tsc * refactor * Add collection empty state in expanded sidebar * Add empty placeholder within starred collections * Drag and drop improves, Relative refactor * fix: Starring untitled draft leaves empty space * fix: Creating draft in starred collection shouldnt open main * fix: Dupe drop cursor * Final fixes * fix: Canonical redirect replaces starred location state * fix: Don't show reorder cursor at the top of collection with no permission to edit when dragging
This commit is contained in:
29
app/components/Sidebar/components/Folder.tsx
Normal file
29
app/components/Sidebar/components/Folder.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import * as React from "react";
|
||||
import styled from "styled-components";
|
||||
|
||||
type Props = {
|
||||
expanded: boolean;
|
||||
};
|
||||
|
||||
const Folder: React.FC<Props> = ({ expanded, children }) => {
|
||||
const [openedOnce, setOpenedOnce] = React.useState(expanded);
|
||||
|
||||
// allows us to avoid rendering all children when the folder hasn't been opened
|
||||
React.useEffect(() => {
|
||||
if (expanded) {
|
||||
setOpenedOnce(true);
|
||||
}
|
||||
}, [expanded]);
|
||||
|
||||
if (!openedOnce) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <Wrapper $expanded={expanded}>{children}</Wrapper>;
|
||||
};
|
||||
|
||||
const Wrapper = styled.div<{ $expanded?: boolean }>`
|
||||
display: ${(props) => (props.$expanded ? "block" : "none")};
|
||||
`;
|
||||
|
||||
export default Folder;
|
||||
Reference in New Issue
Block a user