Skip to content

Commit

Permalink
Merge pull request #117 from liip/fix/button-default-color
Browse files Browse the repository at this point in the history
fix(): Button default color
  • Loading branch information
tschortsch committed Nov 10, 2022
2 parents 6172e8e + c0b8051 commit e4437f3
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -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');
<?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');
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion e2e-test-plugins/button-filters/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/* eslint-disable wrap-iife */
( function () {
function buttonFiltersStyleOptions( styleOptions ) {
return [ ...styleOptions, { label: 'Brand', value: 'brand' } ];
return [
...styleOptions,
{ label: 'Brand', value: 'brand', color: '#FF0000' },
];
}
wp.hooks.addFilter(
'wpBootstrapBlocks.button.styleOptions',
Expand Down
2 changes: 1 addition & 1 deletion languages/wp-bootstrap-blocks-de_CH.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is distributed under the same license as the Bootstrap Blocks plugin.
msgid ""
msgstr ""
"Project-Id-Version: Bootstrap Blocks 4.3.0\n"
"Project-Id-Version: Bootstrap Blocks 4.3.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-bootstrap-"
"blocks\n"
"POT-Creation-Date: 2022-05-12T07:38:53+00:00\n"
Expand Down
2 changes: 1 addition & 1 deletion languages/wp-bootstrap-blocks-de_DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is distributed under the same license as the Bootstrap Blocks plugin.
msgid ""
msgstr ""
"Project-Id-Version: Bootstrap Blocks 4.3.0\n"
"Project-Id-Version: Bootstrap Blocks 4.3.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-bootstrap-"
"blocks\n"
"POT-Creation-Date: 2022-05-12T07:38:53+00:00\n"
Expand Down
2 changes: 1 addition & 1 deletion languages/wp-bootstrap-blocks.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is distributed under the GPL2+.
msgid ""
msgstr ""
"Project-Id-Version: Bootstrap Blocks 4.3.0\n"
"Project-Id-Version: Bootstrap Blocks 4.3.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-bootstrap-blocks\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wp-bootstrap-blocks",
"version": "4.3.0",
"version": "4.3.1",
"private": true,
"description": "Bootstrap Gutenberg Blocks for WordPress",
"author": "Liip AG",
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: gutenberg, blocks, bootstrap
Requires at least: 5.0
Tested up to: 6.1
Requires PHP: 5.6
Stable tag: 4.3.0
Stable tag: 4.3.1
License: GPLv2
License URI: https://www.gnu.org/licenses/gpl-2.0.html

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

== Changelog ==

= 4.3.0 =
= 4.3.1 =

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

* [FIX] Apply default color to button if `color` attribute is missing in `styleOptions`.

= 4.3.0 =

* [COMPATIBILITY] Tested up to WordPress 6.1.
* [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.
* [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.
Expand Down
7 changes: 5 additions & 2 deletions src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ styleOptions = applyFilters(
styleOptions
);

const DEFAULT_COLOR = colors.primary;
const NEW_TAB_REL_DEFAULT_VALUE = 'noreferrer noopener';

class BootstrapButtonEdit extends Component {
Expand Down Expand Up @@ -66,14 +67,16 @@ class BootstrapButtonEdit extends Component {
// Prepare CSS rules for selected button style
let inlineStyle = {
backgroundColor:
styleOptions.length > 0 ? styleOptions[ 0 ].color : '',
styleOptions.length > 0
? styleOptions[ 0 ].color
: DEFAULT_COLOR,
};

if ( style ) {
const selectedButtonColor = styleOptions.find(
( styleOption ) => styleOption.value === style
);
if ( selectedButtonColor ) {
if ( selectedButtonColor?.color ) {
inlineStyle = {
backgroundColor: selectedButtonColor.color,
};
Expand Down
2 changes: 1 addition & 1 deletion src/class-wp-bootstrap-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class WP_Bootstrap_Blocks {
*
* @var string
*/
public static $version = '4.3.0';
public static $version = '4.3.1';

/**
* The plugin token.
Expand Down
2 changes: 1 addition & 1 deletion wp-bootstrap-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Bootstrap Gutenberg Blocks for WordPress.
* Author: Liip AG
* Author URI: https://liip.ch
* Version: 4.3.0
* Version: 4.3.1
* License: GPL2+
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: wp-bootstrap-blocks
Expand Down

0 comments on commit e4437f3

Please sign in to comment.