Skip to content

Commit ca922b3

Browse files
authored
Merge pull request #119 from liip/improvement/better-property-names
feat(): Improve button property names
2 parents 1846253 + 223f2d7 commit ca922b3

22 files changed

+159
-37
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,12 @@ Modify available button styles.
562562

563563
```javascript
564564
function myButtonStyleOptions( styleOptions ) {
565-
styleOptions.push( { label: 'My Option', value: 'my-option', color: '#FF0000' } );
565+
styleOptions.push( {
566+
label: 'My Option',
567+
value: 'my-option',
568+
bgColor: '#ff0000',
569+
textColor: '#ffffff',
570+
} );
566571
return styleOptions;
567572
}
568573
wp.hooks.addFilter(
@@ -576,6 +581,13 @@ wp.hooks.addFilter(
576581

577582
* `styleOptions` (`Array`) Array with button style options.
578583

584+
Each `styleOption` object should have the following attributes:
585+
586+
* `label` (`string`) Label displayed in the select box.
587+
* `value` (`string`) Value of the chosen option.
588+
* `bgColor` (`string`) Background color of button shown in the editor.
589+
* `textColor` (`string`) Text color of button shown in the editor.
590+
579591
### wpBootstrapBlocks.container.marginAfterOptions
580592

581593
Modify margin after options.
@@ -598,6 +610,11 @@ wp.hooks.addFilter(
598610

599611
* `marginAfterOptions` (`Array`) Array margin options.
600612

613+
Each `marginAfterOption` object should have the following attributes:
614+
615+
* `label` (`string`) Label displayed in the select box.
616+
* `value` (`string`) Value of the chosen option.
617+
601618
### wpBootstrapBlocks.row.templates
602619

603620
Define block templates.
@@ -639,7 +656,7 @@ wp.hooks.addFilter(
639656

640657
* `templates` (`array`) List of template objects.
641658

642-
Each template has the following attributes:
659+
Each `template` object should have the following attributes:
643660

644661
* `name` (`string`) Unique identifier of the template
645662
* `title` (`string`) Name of template

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-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '9b6fd2a0b07ab4882cb6');
1+
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '068db33e0cc8e71503c0');

build/index.css

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

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.

cypress/e2e/button/button-block.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe( 'Button Block', () => {
5454
cy.get( '.wp-block-wp-bootstrap-blocks-button' ).should(
5555
'have.attr',
5656
'style',
57-
'background-color: rgb(0, 123, 255);'
57+
'background-color: rgb(0, 123, 255); color: rgb(255, 255, 255);'
5858
);
5959

6060
cy.selectButtonBlock();
@@ -66,7 +66,7 @@ describe( 'Button Block', () => {
6666
cy.get( '.wp-block-wp-bootstrap-blocks-button' ).should(
6767
'have.attr',
6868
'style',
69-
'background-color: rgb(108, 117, 125);'
69+
'background-color: rgb(108, 117, 125); color: rgb(255, 255, 255);'
7070
);
7171

7272
// Editor content should match snapshot

cypress/e2e/button/button-filters.cy.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,49 @@ describe( 'Button Block Filters', () => {
2727
// Style option should be applied
2828
cy.getSelectByLabel( 'Style' ).select( 'brand' );
2929

30+
// Style should be visible in UI
31+
cy.get( '.wp-block-wp-bootstrap-blocks-button' ).should(
32+
'have.attr',
33+
'style',
34+
'background-color: rgb(255, 0, 0); color: rgb(255, 255, 255);'
35+
);
36+
37+
// Editor content should match snapshot
38+
cy.postContentMatchesSnapshot();
39+
} );
40+
41+
it( 'Deprecated color attribute should be visible in UI', () => {
42+
cy.insertButtonBlock();
43+
cy.selectButtonBlock();
44+
cy.ensureSidebarOpened();
45+
46+
cy.getSelectByLabel( 'Style' ).select( 'brand-deprecated-color' );
47+
48+
// Style should be visible in UI
49+
cy.get( '.wp-block-wp-bootstrap-blocks-button' ).should(
50+
'have.attr',
51+
'style',
52+
'background-color: rgb(255, 0, 0); color: rgb(255, 255, 255);'
53+
);
54+
55+
// Editor content should match snapshot
56+
cy.postContentMatchesSnapshot();
57+
} );
58+
59+
it( 'Use default colors if textColor or bgColor attributes are missing in styleOption', () => {
60+
cy.insertButtonBlock();
61+
cy.selectButtonBlock();
62+
cy.ensureSidebarOpened();
63+
64+
cy.getSelectByLabel( 'Style' ).select( 'missing-colors' );
65+
66+
// Style should be visible in UI
67+
cy.get( '.wp-block-wp-bootstrap-blocks-button' ).should(
68+
'have.attr',
69+
'style',
70+
'background-color: rgb(0, 123, 255); color: rgb(255, 255, 255);'
71+
);
72+
3073
// Editor content should match snapshot
3174
cy.postContentMatchesSnapshot();
3275
} );

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@
33
function buttonFiltersStyleOptions( styleOptions ) {
44
return [
55
...styleOptions,
6-
{ label: 'Brand', value: 'brand', color: '#FF0000' },
6+
{
7+
label: 'Brand',
8+
value: 'brand',
9+
bgColor: '#FF0000',
10+
textColor: '#FFFFFF',
11+
},
12+
{
13+
label: 'Brand (Deprecated Color)',
14+
value: 'brand-deprecated-color',
15+
color: '#FF0000',
16+
},
17+
{
18+
label: 'Missing colors',
19+
value: 'missing-colors',
20+
},
721
];
822
}
923
wp.hooks.addFilter(

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 5.0.0\n"
5+
"Project-Id-Version: Bootstrap Blocks 5.1.0\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-bootstrap-"
77
"blocks\n"
88
"POT-Creation-Date: 2022-11-11T09:10:58+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 5.0.0\n"
5+
"Project-Id-Version: Bootstrap Blocks 5.1.0\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-bootstrap-"
77
"blocks\n"
88
"POT-Creation-Date: 2022-11-11T09:10:58+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 5.0.0\n"
5+
"Project-Id-Version: Bootstrap Blocks 5.1.0\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 <LL@li.org>\n"

0 commit comments

Comments
 (0)