Skip to content

Commit 1d4042c

Browse files
committed
add block backgrounds & containers tour
1 parent 7d61922 commit 1d4042c

File tree

4 files changed

+251
-5
lines changed

4 files changed

+251
-5
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ export const TOUR_CONDITIONS = {
2727
// Force show the tour if there is a GET parameter tour=site-kit
2828
return window?.location?.search?.includes( 'tour=site-kit' ) ? true : null
2929
},
30+
'block-backgrounds': () => {
31+
// Force show the tour if there is a GET parameter tour=block-backgrounds
32+
return window?.location?.search?.includes( 'tour=block-backgrounds' ) ? true : null
33+
},
3034
}
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
import { __ } from '@wordpress/i18n'
2+
import { i18n } from 'stackable'
3+
import { dispatch, select } from '@wordpress/data'
4+
import { createInterpolateElement } from '@wordpress/element'
5+
6+
export const blockBackgrounds = {
7+
initialize: () => {
8+
// Add some default content that we will select
9+
10+
const blockObject = wp.blocks.createBlock(
11+
'stackable/columns',
12+
{
13+
uniqueId: '1dbe04e',
14+
blockMargin: { bottom: '' },
15+
align: 'full',
16+
containerWidth: 50,
17+
containerHorizontalAlign: 'flex-start',
18+
containerWidthUnit: '%',
19+
},
20+
[
21+
wp.blocks.createBlock(
22+
'stackable/column',
23+
{
24+
uniqueId: 'f957abc',
25+
columnSpacing: {
26+
top: '', right: '', bottom: '', left: '',
27+
},
28+
},
29+
[
30+
wp.blocks.createBlock(
31+
'stackable/heading',
32+
{
33+
uniqueId: 'a8ebea7',
34+
// Retain our text
35+
text: 'Explore the World with Us',
36+
textTag: 'h2',
37+
}
38+
),
39+
wp.blocks.createBlock(
40+
'stackable/text',
41+
{
42+
uniqueId: '57e76a1',
43+
// Retain our text
44+
text: 'Discover breathtaking destinations, plan your next adventure, and make unforgettable memories with our travel guides and tips.',
45+
}
46+
),
47+
wp.blocks.createBlock(
48+
'stackable/button-group',
49+
{ uniqueId: 'e063798' },
50+
[
51+
wp.blocks.createBlock(
52+
'stackable/button',
53+
{
54+
uniqueId: '5d04ca8',
55+
// Retain our text
56+
text: 'Start your journey',
57+
url: '',
58+
}
59+
),
60+
]
61+
),
62+
]
63+
),
64+
]
65+
)
66+
// Insert our block
67+
dispatch( 'core/block-editor' ).insertBlocks( [ blockObject ], 0 )
68+
69+
// Select the inner columns block for the tour
70+
dispatch( 'core/block-editor' ).selectBlock( blockObject.clientId )
71+
},
72+
steps: [
73+
{
74+
title: __( 'Discover Stackable Block Backgrounds & Containers', i18n ),
75+
description: __( 'Welcome! Let\'s enhance your page by first adding a background to the Columns block. The Style Tab lets you tweak backgrounds, colors, borders, and typography for a custom look.', i18n ),
76+
help: createInterpolateElement( __( 'Click the <strong>Style Tab</strong> in the sidebar to get started.', i18n ), {
77+
strong: <strong />,
78+
} ),
79+
anchor: '.edit-post-sidebar__panel-tab.ugb-tab--style',
80+
position: 'left',
81+
glowTarget: '.edit-post-sidebar__panel-tab.ugb-tab--style',
82+
nextEventTarget: '.edit-post-sidebar__panel-tab.ugb-tab--style',
83+
preStep: () => {
84+
// Open the inspector sidebar
85+
dispatch( 'core/edit-post' ).openGeneralSidebar( 'edit-post/block' )
86+
87+
// Look for the first "stackable/columns" block
88+
const allBlocks = select( 'core/block-editor' ).getBlocks()
89+
const columnsBlock = allBlocks.find( block => block.name === 'stackable/columns' )
90+
if ( columnsBlock ) {
91+
dispatch( 'core/block-editor' ).selectBlock( columnsBlock.clientId )
92+
}
93+
},
94+
postStep: () => {
95+
// Click the tab
96+
document.querySelector( '.edit-post-sidebar__panel-tab.ugb-tab--style:not(.is-active)' )?.click()
97+
},
98+
},
99+
{
100+
title: __( 'Enable a Block Background', i18n ),
101+
description: __( 'Turn on the background option to instantly add a background layer to your section. Watch as your design transforms with a single toggle.', i18n ),
102+
help: createInterpolateElement( __( 'Toggle ON the <strong>Background</strong> option to continue.', i18n ), {
103+
strong: <strong />,
104+
} ),
105+
anchor: '.ugb-block-background-panel .components-panel__body-title',
106+
position: 'left',
107+
glowTarget: '.ugb-block-background-panel .components-panel__body-title',
108+
nextEventTarget: '.ugb-block-background-panel .components-panel__body-title input[type="checkbox"]',
109+
nextEvent: 'mousedown',
110+
preStep: () => {
111+
// Open the inspector sidebar
112+
dispatch( 'core/edit-post' ).openGeneralSidebar( 'edit-post/block' )
113+
114+
// Look for the first "stackable/columns" block
115+
const allBlocks = select( 'core/block-editor' ).getBlocks()
116+
const columnsBlock = allBlocks.find( block => block.name === 'stackable/columns' )
117+
if ( columnsBlock ) {
118+
dispatch( 'core/block-editor' ).selectBlock( columnsBlock.clientId )
119+
}
120+
121+
setTimeout( () => {
122+
// Click the tab
123+
document.querySelector( '.edit-post-sidebar__panel-tab.ugb-tab--style:not(.is-active)' )?.click()
124+
}, 100 )
125+
},
126+
},
127+
{
128+
title: __( 'Customize the Background Color', i18n ),
129+
description: __( 'Now let\'s personalize your section. Choose a background color to help your content stand out or integrate it seamlessly into your page design.', i18n ),
130+
help: createInterpolateElement( __( 'Open the <strong>Background Color</strong> panel to select a color.', i18n ), {
131+
strong: <strong />,
132+
} ),
133+
anchor: '.stk-color-palette-control',
134+
position: 'left',
135+
glowTarget: '.ugb-block-background-panel .block-editor-panel-color-gradient-settings__dropdown',
136+
nextEventTarget: '.ugb-block-background-panel .block-editor-panel-color-gradient-settings__dropdown',
137+
nextEvent: 'mousedown',
138+
preStep: () => {
139+
// Toggle background on
140+
document.querySelector( '.ugb-block-background-panel:not(is-opened)' )?.click()
141+
document.querySelector( '.ugb-block-background-panel .ugb-toggle-panel-form-toggle:not(is-checked) input' )?.click()
142+
},
143+
postStep: () => {
144+
// Click the tab
145+
document.querySelector( '.ugb-block-background-panel .stk-color-palette-control .block-editor-panel-color-gradient-settings__dropdown:not(is-open)' )?.click()
146+
},
147+
},
148+
{
149+
title: __( 'Pick Your Brand Color', i18n ),
150+
description: __( 'Select a color that matches your brand or mood. Try out different colors and instantly see the changes on your block.', i18n ),
151+
help: createInterpolateElement( __( 'Choose a <strong>Color</strong> from the palette to apply it.', i18n ), {
152+
strong: <strong />,
153+
} ),
154+
anchor: '.stk-color-palette-control__popover-content',
155+
position: 'left',
156+
glowTarget: '.stk-color-palette-control__popover-content',
157+
nextEvent: 'mousedown',
158+
nextEventTarget: '.stk-color-palette-control__popover-content *',
159+
postStep: () => {
160+
// Click the color picker
161+
document.querySelector( '.ugb-block-background-panel .stk-color-palette-control .block-editor-panel-color-gradient-settings__dropdown.is-open' )?.click()
162+
},
163+
},
164+
{
165+
title: __( 'Add a Container for Better Layout', i18n ),
166+
description: __( 'Turn on the Container option to give your columns content a background, padding, and improved alignment for a polished look.', i18n ),
167+
help: createInterpolateElement( __( 'Toggle ON the <strong>Container</strong> to proceed.', i18n ), {
168+
strong: <strong />,
169+
} ),
170+
anchor: '.ugb-panel--container-size .components-panel__body-title',
171+
position: 'left',
172+
glowTarget: '.ugb-panel--container-size .components-panel__body-title',
173+
nextEventTarget: '.ugb-panel--container-size .components-panel__body-title input[type="checkbox"]',
174+
nextEvent: 'mousedown',
175+
preStep: () => {
176+
// Click the tab
177+
document.querySelector( '.ugb-block-background-panel .stk-color-palette-control .block-editor-panel-color-gradient-settings__dropdown.is-open' )?.click()
178+
179+
const allBlocks = select( 'core/block-editor' ).getBlocks()
180+
const columnsBlock = allBlocks.find( block => block.name === 'stackable/columns' )
181+
if ( columnsBlock && columnsBlock.innerBlocks[ 0 ] ) {
182+
dispatch( 'core/block-editor' ).selectBlock( columnsBlock.innerBlocks[ 0 ].clientId )
183+
document.querySelector( '.edit-post-sidebar__panel-tab.ugb-tab--layout:not(.is-active)' )?.click()
184+
setTimeout( () => {
185+
document.querySelector( '.ugb-panel--layout.is-opened .components-panel__body-title button' )?.click()
186+
}, 100 )
187+
}
188+
},
189+
},
190+
{
191+
title: __( 'Block Backgrounds & Containers Recap', i18n ),
192+
description: __( 'Great job! You\'ve learned how to add and customize block backgrounds and containers. These features are available in most Stackable blocks, helping you create beautiful, consistent layouts with ease.', i18n ),
193+
preStep: () => {
194+
// Toggle background on
195+
document.querySelector( '.ugb-panel--container-size:not(is-opened)' )?.click()
196+
document.querySelector( '.ugb-panel--container-size .ugb-toggle-panel-form-toggle:not(is-checked) input' )?.click()
197+
},
198+
},
199+
{
200+
title: __( 'Tip: Style All Blocks Efficiently', i18n ),
201+
description: createInterpolateElement( __( 'Use the <strong>Stackable Design System</strong> to manage styles for all Stackable blocks globally. Perfect for a unified look and quick design changes!', i18n ), {
202+
strong: <strong />,
203+
} ),
204+
anchor: '[aria-controls="stackable-global-settings:sidebar"]',
205+
position: 'left-top',
206+
offsetY: '-30px',
207+
offsetX: '-8px',
208+
glowTarget: '[aria-controls="stackable-global-settings:sidebar"]',
209+
},
210+
],
211+
}

