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 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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
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