Skip to content

Commit 86c02b2

Browse files
committed
fix issues from user testing
- modify disabled blocks tooltip - fix block style inheritance not being applied - change 'add color scheme' to 'manage color scheme' - add style option tooltips
1 parent 37fa05a commit 86c02b2

File tree

8 files changed

+64
-39
lines changed

8 files changed

+64
-39
lines changed

src/components/color-schemes-help/index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { dispatch } from '@wordpress/data'
66

77
export const ColorSchemesHelp = props => {
88
const {
9-
customText, callback, renderComponent,
9+
customText, callback, className,
1010
} = props
1111
const onClick = () => {
1212
if ( callback ) {
@@ -37,15 +37,11 @@ export const ColorSchemesHelp = props => {
3737
}, 10 )
3838
}
3939

40-
if ( renderComponent ) {
41-
return renderComponent( onClick )
42-
}
43-
4440
return <>
45-
{ customText ? customText
41+
{ customText || customText === '' ? customText
4642
: <span>{ __( 'Change the color scheme.', i18n ) }</span> }
47-
&nbsp;
48-
<Link onClick={ onClick }> { __( 'Manage your color schemes.', i18n ) } </Link>
43+
{ customText !== '' && <>&nbsp;</> }
44+
<Link className={ className } onClick={ onClick }> { __( 'Manage your color schemes.', i18n ) } </Link>
4945
</>
5046
}
5147

src/components/design-library-list/design-library-list-item.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ const DesignLibraryListItem = forwardRef( ( props, ref ) => {
279279
<div>
280280
<h4> { label } </h4>
281281
{ blocksForSubstitutionRef.current !== false && blocksForSubstitutionRef.current.size !== 0 &&
282-
<Tooltip text={ __( 'This design contains disabled blocks.', i18n ) }>
282+
<Tooltip text={ __( 'This design contains disabled blocks. You can still insert this design with blocks substituted with other enabled blocks.', i18n ) }>
283283
<Dashicon icon="warning" size={ 16 } />
284284
</Tooltip>
285285
}
@@ -317,10 +317,12 @@ const DesignPreview = ( {
317317
setTimeout( adjustScale, 50 )
318318
}, [ blocks, enableBackground ] )
319319

320+
const shadowBodyClasses = classnames( applyFilters( 'stackable.global-styles.classnames', [ 'entry-content' ] ) )
321+
320322
return (
321323
<body
322324
dangerouslySetInnerHTML={ { __html: blocks } }
323-
className="entry-content stk-has-color-schemes stk-has-block-style-inheritance stk-has-design-system-spacing-and-borders stk-has-design-system-buttons-and-icons"
325+
className={ shadowBodyClasses }
324326
style={ { pointerEvents: 'none' } } // prevent blocks from being clicked
325327
/>
326328
)

src/components/modal-design-library/editor.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,4 +433,9 @@ div.ugb-modal-design-library__enable-background {
433433
list-style: circle;
434434
margin-inline-start: 20px;
435435
}
436+
}
437+
438+
.ugb-design-library__manage-scheme {
439+
display: block;
440+
text-align: center;
436441
}

src/components/modal-design-library/modal.js

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { sprintf, __ } from '@wordpress/i18n'
3232
import { useBlockColorSchemes } from '~stackable/hooks'
3333
import ColorSchemePreview from '../color-scheme-preview'
3434
import { ColorSchemesHelp } from '../color-schemes-help'
35+
import Tooltip from '../tooltip'
3536

3637
const PLAN_OPTIONS = [ { key: '', label: __( 'All', i18n ) }, { key: 'free', label: __( 'Free', i18n ) }, { key: 'premium', label: __( 'Premium', i18n ) } ]
3738
const popoverProps = {
@@ -197,13 +198,22 @@ export const ModalDesignLibrary = props => {
197198
<h4 style={ { margin: '0 0 1em ' } }>{ __( 'Style Options', i18n ) }</h4>
198199
<ToggleControl
199200
className="ugb-modal-design-library__enable-background"
200-
label="Section Background"
201+
label={ <Tooltip placement="top" text={ <a href="https://docs.wpstackable.com/article/343-using-the-design-library#Section-Background-KYOys" target="_docs">
202+
{ __( 'Learn more about section background here.', i18n ) }
203+
</a> }>
204+
<span className="stk-control__label--has-tooltip"> { __( 'Section Background', i18n ) }</span>
205+
</Tooltip> }
201206
checked={ enableBackground }
202207
onChange={ value => {
203208
setEnableBackground( value )
204209
} }
205210
/>
206-
<BaseControl label={ `${ __( 'Background Scheme', i18n ) }` }
211+
<BaseControl
212+
label={ <Tooltip placement="top" text={ <a href="https://docs.wpstackable.com/article/343-using-the-design-library#Background-Scheme-Wn_CV" target="_docs">
213+
{ __( 'Learn more about background schemes here.', i18n ) }
214+
</a> }>
215+
<span className="stk-control__label--has-tooltip">{ __( 'Background Scheme', i18n ) }</span>
216+
</Tooltip> }
207217
className="ugb-modal-design-library__color-scheme-label"
208218
>
209219
<Dropdown
@@ -226,7 +236,6 @@ export const ModalDesignLibrary = props => {
226236
? <ColorSchemePreview isCollapsed={ true } colors={ colorSchemesCollection[ selectedBackgroundScheme || backgroundModeColorScheme ].desktopColors } />
227237
: <ColorSchemeTextItem label={ __( 'Default', i18n ) } />
228238
}
229-
230239
</Button>
231240
) }
232241
renderContent={ ( { onClose } ) => (
@@ -264,27 +273,22 @@ export const ModalDesignLibrary = props => {
264273
</Button>
265274
} ) }
266275
{ Object.keys( colorSchemesCollection ).length
267-
? <ColorSchemesHelp renderComponent={ onClick => (
268-
<Button
269-
className="ugb-modal-design-library__stk-color-scheme"
270-
onClick={ () => {
271-
props.onClose()
272-
onClick()
273-
} }
274-
>
275-
<span className="stk-color-scheme-name stk-color-scheme__none"> { __( 'Add Color Scheme', i18n ) } </span>
276-
</Button>
277-
) } />
276+
? <ColorSchemesHelp customText="" callback={ props.onClose } className="ugb-design-library__manage-scheme" />
278277
: <ColorSchemesHelp customText={ __( 'You do not have any color schemes.', i18n ) } callback={ props.onClose } />
279278
}
280279
</div>
281280
</div>
282281
) }
283282
/>
284283
</BaseControl>
285-
<BaseControl label={ `${ __( 'Container Scheme', i18n ) }` }
286-
287-
className="ugb-modal-design-library__color-scheme-label">
284+
<BaseControl
285+
label={ <Tooltip placement="top" text={ <a href="https://docs.wpstackable.com/article/343-using-the-design-library#Container-Scheme-HyK91" target="_docs">
286+
{ __( 'Learn more about container schemes here.', i18n ) }
287+
</a> }>
288+
<span className="stk-control__label--has-tooltip">{ __( 'Container Scheme', i18n ) }</span>
289+
</Tooltip> }
290+
className="ugb-modal-design-library__color-scheme-label"
291+
>
288292
<Dropdown
289293
popoverProps={ popoverProps }
290294
focusOnMount={ false }
@@ -334,17 +338,7 @@ export const ModalDesignLibrary = props => {
334338
</Button>
335339
} ) }
336340
{ Object.keys( colorSchemesCollection ).length
337-
? <ColorSchemesHelp renderComponent={ onClick => (
338-
<Button
339-
className="ugb-modal-design-library__stk-color-scheme"
340-
onClick={ () => {
341-
props.onClose()
342-
onClick()
343-
} }
344-
>
345-
<span className="stk-color-scheme-name stk-color-scheme__none"> { __( 'Add Color Scheme', i18n ) } </span>
346-
</Button>
347-
) } />
341+
? <ColorSchemesHelp customText="" callback={ props.onClose } className="ugb-design-library__manage-scheme" />
348342
: <ColorSchemesHelp customText={ __( 'You do not have any color schemes.', i18n ) } callback={ props.onClose } />
349343
}
350344
</div>

src/plugins/editor-device-preview-class/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useDeviceType, useBlockHoverState } from '~stackable/hooks'
1515
import { useEffect } from '@wordpress/element'
1616
import { useSelect } from '@wordpress/data'
1717
import { registerPlugin } from '@wordpress/plugins'
18+
import { addFilter } from '@wordpress/hooks'
1819

1920
const EditorPreviewClass = () => {
2021
const deviceType = useDeviceType()
@@ -45,6 +46,10 @@ const EditorPreviewClass = () => {
4546
if ( document.querySelector( 'body' ).className.match( themeRegex ) && ! editorEl.className.match( themeRegex ) ) {
4647
const theme = document.querySelector( 'body' ).className.match( themeRegex )[ 0 ]
4748
editorEl.classList.add( theme )
49+
addFilter( 'stackable.global-styles.classnames', 'stackable/theme-classname', styleIds => {
50+
styleIds.push( theme )
51+
return styleIds
52+
} )
4853
}
4954

5055
// At first load of the editor, the `stk-preview-device-*` and `stk--is-*-theme` are removed, so we have to re-add it.
@@ -60,6 +65,10 @@ const EditorPreviewClass = () => {
6065
if ( document.querySelector( 'body' ).className.match( themeRegex ) && ! editorEl.className.match( themeRegex ) ) {
6166
const theme = document.querySelector( 'body' ).className.match( themeRegex )[ 0 ]
6267
editorEl.classList.add( theme )
68+
addFilter( 'stackable.global-styles.classnames', 'stackable/theme-classname', styleIds => {
69+
styleIds.push( theme )
70+
return styleIds
71+
} )
6372
}
6473
} )
6574

src/plugins/global-settings/color-schemes/editor-loader.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { useBlockColorSchemes, useBlockHoverState } from '~stackable/hooks'
1717
*/
1818
import { useEffect, useState } from '@wordpress/element'
1919
import { useSelect } from '@wordpress/data'
20+
import { addFilter } from '@wordpress/hooks'
2021
const renderGlobalStyles = (
2122
setStyles,
2223
colorSchemesArray,
@@ -148,6 +149,10 @@ export const GlobalColorSchemeStyles = () => {
148149
const mo = onClassChange( editorEl, () => {
149150
if ( styles !== '' && editorEl?.classList.contains( 'stk-has-color-schemes' ) === false ) {
150151
editorEl?.classList.add( 'stk-has-color-schemes' )
152+
addFilter( 'stackable.global-styles.classnames', `stackable/global-settings.color-schemes`, classnames => {
153+
classnames.push( 'stk-has-color-schemes' )
154+
return classnames
155+
} )
151156
}
152157
if ( styles === '' ) {
153158
editorEl?.classList.remove( 'stk-has-color-schemes' )

src/plugins/global-settings/utils/use-block-layout-editor-loader.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { getDefault, onClassChange } from './block-layout-utils'
88
*/
99
import { useSelect } from '@wordpress/data'
1010
import { useEffect, useState } from '@wordpress/element'
11+
import { addFilter } from '@wordpress/hooks'
1112

1213
/**
1314
* External dependencies
@@ -167,6 +168,10 @@ export const useBlockLayoutEditorLoader = ( storeName, classSuffix ) => {
167168
const className = `stk-has-design-system-${ classSuffix }`
168169
if ( styles !== '' && editorEl.classList.contains( className ) === false ) {
169170
editorEl.classList.add( className )
171+
addFilter( 'stackable.global-styles.classnames', `stackable/global-settings.${ classSuffix }`, classnames => {
172+
classnames.push( className )
173+
return classnames
174+
} )
170175
}
171176
if ( styles === '' ) {
172177
editorEl.classList.remove( className )

src/plugins/theme-block-style-inheritance/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { fetchSettings } from '~stackable/util'
99
import { useEffect, useState } from '@wordpress/element'
1010
import { useSelect } from '@wordpress/data'
1111
import { registerPlugin } from '@wordpress/plugins'
12+
import { addFilter } from '@wordpress/hooks'
1213

1314
// Adds a body class for block style inheritance
1415
const ThemeBlockStyleInheritanceClass = () => {
@@ -19,7 +20,15 @@ const ThemeBlockStyleInheritanceClass = () => {
1920

2021
useEffect( () => {
2122
fetchSettings().then( response => {
22-
setDisableBlockStyleInheritance( response.stackable_disable_block_style_inheritance )
23+
const isDisabled = response.stackable_disable_block_style_inheritance
24+
setDisableBlockStyleInheritance( isDisabled )
25+
26+
if ( ! isDisabled ) {
27+
addFilter( 'stackable.global-styles.classnames', `stackable/global-settings.block-style-inheritance`, classnames => {
28+
classnames.push( 'stk-has-block-style-inheritance' )
29+
return classnames
30+
} )
31+
}
2332
} )
2433
}, [] )
2534

0 commit comments

Comments
 (0)