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

bug/previews other than favorites in favorit tab #589

Merged
merged 7 commits into from
Jun 27, 2024
Merged
Changes from 5 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 @@ -128,81 +128,83 @@
}, [ 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?.home === 'favorites' ) ) {
manikantakailasa marked this conversation as resolved.
Show resolved Hide resolved
arunshenoy99 marked this conversation as resolved.
Show resolved Hide resolved
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?.home', 'handleFavorite', and 'handlePreview'. Either include them or remove the dependency array

return (
<Fill
Expand Down
Loading