@@ -3,12 +3,13 @@ import PropTypes from 'prop-types';
33import  React  from  'react' ; 
44import  bindAll  from  'lodash.bindall' ; 
55import  parseColor  from  'parse-color' ; 
6- import  { changeStrokeColor }  from  '../reducers/stroke-style' ; 
6+ import  { changeStrokeColor ,   changeStrokeColor2 ,   changeStrokeGradientType }  from  '../reducers/stroke-style' ; 
77import  { changeStrokeWidth }  from  '../reducers/stroke-width' ; 
88import  StrokeWidthIndicatorComponent  from  '../components/stroke-width-indicator.jsx' ; 
99import  { getSelectedLeafItems }  from  '../helper/selection' ; 
1010import  { applyColorToSelection ,  applyStrokeWidthToSelection ,  getColorsFromSelection ,  MIXED } 
1111    from  '../helper/style-path' ; 
12+ import  GradientTypes  from  '../lib/gradient-types' ; 
1213import  Modes  from  '../lib/modes' ; 
1314import  Formats  from  '../lib/format' ; 
1415import  { isBitmap }  from  '../lib/format' ; 
@@ -23,20 +24,31 @@ class StrokeWidthIndicator extends React.Component {
2324    handleChangeStrokeWidth  ( newWidth )  { 
2425        let  changed  =  applyStrokeWidthToSelection ( newWidth ,  this . props . textEditTarget ) ; 
2526        if  ( ( ! this . props . strokeWidth  ||  this . props . strokeWidth  ===  0 )  &&  newWidth  >  0 )  { 
26-             let  currentColor  =  getColorsFromSelection ( getSelectedLeafItems ( ) ,  isBitmap ( this . props . format ) ) . strokeColor ; 
27-             if  ( currentColor  ===  null )  { 
27+             const  currentColorState  =  getColorsFromSelection ( getSelectedLeafItems ( ) ,  isBitmap ( this . props . format ) ) ; 
28+ 
29+             // Color counts as null if either both colors are null or the primary color is null and it's solid 
30+             // TODO: consolidate this check in one place 
31+             const  wasNull  =  currentColorState . strokeColor  ===  null  && 
32+                 ( currentColorState . strokeColor2  ===  null  || 
33+                  currentColorState . strokeGradientType  ===  GradientTypes . SOLID ) ; 
34+ 
35+             if  ( wasNull )  { 
2836                changed  =  applyColorToSelection ( 
2937                    '#000' , 
3038                    0 ,  // colorIndex, 
3139                    true ,  // isSolidGradient 
3240                    true ,  // applyToStroke 
3341                    this . props . textEditTarget )  || 
3442                    changed ; 
35-                 currentColor  =  '#000' ; 
36-             }  else  if  ( currentColor  !==  MIXED )  { 
37-                 currentColor  =  parseColor ( currentColor ) . hex ; 
43+                 // If there's no previous stroke color, default to solid black 
44+                 this . props . onChangeStrokeGradientType ( GradientTypes . SOLID ) ; 
45+                 this . props . onChangeStrokeColor ( '#000' ) ; 
46+             }  else  if  ( currentColorState . strokeColor  !==  MIXED )  { 
47+                 // Set color state from the selected item's stroke color 
48+                 this . props . onChangeStrokeGradientType ( currentColorState . strokeGradientType ) ; 
49+                 this . props . onChangeStrokeColor ( parseColor ( currentColorState . strokeColor ) . hex ) ; 
50+                 this . props . onChangeStrokeColor2 ( parseColor ( currentColorState . strokeColor2 ) . hex ) ; 
3851            } 
39-             this . props . onChangeStrokeColor ( currentColor ) ; 
4052        } 
4153        this . props . onChangeStrokeWidth ( newWidth ) ; 
4254        if  ( changed )  this . props . onUpdateImage ( ) ; 
@@ -64,6 +76,12 @@ const mapDispatchToProps = dispatch => ({
6476    onChangeStrokeColor : strokeColor  =>  { 
6577        dispatch ( changeStrokeColor ( strokeColor ) ) ; 
6678    } , 
79+     onChangeStrokeColor2 : strokeColor  =>  { 
80+         dispatch ( changeStrokeColor2 ( strokeColor ) ) ; 
81+     } , 
82+     onChangeStrokeGradientType : strokeColor  =>  { 
83+         dispatch ( changeStrokeGradientType ( strokeColor ) ) ; 
84+     } , 
6785    onChangeStrokeWidth : strokeWidth  =>  { 
6886        dispatch ( changeStrokeWidth ( strokeWidth ) ) ; 
6987    } 
@@ -73,6 +91,8 @@ StrokeWidthIndicator.propTypes = {
7391    disabled : PropTypes . bool . isRequired , 
7492    format : PropTypes . oneOf ( Object . keys ( Formats ) ) , 
7593    onChangeStrokeColor : PropTypes . func . isRequired , 
94+     onChangeStrokeColor2 : PropTypes . func . isRequired , 
95+     onChangeStrokeGradientType : PropTypes . func . isRequired , 
7696    onChangeStrokeWidth : PropTypes . func . isRequired , 
7797    onUpdateImage : PropTypes . func . isRequired , 
7898    strokeWidth : PropTypes . number , 
0 commit comments