Skip to content

Commit

Permalink
Merge pull request #1 from colorful-tones/single-block-organization
Browse files Browse the repository at this point in the history
‼️ BREAKING: Major refactor - simplification
  • Loading branch information
colorful-tones authored Dec 4, 2023
2 parents ba82909 + af601e4 commit fbc8132
Show file tree
Hide file tree
Showing 35 changed files with 154 additions and 297 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ This is a demonstration of how you might create a custom Slider Block, which is

## Changelog

### 0.1.1 – 2023-12-04

- Major refactor 😎:
- Remove need to have two custom blocks: Slider and Slide (`"parent": ['wpe/slider]`). This was just unnecessary and mildly confusing. We're ultimately utilising `InnerBlocks` and `useInnerBlocksProps()` to nest things.
- Create `constants.js` to try and allow builders to drop in their own default blocks for slides.
- Generally "cleaner" codebase.

### 0.1.0 – 2023-11-28

Initial release, which includes:
Expand Down
2 changes: 1 addition & 1 deletion build/blocks/slider/block.json → build/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
},
"textdomain": "wpe",
"version": "0.1.0",
"version": "0.1.1",
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"render": "file:./render.php",
Expand Down
31 changes: 0 additions & 31 deletions build/blocks/slide/block.json

This file was deleted.

1 change: 0 additions & 1 deletion build/blocks/slide/index.asset.php

This file was deleted.

1 change: 0 additions & 1 deletion build/blocks/slide/index.js

This file was deleted.

25 changes: 0 additions & 25 deletions build/blocks/slide/render.php

This file was deleted.

1 change: 0 additions & 1 deletion build/blocks/slider/index.js

This file was deleted.

1 change: 0 additions & 1 deletion build/blocks/slider/view.asset.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'fe5e00eb9597bb99cf08');
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '552a734820b0ed0f0b13');
File renamed without changes.
1 change: 1 addition & 0 deletions build/index.js

Large diffs are not rendered by default.

File renamed without changes.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/view.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array(), 'version' => 'f285e13fee9805515472');
2 changes: 1 addition & 1 deletion build/blocks/slider/view.js → build/view.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "slider-block",
"version": "0.1.0",
"version": "0.1.1",
"description": "A slider carousel block for WordPress with SwiperJS.",
"author": "Damon Cook",
"license": "GPL-2.0-or-later",
Expand Down
6 changes: 2 additions & 4 deletions slider-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: A slider carousel block for WordPress with SwiperJS.
* Requires at least: 6.4
* Requires PHP: 7.0
* Version: 0.1.0
* Version: 0.1.1
* Author: Damon Cook
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand All @@ -22,9 +22,7 @@
* @see https://developer.wordpress.org/reference/functions/register_block_type/
*/
function wpe_slider_block_init() {
// Register Slide block.
register_block_type( __DIR__ . '/build/blocks/slide' );
// Register Slider block.
register_block_type( __DIR__ . '/build/blocks/slider' );
register_block_type( __DIR__ . '/build' );
}
add_action( 'init', 'wpe_slider_block_init' );
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion src/blocks/slider/block.json → src/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
},
"textdomain": "wpe",
"version": "0.1.0",
"version": "0.1.1",
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"render": "file:./render.php",
Expand Down
26 changes: 0 additions & 26 deletions src/blocks/slide/block.json

This file was deleted.

60 changes: 0 additions & 60 deletions src/blocks/slide/edit.js

This file was deleted.

30 changes: 0 additions & 30 deletions src/blocks/slide/index.js

This file was deleted.

25 changes: 0 additions & 25 deletions src/blocks/slide/render.php

This file was deleted.

21 changes: 0 additions & 21 deletions src/blocks/slide/save.js

This file was deleted.

56 changes: 56 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* These are the block we'll allow to be inserted
* as a slide.
*/
export const ALLOWED_BLOCKS = [
'core/button',
'core/buttons',
'core/cover',
'core/group',
'core/heading',
'core/image',
'core/paragraph',
];

/**
* This is the default block we'll use for our slide.
*/
export const DEFAULT_BLOCK = 'core/cover';

/**
* These are the attributes we assign for our DEFAULT_BLOCK.
*/
export const DEFAULT_BLOCK_ATTRIBUTES = {
align: 'center',
className: 'swiper-slide',
contentPosition: 'bottom left',
dimRatio: 0,
layout: {
type: 'constrained',
},
};

/**
* These are the default inner blocks we'll use
* when our DEFAULT_BLOCK is inserted.
*/
export const DEFAULT_INNERBLOCK = 'core/paragraph';

/**
* These are the attributes we assign for our default
* inner blocks.
*/
export const DEFAULT_INNERBLOCK_ATTRIBUTES = {
backgroundColor: 'contrast',
fontSize: 'large',
style: {
spacing: {
padding: {
top: '0',
bottom: '0',
left: '0.5rem',
right: '0.5rem',
},
},
},
};
Loading

0 comments on commit fbc8132

Please sign in to comment.