Skip to content

Commit

Permalink
Merge pull request #493 from newfold-labs/fix/site-logo-data
Browse files Browse the repository at this point in the history
Sitegen: Fix Site Logo Data
  • Loading branch information
arunshenoy99 authored Feb 28, 2024
2 parents a601bb0 + 97b963f commit cbb1890
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const ImageUploaderWithText = ( { image, imageSetter } ) => {
const getContrastingColor = ( color ) => {
/* if the contrast value more than 150 it should have black bg, otherwise white */
const [ r, g, b ] = color.match( /\d+/g ).map( Number );
const contrastValue = ( 0.2126 * r ) + ( 0.7152 * g ) + ( 0.0722 * b );
const contrastValue = 0.2126 * r + 0.7152 * g + 0.0722 * b;
return contrastValue > 160 ? 'black' : 'white';
};

Expand Down Expand Up @@ -130,6 +130,8 @@ const ImageUploaderWithText = ( { image, imageSetter } ) => {
imageSetter( {
id: 0,
url: '',
fileName: '',
fileSize: 0,
} );
if ( inputRef?.current?.files.length > 0 ) {
inputRef.current.value = '';
Expand Down
12 changes: 6 additions & 6 deletions src/OnboardingSPA/steps/SiteGen/SiteLogo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@ const SiteGenSiteLogo = () => {
setIsHeaderNavigationEnabled( true );
setHeaderActiveView( HEADER_SITEGEN );
setDrawerActiveView( false );
if ( currentData.data.siteLogo?.id !== 0 ) {
if ( currentData.sitegen.siteLogo?.id !== 0 ) {
setIsFooterNavAllowed( true );
return setSiteLogo( currentData.data.siteLogo );
return setSiteLogo( currentData.sitegen.siteLogo );
}
setIsFooterNavAllowed( false );
getEditedEntityRecord( 'root', 'site' );
}, [] );

Check warning on line 70 in src/OnboardingSPA/steps/SiteGen/SiteLogo/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'currentData.sitegen.siteLogo', 'getEditedEntityRecord', 'setDrawerActiveView', 'setHeaderActiveView', 'setHideFooterNav', 'setIsFooterNavAllowed', 'setIsHeaderEnabled', 'setIsHeaderNavigationEnabled', and 'setSidebarActiveView'. Either include them or remove the dependency array

const handleSiteLogo = ( siteLogoNew ) => {
const currentDataCopy = { ...currentData };
currentDataCopy.data.siteLogo.id = siteLogoNew.id;
currentDataCopy.data.siteLogo.url = siteLogoNew.url;
currentDataCopy.data.siteLogo.fileName = siteLogoNew.fileName;
currentDataCopy.data.siteLogo.fileSize = siteLogoNew.fileSize;
currentDataCopy.sitegen.siteLogo.id = siteLogoNew.id;
currentDataCopy.sitegen.siteLogo.url = siteLogoNew.url;
currentDataCopy.sitegen.siteLogo.fileName = siteLogoNew.fileName;
currentDataCopy.sitegen.siteLogo.fileSize = siteLogoNew.fileSize;
setCurrentOnboardingData( currentDataCopy );
setIsFooterNavAllowed( siteLogoNew.id !== 0 );
editEntityRecord( 'root', 'site', undefined, {
Expand Down

0 comments on commit cbb1890

Please sign in to comment.