Skip to content

Commit

Permalink
Return early
Browse files Browse the repository at this point in the history
  • Loading branch information
PatelUtkarsh committed Jul 12, 2022
1 parent 7e6ec7d commit cc3545e
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions plugin/assets/src/customizer/components/color-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,28 @@ const ColorControl = ( { defaultValue, params, onColorChange, mode } ) => {
};

useEffect( () => {
if ( color ) {
let hexColor = color.substring( 1 );

if ( hexColor.length === 3 ) {
hexColor = hexColor
.split( '' )
.map( hex => hex + hex )
.join( '' );
}

if ( 6 !== hexColor.length ) {
return;
}

onColorChange( `#${ hexColor }` );
api.previewer.send( 'materialDesignM3PaletteUpdate', {
color,
isDarkMode,
} );
if ( ! color ) {
return;
}

let hexColor = color.substring( 1 );

if ( hexColor.length === 3 ) {
hexColor = hexColor
.split( '' )
.map( hex => hex + hex )
.join( '' );
}

if ( 6 !== hexColor.length ) {
return;
}

onColorChange( `#${ hexColor }` );
api.previewer.send( 'materialDesignM3PaletteUpdate', {
color,
isDarkMode,
} );
}, [ color ] );

return (
Expand Down

0 comments on commit cc3545e

Please sign in to comment.