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

Commit 008e0aa

Browse files
committed
refactor(TagsEditor): add topic & code refactor
1 parent f4a6950 commit 008e0aa

File tree

22 files changed

+151
-86
lines changed

22 files changed

+151
-86
lines changed

components/CategoriesCell/styles/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export const CategoryTag = styled.div`
2929
border: 1px solid #97dbfc;
3030
}
3131
`
32-
3332
export const DeleteCross = styled.div`
3433
margin-left: 8px;
3534
&:hover {

components/ColorCell/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types'
99

1010
import { makeDebugger } from '../../utils'
1111

12-
import { ColorCell, ColorDot, ColorTitle } from './styles'
12+
import { ColorCell, ColorDot /* ColorTitle */ } from './styles'
1313
/* eslint-disable no-unused-vars */
1414
const debug = makeDebugger('c:ColorCell:index')
1515
/* eslint-enable no-unused-vars */
@@ -18,7 +18,7 @@ const ColorCellComponent = ({ color }) => {
1818
return (
1919
<ColorCell>
2020
<ColorDot color={color} />
21-
<ColorTitle>{color}</ColorTitle>
21+
{/* <ColorTitle>{color}</ColorTitle> */}
2222
</ColorCell>
2323
)
2424
}

components/ColorCell/styles/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export const ColorCell = styled.div`
77
`
88

99
export const ColorDot = styled.div`
10-
width: 10px;
11-
height: 10px;
10+
width: 15px;
11+
height: 15px;
1212
background: ${props => props.color};
1313
border-radius: 100%;
1414
`

components/FormInputer/index.js

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import React from 'react'
88
import PropTypes from 'prop-types'
9-
import { Input } from 'antd'
9+
import { Input, InputNumber } from 'antd'
1010
import R from 'ramda'
1111

1212
import FormItem from '../FormItem'
@@ -19,39 +19,73 @@ const debug = makeDebugger('c:FormInputer:index')
1919

2020
const { TextArea } = Input
2121

22-
const FormInputer = ({ label, textarea, value, onChange, note }) => (
23-
<FormItem label={label}>
24-
<FormInput>
25-
{textarea ? (
26-
<TextArea
27-
value={value}
28-
placeholder={value}
29-
autosize={{ minRows: 3, maxRows: 6 }}
30-
onChange={onChange}
31-
/>
32-
) : (
33-
<Input size="default" value={value} onChange={onChange} />
34-
)}
35-
{R.isEmpty(note) ? <div /> : <Note>{note}</Note>}
36-
</FormInput>
37-
</FormItem>
38-
)
22+
const FormInputer = ({ label, value, onChange, note, type, disabled }) => {
23+
switch (type) {
24+
case 'number': {
25+
return (
26+
<FormItem label={label}>
27+
<InputNumber
28+
min={0}
29+
defaultValue={0}
30+
onChange={onChange}
31+
disabled={disabled}
32+
/>
33+
{R.isEmpty(note) ? <div /> : <Note>{note}</Note>}
34+
</FormItem>
35+
)
36+
}
37+
case 'textarea': {
38+
return (
39+
<FormItem label={label}>
40+
<FormInput>
41+
<TextArea
42+
value={value}
43+
placeholder={value}
44+
autosize={{ minRows: 3, maxRows: 6 }}
45+
onChange={onChange}
46+
disabled={disabled}
47+
/>
48+
{R.isEmpty(note) ? <div /> : <Note>{note}</Note>}
49+
</FormInput>
50+
</FormItem>
51+
)
52+
}
53+
54+
default: {
55+
return (
56+
<FormItem label={label}>
57+
<FormInput>
58+
<Input
59+
size="default"
60+
value={value}
61+
onChange={onChange}
62+
disabled={disabled}
63+
/>
64+
{R.isEmpty(note) ? <div /> : <Note>{note}</Note>}
65+
</FormInput>
66+
</FormItem>
67+
)
68+
}
69+
}
70+
}
3971

4072
FormInputer.propTypes = {
4173
// https://www.npmjs.com/package/prop-types
4274
onChange: PropTypes.func,
4375
label: PropTypes.string,
4476
value: PropTypes.string,
45-
textarea: PropTypes.bool,
4677
note: PropTypes.string,
78+
type: PropTypes.oneOf(['default', 'textarea', 'number']),
79+
disabled: PropTypes.bool,
4780
}
4881

4982
FormInputer.defaultProps = {
5083
onChange: debug,
5184
value: '',
5285
label: '',
53-
textarea: false,
5486
note: '',
87+
type: 'default',
88+
disabled: false,
5589
}
5690

5791
export default FormInputer

components/FormItem/styles/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ export const FormItemWrapper = styled.div`
77
margin-bottom: 25px;
88
`
99
export const FormLable = styled.div`
10-
font-size: 1em;
10+
font-size: 0.9rem;
1111
color: grey;
1212
margin-right: 10px;
1313
margin-top: 5px;
1414
max-width: 20%;
1515
width: 20%;
1616
text-align: right;
17+
min-width: 40px;
1718
`
1819

1920
export const ChildWrapper = styled.div`

components/ThreadsCell/styles/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { Animate } from '../../../utils'
66
export const Wrapper = styled.div`
77
display: flex;
88
flex-wrap: wrap;
9-
justify-content: center;
9+
justify-content: flex-start;
1010
`
1111
export const Thread = styled.div`
1212
margin-right: 5px;
13-
margin-bottom: 3px;
13+
margin-bottom: 5px;
1414
padding: 0 5px;
1515
background: #f1f1f1;
1616
color: #6cbf6c;

config/general.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@ export const TAG_COLORS = [
3030
export const CMS_THREADS = [
3131
'post',
3232
'job',
33+
'video',
34+
'repo',
3335
// ...
3436
]

containers/CategoryEditor/logic.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
makeDebugger,
77
closePreviewer,
88
$solver,
9-
castArgs,
9+
cast,
1010
} from '../../utils'
1111
import S from './schema'
1212
import SR71 from '../../utils/network/sr71'
@@ -31,13 +31,10 @@ export const mutateConfirm = () => {
3131
const args = { ...store.categoryData }
3232

3333
store.markState({ mutating: true })
34-
const fargs = castArgs(args, requiredArgs)
34+
const fargs = cast(requiredArgs, args)
3535

3636
if (store.isEdit) {
37-
return sr71$.mutate(
38-
S.updateCategory,
39-
castArgs(args, ['id', ...requiredArgs])
40-
)
37+
return sr71$.mutate(S.updateCategory, cast(['id', ...requiredArgs], args))
4138
}
4239
console.log('fargs --- xxx ', fargs)
4340
return sr71$.mutate(S.createCategory, fargs)

containers/CommunitiesContent/TagsContent.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ const columns = [
6060
return <div>{text}</div>
6161
},
6262
},
63+
{
64+
title: 'topic',
65+
width: 150,
66+
dataIndex: 'topic',
67+
align: 'center',
68+
render: text => {
69+
return <div>{text.title}</div>
70+
},
71+
},
6372
{
6473
title: '创建时间',
6574
width: 150,

containers/CommunitiesContent/logic.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ const DataSolver = [
255255
{
256256
match: asyncRes('pagedTags'),
257257
action: ({ pagedTags }) => {
258+
debug('load pagedTags: ', pagedTags)
258259
cancleLoading()
259260
store.markState({ pagedTags })
260261
},

0 commit comments

Comments
 (0)