src/plugins/guided-modal-tour/editor-block-tour.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { registerPlugin } from '@wordpress/plugins'
33
import { GuidedModalTour } from '~stackable/components'
44

55
const EditorBlockTour = () => {
6-
return <GuidedModalTour tourId="blocks" />
6+
return <>
7+
<GuidedModalTour tourId="blocks" />
8+
<GuidedModalTour tourId="block-backgrounds" />
9+
</>
710
}
811

912
registerPlugin( 'stackable-editor-block-tour', {

src/welcome/getting-started.js

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,36 +119,64 @@ const QUICK_BUTTONS = [ {
119119
description: __( 'Jump straight into our Design Library and insert polished, pre-built sections; no more blank-page overwhelm.', i18n ),
120120
link: `/wp-admin/post-new.php?post_type=page&content=${ __( 'Welcome to Stackable', i18n ) }&tour=design-library`,
121121
cta: __( 'Build Now', i18n ),
122-
}, {
122+
},
123+
{
123124
id: 'blocks',
124125
icon: blockDefaultIcon,
125126
title: __( 'Stackable Block Settings', i18n ),
126127
description: __( 'Learn how to use Stackable blocks and get more out of them.', i18n ),
127128
link: `/wp-admin/post-new.php?post_type=page&content=${ __( 'Welcome to Stackable', i18n ) }&tour=blocks`,
128129
cta: __( 'Use Blocks', i18n ),
129-
}, {
130+
},
131+
{
130132
id: 'design-system',
131133
icon: stylesIcon,
132134
title: __( 'Apply Global Styles Instantly', i18n ),
133135
description: __( 'Set your brand\'s colors, fonts, and spacing once in the Design System; every Stackable block updates automatically.', i18n ),
134136
link: `/wp-admin/post-new.php?post_type=page&content=${ __( 'Welcome to Stackable', i18n ) }&tour=design-system`,
135137
cta: __( 'Try Now', i18n ),
136-
}, {
138+
},
139+
{
137140
id: 'site-kit',
138141
icon: scheduledIcon,
139142
title: __( 'Start with a Complete Site Kit', i18n ),
140143
description: __( 'Pick a ready-made website template to kickstart your project — fully built layouts and styles, just swap in your content.', i18n ),
141144
link: '/wp-admin/post-new.php?post_type=page',
142145
cta: __( 'Select Kit', i18n ),
143146
style: { display: 'none' },
144-
}, {
147+
},
148+
{
145149
id: 'design-system-picker',
146150
icon: brushIcon,
147151
title: __( 'Pre-set Design Systems', i18n ),
148152
description: __( 'Browse curated Design System presets — apply a professional look instantly without building from scratch.', i18n ),
149153
link: '/wp-admin/post-new.php?post_type=page',
150154
cta: __( 'Pick A System', i18n ),
151155
style: { display: 'none' },
156+
},
157+
{
158+
id: 'block-backgrounds',
159+
icon: brushIcon,
160+
title: __( 'Block Backgrounds & Containers', i18n ),
161+
description: __( 'Use backgrounds to create stunning full-width sections, and containers to add boxed content for organizing your page.', i18n ),
162+
link: `/wp-admin/post-new.php?post_type=page&content=${ __( 'Welcome to Stackable', i18n ) }&tour=block-backgrounds`,
163+
cta: __( 'Try Now', i18n ),
164+
},
165+
{
166+
id: 'responsive-controls',
167+
icon: brushIcon,
168+
title: __( 'Responsive Controls', i18n ),
169+
description: __( 'Adjust styles for desktop, tablet, and mobile — easily control layout, spacing, and appearance for a seamless experience on any device.', i18n ),
170+
link: `/wp-admin/post-new.php?post_type=page&content=${ __( 'Welcome to Stackable', i18n ) }&tour=responsive-controls`,
171+
cta: __( 'Try Now', i18n ),
172+
},
173+
{
174+
id: 'hover-states',
175+
icon: brushIcon,
176+
title: __( 'Styling Hover States', i18n ),
177+
description: __( 'Adjust styles for different hover states — create engaging effects when users interact with your designs.', i18n ),
178+
link: `/wp-admin/post-new.php?post_type=page&content=${ __( 'Welcome to Stackable', i18n ) }&tour=hover-states`,
179+
cta: __( 'Try Now', i18n ),
152180
} ]
153181

154182
export const GettingStarted = () => {

0 commit comments

Comments
 (0)