Skip to content

Commit 3330c34

Browse files
finalized design library
1 parent b0000eb commit 3330c34

File tree

3 files changed

+67
-11
lines changed

3 files changed

+67
-11
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@
145145
}
146146
}
147147
}
148+
&.ugb-tour-modal--top-right {
149+
.components-modal__content {
150+
&::after {
151+
left: auto;
152+
right: 16px;
153+
}
154+
}
155+
}
148156
&.ugb-tour-modal--bottom {
149157
.components-modal__content {
150158
box-shadow: rgba(0, 0, 0, 0.2) 0px -22px 60px -4px;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ const ModalTour = props => {
261261
let clickListener = null
262262

263263
if ( nextEventTarget ) {
264-
if ( nextEvent === 'click' ) {
264+
if ( nextEvent === 'click' || nextEvent === 'mousedown' ) {
265265
clickListener = event => {
266266
// Check if the event target matches the selector or is inside an element that matches
267267
if (
@@ -273,7 +273,7 @@ const ModalTour = props => {
273273
}
274274
// Use ownerDocument instead of document directly
275275
const doc = modalRef.current?.ownerDocument || document
276-
doc.addEventListener( 'click', clickListener )
276+
doc.addEventListener( nextEvent, clickListener )
277277
} else {
278278
const elements = document.querySelectorAll( nextEventTarget )
279279
for ( let i = 0; i < elements.length; i++ ) {
@@ -284,10 +284,10 @@ const ModalTour = props => {
284284

285285
return () => {
286286
if ( nextEventTarget ) {
287-
if ( nextEvent === 'click' && clickListener ) {
287+
if ( ( nextEvent === 'click' || nextEvent === 'mousedown' ) && clickListener ) {
288288
// Use ownerDocument instead of document directly
289289
const doc = modalRef.current?.ownerDocument || document
290-
doc.removeEventListener( 'click', clickListener )
290+
doc.removeEventListener( nextEvent, clickListener )
291291
} else {
292292
const elements = document.querySelectorAll( nextEventTarget )
293293
for ( let i = 0; i < elements.length; i++ ) {
@@ -356,7 +356,7 @@ const ModalTour = props => {
356356
case 'top-left':
357357
return [ `${ anchorRect.left + 16 }px`, `${ anchorRect.top - modalRect.height - 16 }px` ]
358358
case 'top-right':
359-
return [ `${ anchorRect.right - modalRect.width - 16 }px`, `${ anchorRect.top + 16 }px` ]
359+
return [ `${ anchorRect.right - modalRect.width - 16 }px`, `${ anchorRect.top - modalRect.height - 16 }px` ]
360360
case 'bottom':
361361
// Center, bottom
362362
return [ `${ anchorRect.left + ( anchorRect.width / 2 ) - ( modalRect.width / 2 ) }px`, `${ anchorRect.bottom + 16 }px` ]

src/components/guided-modal-tour/tours/design-library.js

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ export const designLibrary = {
2020
} ),
2121
size: 'medium',
2222
nextEventTarget: '.ugb-design-library-item',
23+
nextEvent: 'mousedown',
2324
offsetX: '-400px',
25+
postStep: () => {
26+
// Make sure the first one (or at least there is one) that's toggled
27+
if ( ! document.querySelector( '.ugb-design-library-item.ugb--is-toggled' ) ) {
28+
document.querySelector( '.ugb-design-library-item' )?.click()
29+
}
30+
},
2431
},
2532
{
2633
title: __( 'Pick Styling Options', i18n ),
@@ -63,15 +70,56 @@ export const designLibrary = {
6370
},
6471
{
6572
title: __( 'Patterns and Full-Pages', i18n ),
66-
description: __( 'Great! Your entire library is now styled. Aside from patterns, there are also full-page layouts in the library.', i18n ),
67-
help: createInterpolateElement( __( 'Click the <strong>Pages</strong> tab to continue.', i18n ), {
73+
description: __( 'Great! Your entire library is now styled. Aside from patterns, Stackable also provides you with full-page layouts.', i18n ),
74+
help: createInterpolateElement( __( 'Click the <strong>Next</strong> to continue.', i18n ), {
6875
strong: <strong />,
6976
} ),
70-
// TODO: Change these when we have the pages tab already.
71-
anchor: '.ugb-modal-design-library .components-modal__header',
77+
anchor: '.stk-design-library-tabs .components-button-group',
7278
position: 'bottom',
73-
nextEventTarget: '.ugb-modal-design-library .components-modal__header',
74-
glowTarget: '.ugb-modal-design-library .components-modal__header',
79+
nextEventTarget: '.stk-design-library-tabs .components-button-group',
80+
glowTarget: '.stk-design-library-tabs .components-button-group',
81+
preStep: () => {
82+
// Disable for now the pages tab
83+
const pagesButton = document.querySelector( '.stk-design-library-tabs button[value="pages"]' )
84+
if ( pagesButton ) {
85+
pagesButton.disabled = true
86+
}
87+
},
88+
postStep: () => {
89+
// Enable the pages tab
90+
const pagesButton = document.querySelector( '.stk-design-library-tabs button[value="pages"]' )
91+
if ( pagesButton ) {
92+
pagesButton.disabled = false
93+
}
94+
},
95+
},
96+
{
97+
title: __( 'Let\'s Insert Our Pattern', i18n ),
98+
description: __( 'Now let\'s insert our pattern into our page.', i18n ),
99+
help: createInterpolateElement( __( 'Click on <strong>Add Designs</strong> to continue.', i18n ), {
100+
strong: <strong />,
101+
} ),
102+
anchor: '.ugb-modal-design-library__add-multi',
103+
position: 'top-right',
104+
nextEventTarget: '.ugb-modal-design-library__add-multi',
105+
glowTarget: '.ugb-modal-design-library__add-multi',
106+
preStep: () => {
107+
// Make sure the patterns tab is selected
108+
document.querySelector( '.ugb-modal-design-library button[value="patterns"]:not(.is-primary)' )?.click()
109+
110+
// Make sure the first one (or at least there is one) that's toggled
111+
if ( ! document.querySelector( '.ugb-design-library-item.ugb--is-toggled' ) ) {
112+
document.querySelector( '.ugb-design-library-item' )?.click()
113+
}
114+
},
115+
postStep: () => {
116+
setTimeout( () => {
117+
// If the design library is still open, click the add button.
118+
if ( document.querySelector( '.ugb-modal-design-library' ) ) {
119+
document.querySelector( '.ugb-modal-design-library__add-multi' )?.click()
120+
}
121+
}, 100 )
122+
},
75123
},
76124
],
77125
}

0 commit comments

Comments
 (0)