Skip to content

Commit 7d0dfb8

Browse files
refactored tours, added block tour
1 parent 03139ec commit 7d0dfb8

File tree

15 files changed

+813
-299
lines changed

15 files changed

+813
-299
lines changed

src/block-components/alignment/edit.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ export const Edit = memo( props => {
201201
selector: ', .stk-block-columns:has( > .stk-inner-blocks > * > * > [data-type="stackable/column"] > * > .stk-%s)',
202202
highlight: 'outline-second-offset',
203203
} }
204+
className="ugb-column-align-control"
204205
/>
205206
}
206207
{ props.hasRowAlignment &&

src/block-components/block-div/edit.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export const Edit = memo( props => {
9090
checked={ hasBackground }
9191
onChange={ hasBackground => setAttributes( { hasBackground } ) }
9292
initialOpen={ initialOpen === 'background' }
93+
className="ugb-block-background-panel"
9394
>
9495
<AdvancedSelectControl
9596
label={ __( 'Color Scheme', i18n ) }
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
import { registerPlugin } from '@wordpress/plugins'
3+
import GuidedModalTour from './index'
4+
5+
const EditorBlockTour = () => {
6+
return <GuidedModalTour tourId="blocks" />
7+
}
8+
9+
registerPlugin( 'stackable-editor-block-tour', {
10+
render: EditorBlockTour,
11+
} )

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
transform: scale(1);
4646
}
4747

48+
.components-modal__header-heading {
49+
line-height: 1.2;
50+
}
51+
4852
.components-button {
4953
border-radius: 4px;
5054
}
@@ -123,6 +127,13 @@
123127
}
124128
}
125129
}
130+
&.ugb-tour-modal--left-top {
131+
.components-modal__content {
132+
&::after {
133+
top: 30px;
134+
}
135+
}
136+
}
126137
&.ugb-tour-modal--top {
127138
.components-modal__content {
128139
box-shadow: rgba(0, 0, 0, 0.2) 0px 22px 60px -4px;

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Internal dependencies
33
*/
44
import { TOUR_STEPS } from './tour-steps'
5+
import './editor-block-tour'
56

67
/**
78
* External dependencies
@@ -46,6 +47,7 @@ const GuidedModalTour = props => {
4647
steps = [],
4748
condition = null,
4849
hasConfetti = true,
50+
initialize = NOOP,
4951
} = TOUR_STEPS[ tourId ]
5052

5153
if ( justCompleted ) {
@@ -72,6 +74,7 @@ const GuidedModalTour = props => {
7274
return <ModalTour
7375
steps={ steps }
7476
hasConfetti={ hasConfetti }
77+
initialize={ initialize }
7578
onClose={ () => {
7679
setIsDone( true )
7780
setJustCompleted( true )
@@ -99,6 +102,7 @@ const ModalTour = props => {
99102
steps,
100103
onClose = NOOP,
101104
hasConfetti = true,
105+
initialize = NOOP,
102106
} = props
103107

104108
const [ currentStep, setCurrentStep ] = useState( 0 )
@@ -132,6 +136,12 @@ const ModalTour = props => {
132136
skipIf = NOOP, // If provided, this is a function to check if the step should be skipped.
133137
} = steps[ currentStep ]
134138

139+
useEffect( () => {
140+
setTimeout( () => {
141+
initialize()
142+
}, 50 )
143+
}, [ initialize ] )
144+
135145
// While the modal is visible, just keep on force refreshing the modal in an interval to make sure the modal is always in the correct position.
136146
useEffect( () => {
137147
let interval
@@ -418,10 +428,14 @@ const ModalTour = props => {
418428
shouldCloseOnClickOutside={ false }
419429
size={ size }
420430
// onRequestClose={ onClose } // Do not use onRequestClose, it will cause the tour finish
421-
className={ classNames( 'ugb-tour-modal', `ugb-tour-modal--${ position.replace( /-.*$/, '' ) }`, {
422-
'ugb-tour-modal--visible': isVisible,
423-
'ugb-tour-modal--visible-delayed': isVisibleDelayed,
424-
} ) }
431+
className={ classNames(
432+
'ugb-tour-modal',
433+
`ugb-tour-modal--${ position.replace( /-.*$/, '' ) }`,
434+
`ugb-tour-modal--${ position }`,
435+
{
436+
'ugb-tour-modal--visible': isVisible,
437+
'ugb-tour-modal--visible-delayed': isVisibleDelayed,
438+
} ) }
425439
ref={ modalRef }
426440
>
427441
<style>

0 commit comments

Comments
 (0)