Skip to content

Commit 1972f4f

Browse files
author
seraphimrose
committed
card remove
1 parent 1bab8f1 commit 1972f4f

File tree

6 files changed

+44
-5
lines changed

6 files changed

+44
-5
lines changed

app/action/entity.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ import { createAction } from 'redux-act'
33

44
export const addList = createAction("Add a new list", data => fromJS(data))
55

6-
export const addCard = createAction("Add a new card", data => fromJS(data))
6+
export const addCard = createAction("Add a new card", data => fromJS(data))
7+
8+
export const removeCard = createAction("Remove a card", data => fromJS(data))

app/component/app/app.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
body {
2-
background: url('/COTO/static/img/bg1.jpg') no-repeat;
2+
background: url('/COTO/static/img/bg3.jpg') no-repeat;
33
background-size: 100% 100%;
44
}
55

app/component/card/card.css

+14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
:local(.card) {
2+
position: relative;
23
width: 260px;
34
padding: 5px;
45
margin-bottom: 8px;
@@ -34,6 +35,19 @@
3435
}
3536
}
3637

38+
:local(.control) {
39+
position: absolute;
40+
top: 3px;
41+
right: 5px;
42+
color: #ccc;
43+
i {
44+
cursor: pointer;
45+
&:hover {
46+
color: #aaa;
47+
}
48+
}
49+
}
50+
3751
:local(.title) {
3852
padding-left: 2px;
3953
}

app/component/card/index.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React, { Component } from 'react'
22
import Tooltip from 'antd/lib/tooltip'
3+
import Icon from 'antd/lib/icon'
34
import { DragSource } from 'react-dnd';
45

6+
import { removeCard } from 'action/entity'
57
import style from './card.css'
68

79
const cardSource = {
@@ -28,12 +30,20 @@ export default class Card extends Component {
2830
card,
2931
tag,
3032
member,
33+
index,
34+
listIndex,
3135
connectDragSource,
32-
isDragging
36+
isDragging,
37+
dispatch
3338
} = this.props
3439

3540
return connectDragSource(
36-
<div className={style.card}>
41+
<div
42+
style={{
43+
transform: isDragging && "rotate(10deg)"
44+
}}
45+
className={style.card}
46+
>
3747
<div className={style.tag}>
3848
{card.get('tag').map(value => (
3949
<Tooltip
@@ -46,6 +56,12 @@ export default class Card extends Component {
4656
</Tooltip>
4757
))}
4858
</div>
59+
<div className={style.control}>
60+
<Icon
61+
type="cross"
62+
onClick={() => dispatch(removeCard({listIndex, index}))}
63+
/>
64+
</div>
4965
<div className={style.title}>
5066
{card.get('title')}
5167
</div>

app/component/list/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ export default class List extends Component {
114114
<Card
115115
{...this.props}
116116
key={value}
117+
index={value}
118+
listIndex={index}
117119
card={card.get(value)}
118120
/>
119121
))}

app/reducer/entity.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@ const initialState = fromJS(entity)
88

99
export default createReducer({
1010
[actions.addList]: (state, data) => state.mergeDeep(data),
11-
[actions.addCard]: (state, data) => state.mergeDeep(data)
11+
[actions.addCard]: (state, data) => state.mergeDeep(data),
12+
[actions.removeCard]: (state, key) => (
13+
state//.deleteIn(['card', key.get('index')]) // <-- unnecessary?
14+
.deleteIn(['list', key.get('listIndex'), 'card',
15+
state.getIn(['list', key.get('listIndex'), 'card']).indexOf(key.get('index'))])
16+
)
1217
}, initialState)

0 commit comments

Comments
 (0)