Skip to content

Commit 3d49f58

Browse files
committed
Merge branch 'develop' of github.com:BracketSpace/DoW-Starter-Theme into develop
2 parents b4cf690 + 67404b1 commit 3d49f58

File tree

8 files changed

+119
-47
lines changed

8 files changed

+119
-47
lines changed

.tools/utils/generate-theme-json.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import { mapValues, pick, startCase } from 'lodash-es';
1010
import { loadConfig, saveConfig } from './config.js';
1111

1212
const getColorPalette = async () =>
13-
Object.entries(await loadConfig('colors')).map(([slug, color]) => ({
14-
slug,
15-
color,
16-
name: startCase(slug),
17-
}));
13+
Object.entries(await loadConfig('colors'))
14+
.filter(([slug]) => !slug.startsWith('_'))
15+
.map(([slug, color]) => ({
16+
slug,
17+
color,
18+
name: startCase(slug),
19+
}));
1820

1921
const getLayoutSettings = async () =>
2022
mapValues(

config/app.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// phpcs:disable SlevomatCodingStandard.Namespaces.UseFromSameNamespace.UseFromSameNamespace
66

77
use DoWStarterTheme\Common\{
8+
Assets,
89
Customizer,
910
Helpers,
1011
Hooks,
@@ -38,6 +39,10 @@
3839
CommonIntegrations\ACF::class,
3940
CommonIntegrations\ACFBlockCreator::class,
4041

42+
// Assets
43+
Assets\MainScript::class,
44+
Assets\MainStyle::class,
45+
4146
// Block Editor Integration
4247
CommonIntegrations\Editor\Editor::class,
4348

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const MIN_SPACER_HEIGHT = 20;
2-
export const MAX_SPACER_HEIGHT = 500;
2+
export const MAX_SPACER_HEIGHT = 300;
33
export const MAX_MOBILE_HEIGHT = 40;

src/assets/ts/blocks/responsiveSpacer/edit.tsx

Lines changed: 63 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
/**
22
* External dependencies
33
*/
4-
import { FC } from 'react';
4+
import { FC, useEffect, useState } from 'react';
55
import classnames from 'classnames';
66

77
/**
88
* WordPress dependencies
99
*/
1010
import { __ } from '@wordpress/i18n';
11-
import { InspectorControls } from '@wordpress/block-editor';
11+
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
1212
import {
1313
TextControl,
1414
PanelBody,
1515
RangeControl,
1616
ResizableBox,
1717
ToggleControl,
1818
} from '@wordpress/components';
19+
import { View } from '@wordpress/primitives';
1920

2021
/**
2122
* Internal dependencies
@@ -31,6 +32,13 @@ const Edit: FC<BlockEditProps> = ({
3132
isSelected,
3233
toggleSelection,
3334
}) => {
35+
const [isResizing, setIsResizing] = useState(false);
36+
const [_height, setHeight] = useState(height);
37+
38+
useEffect(() => {
39+
setHeight(height);
40+
}, [height]);
41+
3442
const updateTabletHeight = (value: number | undefined) =>
3543
setAttributes({ tabletHeight: value });
3644

@@ -54,44 +62,60 @@ const Edit: FC<BlockEditProps> = ({
5462

5563
return (
5664
<>
57-
<ResizableBox
58-
className={classnames(
59-
'block-library-spacer__resize-container',
60-
className,
61-
{
62-
'is-selected': isSelected,
63-
}
64-
)}
65-
size={{
66-
height,
67-
width: '100%',
68-
}}
69-
minHeight={MIN_SPACER_HEIGHT}
70-
enable={{
71-
top: false,
72-
right: false,
73-
bottom: true,
74-
left: false,
75-
topRight: false,
76-
bottomRight: false,
77-
bottomLeft: false,
78-
topLeft: false,
79-
}}
80-
onResizeStart={() => toggleSelection && toggleSelection(false)}
81-
onResizeStop={(event, direction, elt, delta) => {
82-
if (toggleSelection) {
83-
toggleSelection(true);
84-
}
65+
<View
66+
{...useBlockProps({
67+
style: {
68+
height: _height,
69+
},
70+
})}
71+
>
72+
<ResizableBox
73+
className={classnames(
74+
'block-library-spacer__resize-container',
75+
className,
76+
{
77+
'is-resizing': isResizing,
78+
'is-selected': isSelected,
79+
}
80+
)}
81+
minHeight={MIN_SPACER_HEIGHT}
82+
enable={{
83+
top: false,
84+
right: false,
85+
bottom: true,
86+
left: false,
87+
topRight: false,
88+
bottomRight: false,
89+
bottomLeft: false,
90+
topLeft: false,
91+
}}
92+
onResizeStart={() => {
93+
if (toggleSelection) {
94+
toggleSelection(false);
95+
}
96+
97+
setIsResizing(true);
98+
}}
99+
onResizeStop={(event, direction, elt) => {
100+
if (toggleSelection) {
101+
toggleSelection(true);
102+
}
103+
104+
updateHeight(elt.clientHeight);
105+
106+
setIsResizing(false);
107+
}}
108+
onResize={(event, direction, elt) => {
109+
if (!isResizing) {
110+
setIsResizing(true);
111+
}
85112

86-
const spacerHeight = Math.min(
87-
height + delta.height,
88-
MAX_SPACER_HEIGHT
89-
);
90-
updateHeight(spacerHeight);
91-
}}
92-
showHandle={isSelected}
93-
children={undefined} // Fix TypeScript error due to invalid types
94-
/>
113+
setHeight(elt.clientHeight);
114+
}}
115+
showHandle={isSelected}
116+
children={undefined} // Fix TypeScript error due to invalid types
117+
/>
118+
</View>
95119
<InspectorControls>
96120
<PanelBody title={__('Size settings')}>
97121
<RangeControl
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoWStarterTheme\Common\Assets;
6+
7+
class MainScript extends Script
8+
{
9+
/**
10+
* Enqueues asset.
11+
*
12+
* @action wp_enqueue_scripts
13+
*/
14+
public function enqueueAsset(): void
15+
{
16+
$this->enqueue();
17+
}
18+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoWStarterTheme\Common\Assets;
6+
7+
class MainStyle extends Style
8+
{
9+
protected string $name = 'style';
10+
11+
/**
12+
* Enqueues asset.
13+
*
14+
* @action wp_enqueue_scripts
15+
*/
16+
public function enqueueAsset(): void
17+
{
18+
$this->enqueue();
19+
}
20+
}

src/classes/Features/BlockSpacing/BlockSpacingHooks.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace DoWStarterTheme\Features\BlockSpacing;
66

7+
use DoWStarterTheme\Common\Assets\MainStyle;
78
use DoWStarterTheme\Common\Contracts\Hookable;
89
use DoWStarterTheme\Common\Helpers\CSSGenerator;
910
use WP_Post;
@@ -17,9 +18,11 @@ class BlockSpacingHooks implements Hookable
1718
* Class constructor.
1819
*
1920
* @param BlockSpacing $blockSpacing Block spacing helper instance.
21+
* @param MainStyle $style Main style asset instance.
2022
*/
2123
public function __construct(
2224
private BlockSpacing $blockSpacing,
25+
private MainStyle $style,
2326
) {
2427
}
2528

@@ -38,7 +41,7 @@ public function addStyles(): void
3841
return;
3942
}
4043

41-
wp_add_inline_style('dow-starter-theme-front-style', $styles);
44+
wp_add_inline_style($this->style->getHandle(), $styles);
4245
}
4346

4447
/**

src/classes/Features/ReusableContent/ReusableContentHooks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function printStyles(): void
5454
public function contentSlotsField(array $field): array
5555
{
5656
if ($field['name'] === 'content_slot') {
57-
$field['choices'] = $this->config;
57+
$field['choices'] = $this->config->get('content-slots');
5858
}
5959

6060
return $field;

0 commit comments

Comments
 (0)