Skip to content

Commit fe9b376

Browse files
detect size of glow area, added global settings
1 parent b0929a5 commit fe9b376

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@
150150
will-change: transform, box-shadow;
151151
}
152152

153+
.ugb-tour-modal__glow--medium,
154+
.ugb-tour-modal__glow--large {
155+
animation: tour-modal-glow-small 0.7s infinite alternate;
156+
}
157+
153158
// Animation keyframes to grow the box-shadow like it's glowing
154159
@keyframes tour-modal-glow {
155160
0% {
@@ -161,3 +166,15 @@
161166
transform: scaleX(1.05) scaleY(1.12);
162167
}
163168
}
169+
170+
// Animation keyframes for small glow
171+
@keyframes tour-modal-glow-small {
172+
0% {
173+
box-shadow: 0 0 20px #ff2283, 0 0 5px #f00069;
174+
transform: scaleX(1) scaleY(1);
175+
}
176+
100% {
177+
box-shadow: 0 0 50px #ff2283, 0 0 5px #f00069;
178+
transform: scaleX(1.02) scaleY(1.02);
179+
}
180+
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,20 @@ const ModalTour = props => {
158158

159159
// If we have a glow target, create a new element in the body, placed on the top of the target, below the modal.
160160
useEffect( () => {
161-
if ( glowTarget ) {
161+
if ( glowTarget && isVisibleDelayed ) {
162162
// Get the top, left, width, and height of the target.
163163
const target = document.querySelector( glowTarget )
164164
if ( target ) {
165165
const targetRect = target.getBoundingClientRect()
166166

167+
// Estimate the size of the glow target based on the size of the target.
168+
const glowTargetSize = targetRect.width > 300 || targetRect.height > 200 ? 'large'
169+
: targetRect.width > 300 || targetRect.height > 100 ? 'medium'
170+
: 'small'
171+
167172
// Create the element.
168173
const element = document.createElement( 'div' )
169-
element.className = 'ugb-tour-modal__glow'
174+
element.className = `ugb-tour-modal__glow ugb-tour-modal__glow--${ glowTargetSize }`
170175
element.style.top = `${ targetRect.top - 8 }px`
171176
element.style.left = `${ targetRect.left - 8 }px`
172177
element.style.width = `${ targetRect.width + 16 }px`

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ import { __ } from '@wordpress/i18n'
22
import { i18n } from 'stackable'
33

44
export const TOUR_STEPS = {
5+
'design-system-welcome': [
6+
{
7+
title: '👋 ' + __( 'Welcome to Your Design System', 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: '.interface-interface-skeleton__sidebar',
11+
position: 'left',
12+
// nextEventTarget: '.ugb-insert-library-button',
13+
glowTarget: '.interface-interface-skeleton__sidebar',
14+
// showNext: false,
15+
},
16+
],
517
'editor-welcome': [
618
{
719
title: '👋 ' + __( 'Welcome to Stackable', i18n ),

src/plugins/global-settings/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
isContentOnlyMode,
1919
settings,
2020
} from 'stackable'
21+
import { GuidedModalTour } from '~stackable/components'
2122
import { currentUserHasCapability } from '~stackable/util'
2223

2324
/** WordPress dependencies
@@ -78,6 +79,7 @@ const GlobalSettings = () => {
7879
</p>
7980
</PanelBody>
8081
{ globalSettingsInspector }
82+
<GuidedModalTour tourId="design-system-welcome" />
8183
</PluginSidebar>
8284
}
8385
</>

0 commit comments

Comments
 (0)