-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creator: Add welcome guide on first load. (#97)
- Loading branch information
1 parent
78be0a7
commit 9327b7f
Showing
7 changed files
with
321 additions
and
5 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
122 changes: 122 additions & 0 deletions
122
public_html/wp-content/plugins/pattern-creator/src/components/welcome-guide/images.js
Large diffs are not rendered by default.
Oops, something went wrong.
99 changes: 99 additions & 0 deletions
99
public_html/wp-content/plugins/pattern-creator/src/components/welcome-guide/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,99 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Guide } from '@wordpress/components'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { store as editPostStore } from '@wordpress/edit-post'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { ImageCollectionImage, PatternEditorImage, PatternsImage } from './images'; | ||
import './style.css'; | ||
|
||
/** | ||
* Module constants | ||
*/ | ||
export const GUIDE_ID = 'wporgWelcomeGuide'; | ||
|
||
export default function WelcomeGuide() { | ||
const isActive = useSelect( ( select ) => select( editPostStore ).isFeatureActive( GUIDE_ID ), [] ); | ||
|
||
const { toggleFeature } = useDispatch( editPostStore ); | ||
|
||
if ( ! isActive ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Guide | ||
className="pattern-creator-welcome-guide" | ||
contentLabel={ __( 'Welcome to the pattern creator', 'wporg-patterns' ) } | ||
finishButtonText={ __( 'Done', 'wporg-patterns' ) } | ||
onFinish={ () => toggleFeature( GUIDE_ID ) } | ||
pages={ [ | ||
{ | ||
image: ( | ||
<div className="pattern-creator-welcome-guide__image circle-background"> | ||
<PatternsImage /> | ||
</div> | ||
), | ||
content: ( | ||
<> | ||
<h1 className="pattern-creator-welcome-guide__title"> | ||
{ __( 'Welcome to the pattern editor', 'wporg-patterns' ) } | ||
</h1> | ||
<p> | ||
{ __( | ||
'Mix and match WordPress blocks together to create unique and compelling designs.', | ||
'wporg-patterns' | ||
) } | ||
</p> | ||
</> | ||
), | ||
}, | ||
{ | ||
image: ( | ||
<div className="pattern-creator-welcome-guide__image diamond-background"> | ||
<ImageCollectionImage /> | ||
</div> | ||
), | ||
content: ( | ||
<> | ||
<h1 className="pattern-creator-welcome-guide__title"> | ||
{ __( 'Use our collection of license-free images', 'wporg-patterns' ) } | ||
</h1> | ||
<p> | ||
{ __( | ||
'Don’t worry about licensing. We’ve provided a collection of worry-free images and media for you to use.', | ||
'wporg-patterns' | ||
) } | ||
</p> | ||
</> | ||
), | ||
}, | ||
{ | ||
image: ( | ||
<div className="pattern-creator-welcome-guide__image triangles-background"> | ||
<PatternEditorImage /> | ||
</div> | ||
), | ||
content: ( | ||
<> | ||
<h1 className="pattern-creator-welcome-guide__title"> | ||
{ __( 'Submit your pattern to the directory', 'wporg-patterns' ) } | ||
</h1> | ||
<p> | ||
{ __( | ||
'Choose a category and share your pattern with the world. All patterns in the directory are available from any WordPress site.', | ||
'wporg-patterns' | ||
) } | ||
</p> | ||
</> | ||
), | ||
}, | ||
] } | ||
/> | ||
); | ||
} |
61 changes: 61 additions & 0 deletions
61
public_html/wp-content/plugins/pattern-creator/src/components/welcome-guide/style.css
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 @@ | ||
|
||
.pattern-creator-welcome-guide { | ||
max-width: 320px; | ||
} | ||
|
||
.pattern-creator-welcome-guide__image { | ||
margin-bottom: calc(var(--grid-unit) / 2); /* Pushes the dot controls away */ | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background: #1d2327; | ||
height: 240px; | ||
overflow: hidden; | ||
} | ||
|
||
/* Change circle indicator color */ | ||
.pattern-creator-welcome-guide .components-guide__page-control [aria-current="step"] circle { | ||
fill: var(--wp-admin-theme-color); | ||
} | ||
|
||
/* Change the close button color */ | ||
.pattern-creator-welcome-guide .components-modal__header button { | ||
background: #000; | ||
color: #fff; | ||
} | ||
|
||
/* Change the link color */ | ||
.pattern-creator-welcome-guide .components-button.components-guide__forward-button { | ||
color: var(--wp-admin-theme-color); | ||
} | ||
|
||
.pattern-creator-welcome-guide__image svg { | ||
position: absolute; | ||
} | ||
|
||
.pattern-creator-welcome-guide__title, | ||
.pattern-creator-welcome-guide p { | ||
margin: 0; | ||
padding: 0 calc(var(--grid-unit) * 2); | ||
} | ||
|
||
.pattern-creator-welcome-guide__title { | ||
margin: var(--grid-unit) 0; | ||
font-size: 20px; | ||
font-weight: 600; | ||
line-height: normal; | ||
} | ||
|
||
.pattern-creator-welcome-guide p { | ||
margin-bottom: var(--grid-unit); | ||
font-size: 14px; | ||
} | ||
|
||
.pattern-creator-welcome-guide__link { | ||
margin-top: calc(var(--grid-unit) / 2); | ||
display: block; | ||
} | ||
|
||
.pattern-creator-welcome-guide .components-guide__footer > button { | ||
padding: 6px 12px; | ||
} |
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
28 changes: 28 additions & 0 deletions
28
public_html/wp-content/plugins/pattern-creator/src/plugins/welcome-guide-plugin.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,28 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { dispatch, select } from '@wordpress/data'; | ||
import { registerPlugin } from '@wordpress/plugins'; | ||
import { store } from '@wordpress/edit-post'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import WelcomeGuide, { GUIDE_ID } from '../components/welcome-guide'; | ||
|
||
registerPlugin( 'welcome-guide-plugin', { | ||
render: () => { | ||
// Turn off the default welcome guide | ||
if ( select( store ).isFeatureActive( 'welcomeGuide' ) ) { | ||
dispatch( store ).toggleFeature( 'welcomeGuide' ); | ||
} | ||
|
||
const features = select( store ).getPreference( 'features' ); | ||
|
||
if ( features[ GUIDE_ID ] === undefined ) { | ||
dispatch( store ).toggleFeature( GUIDE_ID ); | ||
} | ||
|
||
return <WelcomeGuide />; | ||
}, | ||
} ); |