Skip to content

Commit 9069672

Browse files
committed
Merge branch 'develop' into fix/3500-sunset-block-defaults
# Conflicts: # e2e/tests/global-settings.spec.ts
2 parents 5d3a6ca + 8654d2e commit 9069672

File tree

12 files changed

+123
-59
lines changed

12 files changed

+123
-59
lines changed

.prettierignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Ignore JavaScript files to prevent conflicts with ESLint
2+
*.js
3+
*.jsx
4+
*.ts
5+
*.tsx
6+
7+
# Ignore build files
8+
dist/
9+
build/
10+
node_modules/
11+
12+
# Ignore other files that shouldn't be formatted
13+
*.min.js
14+
*.min.css

.vscode/settings.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
{
22
"editor.codeActionsOnSave": {
3-
"source.fixAll.eslint": true,
4-
"source.fixAll.stylelint": true
3+
"source.fixAll.eslint": "explicit",
4+
"source.fixAll.stylelint": "explicit"
55
},
66
"editor.formatOnSave": false,
7-
"eslint.validate": [
8-
"javascript"
9-
],
7+
"editor.defaultFormatter": null,
8+
"[javascript]": {
9+
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
10+
"editor.formatOnSave": false
11+
},
12+
"[javascriptreact]": {
13+
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
14+
"editor.formatOnSave": false
15+
},
1016
"stylelint.validate": [
1117
"css",
1218
"scss"
1319
]
14-
}
20+
}

