@@ -5,6 +5,7 @@ import TextareaAutosize from 'react-textarea-autosize'
55import Modal , { ModalProps } from "../Shared/Modal/Modal"
66import debounce from '../Shared/debounce'
77import Card from '../Shared/Card'
8+ import Palette from './palette'
89
910function calcMaxRows ( ) {
1011 const small = 576
@@ -20,7 +21,7 @@ function calcMaxRows() {
2021}
2122
2223function ModalCardEdit ( props ) {
23- const { removeCard, changeCardState , unsetEditCard, editCardContent } = React . useContext ( Context )
24+ const { removeCard, changeCardColor , unsetEditCard, editCardContent } = React . useContext ( Context )
2425 const { card, index } = props
2526 React . useEffect ( ( ) => { if ( card !== null ) open ( ) } , [ card ] )
2627
@@ -57,8 +58,8 @@ function ModalCardEdit(props) {
5758 save ( name , text )
5859 }
5960
60- function tryStateChange ( ) {
61- changeCardState ( index )
61+ function tryChangeColor ( color ) {
62+ changeCardColor ( index , color )
6263 }
6364 function tryRemove ( ) {
6465 unsetEditCard ( ) ;
@@ -70,9 +71,6 @@ function ModalCardEdit(props) {
7071 close ( )
7172 }
7273
73- // eslint-disable-next-line no-unused-vars
74- const [ color , btcolor ] = cardEdit && cardEdit . completed ? [ "green" , "success" ] : [ "red" , "danger" ]
75-
7674 return (
7775 < Modal { ...modalProps . bind ( ) } >
7876 < div className = "container p-2" >
@@ -91,9 +89,9 @@ function ModalCardEdit(props) {
9189 />
9290
9391 < p style = { { fontWeight : "500" } } className = "mb-2 text-dark" >
94- Completed :
95- < span className = { `m-1 d-inline-block text-center badge badge- ${ btcolor } ` } style = { { width : "3em" } } >
96- { String ( cardEdit . completed ) }
92+ Color :
93+ < span className = { `m-1 d-inline-block text-center badge` } style = { { width : "3em" , backgroundColor : cardEdit . color } } >
94+
9795 </ span >
9896 </ p >
9997
@@ -114,11 +112,11 @@ function ModalCardEdit(props) {
114112
115113 < div style = { { display : "flex" , justifyContent : "space-around" , alignItems : "center" , flexWrap : "wrap" } } >
116114 < div >
117- < button
115+ < Palette
118116 className = "btn btn-light mx-1"
119117 disabled = { ! cardEdit }
120- onClick = { tryStateChange }
121- > ✓ </ button >
118+ setColor = { tryChangeColor }
119+ > </ Palette >
122120 < button
123121 className = "btn btn-light"
124122 disabled = { ! cardEdit }
0 commit comments