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