-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { Icon, search } from '@wordpress/icons'; | ||
import { LivePreview } from '..'; | ||
import favorite from '../../../static/icons/sitegen/favorite.svg'; | ||
|
||
const LivePreviewSiteGenCard = ( { | ||
className = 'nfd-onboarding-live-preview--sitegen-card', | ||
slug, | ||
title, | ||
blockGrammer, | ||
styling, | ||
isFavorite = false, | ||
viewportWidth, | ||
previewSettings, | ||
skeletonLoadingTime = 2500, | ||
onFavorite, | ||
onRegenerate, | ||
onPreview, | ||
} ) => { | ||
const handleFavorite = ( slug ) => { | ||
if ( typeof onFavorite === 'function' ) { | ||
return onFavorite( slug ); | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
const handleRegenerate = ( slug ) => { | ||
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 | ||
Check failure on line 52 in src/OnboardingSPA/components/LivePreview/SiteGenCard/index.js GitHub Actions / Run Lint Checks
Check failure on line 52 in src/OnboardingSPA/components/LivePreview/SiteGenCard/index.js GitHub Actions / Run Lint Checks
|
||
className={ `${ className }__live-preview-container__overlay` } | ||
onClick={ () => 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 | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div className={ `${ className }__buttons` }> | ||
<div className={ `${ className }__buttons__favorite` }> | ||
<img | ||
Check failure on line 73 in src/OnboardingSPA/components/LivePreview/SiteGenCard/index.js GitHub Actions / Run Lint Checks
Check failure on line 73 in src/OnboardingSPA/components/LivePreview/SiteGenCard/index.js GitHub Actions / Run Lint Checks
|
||
src={ favorite } | ||
className={ `${ className }__buttons__favorite__icon ${ | ||
isFavorite && | ||
`${ className }__buttons__favorite__icon__fill` | ||
}` } | ||
onClick={ () => handleFavorite( slug ) } | ||
/> | ||
<div | ||
className={ `${ className }__buttons__favorite__text` } | ||
> | ||
{ title } | ||
</div> | ||
</div> | ||
<div className={ `${ className }__buttons__regenerate` }> | ||
<div | ||
Check failure on line 88 in src/OnboardingSPA/components/LivePreview/SiteGenCard/index.js GitHub Actions / Run Lint Checks
Check failure on line 88 in src/OnboardingSPA/components/LivePreview/SiteGenCard/index.js GitHub Actions / Run Lint Checks
|
||
className={ `${ className }__buttons__regenerate__icon` } | ||
onClick={ () => handleRegenerate( slug ) } | ||
></div> | ||
<div | ||
className={ `${ className }__buttons__regenerate__text` } | ||
> | ||
Regenerate | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LivePreviewSiteGenCard; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
.nfd-onboarding-live-preview { | ||
&--sitegen-card { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
margin: 24px; | ||
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: 20px; | ||
margin-right: 12px; | ||
cursor: pointer; | ||
|
||
&__fill { | ||
background-color: var(--nfd-onboarding-favorite-fill); | ||
} | ||
|
||
} | ||
|
||
&__text {} | ||
} | ||
|
||
&__regenerate { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
align-items: center; | ||
&__icon { | ||
background-image: var(--sitegen-regenerate); | ||
width: 16px; | ||
height: 18px; | ||
margin-right: 12px; | ||
} | ||
} | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import one from './1.json'; | ||
import two from './2.json'; | ||
import three from './3.json'; | ||
const getHomepages = () => { | ||
return [one, two, three]; | ||
} | ||
|
||
export default getHomepages; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Fill, Dropdown } from '@wordpress/components'; | ||
import { HEADER_CENTER, HEADER_END, HEADER_SITEGEN, HEADER_START } from '../../../../../constants'; | ||
import { Icon, chevronDown, home } from '@wordpress/icons'; | ||
import { store as nfdOnboardingStore } from '../../../../store'; | ||
|
||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
|
||
import { useEffect, useState } from '@wordpress/element'; | ||
|
||
const StepSiteGenEditorHeader = () => { | ||
const [homepage, setHomepage] = useState(); | ||
|
||
const { setCurrentOnboardingData } = useDispatch(nfdOnboardingStore); | ||
const { currentData } = useSelect((select) => { | ||
return { | ||
currentData: select(nfdOnboardingStore).getCurrentOnboardingData(), | ||
} | ||
}) | ||
|
||
const handleFavorite = () => { | ||
homepage.favorite = ! homepage.favorite; | ||
currentData.sitegen.homepages.data[homepage.slug] = homepage; | ||
setCurrentOnboardingData( currentData ); | ||
} | ||
|
||
useEffect(() => { | ||
if ( currentData.sitegen.homepages.active ) { | ||
|
||
setHomepage(currentData.sitegen.homepages.active) | ||
} | ||
}, []) | ||
return <> | ||
<Fill name={ `${ HEADER_SITEGEN }/${ HEADER_START }` }> | ||
<div className='nfd-onboarding-header--sitegen__editor__start'> | ||
<button className='nfd-onboarding-header--sitegen__editor__start__regenerate'> | ||
<div className={`nfd-onboarding-header--sitegen__editor__start__regenerate__icon`}></div> | ||
<div className={`nfd-onboarding-header--sitegen__editor__start__regenerate__text`}>Regenerate</div> | ||
</button> | ||
</div> | ||
</Fill> | ||
<Fill name={`${HEADER_SITEGEN}/${HEADER_CENTER}`}> | ||
<div className='nfd-onboarding-header--sitegen__editor__center'> | ||
<div className='nfd-onboarding-header--sitegen__editor__center__icon'></div> | ||
<Dropdown className='nfd-onboarding-header--sitegen__editor__center__dropdown' | ||
renderToggle={( { isOpen, onToggle } ) => { | ||
return <> | ||
<p className={`nfd-onboarding-header--sitegen__editor__center__dropdown__favorite-icon ${homepage.favorite && 'nfd-onboarding-header--sitegen__editor__center__dropdown__favorite-icon__fill'}`} onClick={handleFavorite}></p> | ||
<div className='nfd-onboarding-header--sitegen__editor__center__dropdown__info' onClick={onToggle}> | ||
<p className='nfd-onboarding-header--sitegen__editor__center__dropdown__info__text'>{homepage.title}</p> | ||
<Icon className='nfd-onboarding-header--sitegen__editor__center__dropdown__info__down-icon' icon={chevronDown} /> | ||
</div> | ||
</> | ||
|
||
}} | ||
renderContent={() => <div>Hello World</div>} | ||
/> | ||
</div> | ||
</Fill> | ||
<Fill name={ `${ HEADER_SITEGEN }/${ HEADER_END }` }> | ||
</Fill> | ||
</> | ||
} | ||
|
||
export default StepSiteGenEditorHeader; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
.nfd-onboarding-header { | ||
&--sitegen{ | ||
&__editor { | ||
&__start { | ||
&__regenerate { | ||
margin-left: 20px; | ||
height: 36px; | ||
color: var(--nfd-onboarding-primary); | ||
background-color: var(--nfd-onboarding-preview-favorite-background); | ||
border: none; | ||
:hover { | ||
cursor: pointer; | ||
} | ||
&__icon { | ||
background-image: var(--sitegen-regenerate); | ||
width: 16px; | ||
height: 18px; | ||
} | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: space-evenly; | ||
width: 130px; | ||
} | ||
} | ||
|
||
&__center { | ||
&__dropdown { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
color: var(--nfd-onboarding-primary); | ||
|
||
&__favorite-icon { | ||
background-image: var(--sitegen-favorite); | ||
height: 20px; | ||
width: 20px; | ||
margin-right: 15px; | ||
cursor: pointer; | ||
|
||
&__fill { | ||
background-color: var(--nfd-onboarding-favorite-fill); | ||
} | ||
} | ||
|
||
&__info { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
cursor: pointer; | ||
&__text { | ||
font-size: 18px; | ||
margin-right: 15px; | ||
} | ||
|
||
&__down-icon { | ||
fill: var(--nfd-onboarding-primary); | ||
width: 20px; | ||
height: 20px; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |