Skip to content

Commit

Permalink
Fix unit tests and update to use the inline styles
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Apr 8, 2020
1 parent 11ce8e7 commit cb39108
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions packages/block-editor/src/hooks/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function getInlineStyles( styles = {} ) {
const mappings = {
lineHeight: [ 'typography', 'lineHeight' ],
fontSize: [ 'typography', 'fontSize' ],
background: [ 'color', 'gradient' ],
backgroundColor: [ 'color', 'background' ],
color: [ 'color', 'text' ],
};
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function ButtonEdit( { attributes, setAttributes, className, isSelected } ) {
value={ text }
onChange={ ( value ) => setAttributes( { text: value } ) }
withoutInteractiveFormatting
className={ classnames( className, {
className={ classnames( className, 'wp-block-button__link', {
'no-border-radius': borderRadius === 0,
} ) }
style={ {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/button/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { RichText } from '@wordpress/block-editor';
export default function save( { attributes } ) {
const { borderRadius, linkTarget, rel, text, title, url } = attributes;

const buttonClasses = classnames( {
const buttonClasses = classnames( 'wp-block-button__link', {
'no-border-radius': borderRadius === 0,
} );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:button {"align":"center"} -->
<a class="wp-block-button aligncenter" href="https://github.com/WordPress/gutenberg">Help build Gutenberg</a>
<a class="wp-block-button aligncenter wp-block-button__link" href="https://github.com/WordPress/gutenberg">Help build Gutenberg</a>
<!-- /wp:button -->
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:button {"borderRadius":0,"align":"none","style":{"color":{"text":"#1b9b6c","background":"#aa5a20"}}} -->
<a class="wp-block-button no-border-radius has-text-color has-background" style="--wp--color--text:#1b9b6c;--wp--color--background:#aa5a20">My button</a>
<a class="wp-block-button wp-block-button__link no-border-radius has-text-color has-background" style="background-color:#aa5a20;color:#1b9b6c">My button</a>
<!-- /wp:button -->
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"borderRadius": 0
},
"innerBlocks": [],
"originalContent": "<a class=\"wp-block-button no-border-radius has-text-color has-background\" style=\"--wp--color--text:#1b9b6c;--wp--color--background:#aa5a20\">My button</a>"
"originalContent": "<a class=\"wp-block-button wp-block-button__link no-border-radius has-text-color has-background\" style=\"background-color:#aa5a20;color:#1b9b6c\">My button</a>"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
}
},
"innerBlocks": [],
"innerHTML": "\n<a class=\"wp-block-button no-border-radius has-text-color has-background\" style=\"--wp--color--text:#1b9b6c;--wp--color--background:#aa5a20\">My button</a>\n",
"innerHTML": "\n<a class=\"wp-block-button wp-block-button__link no-border-radius has-text-color has-background\" style=\"background-color:#aa5a20;color:#1b9b6c\">My button</a>\n",
"innerContent": [
"\n<a class=\"wp-block-button no-border-radius has-text-color has-background\" style=\"--wp--color--text:#1b9b6c;--wp--color--background:#aa5a20\">My button</a>\n"
"\n<a class=\"wp-block-button wp-block-button__link no-border-radius has-text-color has-background\" style=\"background-color:#aa5a20;color:#1b9b6c\">My button</a>\n"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:button {"borderRadius":0,"align":"none","style":{"color":{"text":"#1b9b6c","background":"#aa5a20"}}} -->
<a class="wp-block-button no-border-radius has-text-color has-background" style="--wp--color--text:#1b9b6c;--wp--color--background:#aa5a20">My button</a>
<a class="wp-block-button wp-block-button__link no-border-radius has-text-color has-background" style="background-color:#aa5a20;color:#1b9b6c">My button</a>
<!-- /wp:button -->
4 changes: 2 additions & 2 deletions packages/e2e-tests/fixtures/blocks/core__buttons.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!-- wp:buttons -->
<div class="wp-block-buttons">
<!-- wp:button -->
<a class="wp-block-button">My button 1</a>
<a class="wp-block-button wp-block-button__link">My button 1</a>
<!-- /wp:button -->

<!-- wp:button -->
<a class="wp-block-button">My button 2</a>
<a class="wp-block-button wp-block-button__link">My button 2</a>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->
4 changes: 2 additions & 2 deletions packages/e2e-tests/fixtures/blocks/core__buttons.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"text": "My button 1"
},
"innerBlocks": [],
"originalContent": "<a class=\"wp-block-button\">My button 1</a>"
"originalContent": "<a class=\"wp-block-button wp-block-button__link\">My button 1</a>"
},
{
"clientId": "_clientId_1",
Expand All @@ -23,7 +23,7 @@
"text": "My button 2"
},
"innerBlocks": [],
"originalContent": "<a class=\"wp-block-button\">My button 2</a>"
"originalContent": "<a class=\"wp-block-button wp-block-button__link\">My button 2</a>"
}
],
"originalContent": "<div class=\"wp-block-buttons\">\n\t\n\n\t\n</div>"
Expand Down
8 changes: 4 additions & 4 deletions packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
"blockName": "core/button",
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n\t<a class=\"wp-block-button\">My button 1</a>\n\t",
"innerHTML": "\n\t<a class=\"wp-block-button wp-block-button__link\">My button 1</a>\n\t",
"innerContent": [
"\n\t<a class=\"wp-block-button\">My button 1</a>\n\t"
"\n\t<a class=\"wp-block-button wp-block-button__link\">My button 1</a>\n\t"
]
},
{
"blockName": "core/button",
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n\t<a class=\"wp-block-button\">My button 2</a>\n\t",
"innerHTML": "\n\t<a class=\"wp-block-button wp-block-button__link\">My button 2</a>\n\t",
"innerContent": [
"\n\t<a class=\"wp-block-button\">My button 2</a>\n\t"
"\n\t<a class=\"wp-block-button wp-block-button__link\">My button 2</a>\n\t"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button -->
<a class="wp-block-button">My button 1</a>
<a class="wp-block-button wp-block-button__link">My button 1</a>
<!-- /wp:button -->

<!-- wp:button -->
<a class="wp-block-button">My button 2</a>
<a class="wp-block-button wp-block-button__link">My button 2</a>
<!-- /wp:button --></div>
<!-- /wp:buttons -->

0 comments on commit cb39108

Please sign in to comment.