chore: Reduce loading jank in sidebar (#1294)

This commit is contained in:
Tom Moor
2020-05-30 12:50:08 -07:00
committed by GitHub
parent c929f83813
commit ccedea55d6
2 changed files with 36 additions and 5 deletions

View File

@@ -10,6 +10,7 @@ import { newDocumentUrl } from 'utils/routeHelpers';
import Header from './Header';
import SidebarLink from './SidebarLink';
import CollectionLink from './CollectionLink';
import CollectionsLoading from './CollectionsLoading';
import Fade from 'components/Fade';
import CollectionsStore from 'stores/CollectionsStore';
@@ -55,8 +56,7 @@ class Collections extends React.Component<Props> {
const { collections, ui, documents } = this.props;
const content = (
<Flex column>
<Header>Collections</Header>
<React.Fragment>
{collections.orderedData.map(collection => (
<CollectionLink
key={collection.id}
@@ -74,12 +74,22 @@ class Collections extends React.Component<Props> {
label="New collection…"
exact
/>
</Flex>
</React.Fragment>
);
return (
collections.isLoaded &&
(this.isPreloaded ? content : <Fade>{content}</Fade>)
<Flex column>
<Header>Collections</Header>
{collections.isLoaded ? (
this.isPreloaded ? (
content
) : (
<Fade>{content}</Fade>
)
) : (
<CollectionsLoading />
)}
</Flex>
);
}
}

View File

@@ -0,0 +1,21 @@
// @flow
import * as React from 'react';
import styled from 'styled-components';
import Mask from 'components/Mask';
function CollectionsLoading() {
return (
<Wrapper>
<Mask />
<Mask />
<Mask />
</Wrapper>
);
}
const Wrapper = styled.div`
margin: 4px 16px;
width: 75%;
`;
export default CollectionsLoading;