Skip to content

Commit 03139ec

Browse files
finalized design system tour
1 parent 86aa8e2 commit 03139ec

File tree

3 files changed

+60
-37
lines changed

3 files changed

+60
-37
lines changed

src/components/guided-modal-tour/editor.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,19 @@
7272
}
7373

7474
.ugb-tour-modal__help {
75+
position: relative;
7576
background: #f4fbff;
7677
padding: 8px 12px;
78+
padding-inline-start: 30px;
7779
border-radius: 8px;
7880
border: 1px solid rgba(0, 0, 0, 0.1);
7981
margin-block: 16px;
8082
svg {
8183
vertical-align: text-top;
8284
margin-inline-end: 8px;
85+
margin-top: 1px;
86+
position: absolute;
87+
inset-inline-start: 9px;
8388
}
8489
}
8590

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

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ const ModalTour = props => {
153153

154154
// If at the last step, just close
155155
if ( currentStep === steps.length - 1 ) {
156+
steps[ currentStep ]?.postStep?.( currentStep )
157+
if ( hasConfetti ) {
158+
throwConfetti()
159+
}
156160
onClose()
157161
return
158162
}
@@ -185,7 +189,7 @@ const ModalTour = props => {
185189
setTimeout( () => {
186190
setForceRefresh( forceRefresh => forceRefresh + 1 )
187191
}, 650 )
188-
}, [ currentStep, steps ] )
192+
}, [ currentStep, steps, hasConfetti ] )
189193

190194
const handleBackEvent = useCallback( () => {
191195
// Hide modal during transition
@@ -465,41 +469,7 @@ const ModalTour = props => {
465469
{ showNext && (
466470
<Button
467471
variant="primary"
468-
onClick={ () => {
469-
if ( currentStep === steps.length - 1 ) {
470-
if ( hasConfetti ) {
471-
confetti( {
472-
particleCount: 50,
473-
angle: 60,
474-
spread: 70,
475-
origin: { x: 0 },
476-
zIndex: 100000,
477-
disableForReducedMotion: true,
478-
} )
479-
confetti( {
480-
particleCount: 50,
481-
angle: 120,
482-
spread: 70,
483-
origin: { x: 1 },
484-
zIndex: 100000,
485-
disableForReducedMotion: true,
486-
} )
487-
setTimeout( () => {
488-
confetti( {
489-
particleCount: 50,
490-
angle: -90,
491-
spread: 90,
492-
origin: { y: -0.3 },
493-
zIndex: 100000,
494-
disableForReducedMotion: true,
495-
} )
496-
}, 150 )
497-
}
498-
onClose()
499-
} else {
500-
handleNextEvent()
501-
}
502-
} }
472+
onClick={ handleNextEvent }
503473
>
504474
{ currentStep === steps.length - 1 ? (
505475
__( 'Finish', i18n )
@@ -517,6 +487,35 @@ const ModalTour = props => {
517487
)
518488
}
519489

490+
const throwConfetti = () => {
491+
confetti( {
492+
particleCount: 50,
493+
angle: 60,
494+
spread: 70,
495+
origin: { x: 0 },
496+
zIndex: 100000,
497+
disableForReducedMotion: true,
498+
} )
499+
confetti( {
500+
particleCount: 50,
501+
angle: 120,
502+
spread: 70,
503+
origin: { x: 1 },
504+
zIndex: 100000,
505+
disableForReducedMotion: true,
506+
} )
507+
setTimeout( () => {
508+
confetti( {
509+
particleCount: 50,
510+
angle: -90,
511+
spread: 90,
512+
origin: { y: -0.3 },
513+
zIndex: 100000,
514+
disableForReducedMotion: true,
515+
} )
516+
}, 150 )
517+
}
518+
520519
const Steps = props => {
521520
const {
522521
numSteps = 3,

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ export const TOUR_STEPS = {
144144
if ( document.querySelector( '.ugb-global-typography__panel:not(.is-opened)' ) ) {
145145
document.querySelector( '.ugb-global-typography__panel .components-panel__body-title' )?.click()
146146
}
147+
const el = document.querySelector( '.ugb-global-settings-font-pair__container' )
148+
if ( el ) {
149+
// Scroll this to the top.
150+
el.scrollTo( {
151+
top: 0,
152+
behavior: 'instant',
153+
} )
154+
}
147155
},
148156
},
149157
{
@@ -166,7 +174,7 @@ export const TOUR_STEPS = {
166174
},
167175
{
168176
title: __( 'Share Your Style Guide', i18n ),
169-
description: __( 'Lastly, you can easily share your design system with others by exporting your Style Guide as an image. This is perfect for sharing with clients, teammates, or for documentation.', i18n ),
177+
description: __( 'You can easily share your design system with others by exporting your Style Guide as an image. This is perfect for sharing with clients, teammates, or for documentation.', i18n ),
170178
anchor: '.ugb-style-guide__print-button',
171179
position: 'bottom',
172180
glowTarget: '.ugb-style-guide__print-button',
@@ -181,6 +189,17 @@ export const TOUR_STEPS = {
181189
}
182190
},
183191
},
192+
{
193+
title: __( 'You Did It!', i18n ),
194+
description: __( 'That\'s it for the tour! Click the X to close the Style Guide. Your new styles are now live on your site. 🎉', i18n ),
195+
anchor: '.ugb-style-guide-popover__close-button',
196+
position: 'bottom',
197+
glowTarget: '.ugb-style-guide-popover__close-button',
198+
nextEventTarget: '.ugb-style-guide-popover__close-button',
199+
postStep: () => {
200+
document.querySelector( '.ugb-style-guide-popover__close-button' )?.click()
201+
},
202+
},
184203
],
185204
},
186205
'design-library': {

0 commit comments

Comments
 (0)