Skip to content

Commit

Permalink
Cover Image: Ensure backcompat via default attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
mcsf committed Sep 29, 2017
1 parent f6ae7fe commit eab53ef
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions blocks/library/cover-image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ registerBlockType( 'core/cover-image', {
},
dimRatio: {
type: 'number',
default: 0,
default: 50,
},
},

Expand Down Expand Up @@ -191,7 +191,7 @@ registerBlockType( 'core/cover-image', {
} );

function dimRatioToClass( ratio ) {
return ratio === 0
return ( ratio === 0 || ratio === 50 )
? null
: 'has-background-dim-' + Math.round( ratio / 10 );
}
2 changes: 1 addition & 1 deletion blocks/library/cover-image/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
left: 0;
bottom: 0;
right: 0;
background: rgba( black, 0 );
background: rgba( black, 0.5 );
}

@for $i from 1 through 10 {
Expand Down
4 changes: 2 additions & 2 deletions blocks/test/fixtures/core__cover-image.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- wp:core/cover-image {"url":"https://cldup.com/uuUqE_dXzy.jpg","dimRatio":50} -->
<section class="wp-block-cover-image has-background-dim-5 has-background-dim" style="background-image:url(https://cldup.com/uuUqE_dXzy.jpg);">
<!-- wp:core/cover-image {"url":"https://cldup.com/uuUqE_dXzy.jpg","dimRatio":40} -->
<section class="wp-block-cover-image has-background-dim-4 has-background-dim" style="background-image:url(https://cldup.com/uuUqE_dXzy.jpg);">
<h2>Guten Berg!</h2>
</section>
<!-- /wp:core/cover-image -->
4 changes: 2 additions & 2 deletions blocks/test/fixtures/core__cover-image.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
],
"url": "https://cldup.com/uuUqE_dXzy.jpg",
"hasParallax": false,
"dimRatio": 50
"dimRatio": 40
},
"originalContent": "<section class=\"wp-block-cover-image has-background-dim-5 has-background-dim\" style=\"background-image:url(https://cldup.com/uuUqE_dXzy.jpg);\">\n <h2>Guten Berg!</h2>\n</section>"
"originalContent": "<section class=\"wp-block-cover-image has-background-dim-4 has-background-dim\" style=\"background-image:url(https://cldup.com/uuUqE_dXzy.jpg);\">\n <h2>Guten Berg!</h2>\n</section>"
}
]
4 changes: 2 additions & 2 deletions blocks/test/fixtures/core__cover-image.parsed.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"blockName": "core/cover-image",
"attrs": {
"url": "https://cldup.com/uuUqE_dXzy.jpg",
"dimRatio": 50
"dimRatio": 40
},
"rawContent": "\n<section class=\"wp-block-cover-image has-background-dim-5 has-background-dim\" style=\"background-image:url(https://cldup.com/uuUqE_dXzy.jpg);\">\n <h2>Guten Berg!</h2>\n</section>\n"
"rawContent": "\n<section class=\"wp-block-cover-image has-background-dim-4 has-background-dim\" style=\"background-image:url(https://cldup.com/uuUqE_dXzy.jpg);\">\n <h2>Guten Berg!</h2>\n</section>\n"
},
{
"attrs": {},
Expand Down
4 changes: 2 additions & 2 deletions blocks/test/fixtures/core__cover-image.serialized.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- wp:core/cover-image {"url":"https://cldup.com/uuUqE_dXzy.jpg","dimRatio":50} -->
<section class="wp-block-cover-image has-background-dim-5 has-background-dim" style="background-image:url(https://cldup.com/uuUqE_dXzy.jpg);">
<!-- wp:core/cover-image {"url":"https://cldup.com/uuUqE_dXzy.jpg","dimRatio":40} -->
<section class="wp-block-cover-image has-background-dim-4 has-background-dim" style="background-image:url(https://cldup.com/uuUqE_dXzy.jpg);">
<h2>Guten Berg!</h2>
</section>
<!-- /wp:core/cover-image -->

0 comments on commit eab53ef

Please sign in to comment.