1
1
import { TrashAlt } from '@styled-icons/boxicons-solid'
2
+ import { ReOrderDotsVertical } from '@styled-icons/fluentui-system-filled/ReOrderDotsVertical'
2
3
import { CSSProperties , useEffect , useState } from 'react'
3
4
import {
4
5
DragDropContext ,
8
9
DropResult ,
9
10
NotDraggingStyle ,
10
11
} from 'react-beautiful-dnd'
12
+ import styled , { css } from 'styled-components'
11
13
12
14
import { ModuleResInterface } from '../../interfaces'
13
15
import {
@@ -20,11 +22,38 @@ import LifelineCard from './LifelineCard'
20
22
interface DraggableLifelinesInterface {
21
23
lifelinesProp : ModuleResInterface [ ]
22
24
}
25
+ const StyledDiv = styled . div `
26
+ display: flex;
27
+ background: #f1f1f1;
28
+ border-radius: 10px;
29
+ width: 92.5%;
30
+ padding: 0 2% 0 1%;
31
+ grid-column: 2;
32
+ border: 2px lightgrey solid;
33
+ ${ ( props ) =>
34
+ props . draggingOver
35
+ ? css `
36
+ border-color: ${ ( { theme } ) => theme . buttonBackground } ;
37
+ `
38
+ : css `
39
+ border-color: ${ ( { theme } ) => theme . secondaryText } ;
40
+ ` }
41
+ `
42
+ const Card = styled . div `
43
+ display: flex;
44
+ align-self: center;
45
+ width: 5%;
46
+ font-size: 1.29em;
47
+ margin-left: 0%;
48
+ `
23
49
50
+ const Alignment = styled . div `
51
+ margin-left: 15%;
52
+ align-self: center;
53
+ `
24
54
const DraggableLifelines = ( { lifelinesProp } : DraggableLifelinesInterface ) => {
25
55
const BASE_PADDING = 4
26
56
const [ lifelines , setLifelines ] = useState < ModuleResInterface [ ] > ( [ ] )
27
-
28
57
/* fill lifelines with passed in props for rendering */
29
58
useEffect ( ( ) => {
30
59
setLifelines ( lifelinesProp )
@@ -41,19 +70,18 @@ const DraggableLifelines = ({ lifelinesProp }: DraggableLifelinesInterface) => {
41
70
42
71
const getDraggableItemStyle = (
43
72
draggableStyle : DraggingStyle | NotDraggingStyle | undefined ,
73
+ isDraggingOver ,
44
74
) : CSSProperties => ( {
45
- padding : BASE_PADDING * 2 ,
46
- margin : `0 0 ${ BASE_PADDING } px 0` ,
75
+ paddingBottom : BASE_PADDING * 2 ,
76
+ margin : `0 0 15px 0` ,
47
77
alignItems : 'center' ,
48
78
display : 'grid' ,
49
- gridTemplateColumns : '2.5fr 95fr 2.5fr' ,
50
-
79
+ gridTemplateColumns : '0fr 95fr 2.5fr' ,
51
80
// styles we need to apply on draggables
52
81
...draggableStyle ,
53
82
} )
54
83
55
84
const getDroppableStyle = ( ) => ( {
56
- padding : `${ BASE_PADDING } px` ,
57
85
margin : '0 auto' ,
58
86
width : '95vw' ,
59
87
} )
@@ -84,41 +112,28 @@ const DraggableLifelines = ({ lifelinesProp }: DraggableLifelinesInterface) => {
84
112
draggableId = { index . toString ( ) }
85
113
index = { index }
86
114
>
87
- { ( provided , _ ) => (
115
+ { ( provided , snapshot ) => (
88
116
< div
89
117
ref = { provided . innerRef }
90
118
{ ...provided . draggableProps }
91
119
{ ...provided . dragHandleProps }
92
- style = { getDraggableItemStyle ( provided . draggableProps . style ) }
93
- >
94
- { index < NUM_LIFELINES_DISPLAYED && (
95
- < p
96
- style = { {
97
- border : 'black 2px solid' ,
98
- borderRadius : '5px' ,
99
- gridColumn : 1 ,
100
- fontSize : '0.65em' ,
101
- justifySelf : 'center' ,
102
- padding : '10%' ,
103
- } }
104
- >
105
- { index + 1 }
106
- </ p >
120
+ style = { getDraggableItemStyle (
121
+ provided . draggableProps . style ,
122
+ snapshot . draggingOver ,
107
123
) }
108
- < div
109
- style = { {
110
- background : '#f1f1f1' ,
111
- borderRadius : '10px' ,
112
- width : '92.5%' ,
113
- padding : '0 2%' ,
114
- gridColumn : 2 ,
115
- } }
116
- >
124
+ >
125
+ < StyledDiv draggingOver = { snapshot . draggingOver } >
126
+ < Card >
127
+ < ReOrderDotsVertical size = "20px" />
128
+ < Alignment >
129
+ { index < NUM_LIFELINES_DISPLAYED && index + 1 }
130
+ </ Alignment >
131
+ </ Card >
117
132
< LifelineCard
118
133
lifeline = { lifeline }
119
134
isDisplayed = { index < NUM_LIFELINES_DISPLAYED }
120
135
/>
121
- </ div >
136
+ </ StyledDiv >
122
137
{ /* render delete button */ }
123
138
< TrashAlt
124
139
size = { '1.5em' }
0 commit comments