@@ -3,6 +3,7 @@ import PropTypes from 'prop-types'
33import Context from '../context'
44import TextareaAutosize from 'react-textarea-autosize'
55import Modal , { ModalProps } from "../Modal/Modal"
6+ import debounce from '../Shared/debounce'
67
78function calcMaxRows ( ) {
89 const small = 576
@@ -42,11 +43,16 @@ function ModalCardEdit(props) {
4243
4344 /////
4445
45- function save ( text ) {
46- editCardContent ( index , text )
46+ function save ( name , text ) {
47+ editCardContent ( index , name , text )
4748 }
49+
4850 function onInputCange ( e ) {
49- save ( e . target . value )
51+ let name = card . name
52+ let text = card . text
53+ if ( e . target . id === "modal-edit-name" ) name = e . target . value
54+ if ( e . target . id === "modal-edit-text" ) text = e . target . value
55+ save ( name , text )
5056 }
5157
5258 function tryStateChange ( ) {
@@ -63,7 +69,7 @@ function ModalCardEdit(props) {
6369 }
6470
6571 // eslint-disable-next-line no-unused-vars
66- const [ color , btcolor ] = card && card . completed ? [ "green" , "success" ] : [ "red" , "danger" ]
72+ const [ color , btcolor ] = card && card . completed ? [ "green" , "success" ] : [ "red" , "danger" ]
6773
6874 return (
6975 < Modal { ...modalProps . bind ( ) } >
@@ -72,30 +78,40 @@ function ModalCardEdit(props) {
7278 < div >
7379 { card ? (
7480 < React . Fragment >
75- < h1 className = "mb-2" > Id: { card . id } </ h1 >
76- < h5 className = "mb-2" > Completed:
77- < span
78- className = { `p-1 m-1 d-inline-block text-center badge badge-${ btcolor } ` }
79- style = { { width : "3em" } }
80- >
81+ < TextareaAutosize
82+ className = "form-control form-control-lg p-0 mb-2 bg-light text-dark"
83+ id = "modal-edit-name"
84+ style = { { color : "black" , fontWeight : "600" , fontSize : 'x-large' , border : "none" , outline : "none" , boxShadow : "none" , resize : "none" } }
85+ minRows = { 1 }
86+ maxRows = { 3 }
87+ maxLength = "100"
88+ value = { card . name }
89+ onChange = { debounce ( onInputCange , 700 ) }
90+ />
91+
92+ < p style = { { fontWeight : "500" } } className = "mb-2 text-dark" >
93+ Completed:
94+ < span className = { `m-1 d-inline-block text-center badge badge-${ btcolor } ` } style = { { width : "3em" } } >
8195 { String ( card . completed ) }
8296 </ span >
83- </ h5 >
97+ </ p >
98+
8499 < TextareaAutosize
85100 className = "form-control p-0 mb-2 bg-light"
101+ id = "modal-edit-text"
86102 style = { { border : "none" , outline : "none" , boxShadow : "none" , resize : "none" } }
87103 minRows = { 3 }
88104 maxRows = { calcMaxRows ( ) }
89105 value = { card . text }
90- onChange = { onInputCange }
106+ onChange = { debounce ( onInputCange , 1000 ) }
91107 />
92108 </ React . Fragment >
93109 ) : (
94110 < h1 > No card</ h1 >
95111 ) }
96112 </ div >
97113
98- < div style = { { display : "flex" , justifyContent : "space-between " , flexWrap : "wrap" } } >
114+ < div style = { { display : "flex" , justifyContent : "space-around" , alignItems : "center ", flexWrap : "wrap" } } >
99115 < div >
100116 < button
101117 className = "btn btn-light mx-1"
@@ -108,6 +124,11 @@ function ModalCardEdit(props) {
108124 onClick = { tryRemove }
109125 > ✗</ button >
110126 </ div >
127+
128+ < div className = "mx-auto" >
129+ < span style = { { color : "lightgray" , fontWeight : "400" } } > Id: { card && card . id } </ span >
130+ </ div >
131+
111132 < div >
112133 < button
113134 className = "btn btn-light"
0 commit comments