Skip to content

Commit

Permalink
FSE: Add welcome guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Nov 3, 2021
1 parent 40ff1e5 commit 2208939
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import URLQueryController from '../url-query-controller';
import InserterSidebar from '../secondary-sidebar/inserter-sidebar';
import ListViewSidebar from '../secondary-sidebar/list-view-sidebar';
import ErrorBoundary from '../error-boundary';
import WelcomeGuide from '../welcome-guide';
import { store as editSiteStore } from '../../store';
import { GlobalStylesRenderer } from './global-styles-renderer';
import { GlobalStylesProvider } from '../global-styles/global-styles-provider';
Expand Down Expand Up @@ -277,6 +278,7 @@ function Editor( { initialSettings, onError } ) {
}
footer={ <BlockBreadcrumb /> }
/>
<WelcomeGuide />
<Popover.Slot />
<PluginArea />
</ErrorBoundary>
Expand Down
11 changes: 11 additions & 0 deletions packages/edit-site/src/components/welcome-guide/image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default function WelcomeGuideImage( { nonAnimatedSrc, animatedSrc } ) {
return (
<picture className="edit-site-welcome-guide__image">
<source
srcSet={ nonAnimatedSrc }
media="(prefers-reduced-motion: reduce)"
/>
<img src={ animatedSrc } width="312" height="240" alt="" />
</picture>
);
}
56 changes: 56 additions & 0 deletions packages/edit-site/src/components/welcome-guide/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* WordPress dependencies
*/
import { useDispatch, useSelect } from '@wordpress/data';
import { Guide } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import WelcomeGuideImage from './image';
import { store as editSiteStore } from '../../store';

export default function WelcomeGuideTemplate() {
const { toggleFeature } = useDispatch( editSiteStore );

const isActive = useSelect(
( select ) => select( editSiteStore ).isFeatureActive( 'welcomeGuide' ),
[]
);

if ( ! isActive ) {
return null;
}

return (
<Guide
className="edit-site-welcome-guide"
contentLabel={ __( 'Welcome to the site editor' ) }
finishButtonText={ __( 'Try Styles' ) }
onFinish={ () => toggleFeature( 'welcomeGuide' ) }
pages={ [
{
image: (
<WelcomeGuideImage
nonAnimatedSrc="https://s.w.org/images/block-editor/welcome-template-editor.svg"
animatedSrc="https://s.w.org/images/block-editor/welcome-template-editor.gif"
/>
),
content: (
<>
<h1 className="edit-site-welcome-guide__heading">
{ __( 'Introducing: Styles' ) }
</h1>
<p className="edit-site-welcome-guide__text">
{ __(
'Try out and apply new colors, typography, and layout across your entire site. You can also customize the appearance of specific blocks, meaning that all paragraph blocks can appear the same with a few clicks.'
) }
</p>
</>
),
},
] }
/>
);
}
33 changes: 33 additions & 0 deletions packages/edit-site/src/components/welcome-guide/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.edit-site-welcome-guide {
width: 312px;

&__image {
background: #00a0d2;
margin: 0 0 $grid-unit-20;
> img {
display: block;
max-width: 100%;
object-fit: cover;
}
}

&__heading {
font-family: $default-font;
font-size: 24px;
line-height: 1.4;
margin: $grid-unit-20 0 $grid-unit-20 0;
padding: 0 $grid-unit-40;
}

&__text {
font-size: $default-font-size;
line-height: 1.4;
margin: 0 0 $grid-unit-30 0;
padding: 0 $grid-unit-40;
}

&__inserter-icon {
margin: 0 4px;
vertical-align: text-top;
}
}
4 changes: 3 additions & 1 deletion packages/edit-site/src/store/defaults.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const PREFERENCES_DEFAULTS = {
features: {},
features: {
welcomeGuide: true,
},
};
1 change: 1 addition & 0 deletions packages/edit-site/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@import "./components/template-details/style.scss";
@import "./components/template-part-converter/style.scss";
@import "./components/secondary-sidebar/style.scss";
@import "./components/welcome-guide/style.scss";

// In order to use mix-blend-mode, this element needs to have an explicitly set background-color.
// We scope it to .wp-toolbar to be wp-admin only, to prevent bleed into other implementations.
Expand Down

0 comments on commit 2208939

Please sign in to comment.