Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commitca5c2d4

Browse files
committed
refactor shortid gen to uid.gen
1 parent594d4f2 commitca5c2d4

File tree

28 files changed

+139
-146
lines changed

28 files changed

+139
-146
lines changed

‎components/AvatarsRow/index.js‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
importReactfrom'react'
88
importPropTypesfrom'prop-types'
9-
importshortidfrom'shortid'
109
importRfrom'ramda'
1110

12-
import{makeDebugger,prettyNum}from'../../utils'
1311
import{ATATARS_LIST_LENGTH}from'../../config/general'
1412

1513
import{Tooltip}from'../../components'
1614
import{Avatars,AvatarsItem,AvatarsImg,AvatarsMore}from'./styles'
1715

1816
/* eslint-disable no-unused-vars */
17+
import{makeDebugger,prettyNum,uid}from'../../utils'
18+
1919
constdebug=makeDebugger('c:AvatarsRow:index')
2020
/* eslint-enable no-unused-vars */
2121

@@ -45,10 +45,7 @@ const AvatarsRow = ({
4545
)}
4646

4747
{R.slice(0,limit,R.reverse(users)).map(user=>(
48-
<AvatarsItem
49-
key={shortid.generate()}
50-
onClick={onUserSelect.bind(this,user)}
51-
>
48+
<AvatarsItemkey={uid.gen()}onClick={onUserSelect.bind(this,user)}>
5249
<Tooltiptitle={user.nickname}>
5350
<AvatarsImgsrc={user.avatar}/>
5451
</Tooltip>

‎components/CategoriesCell/index.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
importReactfrom'react'
88
importPropTypesfrom'prop-types'
99
importRfrom'ramda'
10-
importshortidfrom'shortid'
1110

1211
import{ICON_ASSETS}from'../../config'
1312

1413
import{AdderCell,Icon}from'../../components'
14+
1515
import{
1616
Wrapper,
1717
CategoryWrapper,
@@ -20,13 +20,14 @@ import {
2020
AddIcon,
2121
}from'./styles'
2222

23+
import{uid}from'../../utils'
2324
// import { inject, observer } from 'mobx-react'
2425
// import Link from 'next/link'
2526

2627
constCategoriesList=({ source, onDelete})=>(
2728
<CategoryWrapper>
2829
{source.categories.map(c=>(
29-
<CategoryTagkey={shortid.generate()}>
30+
<CategoryTagkey={uid.gen()}>
3031
{c.title}
3132
<DeleteCrossonClick={onDelete.bind(this,source.id,c)}>
3233
<Icontype="cross"/>

‎components/CommunityCell/index.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ import React from 'react'
88
importRfrom'ramda'
99
importPropTypesfrom'prop-types'
1010
importReactTooltipfrom'react-tooltip'
11-
importshortidfrom'shortid'
1211

1312
import{ICON_ASSETS}from'../../config'
14-
import{makeDebugger}from'../../utils'
1513
import{AdderCell}from'../../components'
1614

1715
import{
@@ -24,6 +22,8 @@ import {
2422
AddIcon,
2523
}from'./styles'
2624

25+
import{uid,makeDebugger}from'../../utils'
26+
2727
/* eslint-disable no-unused-vars */
2828
constdebug=makeDebugger('c:CommunityCell:index')
2929
/* eslint-enable no-unused-vars */
@@ -40,7 +40,7 @@ const SingleCommunity = ({ community }) => (
4040
constCommunitiesLogoArray=({ array})=>(
4141
<Wrapper>
4242
{array.map(c=>(
43-
<Wrapperkey={shortid.generate()}>
43+
<Wrapperkey={uid.gen()}>
4444
<div
4545
data-tip={c.title}
4646
data-for="community_cell"
@@ -56,7 +56,7 @@ const CommunitiesLogoArray = ({ array }) => (
5656
constCommunitiesSetter=({ array, source, thread, onDelete})=>(
5757
<Wrapper>
5858
{array.map(c=>(
59-
<SetterWrapperkey={shortid.generate()}>
59+
<SetterWrapperkey={uid.gen()}>
6060
<CommunityLogosrc={c.logo}/>
6161
<DeleteCrossonClick={onDelete.bind(this,thread,source,c.id)}>
6262
x

‎components/CommunityMatrix/index.js‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
importReactfrom'react'
88
importRfrom'ramda'
99
importPropTypesfrom'prop-types'
10-
importshortidfrom'shortid'
1110
importReactTooltipfrom'react-tooltip'
1211

1312
import{
@@ -18,7 +17,7 @@ import {
1817
}from'./styles'
1918
import{ICON_ASSETS}from'../../config'
2019

21-
import{makeDebugger}from'../../utils'
20+
import{makeDebugger,uid}from'../../utils'
2221

2322
/* eslint-disable no-unused-vars */
2423
constdebug=makeDebugger('c:CommunityMatrix:index')
@@ -30,7 +29,7 @@ const Communities = ({ list, onSelect, activeRaw, lens }) => (
3029
<React.Fragment>
3130
{list.map(c=>(
3231
<div
33-
key={shortid.generate()}
32+
key={uid.gen()}
3433
onClick={onSelect.bind(this,c)}
3534
data-place="right"
3635
data-tip={c.title}

‎components/FormSelector/index.js‎

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,37 @@
77
importReactfrom'react'
88
importRfrom'ramda'
99
importPropTypesfrom'prop-types'
10-
importshortidfrom'shortid'
11-
1210
import{Select}from'antd'
1311

1412
import{FormItem}from'../../components'
15-
16-
import{makeDebugger}from'../../utils'
1713
import{Note}from'./styles'
14+
15+
import{uid,makeDebugger}from'../../utils'
16+
1817
/* eslint-disable no-unused-vars */
1918
constdebug=makeDebugger('c:FormSelector:index')
2019
/* eslint-enable no-unused-vars */
2120

2221
const{ Option}=Select
2322

24-
constFormSelector=({ label, options, value, onChange, note})=>{
25-
return(
26-
<FormItemlabel={label}>
27-
<React.Fragment>
28-
<Select
29-
defaultValue={value}
30-
style={{minWidth:250}}
31-
onChange={onChange}
32-
>
33-
{options.map(v=>(
34-
<Optionkey={shortid.generate()}value={v}>
35-
{v}
36-
</Option>
37-
))}
38-
</Select>
39-
{R.isEmpty(note) ?<div/> :<Note>{note}</Note>}
40-
</React.Fragment>
41-
</FormItem>
42-
)
43-
}
23+
constFormSelector=({ label, options, value, onChange, note})=>(
24+
<FormItemlabel={label}>
25+
<React.Fragment>
26+
<Select
27+
defaultValue={value}
28+
style={{minWidth:250}}
29+
onChange={onChange}
30+
>
31+
{options.map(v=>(
32+
<Optionkey={uid.gen()}value={v}>
33+
{v}
34+
</Option>
35+
))}
36+
</Select>
37+
{R.isEmpty(note) ?<div/> :<Note>{note}</Note>}
38+
</React.Fragment>
39+
</FormItem>
40+
)
4441

4542
FormSelector.propTypes={
4643
// https://www.npmjs.com/package/prop-types

‎components/LoadingEffects/CheatSheetLoading.js‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import React from 'react'
22
importPropTypesfrom'prop-types'
33
importMasonryfrom'react-masonry-component'
44
importRfrom'ramda'
5-
importshortidfrom'shortid'
65
import{withTheme}from'styled-components'
76

87
// import Loading, { Rect, Circle } from 'react-content-loader'
98
importContentLoaderfrom'react-content-loader'
109

11-
import{makeDebugger}from'../../utils'
10+
import{uid,makeDebugger}from'../../utils'
1211
/* eslint-disable no-unused-vars */
1312
constdebug=makeDebugger('c:LoadingEffects:index')
1413
/* eslint-enable no-unused-vars */
@@ -41,7 +40,7 @@ const LoadingBlock = ({ theme }) => (
4140
constCheatSheetLoading=({ column, theme})=>(
4241
<Masonry>
4342
{R.range(0,column).map(()=>(
44-
<LoadingBlockkey={shortid.generate()}theme={theme}/>
43+
<LoadingBlockkey={uid.gen()}theme={theme}/>
4544
))}
4645
</Masonry>
4746
)

‎components/LoadingEffects/CommentLoading.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const LoadingWrapper = styled.div`
99
`
1010

1111
constCommentLoading=({ theme})=>{
12-
// const ukey =shortid.generate()
12+
// const ukey =uid.gen()
1313
return(
1414
<LoadingWrapper>
1515
<ContentLoader

‎components/LoadingEffects/PostLoading.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import R from 'ramda'
33
importPropTypesfrom'prop-types'
44
importstyled,{withTheme}from'styled-components'
55
importContentLoaderfrom'react-content-loader'
6-
importshortidfrom'shortid'
76

7+
import{uid}from'../../utils'
88
// Config-page: http://danilowoz.com/create-react-content-loader/
99
constLoadingWrapper=styled.div`
1010
width: 100%;
@@ -29,11 +29,11 @@ const LoadingItem = ({ theme }) => (
2929
)
3030

3131
constPostLoading=({ num, theme})=>{
32-
// const ukey =shortid.generate()
32+
// const ukey =uid.gen()
3333
constrange=R.range(0,num)
3434
returnrange.map(()=>(
35-
<LoadingWrapperkey={shortid.generate()}>
36-
<LoadingItemuniquekey={shortid.generate()}theme={theme}/>
35+
<LoadingWrapperkey={uid.gen()}>
36+
<LoadingItemuniquekey={uid.gen()}theme={theme}/>
3737
</LoadingWrapper>
3838
))
3939
}

‎components/LoadingEffects/PostsLoading.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import R from 'ramda'
33
importPropTypesfrom'prop-types'
44
importstyled,{withTheme}from'styled-components'
55
importContentLoaderfrom'react-content-loader'
6-
importshortidfrom'shortid'
76

7+
import{uid}from'../../utils'
88
// Config-page: http://danilowoz.com/create-react-content-loader/
99
constLoadingWrapper=styled.div`
1010
width: 100%;
@@ -33,11 +33,11 @@ const LoadingItem = ({ theme }) => (
3333
)
3434

3535
constPostsLoading=({ num, theme})=>{
36-
// const ukey =shortid.generate()
36+
// const ukey =uid.gen()
3737
constrange=R.range(0,num)
3838
returnrange.map(()=>(
39-
<LoadingWrapperkey={shortid.generate()}>
40-
<LoadingItemuniquekey={shortid.generate()}theme={theme}/>
39+
<LoadingWrapperkey={uid.gen()}>
40+
<LoadingItemuniquekey={uid.gen()}theme={theme}/>
4141
</LoadingWrapper>
4242
))
4343
}

‎components/LoadingEffects/TagsLoading.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import R from 'ramda'
33
importPropTypesfrom'prop-types'
44
importstyledfrom'styled-components'
55
importContentLoaderfrom'react-content-loader'
6-
importshortidfrom'shortid'
6+
7+
import{uid}from'../../utils'
78

89
// Config-page: http://danilowoz.com/create-react-content-loader/
910
constLoadingWrapper=styled.div`
@@ -28,7 +29,7 @@ const LoadingItem = () => (
2829
)
2930

3031
constTagListLoading=({ num})=>{
31-
constukey=shortid.generate()
32+
constukey=uid.gen()
3233
constrange=R.range(0,num)
3334
returnrange.map(()=>(
3435
<LoadingWrapperkey={ukey}>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp