Skip to content

Commit e4437f3

Browse files
authored
Merge pull request #117 from liip/fix/button-default-color
fix(): Button default color
2 parents 6172e8e + c0b8051 commit e4437f3

File tree

12 files changed

+25
-15
lines changed

12 files changed

+25
-15
lines changed

build/index.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '7cf780b987df063ad572');
1+
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '6010ac73ad30738b341d');

build/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e-test-plugins/button-filters/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
/* eslint-disable wrap-iife */
22
( function () {
33
function buttonFiltersStyleOptions( styleOptions ) {
4-
return [ ...styleOptions, { label: 'Brand', value: 'brand' } ];
4+
return [
5+
...styleOptions,
6+
{ label: 'Brand', value: 'brand', color: '#FF0000' },
7+
];
58
}
69
wp.hooks.addFilter(
710
'wpBootstrapBlocks.button.styleOptions',

languages/wp-bootstrap-blocks-de_CH.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is distributed under the same license as the Bootstrap Blocks plugin.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Bootstrap Blocks 4.3.0\n"
5+
"Project-Id-Version: Bootstrap Blocks 4.3.1\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-bootstrap-"
77
"blocks\n"
88
"POT-Creation-Date: 2022-05-12T07:38:53+00:00\n"

languages/wp-bootstrap-blocks-de_DE.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is distributed under the same license as the Bootstrap Blocks plugin.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Bootstrap Blocks 4.3.0\n"
5+
"Project-Id-Version: Bootstrap Blocks 4.3.1\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-bootstrap-"
77
"blocks\n"
88
"POT-Creation-Date: 2022-05-12T07:38:53+00:00\n"

languages/wp-bootstrap-blocks.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is distributed under the GPL2+.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Bootstrap Blocks 4.3.0\n"
5+
"Project-Id-Version: Bootstrap Blocks 4.3.1\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-bootstrap-blocks\n"
77
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
88
"Language-Team: LANGUAGE <[email protected]>\n"

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wp-bootstrap-blocks",
3-
"version": "4.3.0",
3+
"version": "4.3.1",
44
"private": true,
55
"description": "Bootstrap Gutenberg Blocks for WordPress",
66
"author": "Liip AG",

readme.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Tags: gutenberg, blocks, bootstrap
55
Requires at least: 5.0
66
Tested up to: 6.1
77
Requires PHP: 5.6
8-
Stable tag: 4.3.0
8+
Stable tag: 4.3.1
99
License: GPLv2
1010
License URI: https://www.gnu.org/licenses/gpl-2.0.html
1111

@@ -143,11 +143,15 @@ Please create a new GitHub issue and let us know: [https://github.com/liip/boots
143143

144144
== Changelog ==
145145

146-
= 4.3.0 =
146+
= 4.3.1 =
147147

148148
**NOTICE:** Version 4.x of the plugin will be the last version to support WordPress versions lower than 5.3.
149149
If you're on a lower version of WordPress think about updating it if you still would like receive updates for this plugin.
150150

151+
* [FIX] Apply default color to button if `color` attribute is missing in `styleOptions`.
152+
153+
= 4.3.0 =
154+
151155
* [COMPATIBILITY] Tested up to WordPress 6.1.
152156
* [CHANGE] Set default `style` attribute of the Button block to `primary`. This shouldn't be a breaking change since the template already added the `btn-primary` class if no `style` was selected.
153157
* [FEATURE] Add `color` attribute to the `styleOptions` to be able to display the buttons in the correct color in the editor. If you have changed the `styleOptions` via the [`wpBootstrapBlocks.button.styleOptions`](https://github.com/liip/bootstrap-blocks-wordpress-plugin#wpbootstrapblocksbuttonstyleoptions) JavaScript filter please add the according colors to your style objects.

src/button/edit.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ styleOptions = applyFilters(
3939
styleOptions
4040
);
4141

42+
const DEFAULT_COLOR = colors.primary;
4243
const NEW_TAB_REL_DEFAULT_VALUE = 'noreferrer noopener';
4344

4445
class BootstrapButtonEdit extends Component {
@@ -66,14 +67,16 @@ class BootstrapButtonEdit extends Component {
6667
// Prepare CSS rules for selected button style
6768
let inlineStyle = {
6869
backgroundColor:
69-
styleOptions.length > 0 ? styleOptions[ 0 ].color : '',
70+
styleOptions.length > 0
71+
? styleOptions[ 0 ].color
72+
: DEFAULT_COLOR,
7073
};
7174

7275
if ( style ) {
7376
const selectedButtonColor = styleOptions.find(
7477
( styleOption ) => styleOption.value === style
7578
);
76-
if ( selectedButtonColor ) {
79+
if ( selectedButtonColor?.color ) {
7780
inlineStyle = {
7881
backgroundColor: selectedButtonColor.color,
7982
};

0 commit comments

Comments
 (0)