Skip to content

Commit

Permalink
Merge pull request #589 from newfold-labs/PRESS0-1540
Browse files Browse the repository at this point in the history
bug/previews other than favorites in favorit tab
  • Loading branch information
arunshenoy99 authored Jun 27, 2024
2 parents ddf9382 + 5b3349d commit 573cf5a
Showing 1 changed file with 68 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,80 +128,82 @@ const SitegenEditorPatternsSidebar = () => {
}, [ currentData ] );

useEffect( () => {
setActiveTab( {
name: 'all_versions',
title: (
<div className="nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab">
<p>{ __( 'All Versions', 'wp-module-onboarding' ) }</p>
</div>
),
content:
homepages &&
activeHomepage &&
globalStyles &&
Object.keys( homepages ).map( ( homepage, idx ) => {
const data = homepages[ homepage ];
const newPreviewSettings = cloneDeep( globalStyles[ 0 ] );
newPreviewSettings.settings.color.palette =
data.color.palette;
let blockGrammar = '';
[ 'header', 'content', 'footer' ].forEach( ( part ) => {
if ( part in data ) {
blockGrammar += data[ part ];
}
} );
return (
<div
className={ `nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab__preview-container` }
key={ data.slug }
>
if ( activeTab?.name !== 'favorites' ) {
setActiveTab( {
name: 'all_versions',
title: (
<div className="nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab">
<p>{ __( 'All Versions', 'wp-module-onboarding' ) }</p>
</div>
),
content:
homepages &&
activeHomepage &&
globalStyles &&
Object.keys( homepages ).map( ( homepage, idx ) => {
const data = homepages[ homepage ];
const newPreviewSettings = cloneDeep( globalStyles[ 0 ] );
newPreviewSettings.settings.color.palette =
data.color.palette;
let blockGrammar = '';
[ 'header', 'content', 'footer' ].forEach( ( part ) => {
if ( part in data ) {
blockGrammar += data[ part ];
}
} );
return (
<div
className="nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab__preview-container__previews"
onClick={ () =>
handlePreview( data.slug, idx )
}
role="button"
tabIndex={ 0 }
onKeyDown={ () =>
handlePreview( data.slug, idx )
}
className={ `nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab__preview-container` }
key={ data.slug }
>
<LivePreview
styling={
data.slug !== activeHomepage.slug
? 'custom'
: 'custom__highlighted'
}
blockGrammer={ blockGrammar }
viewportWidth={ 1300 }
previewSettings={ newPreviewSettings }
skeletonLoadingTime={ 0 }
/>
</div>

<div className="nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab__preview-container__context">
<div
className={ `nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab__preview-container__context__icon ${
data.isFavorite &&
'nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab__preview-container__context__icon__fill'
}` }
role="button"
tabIndex={ 0 }
className="nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab__preview-container__previews"
onClick={ () =>
handleFavorite( data.slug, idx )
handlePreview( data.slug, idx )
}
role="button"
tabIndex={ 0 }
onKeyDown={ () =>
handleFavorite( data.slug, idx )
handlePreview( data.slug, idx )
}
></div>
<p className="nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab__preview-container__context__title">
{ data.title }
</p>
>
<LivePreview
styling={
data.slug !== activeHomepage.slug
? 'custom'
: 'custom__highlighted'
}
blockGrammer={ blockGrammar }
viewportWidth={ 1300 }
previewSettings={ newPreviewSettings }
skeletonLoadingTime={ 0 }
/>
</div>

<div className="nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab__preview-container__context">
<div
className={ `nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab__preview-container__context__icon ${
data.isFavorite &&
'nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab__preview-container__context__icon__fill'
}` }
role="button"
tabIndex={ 0 }
onClick={ () =>
handleFavorite( data.slug, idx )
}
onKeyDown={ () =>
handleFavorite( data.slug, idx )
}
></div>
<p className="nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab__preview-container__context__title">
{ data.title }
</p>
</div>
</div>
</div>
);
} ),
} );
);
} ),
} );
}
}, [ homepages, activeHomepage, globalStyles ] );

Check warning on line 207 in src/OnboardingSPA/components/Sidebar/components/SitegenEditorPatterns/Sidebar.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'activeTab?.name', 'handleFavorite', and 'handlePreview'. Either include them or remove the dependency array

return (
Expand Down

0 comments on commit 573cf5a

Please sign in to comment.