Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 620d113

Browse files
committed
feat(LoadingBar): add RepoLoadingBar
1 parent e4073f5 commit 620d113

File tree

5 files changed

+59
-6
lines changed

5 files changed

+59
-6
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React from 'react'
2+
import R from 'ramda'
3+
import PropTypes from 'prop-types'
4+
import styled, { withTheme } from 'styled-components'
5+
import ContentLoader from 'react-content-loader'
6+
7+
import { uid } from '../../utils'
8+
9+
// Config-page: http://danilowoz.com/create-react-content-loader/
10+
const LoadingWrapper = styled.div`
11+
width: 100%;
12+
overflow: hidden;
13+
`
14+
15+
const LoadingItem = ({ theme }) => (
16+
<ContentLoader
17+
height={80}
18+
width={500}
19+
speed={2}
20+
primaryColor={theme.loading.basic}
21+
secondaryColor={theme.loading.animate}
22+
>
23+
<rect x="13" y="10.69" rx="4" ry="4" width="183" height="8.64" />
24+
<rect x="13" y="29.22" rx="4" ry="4" width="401.3464" height="5.2" />
25+
<rect x="13" y="43.2" rx="4" ry="4" width="331.58" height="5.2" />
26+
<rect x="283.02" y="141.21" rx="4" ry="4" width="86.5" height="9.76" />
27+
<rect x="433" y="12.2" rx="0" ry="0" width="60" height="5.6" />
28+
<rect x="13" y="58.2" rx="0" ry="0" width="137" height="6.5" />
29+
</ContentLoader>
30+
)
31+
32+
const RepoItemLoading = ({ num, theme }) => {
33+
// const ukey = uid.gen()
34+
const range = R.range(0, num)
35+
return range.map(() => (
36+
<LoadingWrapper key={uid.gen()}>
37+
<LoadingItem uniquekey={uid.gen()} theme={theme} />
38+
</LoadingWrapper>
39+
))
40+
}
41+
42+
RepoItemLoading.propTypes = {
43+
num: PropTypes.number,
44+
}
45+
46+
RepoItemLoading.defaultProps = {
47+
num: 1,
48+
}
49+
50+
export default withTheme(RepoItemLoading)

components/LoadingEffects/VideoItemLoading.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const LoadingItem = ({ theme }) => (
3030
</ContentLoader>
3131
)
3232

33-
const PostLoading = ({ num, theme }) => {
33+
const VideoItemLoading = ({ num, theme }) => {
3434
// const ukey = uid.gen()
3535
const range = R.range(0, num)
3636
return range.map(() => (
@@ -40,12 +40,12 @@ const PostLoading = ({ num, theme }) => {
4040
))
4141
}
4242

43-
PostLoading.propTypes = {
43+
VideoItemLoading.propTypes = {
4444
num: PropTypes.number,
4545
}
4646

47-
PostLoading.defaultProps = {
47+
VideoItemLoading.defaultProps = {
4848
num: 1,
4949
}
5050

51-
export default withTheme(PostLoading)
51+
export default withTheme(VideoItemLoading)

components/LoadingEffects/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export { default as CheatSheetLoading } from './CheatSheetLoading'
88
export { default as CommentLoading } from './CommentLoading'
99
export { default as PostItemLoading } from './PostItemLoading'
1010
export { default as VideoItemLoading } from './VideoItemLoading'
11+
export { default as RepoItemLoading } from './RepoItemLoading'
1112
export { default as TypeWriterLoading } from './TypeWriterLoading'
1213

1314
export { default as ArticleContentLoading } from './ArticleContentLoading'

components/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export {
5151
CheatSheetLoading,
5252
PostItemLoading,
5353
VideoItemLoading,
54+
RepoItemLoading,
5455
TypeWriterLoading,
5556
ArticleContentLoading,
5657
} from './LoadingEffects'

containers/ReposThread/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import TagsBar from '../TagsBar'
1313

1414
import {
1515
Affix,
16-
PostItemLoading,
16+
RepoItemLoading,
1717
Pagi,
1818
EmptyThread,
1919
ContentFilter,
@@ -45,6 +45,7 @@ const View = ({ community, thread, entries, curView, active }) => {
4545
case TYPE.RESULT: {
4646
return (
4747
<React.Fragment>
48+
<RepoItemLoading num={1} />
4849
{entries.map(entry => (
4950
<RepoItem key={uid.gen()} entry={entry} active={active} />
5051
))}
@@ -59,7 +60,7 @@ const View = ({ community, thread, entries, curView, active }) => {
5960
)
6061
}
6162
default:
62-
return <PostItemLoading num={5} />
63+
return <RepoItemLoading num={5} />
6364
}
6465
}
6566

0 commit comments

Comments
 (0)