Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sitegen: Fix Site Logo Data #493

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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

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
Loading