Skip to content

Commit d25d2a2

Browse files
Merge pull request #32 from WebDevStudios/release/WDSBT-v1.0
Release/WDSBT v1.0
2 parents 8190b60 + ba658ca commit d25d2a2

37 files changed

+5754
-7272
lines changed

.github/workflows/assertions.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
name: Code Quality
22

33
on:
4-
pull_request:
5-
push:
6-
branches:
7-
- main
4+
pull_request:
5+
branches:
6+
- main
87

9-
# Cancel previous workflow run groups that have not completed.
108
concurrency:
11-
# Group workflow runs by workflow name, along with the head branch ref of the pull request
12-
# or otherwise the branch or tag ref.
13-
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
14-
cancel-in-progress: true
9+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
10+
cancel-in-progress: true
1511

1612
jobs:
1713
lint-css:

.github/workflows/security.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
name: Security
22

33
on:
4-
# Run on all pushes and on all pull requests.
5-
push:
6-
pull_request:
7-
# Also run this workflow every Monday at 6:00.
8-
schedule:
9-
- cron: '0 6 * * 1'
10-
# Allow manually triggering the workflow.
11-
workflow_dispatch:
4+
pull_request:
5+
branches:
6+
- main
127

13-
# Cancels all previous workflow runs for the same branch that have not yet completed.
148
concurrency:
15-
# The concurrency group contains the workflow name and the branch name.
16-
group: ${{ github.workflow }}-${{ github.ref }}
17-
cancel-in-progress: true
9+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
10+
cancel-in-progress: true
1811

1912
jobs:
2013
security:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ vendor/
2424
# theme
2525
build/
2626
/blocks/
27+
!assets/blocks/
2728

2829
#tests
2930
pa11y-ci-report/

.markdownlintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
blocks
1+
./blocks
22
build
33
node_modules
44
vendor

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20.12.2
1+
v22.5.1

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
blocks/
1+
/blocks/
2+
!assets/blocks/
23
build/
34
node_modules/
45
vendor/

.stylelintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
build/
21
/blocks/
2+
!assets/blocks/
3+
/build/
34
vendor/
45
node_modules/
56
!.*.js

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Meet WDS BT, a stylish block theme, tailored for WordPress, featuring native blo
145145
│   │   ├── tag-cloud.scss
146146
│   │   ├── verse.scss
147147
│   │   └── video.scss
148-
│   ├── template-parts
148+
│   ├── template-parts
149149
│   │   ├── _index.scss
150150
│   │   ├── footer.scss
151151
│   │   └── header.scss
@@ -299,7 +299,7 @@ This will process JavaScript, SCSS, optimize images, and generate necessary file
299299
<details closed>
300300
<summary><b>Overriding/Customizing Block Styles</b></summary>
301301

302-
1. Navigate to the `assets/scss/blocks/` directory within your theme. If overriding a core block style, use the `core` folder, if overriding a block from a plugin use the `custom` folder.
302+
1. Navigate to the `assets/scss/blocks/` directory within your theme. If overriding a core block style, use the `core` folder, if overriding a block from a plugin use the `third-party` folder.
303303

304304
2. Create an SCSS file with the exact filename as the block name you want to customize. This file will house your custom styles for that specific block.
305305

assets/js/block-filters/buttons.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import { addFilter } from '@wordpress/hooks';
2+
import { createHigherOrderComponent } from '@wordpress/compose';
3+
import { InspectorControls } from '@wordpress/block-editor';
4+
import {
5+
PanelBody,
6+
PanelRow,
7+
ButtonGroup,
8+
Button,
9+
} from '@wordpress/components';
10+
import { __ } from '@wordpress/i18n';
11+
12+
/**
13+
* Renders the edit component for the button block.
14+
*
15+
* @param {Object} props - The properties passed to the component.
16+
* @param {Object} props.attributes - The attributes of the button block.
17+
* @param {string} props.attributes.buttonSize - The size of the button.
18+
* @param {Function} props.setAttributes - The function to set the attributes of the button block.
19+
* @return {JSX.Element} The rendered edit component.
20+
*/
21+
function Edit({ attributes: { buttonSize }, setAttributes }) {
22+
const handleChange = (newSize) => {
23+
// Check if we are toggling the size off
24+
const size = buttonSize === newSize ? undefined : newSize;
25+
const buttonClass = buttonSize !== newSize ? 'has-size-' + newSize : '';
26+
27+
// Update attributes.
28+
setAttributes({
29+
buttonSize: size,
30+
className: buttonClass,
31+
});
32+
};
33+
34+
return (
35+
<InspectorControls>
36+
<PanelBody title={__('Button Sizes')}>
37+
<PanelRow>
38+
<ButtonGroup aria-label={__('Button Sizes')}>
39+
{['s', 'm', 'l', 'xl'].map((sizeValue) => {
40+
return (
41+
<Button
42+
key={sizeValue}
43+
size="medium"
44+
variant={
45+
buttonSize === sizeValue
46+
? 'primary'
47+
: undefined
48+
}
49+
onClick={() => handleChange(sizeValue)}
50+
>
51+
{sizeValue.toUpperCase()}
52+
</Button>
53+
);
54+
})}
55+
</ButtonGroup>
56+
</PanelRow>
57+
</PanelBody>
58+
</InspectorControls>
59+
);
60+
}
61+
62+
addFilter(
63+
'blocks.registerBlockType',
64+
'wds-bt/button-sizes',
65+
(settings, name) => {
66+
if (name !== 'core/button') {
67+
return settings;
68+
}
69+
70+
return {
71+
...settings,
72+
attributes: {
73+
...settings.attributes,
74+
buttonSize: {
75+
type: 'string',
76+
selector: 'a',
77+
default: '',
78+
},
79+
},
80+
};
81+
}
82+
);
83+
84+
addFilter(
85+
'editor.BlockEdit',
86+
'wds-bt/button-sizes',
87+
createHigherOrderComponent((BlockEdit) => {
88+
return (props) => {
89+
if (props.name !== 'core/button') {
90+
return <BlockEdit {...props} />;
91+
}
92+
93+
return (
94+
<>
95+
<BlockEdit {...props} />
96+
<Edit {...props} />
97+
</>
98+
);
99+
};
100+
})
101+
);

assets/js/block-filters/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66

77
// Import the block filter file.
88
import './unregister-core-embed';
9+
import './buttons';

0 commit comments

Comments
 (0)