e2e/tests/global-settings.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test.describe( 'Global Settings', () => {
2020
page,
2121
editor,
2222
} ) => {
23-
await page.getByLabel( 'Stackable Settings' ).click()
23+
await page.getByLabel( 'Stackable Design System' ).click()
2424
await page.getByRole( 'button', { name: 'Global Color Palette' } ).click()
2525

2626
// Add a new Global Color
@@ -66,7 +66,7 @@ test.describe( 'Global Settings', () => {
6666
await page.locator( '.stk-color-palette-control .stk-control-content > .components-dropdown > .components-button' ).first().click()
6767

6868
// Delete added Global Color
69-
await page.getByLabel( 'Stackable Settings' ).click()
69+
await page.getByLabel( 'Stackable Design System' ).click()
7070

7171
page.on( 'dialog', async dialog => await dialog.accept() )
7272
const deleteRequest = page.waitForResponse( response => response.url().includes( 'wp/v2/settings' ) && response.request().method() === 'POST' )
@@ -82,7 +82,7 @@ test.describe( 'Global Settings', () => {
8282
page,
8383
editor,
8484
} ) => {
85-
await page.getByLabel( 'Stackable Settings' ).click()
85+
await page.getByLabel( 'Stackable Design System' ).click()
8686
await page.getByRole( 'button', { name: 'Global Typography' } ).click()
8787

8888
// Set Global Typography Styles of Heading 2 to have a text-transform uppercase
@@ -107,7 +107,7 @@ test.describe( 'Global Settings', () => {
107107
await expect( editor.canvas.locator( '[data-type="stackable/heading"] > .stk-block-heading > h2[role="textbox"]' ) ).toHaveCSS( 'text-transform', 'uppercase' )
108108

109109
// Reset Global Typography Styles
110-
await page.getByLabel( 'Stackable Settings' ).click()
110+
await page.getByLabel( 'Stackable Design System' ).click()
111111

112112
const resetButton = page.locator( '.ugb-global-settings-typography-control' ).nth( 1 ).getByLabel( 'Reset' )
113113
const deleteRequest = page.waitForResponse( response => response.url().includes( 'wp/v2/settings' ) && response.request().method() === 'POST' )

readme.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Add animations that will bring your site to life and make it more visually engag
252252

253253
= Minimum Requirements =
254254

255-
You'll need WordPress version 6.3 or higher for this to work.
255+
You'll need WordPress version 6.5.5 or higher for this to work.
256256

257257
== Frequently Asked Questions ==
258258

@@ -304,6 +304,10 @@ Nope. Stackable only works with Gutenberg, the new WordPress editor.
304304

305305
== Changelog ==
306306

307+
= 3.17.2 =
308+
* Fixed: If using non-English locale, Google Fonts may not load properly in the editor
309+
* Fixed: Do not create a new design library block if there already is one
310+
307311
= 3.17.1 =
308312
* Fixed: Progress circle block - having a prefix/suffix with dynamic content now works #3499
309313
* Fixed: Image block - image becomes small when using a design library item then changing it to dynamic content #3522

src/block/design-library/edit.js

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
srcUrl,
88
settings,
99
cdnUrl,
10+
devMode,
1011
} from 'stackable'
1112
import {
1213
Button,
@@ -163,9 +164,12 @@ const Edit = props => {
163164

164165
const customAttributes = block.attributes.customAttributes
165166

166-
const indexToDelete = customAttributes?.findIndex( attribute => attribute[ 0 ] === 'stk-design-library__bg-target' )
167-
if ( customAttributes && indexToDelete !== -1 ) {
168-
block.attributes.customAttributes.splice( indexToDelete, 1 )
167+
const isDesignLibraryDevMode = devMode && localStorage.getItem( 'stk__design_library__dev_mode' ) === '1'
168+
if ( ! isDesignLibraryDevMode ) {
169+
const indexToDelete = customAttributes?.findIndex( attribute => attribute[ 0 ] === 'stk-design-library__bg-target' )
170+
if ( customAttributes && indexToDelete !== -1 ) {
171+
block.attributes.customAttributes.splice( indexToDelete, 1 )
172+
}
169173
}
170174

171175
for ( const attributeName in block.attributes ) {
@@ -189,30 +193,33 @@ const Edit = props => {
189193
attributes = block[ 0 ].attributes
190194
innerBlocks = block[ 0 ].innerBlocks
191195

192-
if ( category !== 'Header' ) {
193-
if ( ! parentClientId && attributes.hasBackground ) {
194-
attributes.blockMargin = {
195-
top: '',
196-
right: '',
197-
bottom: '0',
198-
left: '',
199-
}
200-
} else if ( ! parentClientId ) {
201-
attributes.blockMargin = {
202-
top: spacingSize,
203-
right: '',
204-
bottom: spacingSize,
205-
left: '',
196+
const isDesignLibraryDevMode = devMode && localStorage.getItem( 'stk__design_library__dev_mode' ) === '1'
197+
if ( ! isDesignLibraryDevMode ) {
198+
if ( category !== 'Header' ) {
199+
if ( ! parentClientId && attributes.hasBackground ) {
200+
attributes.blockMargin = {
201+
top: '',
202+
right: '',
203+
bottom: '0',
204+
left: '',
205+
}
206+
} else if ( ! parentClientId ) {
207+
attributes.blockMargin = {
208+
top: spacingSize,
209+
right: '',
210+
bottom: spacingSize,
211+
left: '',
212+
}
206213
}
207-
}
208214

209-
const blockLayouts = select( 'stackable/global-spacing-and-borders' ).getBlockLayouts()
210-
if ( attributes.hasBackground && typeof blockLayouts === 'object' && ! blockLayouts[ 'block-background-padding' ] ) {
211-
attributes.blockPadding = {
212-
top: spacingSize,
213-
right: spacingSize,
214-
bottom: spacingSize,
215-
left: spacingSize,
215+
const blockLayouts = select( 'stackable/global-spacing-and-borders' ).getBlockLayouts()
216+
if ( attributes.hasBackground && typeof blockLayouts === 'object' && ! blockLayouts[ 'block-background-padding' ] ) {
217+
attributes.blockPadding = {
218+
top: spacingSize,
219+
right: spacingSize,
220+
bottom: spacingSize,
221+
left: spacingSize,
222+
}
216223
}
217224
}
218225
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
*/
1616
import { createRoot } from '~stackable/util'
1717
import {
18-
isPro, i18n, wpGlobalStylesInlineCss,
18+
isPro, i18n, wpGlobalStylesInlineCss, devMode,
1919
} from 'stackable'
2020
import classnames from 'classnames'
2121
import { Tooltip } from '~stackable/components'
@@ -162,7 +162,9 @@ const DesignLibraryListItem = forwardRef( ( props, ref ) => {
162162
useEffect( () => {
163163
const defaultValues = DEFAULT_CONTENT[ category ]
164164
let _content = template
165-
if ( defaultValues ) {
165+
166+
const isDesignLibraryDevMode = devMode && localStorage.getItem( 'stk__design_library__dev_mode' ) === '1'
167+
if ( defaultValues && ! isDesignLibraryDevMode ) {
166168
Object.keys( defaultValues ).forEach( key => {
167169
_content = _content.replaceAll( key, defaultValues[ key ] )
168170
} )

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

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ div.ugb-modal-design-library__enable-background {
319319
margin-bottom: 0 !important;
320320
margin: 0 auto;
321321

322-
.components-base-control__field, .stk-control-label {
322+
.components-base-control__field,
323+
.stk-control-label {
323324
margin: 0;
324325
}
325326
.components-button-group {
@@ -357,16 +358,16 @@ div.ugb-modal-design-library__enable-background {
357358

358359

359360
.ugb-modal-design-library__stk-color-scheme {
360-
display: flex;
361-
align-items: center;
362-
gap: 8px;
363-
outline: 1px solid #e0e0e0;
364-
border-radius: 2px;
361+
display: flex;
362+
align-items: center;
363+
gap: 8px;
364+
outline: 1px solid #e0e0e0;
365+
border-radius: 2px;
365366
margin-bottom: 8px;
366367
padding: 0;
367368
height: auto;
368369
width: 100%;
369-
&:hover {
370+
&:hover {
370371
&.stk-color-scheme__toggle .stk-color-scheme__none,
371372
.stk-global-color-scheme__preview {
372373
color: initial;
@@ -377,7 +378,8 @@ div.ugb-modal-design-library__enable-background {
377378
}
378379

379380
&.stk-color-scheme__selected {
380-
&, &:active {
381+
&,
382+
&:active {
381383
outline: 2px solid var(--wp-admin-theme-color, #f00069);
382384
color: var(--wp-admin-theme-color, #f00069);
383385
}
@@ -408,8 +410,12 @@ div.ugb-modal-design-library__enable-background {
408410
display: flex;
409411
gap: 10px;
410412
align-items: center;
413+
.components-toggle-control {
414+
margin-bottom: 0;
415+
}
411416
}
412-
.stk-design-library__plan-dropdown, .ugb-design-library__color-scheme-popover {
417+
.stk-design-library__plan-dropdown,
418+
.ugb-design-library__color-scheme-popover {
413419
--wp-admin-theme-color: #f00069;
414420
--wp-admin-theme-color-darker-10: #{ darken(#f00069, 10%) };
415421
--wp-admin-theme-color-darker-20: #{ darken(#f00069, 20%) };
@@ -444,7 +450,7 @@ div.ugb-modal-design-library__enable-background {
444450
max-width: 800px;
445451
ul {
446452
list-style: circle;
447-
margin-inline-start: 20px;
453+
margin-inline-start: 20px;
448454
}
449455
}
450456

@@ -462,11 +468,11 @@ div.ugb-modal-design-library__enable-background {
462468
}
463469

464470
.ugb-modal-design-library__stk-color-scheme-list-header {
465-
display: flex;
466-
justify-content: space-between;
467-
padding: 0;
468-
margin: 0 0 4px;
469-
border-bottom: 1px solid #e0e0e0;
471+
display: flex;
472+
justify-content: space-between;
473+
padding: 0;
474+
margin: 0 0 4px;
475+
border-bottom: 1px solid #e0e0e0;
470476

471477
p {
472478
margin: 6px 6px 4px;

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import { getDesigns, filterDesigns } from '~stackable/design-library'
1111
/**
1212
* External deprendencies
1313
*/
14-
import { i18n, isPro } from 'stackable'
14+
import {
15+
i18n, isPro, devMode,
16+
} from 'stackable'
1517
import classnames from 'classnames'
1618
import { useLocalStorage } from '~stackable/util'
1719

@@ -155,6 +157,19 @@ export const ModalDesignLibrary = props => {
155157
/> */ }
156158

157159
<div className="stk-design-library__header-settings">
160+
{ devMode && (
161+
<ToggleControl
162+
label="Dev Mode"
163+
checked={ !! localStorage.getItem( 'stk__design_library__dev_mode' ) || false }
164+
onChange={ value => {
165+
localStorage.setItem( 'stk__design_library__dev_mode', value ? '1' : '' )
166+
setTimeout( () => {
167+
document?.querySelector( '.ugb-insert-library-button__wrapper .ugb-insert-library-button' ).click()
168+
}, 100 )
169+
props.onClose()
170+
} }
171+
/>
172+
) }
158173
<Button
159174
icon="image-rotate"
160175
iconSize={ 14 }

src/plugins/design-library-button/design-library-button.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ const DesignLibraryButton = () => {
1717
const { getEditorDom } = useSelect( 'stackable/editor-dom' )
1818

1919
const onClick = useCallback( () => {
20+
// If there's a design library block already in the editor, just open it.
21+
if ( getEditorDom()?.querySelector( '[data-type="stackable/design-library"]' ) ) {
22+
const button = getEditorDom()?.querySelector( `[data-type="stackable/design-library"] button` )
23+
// Open the design library.
24+
if ( button ) {
25+
button.click()
26+
}
27+
return
28+
}
29+
2030
// Insert a design library block.
2131
const block = createBlock( 'stackable/design-library' )
2232

src/plugins/global-settings/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const GlobalSettings = () => {
6565
{ PluginSidebar && userCanManageOptions &&
6666
<PluginSidebar
6767
name="sidebar"
68-
title={ __( 'Stackable Settings', i18n ) }
68+
title={ __( 'Stackable Design System', i18n ) }
6969
className="ugb-global-settings__inspector"
7070
icon={ <SVGStackableIcon /> }
7171
>

0 commit comments

Comments
 (0)