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

Commit fe9b79c

Browse files
committed
refactor(tags): add color to tags cell
1 parent 088b042 commit fe9b79c

File tree

4 files changed

+79
-77
lines changed

4 files changed

+79
-77
lines changed

components/TagsCell/TagsList.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react'
2+
3+
// import { ICON_CMD } from '../../config'
4+
// import { Wrapper } from './styles'
5+
import { Wrapper, TagWrapper, ColorDot, DeleteCross } from './styles/tags_list'
6+
import { uid } from '../../utils'
7+
8+
const TagsList = ({ source, onDelete }) => (
9+
<Wrapper>
10+
{source.tags.map(c => (
11+
<TagWrapper key={uid.gen()} onClick={onDelete.bind(this, source.id, c)}>
12+
<ColorDot bg={c.color} />
13+
<div>{c.title}</div>
14+
<DeleteCross>x</DeleteCross>
15+
</TagWrapper>
16+
))}
17+
</Wrapper>
18+
)
19+
20+
export default TagsList

components/TagsCell/index.js

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,54 +12,26 @@ import { ICON_CMD } from '../../config'
1212

1313
// import { inject, observer } from 'mobx-react'
1414
// import Link from 'next/link'
15+
import TagsList from './TagsList'
1516
import AdderCell from '../AdderCell'
1617

17-
import {
18-
Wrapper,
19-
ListWrapper,
20-
TagWrapper,
21-
DeleteCross,
22-
AddIcon,
23-
} from './styles'
24-
25-
import { uid } from '../../utils'
26-
27-
const TagsList = ({ source, onDelete }) => (
28-
<ListWrapper>
29-
{source.tags.map(c => (
30-
<TagWrapper key={uid.gen()} onClick={onDelete.bind(this, source.id, c)}>
31-
{c.title}
32-
<DeleteCross>x</DeleteCross>
33-
</TagWrapper>
34-
))}
35-
</ListWrapper>
18+
import { Wrapper, AddIcon } from './styles'
19+
20+
const TagsCell = ({ thread, source, onDelete, onAdd }) => (
21+
<React.Fragment>
22+
{R.isEmpty(source.tags) ? (
23+
<AdderCell onAdd={onAdd.bind(this, thread, source)} />
24+
) : (
25+
<Wrapper>
26+
<TagsList source={source} onDelete={onDelete} />
27+
<div onClick={onAdd.bind(this, thread, source)}>
28+
<AddIcon src={`${ICON_CMD}/plus.svg`} />
29+
</div>
30+
</Wrapper>
31+
)}
32+
</React.Fragment>
3633
)
3734

38-
class TagsCell extends React.Component {
39-
componentDidMount() {}
40-
41-
componentWillUnmount() {}
42-
43-
render() {
44-
const { thread, source, onDelete, onAdd } = this.props
45-
46-
return (
47-
<React.Fragment>
48-
{R.isEmpty(source.tags) ? (
49-
<AdderCell onAdd={onAdd.bind(this, thread, source)} />
50-
) : (
51-
<Wrapper>
52-
<TagsList source={source} onDelete={onDelete} />
53-
<div onClick={onAdd.bind(this, thread, source)}>
54-
<AddIcon src={`${ICON_CMD}/plus.svg`} />
55-
</div>
56-
</Wrapper>
57-
)}
58-
</React.Fragment>
59-
)
60-
}
61-
}
62-
6335
export default TagsCell
6436

6537
TagsCell.propTypes = {

components/TagsCell/styles/index.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,12 @@
11
import styled from 'styled-components'
22

33
import Img from '../../Img'
4-
import { animate } from '../../../utils'
54

6-
export const UnsetText = styled.div`
7-
color: tomato;
8-
`
95
export const Wrapper = styled.div`
106
display: flex;
117
justify-content: left;
128
align-items: center;
139
`
14-
export const ListWrapper = styled.div`
15-
display: flex;
16-
flex-wrap: wrap;
17-
`
18-
19-
export const TagWrapper = 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-
margin-bottom: 6px;
30-
&:hover {
31-
border: 1px solid #97dbfc;
32-
}
33-
`
34-
35-
export const DeleteCross = styled.div`
36-
margin-left: 8px;
37-
&:hover {
38-
cursor: pointer;
39-
animation: ${animate.pulseRule};
40-
}
41-
`
42-
4310
export const AddIcon = styled(Img)`
4411
width: 15px;
4512
height: 15px;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import styled from 'styled-components'
2+
3+
// import Img from '../../Img'
4+
import { animate } from '../../../utils'
5+
6+
export const Wrapper = styled.div`
7+
display: flex;
8+
flex-wrap: wrap;
9+
`
10+
11+
export const ColorDot = styled.div`
12+
width: 10px;
13+
height: 10px;
14+
border-radius: 50%;
15+
background: red;
16+
margin-right: 6px;
17+
background: ${({ bg }) => bg || 'wheat'};
18+
`
19+
20+
export const TagWrapper = styled.div`
21+
display: flex;
22+
align-items: center;
23+
background: #e4f7fe;
24+
border: 1px dashed #97dbfc;
25+
color: #0692fa;
26+
padding-right: 10px;
27+
padding-left: 4px;
28+
padding-right: 6px;
29+
border-radius: 3px;
30+
margin-right: 7px;
31+
margin-bottom: 6px;
32+
&:hover {
33+
border: 1px solid #97dbfc;
34+
}
35+
`
36+
37+
export const DeleteCross = styled.div`
38+
margin-left: 8px;
39+
&:hover {
40+
cursor: pointer;
41+
animation: ${animate.pulseRule};
42+
}
43+
`

0 commit comments

Comments
 (0)