Skip to content

Commit acb8ad7

Browse files
adjustments
1 parent 985e6ba commit acb8ad7

File tree

3 files changed

+59
-45
lines changed

3 files changed

+59
-45
lines changed

src/components/guided-modal-tour/index.js

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1+
/**
2+
* Internal dependencies
3+
*/
4+
import { TOURS } from './tours'
5+
6+
/**
7+
* External dependencies
8+
*/
19
import {
210
i18n,
311
guidedTourStates, // TODO: This doesn't exist yet. The state should be loaded here from localize values, this should be an object with the tour ID as the key and the state as the value.
412
} from 'stackable'
513
import classNames from 'classnames'
614
import confetti from 'canvas-confetti'
715

16+
/**
17+
* WordPress dependencies
18+
*/
819
import {
920
Modal, Flex, Button,
1021
} from '@wordpress/components'
@@ -16,40 +27,11 @@ import {
1627
useEffect, useState, useCallback, useRef, useMemo,
1728
} from '@wordpress/element'
1829

19-
const STEPS = [
20-
{
21-
title: '👋 ' + __( 'Welcome to Your Design Library', i18n ),
22-
description: __( 'These are pre-built designs that are style-matched to your block theme. You can insert one or more patterns to quickly build your page.', i18n ),
23-
size: 'medium',
24-
},
25-
{
26-
title: __( 'Pick Styling Options', i18n ),
27-
description: __( 'Turn on backgrounds, change color schemes, to customize the library. Go ahead and click on "Section Background" and see your changes in real-time.', i18n ),
28-
anchor: '.ugb-modal-design-library__enable-background',
29-
position: 'right',
30-
nextEventTarget: '.ugb-modal-design-library__enable-background',
31-
// ctaLabel: __( 'Enable Background', i18n ),
32-
// ctaOnClick: () => {
33-
// const element = document.querySelector( '.ugb-modal-design-library__enable-background .components-form-toggle__input' )
34-
// element?.click()
35-
// },
36-
glowTarget: '.ugb-modal-design-library__enable-background',
37-
// showNext: false,
38-
},
39-
{
40-
title: __( 'Patterns and Full-Pages', i18n ),
41-
description: __( 'Click here to switch between patterns and full-page layouts.', i18n ),
42-
anchor: '.ugb-modal-design-library .components-modal__header',
43-
position: 'bottom',
44-
},
45-
]
46-
4730
const NOOP = () => {}
4831

4932
// The main tour component.
5033
const GuidedModalTour = props => {
5134
const {
52-
steps = STEPS,
5335
hasConfetti = true,
5436
tourId = '', // This is the ID of the tour, this will be used to store the tour state in the database.
5537
} = props
@@ -62,7 +44,7 @@ const GuidedModalTour = props => {
6244
}
6345

6446
return <ModalTour
65-
steps={ steps }
47+
steps={ TOURS[ tourId ] }
6648
hasConfetti={ hasConfetti }
6749
onClose={ () => {
6850
// TODO: Save the tour state to the database that we finished it.
@@ -73,7 +55,7 @@ const GuidedModalTour = props => {
7355

7456
const ModalTour = props => {
7557
const {
76-
steps = STEPS,
58+
steps,
7759
onClose = NOOP,
7860
hasConfetti = true,
7961
} = props
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { __ } from '@wordpress/i18n'
2+
import { i18n } from 'stackable'
3+
4+
export const TOURS = {
5+
'editor-welcome': [
6+
{
7+
title: '👋 ' + __( 'Welcome to Stackable', i18n ),
8+
description: __( 'We\'re excited to have you here. Let\'s get you started by opening the Design Library. Click the button above to get started.', i18n ),
9+
// size: 'medium',
10+
anchor: '.ugb-insert-library-button',
11+
position: 'bottom',
12+
nextEventTarget: '.ugb-insert-library-button',
13+
glowTarget: '.ugb-insert-library-button',
14+
showNext: false,
15+
},
16+
],
17+
'design-library-welcome': [
18+
{
19+
title: '👋 ' + __( 'Welcome to Your Design Library', i18n ),
20+
description: __( 'These are pre-built designs that are style-matched to your block theme. You can insert one or more patterns to quickly build your page.', i18n ),
21+
size: 'medium',
22+
},
23+
{
24+
title: __( 'Pick Styling Options', i18n ),
25+
description: __( 'Turn on backgrounds, change color schemes, to customize the library. Go ahead and click on "Section Background" and see your changes in real-time.', i18n ),
26+
anchor: '.ugb-modal-design-library__enable-background',
27+
position: 'right',
28+
nextEventTarget: '.ugb-modal-design-library__enable-background',
29+
// ctaLabel: __( 'Enable Background', i18n ),
30+
// ctaOnClick: () => {
31+
// const element = document.querySelector( '.ugb-modal-design-library__enable-background .components-form-toggle__input' )
32+
// element?.click()
33+
// },
34+
glowTarget: '.ugb-modal-design-library__enable-background',
35+
// showNext: false,
36+
},
37+
{
38+
title: __( 'Patterns and Full-Pages', i18n ),
39+
description: __( 'Click here to switch between patterns and full-page layouts.', i18n ),
40+
anchor: '.ugb-modal-design-library .components-modal__header',
41+
position: 'bottom',
42+
},
43+
],
44+
}

src/plugins/design-library-button/design-library-button.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,6 @@ import { useCallback } from '@wordpress/element'
1414
import { ToolbarButton } from '@wordpress/components'
1515
import { GuidedModalTour } from '~stackable/components'
1616

17-
const STEPS = [
18-
{
19-
title: '👋 ' + __( 'Welcome to Stackable', i18n ),
20-
description: __( 'We’re excited to have you here. Let\’s get you started by opening the Design Library. Click the button above to get started.', i18n ),
21-
// size: 'medium',
22-
anchor: '.ugb-insert-library-button',
23-
position: 'bottom',
24-
nextEventTarget: '.ugb-insert-library-button',
25-
glowTarget: '.ugb-insert-library-button',
26-
showNext: false,
27-
},
28-
]
29-
3017
const DesignLibraryButton = () => {
3118
const { getEditorDom } = useSelect( 'stackable/editor-dom' )
3219

@@ -56,7 +43,8 @@ const DesignLibraryButton = () => {
5643

5744
return ( settings.stackable_enable_design_library &&
5845
<>
59-
<GuidedModalTour steps={ STEPS } hasConfetti={ false } />
46+
{ /* TODO: This will need to only play on first time going to the editor, and if there's no quick button that started another tour */ }
47+
<GuidedModalTour tourId="editor-welcome" hasConfetti={ false } />
6048
<ToolbarButton
6149
onClick={ onClick }
6250
className="ugb-insert-library-button"

0 commit comments

Comments
 (0)