-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #385 from newfold-labs/enhance/preview-step
Favorites, regeneration and maintaining state for previews
- Loading branch information
Showing
30 changed files
with
1,375 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
src/OnboardingSPA/components/LivePreview/SiteGenCard/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import { Icon, search } from '@wordpress/icons'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
import { LivePreview } from '..'; | ||
|
||
const LivePreviewSiteGenCard = ( { | ||
className = 'nfd-onboarding-live-preview--sitegen-card', | ||
slug, | ||
title, | ||
blockGrammer, | ||
styling, | ||
isFavorite = false, | ||
viewportWidth, | ||
previewSettings, | ||
skeletonLoadingTime = 2500, | ||
onFavorite, | ||
onRegenerate, | ||
onPreview, | ||
} ) => { | ||
const handleFavorite = () => { | ||
if ( typeof onFavorite === 'function' ) { | ||
return onFavorite( slug ); | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
const handleRegenerate = () => { | ||
if ( typeof onRegenerate === 'function' ) { | ||
return onRegenerate( slug ); | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
const handlePreview = () => { | ||
if ( typeof onPreview === 'function' ) { | ||
return onPreview( slug ); | ||
} | ||
|
||
return false; | ||
}; | ||
return ( | ||
<div className={ className }> | ||
<div className={ `${ className }__live-preview-container` }> | ||
<LivePreview | ||
styling={ styling } | ||
blockGrammer={ blockGrammer } | ||
viewportWidth={ viewportWidth } | ||
previewSettings={ previewSettings } | ||
skeletonLoadingTime={ skeletonLoadingTime } | ||
/> | ||
<div | ||
className={ `${ className }__live-preview-container__overlay` } | ||
role="button" | ||
tabIndex={ 0 } | ||
onClick={ () => handlePreview( slug ) } | ||
onKeyDown={ () => handlePreview( slug ) } | ||
> | ||
<div | ||
className={ `${ className }__live-preview-container__overlay__preview-button` } | ||
> | ||
<Icon | ||
icon={ search } | ||
className={ `${ className }__live-preview-container__overlay__preview-button__icon` } | ||
></Icon> | ||
<p | ||
className={ `${ className }__live-preview-container__overlay__preview-button__text` } | ||
> | ||
{ __( 'Preview', 'wp-module-onboarding' ) } | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div className={ `${ className }__buttons` }> | ||
<div className={ `${ className }__buttons__favorite` }> | ||
<div | ||
className={ `${ className }__buttons__favorite__icon ${ | ||
isFavorite && | ||
`${ className }__buttons__favorite__icon__fill` | ||
}` } | ||
role="button" | ||
tabIndex={ 0 } | ||
onClick={ () => handleFavorite() } | ||
onKeyDown={ () => handleFavorite() } | ||
/> | ||
<div | ||
className={ `${ className }__buttons__favorite__text` } | ||
> | ||
{ title } | ||
</div> | ||
</div> | ||
<div className={ `${ className }__buttons__regenerate` }> | ||
<div | ||
className={ `${ className }__buttons__regenerate__icon` } | ||
role="button" | ||
tabIndex={ 0 } | ||
onClick={ () => handleRegenerate() } | ||
onKeyDown={ () => handleRegenerate() } | ||
></div> | ||
<div | ||
className={ `${ className }__buttons__regenerate__text` } | ||
> | ||
{ __( 'Regenerate', 'wp-module-onboarding' ) } | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LivePreviewSiteGenCard; |
123 changes: 123 additions & 0 deletions
123
src/OnboardingSPA/components/LivePreview/SiteGenCard/stylesheet.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
.nfd-onboarding-live-preview { | ||
|
||
&--sitegen-card { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
width: 100%; | ||
|
||
&__live-preview-container { | ||
position: relative; | ||
width: 90%; | ||
overflow: hidden; | ||
align-items: center; | ||
border-radius: 8px; | ||
|
||
&:hover { | ||
cursor: pointer; | ||
} | ||
|
||
&__overlay { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
height: 100%; | ||
z-index: 2; | ||
width: 100%; | ||
opacity: 0; | ||
transition: 0.5s ease; | ||
background-color: rgba(0, 0, 0, 1); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
&__preview-button { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 250px; | ||
height: 30px; | ||
z-index: 9999; | ||
border-radius: 12px; | ||
background-color: var(--nfd-onboarding-primary); | ||
opacity: 1; | ||
|
||
&__icon { | ||
fill: var(--nfd-onboarding-secondary); | ||
font-size: 20px; | ||
height: 20px; | ||
width: 20px; | ||
text-align: center; | ||
} | ||
} | ||
|
||
&:hover { | ||
cursor: pointer; | ||
opacity: 0.74; | ||
} | ||
} | ||
|
||
.live-preview { | ||
|
||
&__container { | ||
|
||
&-custom { | ||
width: 100%; | ||
overflow: hidden; | ||
height: 300px; | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
&__buttons { | ||
width: 90%; | ||
color: var(--nfd-onboarding-primary); | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 16px; | ||
|
||
&__favorite { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
&__icon { | ||
width: 20px; | ||
height: 21px; | ||
margin-right: 12px; | ||
cursor: pointer; | ||
background-image: var(--sitegen-favorite); | ||
|
||
&__fill { | ||
background-image: var(--sitegen-favorite-filled); | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
&__regenerate { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
align-items: center; | ||
cursor: pointer; | ||
|
||
&__icon { | ||
background-image: var(--sitegen-regenerate); | ||
width: 16px; | ||
height: 18px; | ||
margin-right: 12px; | ||
} | ||
} | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/OnboardingSPA/components/Sidebar/components/SitegenEditorPatterns/Sidebar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Fill, PanelBody, PanelHeader, Button } from '@wordpress/components'; | ||
import { Fragment, memo, Suspense } from '@wordpress/element'; | ||
import { closeSmall } from '@wordpress/icons'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
import { store as nfdOnboardingStore } from '../../../../store'; | ||
import { | ||
SIDEBAR_SITEGEN_EDITOR_PATTERNS, | ||
SIDEBAR_SLOTFILL_PREFIX, | ||
} from '../../../../../constants'; | ||
|
||
const SitegenEditorPatternsSidebar = () => { | ||
const { currentStep } = useSelect( ( select ) => { | ||
return { | ||
currentStep: select( nfdOnboardingStore ).getCurrentStep(), | ||
}; | ||
} ); | ||
|
||
const { setIsSidebarOpened } = useDispatch( nfdOnboardingStore ); | ||
|
||
const closeSideBar = () => { | ||
setIsSidebarOpened( false ); | ||
}; | ||
return ( | ||
<Fill | ||
name={ `${ SIDEBAR_SLOTFILL_PREFIX }/${ SIDEBAR_SITEGEN_EDITOR_PATTERNS }` } | ||
> | ||
<PanelBody | ||
className="nfd-onboarding-sidebar--sitegen-editor-patterns" | ||
initialOpen={ true } | ||
> | ||
<Suspense fallback={ <></> }> | ||
<PanelHeader | ||
label={ __( 'Learn More', 'wp-module-onboarding' ) } | ||
> | ||
<div className="nfd-onboarding-sidebar--sitegen-editor-patterns__header"> | ||
<Button | ||
className="nfd-onboarding-sidebar--sitegen-editor-patterns__header__icon" | ||
onClick={ closeSideBar } | ||
icon={ closeSmall } | ||
></Button> | ||
</div> | ||
</PanelHeader> | ||
{ currentStep?.sidebars?.LearnMore && | ||
currentStep?.sidebars?.LearnMore.SidebarComponents.map( | ||
( SidebarComponent, index ) => { | ||
return ( | ||
<Fragment key={ index }> | ||
<SidebarComponent /> | ||
</Fragment> | ||
); | ||
} | ||
) } | ||
</Suspense> | ||
</PanelBody> | ||
</Fill> | ||
); | ||
}; | ||
|
||
export default memo( SitegenEditorPatternsSidebar ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { getRandomColorPalette } from '../sitemeta/siteMeta'; | ||
import one from './1.json'; | ||
import two from './2.json'; | ||
import three from './3.json'; | ||
import four from './4.json'; | ||
const getHomepages = () => { | ||
return [ one, two, three ]; | ||
}; | ||
|
||
const getRandom = ( homepage ) => { | ||
if ( homepage?.favorite ) { | ||
homepage.slug = homepage.slug + '-copy'; | ||
homepage.title = homepage.title + ' Copy'; | ||
homepage.favorite = false; | ||
homepage.color = getRandomColorPalette( homepage?.color?.slug ); | ||
return homepage; | ||
} | ||
four.color = getRandomColorPalette( homepage?.color?.slug ); | ||
return four; | ||
}; | ||
|
||
export { getHomepages, getRandom }; |
Oops, something went wrong.