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

Commit c9d60cc

Browse files
committed
refactor(uid): rm more uid & refactor code
1 parent 2bd852f commit c9d60cc

File tree

11 files changed

+38
-59
lines changed

11 files changed

+38
-59
lines changed

components/ContentFilter/SelectedTags.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import R from 'ramda'
33
import { Tag } from 'antd'
44

55
import { Wrapper, TagWrapper } from './styles/selected_tags'
6-
import { uid, isEmptyValue } from '../../utils'
6+
import { isEmptyValue } from '../../utils'
77

88
const filterDict = {
99
TODAY: '今天',
@@ -38,7 +38,7 @@ const SelectedTags = ({ onSelect, activeFilter }) => (
3838
<Wrapper>
3939
{R.keys(activeFilter).map(filterKey => (
4040
<FilterTag
41-
key={uid.gen()}
41+
key={filterKey}
4242
onSelect={onSelect}
4343
active={activeFilter[filterKey]}
4444
type={filterKey}

components/InlineTags/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import PropTypes from 'prop-types'
1010
import Maybe from '../Maybe'
1111
import { Wrapper, Tag, Dot, Title } from './styles'
1212

13-
import { makeDebugger, uid, sortByColor, Trans } from '../../utils'
13+
import { makeDebugger, sortByColor, Trans } from '../../utils'
1414
/* eslint-disable no-unused-vars */
1515
const debug = makeDebugger('c:InlineTags:index')
1616
/* eslint-enable no-unused-vars */
@@ -19,7 +19,7 @@ const InlineTags = ({ data }) => (
1919
<Maybe test={data}>
2020
<Wrapper>
2121
{sortByColor(data).map(tag => (
22-
<Tag key={uid.gen()}>
22+
<Tag key={tag.title}>
2323
<Dot color={tag.color} />
2424
<Title>{Trans(tag.title)}</Title>
2525
</Tag>

components/LoadingEffects/ArticleContentLoading.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,12 @@ const LoadingItem = ({ theme }) => (
2929
</ContentLoader>
3030
)
3131

32-
const ArticleContentLoading = ({ num, theme }) => {
33-
// const ukey = uid.gen()
34-
const range = R.range(0, num)
35-
return range.map(() => (
32+
const ArticleContentLoading = ({ num, theme }) =>
33+
R.range(0, num).map(() => (
3634
<LoadingWrapper key={uid.gen()}>
3735
<LoadingItem uniquekey={uid.gen()} theme={theme} />
3836
</LoadingWrapper>
3937
))
40-
}
4138

4239
ArticleContentLoading.propTypes = {
4340
num: PropTypes.number,

components/LoadingEffects/CommentLoading.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,23 @@ const LoadingWrapper = styled.div`
88
overflow: hidden;
99
`
1010

11-
const CommentLoading = ({ theme }) => {
12-
// const ukey = uid.gen()
13-
return (
14-
<LoadingWrapper>
15-
<ContentLoader
16-
height={60}
17-
width={400}
18-
speed={2}
19-
primaryColor={theme.loading.basic}
20-
secondaryColor={theme.loading.animate}
21-
>
22-
<rect x="35" y="6" rx="4" ry="4" width="117" height="5.25" />
23-
<rect x="37" y="20" rx="3" ry="3" width="85" height="5.25" />
24-
<rect x="37" y="37.68" rx="3" ry="3" width="318.5" height="4.6" />
25-
<rect x="37" y="51" rx="3" ry="3" width="319.2" height="5.11" />
26-
<rect x="71" y="104" rx="3" ry="3" width="201" height="6.4" />
27-
<circle cx="14.0" cy="14.0" r="14.0" />
28-
</ContentLoader>
29-
</LoadingWrapper>
30-
)
31-
}
11+
const CommentLoading = ({ theme }) => (
12+
<LoadingWrapper>
13+
<ContentLoader
14+
height={60}
15+
width={400}
16+
speed={2}
17+
primaryColor={theme.loading.basic}
18+
secondaryColor={theme.loading.animate}
19+
>
20+
<rect x="35" y="6" rx="4" ry="4" width="117" height="5.25" />
21+
<rect x="37" y="20" rx="3" ry="3" width="85" height="5.25" />
22+
<rect x="37" y="37.68" rx="3" ry="3" width="318.5" height="4.6" />
23+
<rect x="37" y="51" rx="3" ry="3" width="319.2" height="5.11" />
24+
<rect x="71" y="104" rx="3" ry="3" width="201" height="6.4" />
25+
<circle cx="14.0" cy="14.0" r="14.0" />
26+
</ContentLoader>
27+
</LoadingWrapper>
28+
)
3229

3330
export default withTheme(CommentLoading)

components/LoadingEffects/JobItemLoading.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,12 @@ const LoadingItem = ({ theme }) => (
3434
</ContentLoader>
3535
)
3636

37-
const JobItemLoading = ({ num, theme }) => {
38-
// const ukey = uid.gen()
39-
const range = R.range(0, num)
40-
return range.map(() => (
37+
const JobItemLoading = ({ num, theme }) =>
38+
R.range(0, num).map(() => (
4139
<LoadingWrapper key={uid.gen()}>
4240
<LoadingItem uniquekey={uid.gen()} theme={theme} />
4341
</LoadingWrapper>
4442
))
45-
}
4643

4744
JobItemLoading.propTypes = {
4845
num: PropTypes.number,

components/LoadingEffects/PostItemLoading.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,12 @@ const LoadingItem = ({ theme }) => (
3333
</ContentLoader>
3434
)
3535

36-
const PostItemLoading = ({ num, theme }) => {
37-
// const ukey = uid.gen()
38-
const range = R.range(0, num)
39-
return range.map(() => (
36+
const PostItemLoading = ({ num, theme }) =>
37+
R.range(0, num).map(() => (
4038
<LoadingWrapper key={uid.gen()}>
4139
<LoadingItem uniquekey={uid.gen()} theme={theme} />
4240
</LoadingWrapper>
4341
))
44-
}
4542

4643
PostItemLoading.propTypes = {
4744
num: PropTypes.number,

components/LoadingEffects/RepoItemLoading.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,12 @@ const LoadingItem = ({ theme }) => (
2929
</ContentLoader>
3030
)
3131

32-
const RepoItemLoading = ({ num, theme }) => {
33-
// const ukey = uid.gen()
34-
const range = R.range(0, num)
35-
return range.map(() => (
32+
const RepoItemLoading = ({ num, theme }) =>
33+
R.range(0, num).map(() => (
3634
<LoadingWrapper key={uid.gen()}>
3735
<LoadingItem uniquekey={uid.gen()} theme={theme} />
3836
</LoadingWrapper>
3937
))
40-
}
4138

4239
RepoItemLoading.propTypes = {
4340
num: PropTypes.number,

components/LoadingEffects/TypeWriterLoading.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,12 @@ const Loading = ({ theme }) => (
3030
</ContentLoader>
3131
)
3232

33-
const TypeWriterLoading = ({ num, theme }) => {
34-
// const ukey = uid.gen()
35-
const range = R.range(0, num)
36-
return range.map(() => (
33+
const TypeWriterLoading = ({ num, theme }) =>
34+
R.range(0, num).map(() => (
3735
<LoadingWrapper key={uid.gen()}>
3836
<Loading uniquekey={uid.gen()} theme={theme} />
3937
</LoadingWrapper>
4038
))
41-
}
4239

4340
TypeWriterLoading.propTypes = {
4441
num: PropTypes.number,

components/LoadingEffects/VideoItemLoading.js

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

33-
const VideoItemLoading = ({ num, theme }) => {
34-
// const ukey = uid.gen()
35-
const range = R.range(0, num)
36-
return range.map(() => (
33+
const VideoItemLoading = ({ num, theme }) =>
34+
R.range(0, num).map(() => (
3735
<LoadingWrapper key={uid.gen()}>
3836
<LoadingItem uniquekey={uid.gen()} theme={theme} />
3937
</LoadingWrapper>
4038
))
41-
}
4239

4340
VideoItemLoading.propTypes = {
4441
num: PropTypes.number,

components/UserBrief/SocialIcons.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ICON_CMD } from '../../config'
55
import Popover from '../Popover'
66

77
import { Wrapper, Linker, SocialIcon, PopInfo } from './styles/social_icons'
8-
import { nilOrEmpty, SOCIAL_LISTS, uid } from '../../utils'
8+
import { nilOrEmpty, SOCIAL_LISTS } from '../../utils'
99

1010
const DisplayIcon = ({ user, social }) => {
1111
if (social.siteUrl) {
@@ -46,7 +46,7 @@ const DisplayIcon = ({ user, social }) => {
4646
const SocialIcons = ({ user }) => (
4747
<Wrapper>
4848
{SOCIAL_LISTS.map(social => (
49-
<DisplayIcon key={uid.gen()} user={user} social={social} />
49+
<DisplayIcon key={social.key} user={user} social={social} />
5050
))}
5151
</Wrapper>
5252
)

0 commit comments

Comments
 (0)