Skip to content

Commit 6486879

Browse files
committed
Added skeleton to stories list
1 parent 96075a1 commit 6486879

File tree

3 files changed

+62
-13
lines changed

3 files changed

+62
-13
lines changed

src/assets/scss/components/vote.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
border-radius: 10px;
44
padding: 4px 4px;
55

6+
&-loading {
7+
background-color: unset;
8+
max-width: 68px;
9+
min-width: 50px;
10+
width: 10%;
11+
}
12+
613
&-voted {
714
background-color: $light-blue;
815
}

src/components/Stories.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import Button from './Button'
55
import StoriesList from './StoriesList'
66
import Pagination from './Pagination'
77
import Dropdown from './Dropdown'
8-
import LoadingIndicator from '../modules/LoadingIndicator'
98
import SearchInput from '../modules/SearchInput'
109

1110
import Lists from '../utils/Lists'
@@ -233,17 +232,14 @@ const Stories = ({ authorId, followerId }) => {
233232
/>
234233
</div>
235234
</div>
236-
{promiseInProgress ? (
237-
<LoadingIndicator />
238-
) : (
239-
<div className='stories-div'>
240-
<StoriesList
241-
stories={stories}
242-
state={currentStateSelected}
243-
product={product}
244-
/>
245-
</div>
246-
)}
235+
<div className='stories-div'>
236+
<StoriesList
237+
stories={stories}
238+
state={currentStateSelected}
239+
product={product}
240+
isLoading={promiseInProgress}
241+
/>
242+
</div>
247243
<Pagination
248244
getPage={getPage}
249245
storyCount={storyCount}

src/components/StoriesList.js

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,55 @@ import { navigate, Link } from '@reach/router'
33

44
import Vote from './Vote'
55
import { strip } from '../utils/filterText'
6+
import Skeleton from 'react-loading-skeleton'
7+
8+
const StorySkeleton = () => (
9+
<div className='story'>
10+
<div className='vote-wrapper-loading'>
11+
<Skeleton height={80} />
12+
</div>
13+
<div className='stories-content'>
14+
<h3>
15+
<Skeleton height={20} />
16+
</h3>
17+
<p>
18+
<Skeleton />
19+
</p>
20+
</div>
21+
<div className='story-author story-subcontent'>
22+
<div className='user-avatar'>
23+
<Skeleton circle width={58} height={58} />
24+
</div>
25+
<div className='flex flex-column'>
26+
<Skeleton width={52} />
27+
</div>
28+
</div>
29+
<div className='flex flex-column story-subcontent'>
30+
<Skeleton width={52} />
31+
</div>
32+
<div className='flex flex-column'>
33+
<span className='story-meta'>
34+
<Skeleton width={52} />
35+
</span>
36+
<span className='story-meta'>
37+
<Skeleton width={52} />
38+
</span>
39+
</div>
40+
</div>
41+
)
642

743
const StoriesList = (props) => {
8-
const { stories, state, product } = props
44+
const { stories, state, product, isLoading } = props
45+
46+
if (isLoading) {
47+
return (
48+
<div className='flex flex-column'>
49+
{[1, 2, 3, 4, 5].map((i) => (
50+
<StorySkeleton key={i} />
51+
))}
52+
</div>
53+
)
54+
}
955

1056
return (
1157
<div className='flex flex-column' data-cy='stories'>

0 commit comments

Comments
 (0)