Skip to content

Commit

Permalink
Sidebar fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arunshenoy99 committed Dec 7, 2023
1 parent e0bf252 commit be0a560
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 39 deletions.
12 changes: 7 additions & 5 deletions src/OnboardingSPA/components/LivePreview/SiteGenCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ const LivePreviewSiteGenCard = ( {
{ title }
</div>
</div>
<div className={ `${ className }__buttons__regenerate` }>
<div
className={ `${ className }__buttons__regenerate` }
role="button"
tabIndex={ 0 }
onClick={ () => handleRegenerate() }
onKeyDown={ () => handleRegenerate() }
>
<div
className={ `${ className }__buttons__regenerate__icon` }
role="button"
tabIndex={ 0 }
onClick={ () => handleRegenerate() }
onKeyDown={ () => handleRegenerate() }
></div>
<div
className={ `${ className }__buttons__regenerate__text` }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
width: 80%;
justify-self: center;
align-self: center;

&__live-preview-container {
position: relative;
width: 90%;
overflow: hidden;
align-items: center;
border-radius: 8px;
border-radius: 12px;

&:hover {
cursor: pointer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ const SitegenEditorPatternsSidebar = () => {
const [ activeHomepage, setActiveHomepage ] = useState();
const [ globalStyles, setGlobalStyles ] = useState( [] );
const [ activeTab, setActiveTab ] = useState();
const { currentData } = useSelect( ( select ) => {
return {
currentData:
select( nfdOnboardingStore ).getCurrentOnboardingData(),
};
} );
const { currentData, isSidebarOpened, sideBarView } = useSelect(
( select ) => {
return {
currentData:
select( nfdOnboardingStore ).getCurrentOnboardingData(),
isSidebarOpened: select( nfdOnboardingStore ).isSidebarOpened(),
sideBarView: select( nfdOnboardingStore ).getSidebarView(),
};
}
);

const { setIsSidebarOpened, setCurrentOnboardingData } =
useDispatch( nfdOnboardingStore );
Expand Down Expand Up @@ -84,12 +88,11 @@ const SitegenEditorPatternsSidebar = () => {
};
}
} );
currentData.sitegen.homepages.data = homepagesResponse;
setCurrentOnboardingData( currentData );

homepagesResponse.forEach( ( homepage ) => {
homepagesObject[ homepage.slug ] = homepage;
} );
currentData.sitegen.homepages.data = homepagesObject;
setCurrentOnboardingData( currentData );
} else {
homepagesObject = currentData.sitegen.homepages.data;
}
Expand All @@ -100,19 +103,23 @@ const SitegenEditorPatternsSidebar = () => {
};

useEffect( () => {
loadData();
}, [] );
if (
SIDEBAR_SITEGEN_EDITOR_PATTERNS === sideBarView &&
isSidebarOpened
) {
loadData();
}
}, [ sideBarView, isSidebarOpened ] );

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

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'loadData'. Either include it or remove the dependency array

useEffect( () => {
setActiveTab( {
name: 'All Versions',
name: __( 'All Versions', 'wp-module-onboarding' ),
title: (
<div className="nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab">
<p>{ __( 'All Versions', 'wp-module-onboarding' ) }</p>
</div>
),
content:
activeTab &&
homepages &&
activeHomepage &&
Object.keys( homepages ).map( ( homepage ) => {
Expand All @@ -123,23 +130,28 @@ const SitegenEditorPatternsSidebar = () => {
return (
<div
className={ `nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab__preview-container` }
onClick={ () => handlePreview( data.slug ) }
role="button"
tabIndex={ 0 }
onKeyDown={ () => handlePreview( data.slug ) }
key={ data.slug }
>
<LivePreview
styling={
data.slug !== activeHomepage.slug
? 'custom'
: 'custom__highlighted'
}
blockGrammer={ data.content }
viewportWidth={ 1300 }
previewSettings={ newPreviewSettings }
skeletonLoadingTime={ 0 }
/>
<div
className="nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab__preview-container__previews"
onClick={ () => handlePreview( data.slug ) }
role="button"
tabIndex={ 0 }
onKeyDown={ () => handlePreview( data.slug ) }
>
<LivePreview
styling={
data.slug !== activeHomepage.slug
? 'custom'
: 'custom__highlighted'
}
blockGrammer={ data.content }
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 ${
Expand Down Expand Up @@ -182,7 +194,10 @@ const SitegenEditorPatternsSidebar = () => {
}
tabs={ [
{
name: 'All Versions',
name: __(
'All Versions',
'wp-module-onboarding'
),
title: (
<div className="nfd-onboarding-sidebar--sitegen-editor-patterns__header__tab-panel__versions-tab">
<p>
Expand Down
4 changes: 2 additions & 2 deletions src/OnboardingSPA/steps/SiteGen/Preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ const SiteGenPreview = () => {
};
}
} );
currentData.sitegen.homepages.data = homepagesResponse;
setCurrentOnboardingData( currentData );
homepagesResponse.forEach( ( homepage ) => {
homepagesObject[ homepage.slug ] = homepage;
} );
currentData.sitegen.homepages.data = homepagesObject;
setCurrentOnboardingData( currentData );
} else {
homepagesObject = currentData.sitegen.homepages.data;
}
Expand Down
2 changes: 1 addition & 1 deletion src/OnboardingSPA/steps/SiteGen/Preview/stylesheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
color: var(--nfd-onboarding-primary);
display: flex;
flex-direction: column;
width: 450px;
width: 420px;
justify-content: center;
align-items: center;
margin: 16px 0;
Expand Down

0 comments on commit be0a560

Please sign in to comment.