chore: Reduce loading jank in sidebar (#1294)
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
21
app/components/Sidebar/components/CollectionsLoading.js
Normal file
21
app/components/Sidebar/components/CollectionsLoading.js
Normal 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;
|
||||
Reference in New Issue
Block a user