Skip to content

Commit f5893f7

Browse files
authored
Merge pull request #25 from WebDevStudios/feature/WDSBT-20-custom-blocks
Feature/WDSBT-20 Custom block build process
2 parents 5d5826e + bf2c299 commit f5893f7

36 files changed

+6944
-4167
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
blocks
12
build
23
node_modules
34
vendor

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ vendor/
2323

2424
# theme
2525
build/
26+
blocks/
2627

2728
#tests
2829
pa11y-ci-report/

.markdownlintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
blocks
12
build
23
node_modules
34
vendor

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
blocks/
12
build/
23
node_modules/
34
vendor/
45
style.css
56
README.md
7+
acf-json/

.stylelintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
blocks/
12
build/
23
vendor/
34
node_modules/

README.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- [Getting Started](#getting-started)
1818
- [Development](#development)
1919
- [NPM Scripts](#npm-scripts)
20+
- [Creating Custom Blocks](#creating-blocks)
2021
- [Customizations](#customizations)
2122
- [Implementation](#implementation)
2223
- [Mixins](#mixins)
@@ -205,6 +206,7 @@ npm run setup
205206
|-------|---------|-------------|
206207
| 🌐 | `npm run a11y` | Run accessibility tests using Pa11y-CI. |
207208
| 🛠️ | `npm run build` | Build the theme using `wp-scripts`. |
209+
| 🔨 | `npm run create-block` | Create a custom block with Webpack and @wordpress/create-block. |
208210
| 📝 | `npm run format` | Format files using `wp-scripts` and `composer`. |
209211
| 🔍 | `npm run lint` | Run all linting scripts. |
210212
| 🎨 | `npm run lint:css` | Lint CSS files using `wp-scripts`. |
@@ -218,6 +220,30 @@ npm run setup
218220
| ▶️ | `npm run start` | Start the development server using `wp-scripts`. |
219221

220222

223+
[🔝 Back to Top](#wds-bt)
224+
***
225+
226+
## Creating Blocks
227+
228+
1. Run the Block Creation Script
229+
Navigate to your project root in the terminal and run the following command to create a new block:
230+
231+
```bash
232+
npm run create-block
233+
```
234+
235+
Follow the prompts to configure your new block. The script will scaffold a new block structure inside assets/blocks/.
236+
237+
2. Build your block
238+
After editing and configuring your block, build your project to compile assets using webpack:
239+
240+
```bash
241+
npm run build
242+
```
243+
This will process JavaScript, SCSS, optimize images, and generate necessary files in the build/ directory and custom blocks will have files generated in the blocks/ directory.
244+
245+
246+
221247
[🔝 Back to Top](#wds-bt)
222248
***
223249

@@ -245,13 +271,13 @@ npm run setup
245271
</details>
246272

247273
<details closed>
248-
<summary><b>Overriding/Customizing Core Block Styles</b></summary>
274+
<summary><b>Overriding/Customizing Block Styles</b></summary>
249275

250-
1. Navigate to the `assets/scss/blocks/core` directory within your theme.
276+
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.
251277

252-
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 core block.
278+
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.
253279

254-
3. Files within the `assets/scss/blocks/core` directory are automatically enqueued, simplifying the integration of your custom styles into the WordPress block editor. Do not import these files into the main `index.scss`
280+
3. Files within the `assets/scss/blocks/core/` directory are automatically enqueued, simplifying the integration of your custom styles into the WordPress block editor. Do not import these files into the main `index.scss`
255281

256282
4. After adding your custom SCSS file, run the following command to compile and apply your changes:
257283

assets/blocks/.gitkeep

Whitespace-only changes.

assets/scss/editor.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* -- Editor Stykes -- */

babel.config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["@babel/preset-env", "@babel/preset-react"]
3+
}

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@
2525
"composer/installers": "^2.2.0"
2626
},
2727
"require-dev": {
28+
"php": ">=8.0",
2829
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
2930
"phpcompatibility/phpcompatibility-wp": "^2.1.4",
3031
"squizlabs/php_codesniffer": "^3.10.1",
3132
"wp-cli/wp-cli-bundle": "^2.10.0",
3233
"wp-coding-standards/wpcs": "^3.1.0"
3334
},
3435
"scripts": {
35-
"fix": "./vendor/bin/phpcbf --report=summary,source",
36-
"lint": "./vendor/bin/phpcs --report=summary,source"
36+
"phpcs": "./vendor/bin/phpcs --report=full,source",
37+
"phpcs-fix": "./vendor/bin/phpcbf --report=summary,source"
3738
}
3839
}

0 commit comments

Comments
 (0)