-
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.
Favorites, regeneration and maintaining state
- Loading branch information
1 parent
bdabd26
commit 9f6ab77
Showing
28 changed files
with
831 additions
and
138 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
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
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
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
59 changes: 59 additions & 0 deletions
59
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,59 @@ | ||
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 ); |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,25 @@ | ||
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 ) => { | ||
console.log('homepage', 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 }; |
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,39 @@ | ||
import siteMeta from './siteMeta.json'; | ||
const getSiteMeta = () => { | ||
return siteMeta; | ||
} | ||
|
||
const getColorPalettes = () => { | ||
let colorPalettes = {}; | ||
Object.keys( siteMeta.colorpalette ).forEach((colorPalette) => { | ||
colorPalettes[colorPalette] = Object.keys(siteMeta.colorpalette[colorPalette]).map(( slug ) => { | ||
return { | ||
slug, | ||
title: slug[0].toUpperCase() + slug.slice(1), | ||
color: siteMeta.colorpalette[colorPalette][slug] | ||
} | ||
}) | ||
}) | ||
|
||
return colorPalettes; | ||
} | ||
|
||
const getRandomColorPalette = ( activeColorPaletteSlug ) => { | ||
const colorPalettes = getColorPalettes(); | ||
console.log(colorPalettes) | ||
let keys = Object.keys( colorPalettes ); | ||
if ( activeColorPaletteSlug ) { | ||
keys = keys.filter(( key ) => { | ||
return key != activeColorPaletteSlug | ||
}) | ||
} | ||
|
||
const rand = Math.floor( Math.random() * keys.length ); | ||
console.log(rand) | ||
return { | ||
slug: keys[2], | ||
palette: colorPalettes[ keys[ 2 ] ] | ||
} | ||
} | ||
|
||
export {getSiteMeta, getColorPalettes, getRandomColorPalette}; |
Oops, something went wrong.