Skip to content

Commit da27886

Browse files
committed
merge
2 parents 2f1a97b + 3c24233 commit da27886

File tree

233 files changed

+6924
-1148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

233 files changed

+6924
-1148
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: node_js
22

33
node_js:
4+
- 10
45
- 9
56
- 8
67
- 7

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
<br/><br/>
88

99
<a href="https://travis-ci.org/mydearxym/coderplanets_admin" target="_blank">
10-
<img src="https://api.travis-ci.org/mydearxym/coderplanets_admin.svg?branch=dev" alt="Build Status" />
10+
<img src="https://travis-ci.org/mydearxym/coderplanets_admin.svg?branch=dev" alt="Build Status" />
1111
</a>
1212

13-
<a href='https://coveralls.io/github/mydearxym/coderplanets_admin_web?branch=master' target="_blank">
13+
<a href='https://coveralls.io/github/mydearxym/coderplanets_admin?branch=master' target="_blank">
1414
<img
15-
src='https://coveralls.io/repos/github/mydearxym/coderplanets_admin_web/badge.svg?branch=master'
15+
src='https://coveralls.io/repos/github/mydearxym/coderplanets_admin/badge.svg?branch=master'
1616
alt='Coverage Status' />
1717
</a>
1818

components/AdderCell/index.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
*
3+
* AdderCell
4+
*
5+
*/
6+
7+
import React from 'react'
8+
import PropTypes from 'prop-types'
9+
10+
import { ICON_ASSETS } from '../../config'
11+
12+
import { makeDebugger } from '../../utils'
13+
import { AddWrapper, AddIcon, AddText } from './styles'
14+
15+
/* eslint-disable no-unused-vars */
16+
const debug = makeDebugger('c:AdderCell:index')
17+
/* eslint-enable no-unused-vars */
18+
19+
const AdderCell = ({ onAdd }) => (
20+
<AddWrapper onClick={onAdd}>
21+
<AddIcon src={`${ICON_ASSETS}/cmd/plus.svg`} />
22+
<AddText>添加</AddText>
23+
</AddWrapper>
24+
)
25+
26+
AdderCell.propTypes = {
27+
// https://www.npmjs.com/package/prop-types
28+
onAdd: PropTypes.func,
29+
}
30+
31+
AdderCell.defaultProps = {
32+
onAdd: debug,
33+
}
34+
35+
export default AdderCell
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import styled from 'styled-components'
2+
3+
import { Animate } from '../../../utils'
4+
import { Img } from '../../../components'
5+
6+
export const AddWrapper = styled.div`
7+
display: flex;
8+
justify-content: center;
9+
align-items: center;
10+
`
11+
export const AddIcon = styled(Img)`
12+
width: 15px;
13+
height: 15px;
14+
display: block;
15+
fill: lightgrey;
16+
&:hover {
17+
cursor: pointer;
18+
fill: #646479;
19+
}
20+
${AddWrapper}:hover & {
21+
cursor: pointer;
22+
fill: #646479;
23+
animation: ${Animate.pulse} 0.3s linear;
24+
}
25+
`
26+
27+
export const AddText = styled.div`
28+
margin-left: 5px;
29+
color: lightgrey;
30+
${AddWrapper}:hover & {
31+
cursor: pointer;
32+
color: #646479;
33+
}
34+
transition: color 0.2s linear;
35+
`
36+
//
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// import React from 'react'
2+
// import { shallow } from 'enzyme'
3+
4+
// import AdderCell from '../index'
5+
6+
describe('TODO <AdderCell />', () => {
7+
it('Expect to have unit tests specified', () => {
8+
expect(true).toEqual(true)
9+
})
10+
})

components/BannerCountBrief/index.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import {
2121
const debug = makeDebugger('c:BannerCountBrief:index')
2222
/* eslint-enable no-unused-vars */
2323

24-
const CountBrief = ({ curCount, totalCount, part, unit }) => {
25-
if (totalCount === curCount) {
24+
const CountBrief = ({ filteredCount, totalCount, part, unit }) => {
25+
if (filteredCount === null || totalCount === filteredCount) {
2626
return (
2727
<Result>
2828
<ResultBottom>
@@ -32,7 +32,7 @@ const CountBrief = ({ curCount, totalCount, part, unit }) => {
3232
</ResultBottom>
3333
</Result>
3434
)
35-
} else if (curCount < 0 && totalCount === 0) {
35+
} else if (filteredCount < 0 && totalCount === 0) {
3636
return <Result>正在加载, 请稍后...</Result>
3737
}
3838
return (
@@ -42,32 +42,33 @@ const CountBrief = ({ curCount, totalCount, part, unit }) => {
4242
</ResultTop>
4343
<ResultBottom>
4444
<ResultText>符合当前条件的{part}</ResultText>
45-
<ResultNumber>{curCount} </ResultNumber>
45+
<ResultNumber>{filteredCount} </ResultNumber>
4646
<ResultText>
47-
{unit}, 占比 {toPercentNum(curCount, totalCount)}
47+
{unit}, 占比 {toPercentNum(filteredCount, totalCount)}
4848
</ResultText>
4949
</ResultBottom>
5050
</Result>
5151
)
5252
}
5353

54-
const BannerCountBrief = ({ curCount, totalCount, part, unit }) => (
54+
const BannerCountBrief = ({ filteredCount, totalCount, part, unit }) => (
5555
<CountBrief
56-
curCount={curCount}
56+
filteredCount={filteredCount}
5757
totalCount={totalCount}
5858
part={part}
5959
unit={unit}
6060
/>
6161
)
6262

6363
BannerCountBrief.propTypes = {
64-
curCount: PropTypes.number.isRequired,
64+
filteredCount: PropTypes.number,
6565
totalCount: PropTypes.number.isRequired,
6666
unit: PropTypes.string,
6767
part: PropTypes.string,
6868
}
6969

7070
BannerCountBrief.defaultProps = {
71+
filteredCount: null,
7172
part: '帖子',
7273
unit: '篇',
7374
}

components/CategoriesCell/index.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
*
3+
* CategoriesCell
4+
*
5+
*/
6+
7+
import React from 'react'
8+
import PropTypes from 'prop-types'
9+
import R from 'ramda'
10+
import shortid from 'shortid'
11+
12+
import { ICON_ASSETS } from '../../config'
13+
14+
import { AdderCell } from '../../components'
15+
import {
16+
Wrapper,
17+
CategoryWrapper,
18+
CategoryTag,
19+
DeleteCross,
20+
AddIcon,
21+
} from './styles'
22+
23+
// import { inject, observer } from 'mobx-react'
24+
// import Link from 'next/link'
25+
26+
const CategoriesList = ({ source, onDelete }) => (
27+
<CategoryWrapper>
28+
{source.categories.map(c => (
29+
<CategoryTag
30+
key={shortid.generate()}
31+
onClick={onDelete.bind(this, source.id, c)}
32+
>
33+
{c.title}
34+
<DeleteCross>x</DeleteCross>
35+
</CategoryTag>
36+
))}
37+
</CategoryWrapper>
38+
)
39+
40+
class CategoriesCell extends React.Component {
41+
componentDidMount() {}
42+
43+
componentWillUnmount() {}
44+
45+
render() {
46+
const { source, onDelete, onAdd } = this.props
47+
48+
return (
49+
<div>
50+
{R.isEmpty(source.categories) ? (
51+
<AdderCell onAdd={onAdd.bind(this, source)} />
52+
) : (
53+
<Wrapper>
54+
<CategoriesList source={source} onDelete={onDelete} />
55+
<div onClick={onAdd.bind(this, source)}>
56+
<AddIcon src={`${ICON_ASSETS}/cmd/plus.svg`} />
57+
</div>
58+
</Wrapper>
59+
)}
60+
</div>
61+
)
62+
}
63+
}
64+
65+
export default CategoriesCell
66+
67+
CategoriesCell.propTypes = {
68+
// https://www.npmjs.com/package/prop-types
69+
source: PropTypes.object.isRequired,
70+
onDelete: PropTypes.func.isRequired,
71+
onAdd: PropTypes.func.isRequired,
72+
}
73+
74+
CategoriesCell.defaultProps = {
75+
categories: [],
76+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import styled from 'styled-components'
2+
3+
import { Animate } from '../../../utils'
4+
5+
import { Img } from '../../../components'
6+
7+
export const UnsetText = styled.div`
8+
color: tomato;
9+
`
10+
export const Wrapper = styled.div`
11+
display: flex;
12+
justify-content: center;
13+
align-items: center;
14+
`
15+
export const CategoryWrapper = styled.div`
16+
display: flex;
17+
`
18+
19+
export const CategoryTag = styled.div`
20+
display: flex;
21+
align-items: center;
22+
background: #e4f7fe;
23+
border: 1px dashed #97dbfc;
24+
color: #0692fa;
25+
padding: 0 10px;
26+
padding-right: 6px;
27+
border-radius: 3px;
28+
margin-right: 7px;
29+
&:hover {
30+
border: 1px solid #97dbfc;
31+
}
32+
`
33+
34+
export const DeleteCross = styled.div`
35+
margin-left: 8px;
36+
&:hover {
37+
cursor: pointer;
38+
animation: ${Animate.pulse} 0.3s linear;
39+
}
40+
`
41+
42+
export const AddIcon = styled(Img)`
43+
width: 15px;
44+
height: 15px;
45+
display: block;
46+
fill: lightgrey;
47+
&:hover {
48+
cursor: pointer;
49+
fill: #646479;
50+
}
51+
`
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// import React from 'react'
2+
// import { shallow } from 'enzyme'
3+
4+
// import CategoriesCell from '../index'
5+
6+
describe('TODO <CategoriesCell />', () => {
7+
it('Expect to have unit tests specified', () => {
8+
expect(true).toEqual(true)
9+
})
10+
})

components/ColorCell/index.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
*
3+
* ColorCell
4+
*
5+
*/
6+
7+
import React from 'react'
8+
import PropTypes from 'prop-types'
9+
10+
import { makeDebugger } from '../../utils'
11+
12+
import { ColorCell, ColorDot, ColorTitle } from './styles'
13+
/* eslint-disable no-unused-vars */
14+
const debug = makeDebugger('c:ColorCell:index')
15+
/* eslint-enable no-unused-vars */
16+
17+
const ColorCellComponent = ({ color }) => {
18+
return (
19+
<ColorCell>
20+
<ColorDot color={color} />
21+
<ColorTitle>{color}</ColorTitle>
22+
</ColorCell>
23+
)
24+
}
25+
26+
ColorCellComponent.propTypes = {
27+
// https://www.npmjs.com/package/prop-types
28+
color: PropTypes.string,
29+
}
30+
31+
ColorCellComponent.defaultProps = {
32+
color: 'RED',
33+
}
34+
35+
export default ColorCellComponent

0 commit comments

Comments
 (0)