Skip to content

Commit

Permalink
feat: Add infinite loading to photo lists and album lists
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Aug 10, 2023
1 parent ce14aac commit 02e44ca
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 62 deletions.
13 changes: 13 additions & 0 deletions src/photos/components/LoadMore.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react'

import UILoadMore from 'cozy-ui/transpiled/react/LoadMore'

const LoadMore = ({ label, fetchMore }) => {
return (
<div className="u-flex u-flex-justify-center u-mb-2">
<UILoadMore label={label} fetchMore={fetchMore} />
</div>
)
}

export { LoadMore }
46 changes: 0 additions & 46 deletions src/photos/components/LoadMoreButton.jsx

This file was deleted.

8 changes: 2 additions & 6 deletions src/photos/components/PhotoBoard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import PhotoList from './PhotoList'
import { EmptyPhotos } from 'components/Error/Empty'
import Loading from './Loading'
import ErrorComponent from 'components/Error/ErrorComponent'
import LoadMoreButton from './LoadMoreButton'
import { LoadMore } from 'photos/components/LoadMore'

const PhotoBoard = ({
lists,
Expand Down Expand Up @@ -65,11 +65,7 @@ const PhotoBoard = ({
/>
))}
{hasMore && (
<LoadMoreButton
label={t('Board.load_more')}
width={width}
onClick={fetchMore}
/>
<LoadMore label={t('Board.load_more')} fetchMore={fetchMore} />
)}
</div>
)
Expand Down
5 changes: 3 additions & 2 deletions src/photos/ducks/albums/components/AlbumsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import styles from 'photos/styles/albumsList.styl'
import React from 'react'
import { Content } from 'cozy-ui/transpiled/react/Layout'
import { translate } from 'cozy-ui/transpiled/react/I18n'

import { EmptyPhotos } from 'components/Error/Empty'
import LoadMoreButton from 'photos/components/LoadMoreButton'
import AlbumItem from './AlbumItem'
import { LoadMore } from 'photos/components/LoadMore'

const FALLBACK_CREATION_DATE = null
const sortByCreationDate = (a, b) => {
Expand All @@ -26,7 +27,7 @@ const AlbumsList = ({ data, hasMore, fetchMore, t }) =>
<AlbumItem album={a} key={a.id} />
))}
{hasMore && (
<LoadMoreButton label={t('Albums.load_more')} onClick={fetchMore} />
<LoadMore label={t('Albums.load_more')} fetchMore={fetchMore} />
)}
</div>
</Content>
Expand Down
8 changes: 0 additions & 8 deletions src/photos/styles/photoList.styl
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,3 @@
.pho-photo:hover
.pho-photo-select
opacity 1

.pho-list-morebutton
position relative
margin-bottom 2rem

button
margin 0 auto
display block

0 comments on commit 02e44ca

Please sign in to comment.