Skip to content

Commit

Permalink
Merge 2c2ed68 into 58cf0b3
Browse files Browse the repository at this point in the history
  • Loading branch information
ravichdev authored Apr 6, 2021
2 parents 58cf0b3 + 2c2ed68 commit 0520063
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/lint-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ jobs:
- name: Build assets
run: npm run build:js

- name: Sleep for 10 seconds
uses: jakejarvis/wait-action@master
with:
time: '10s'

- name: Start docker local env
run: |
npm run env:start
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ const CardImageEdit = ( {
[ `material-design-card-with-${ contentLayout }` ]: contentLayout,
}
) }
style={ { backgroundImage: `url(${ imageSourceUrl })` } }
>
<img
src={ imageSourceUrl }
alt={ cardPrimaryProps.title || '' }
/>
{ contentLayout === 'text-over-media' && (
<div className="mdc-card__media-content">
<CardPrimary { ...cardPrimaryProps } />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const CardPrimary = ( {
value={ title }
onChange={ value => setter( 'title', value, cardIndex ) }
placeholder={ __( 'Title goes here', 'material-design' ) }
place
/>
) }
{ displaySecondaryText && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,22 @@
text-decoration: none !important;
}
text-decoration: none !important;

}

.mdc-button__comment-count {
justify-content: left !important;
min-width: 36px !important;
}

.mdc-card__media {

& img {
bottom: 0;
height: 100%;
left: 0;
object-fit: cover;
position: absolute;
top: 0;
width: 100%;
}
}
6 changes: 2 additions & 4 deletions plugin/php/templates/partials/card-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@

if ( ! empty( $featured_image ) ) :
?>
<div
class="<?php echo esc_attr( Template::classnames( $class_names ) ); ?>"
style="background-image: url(<?php echo esc_url( $featured_image ); ?>)"
>
<div class="<?php echo esc_attr( Template::classnames( $class_names ) ); ?>">
<?php echo get_the_post_thumbnail( get_the_ID(), 'list' === $style ? 'medium' : 'large' ); ?>
<?php
if ( 'text-over-media' === $layout ) {
?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,13 @@ Object {
>
<div
class="mdc-card__media mdc-card__media--16-9 material-design-card__media material-design-card-with-text-under-media"
style="background-image: url(http://test.loc/test.jpg);"
tabindex="0"
/>
>
<img
alt="Test title"
src="http://test.loc/test.jpg"
/>
</div>
</div>
<div
class="material-design-card__primary"
Expand Down Expand Up @@ -1202,9 +1206,13 @@ Object {
>
<div
class="mdc-card__media mdc-card__media--16-9 material-design-card__media material-design-card-with-text-under-media"
style="background-image: url(http://test.loc/test.jpg);"
tabindex="0"
/>
>
<img
alt="Test title"
src="http://test.loc/test.jpg"
/>
</div>
</div>
<div
class="material-design-card__primary"
Expand Down Expand Up @@ -1911,9 +1919,13 @@ Object {
>
<div
class="mdc-card__media mdc-card__media--16-9 material-design-card__media material-design-card-with-text-under-media"
style="background-image: url(http://test.loc/test.jpg);"
tabindex="0"
/>
>
<img
alt="Test title"
src="http://test.loc/test.jpg"
/>
</div>
</div>
<div
class="material-design-card__primary"
Expand Down Expand Up @@ -2539,9 +2551,13 @@ Object {
>
<div
class="mdc-card__media mdc-card__media--16-9 material-design-card__media material-design-card-with-text-under-media"
style="background-image: url(http://test.loc/test.jpg);"
tabindex="0"
/>
>
<img
alt="Test title"
src="http://test.loc/test.jpg"
/>
</div>
</div>
<div
class="material-design-card__primary"
Expand Down Expand Up @@ -3248,9 +3264,13 @@ Object {
>
<div
class="mdc-card__media mdc-card__media--square material-design-card__media material-design-card-with-text-under-media"
style="background-image: url(http://test.loc/test.jpg);"
tabindex="0"
/>
>
<img
alt="Test title"
src="http://test.loc/test.jpg"
/>
</div>
</div>
<div
class="material-design-card__primary"
Expand Down Expand Up @@ -3867,9 +3887,13 @@ Object {
>
<div
class="mdc-card__media mdc-card__media--square material-design-card__media material-design-card-with-text-under-media"
style="background-image: url(http://test.loc/test.jpg);"
tabindex="0"
/>
>
<img
alt="Test title"
src="http://test.loc/test.jpg"
/>
</div>
</div>
<div
class="material-design-card__primary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ Object {
>
<div
class="mdc-card__media mdc-card__media--16-9 material-design-card__media material-design-card-with-text-over-media"
style="background-image: url(http://test.loc/test.jpg);"
tabindex="0"
>
<img
alt=""
src="http://test.loc/test.jpg"
/>
<div
class="mdc-card__media-content"
>
Expand Down Expand Up @@ -78,9 +81,12 @@ Object {
>
<div
class="mdc-card__media mdc-card__media--16-9 material-design-card__media material-design-card-with-text-over-media"
style="background-image: url(http://test.loc/test.jpg);"
tabindex="0"
>
<img
alt=""
src="http://test.loc/test.jpg"
/>
<div
class="mdc-card__media-content"
>
Expand Down Expand Up @@ -300,9 +306,12 @@ Object {
>
<div
class="mdc-card__media mdc-card__media--16-9 material-design-card__media material-design-card-with-text-over-media"
style="background-image: url(http://test.loc/test.jpg);"
tabindex="0"
>
<img
alt=""
src="http://test.loc/test.jpg"
/>
<div
class="mdc-card__media-content"
>
Expand All @@ -320,9 +329,12 @@ Object {
>
<div
class="mdc-card__media mdc-card__media--16-9 material-design-card__media material-design-card-with-text-over-media"
style="background-image: url(http://test.loc/test.jpg);"
tabindex="0"
>
<img
alt=""
src="http://test.loc/test.jpg"
/>
<div
class="mdc-card__media-content"
>
Expand Down Expand Up @@ -518,9 +530,12 @@ Object {
>
<div
class="mdc-card__media mdc-card__media--16-9 material-design-card__media material-design-card-with-text-over-media"
style="background-image: url(http://test.loc/test.jpg);"
tabindex="0"
>
<img
alt=""
src="http://test.loc/test.jpg"
/>
<div
class="mdc-card__media-content"
>
Expand All @@ -538,9 +553,12 @@ Object {
>
<div
class="mdc-card__media mdc-card__media--16-9 material-design-card__media material-design-card-with-text-over-media"
style="background-image: url(http://test.loc/test.jpg);"
tabindex="0"
>
<img
alt=""
src="http://test.loc/test.jpg"
/>
<div
class="mdc-card__media-content"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,12 @@ Object {
>
<div
class="mdc-card__media mdc-card__media--16-9 material-design-card__media material-design-card-with-text-over-media"
style="background-image: url(http://test.loc/test.jpg);"
tabindex="0"
>
<img
alt=""
src="http://test.loc/test.jpg"
/>
<div
class="mdc-card__media-content"
>
Expand All @@ -264,9 +267,12 @@ Object {
>
<div
class="mdc-card__media mdc-card__media--16-9 material-design-card__media material-design-card-with-text-over-media"
style="background-image: url(http://test.loc/test.jpg);"
tabindex="0"
>
<img
alt=""
src="http://test.loc/test.jpg"
/>
<div
class="mdc-card__media-content"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11194,7 +11194,6 @@ exports[`blocks: material/cards-collection: Edit removes one card from the ui is
<ForwardRef
className="material-design-card__title mdc-typography mdc-typography--headline6"
onChange={[Function]}
place={true}
placeholder="Title goes here"
tagName="h2"
value="Title #1 goes here"
Expand Down Expand Up @@ -11514,7 +11513,6 @@ exports[`blocks: material/cards-collection: Edit removes one card from the ui is
<ForwardRef
className="material-design-card__title mdc-typography mdc-typography--headline6"
onChange={[Function]}
place={true}
placeholder="Title goes here"
tagName="h2"
value="Title #2 goes here"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function test_render_block_hand_picked() {
$content = $this->clean_content( $content );

// Assert the article with featured image shows content inside the image container.
$this->assertEquals( 1, substr_count( $content, 'style="background-image: url(http://example.org/wp-content/uploads/image.jpg)"><div class="mdc-card__media-content">' ) );
$this->assertEquals( 1, substr_count( $content, '<img width="1" height="1" src="http://example.org/wp-content/uploads/image.jpg"' ) );

// Assert all 4 posts are rendered.
$this->assertEquals( 4, substr_count( $content, 'class="single-post-card__title' ) );
Expand Down Expand Up @@ -427,7 +427,7 @@ public function test_render_block_recent() {
$content = $this->clean_content( $content );

// Assert the article with featured image shows content inside the image container.
$this->assertEquals( 1, substr_count( $content, 'style="background-image: url(http://example.org/wp-content/uploads/image.jpg)"><div class="mdc-card__media-content">' ) );
$this->assertEquals( 1, substr_count( $content, '<img width="1" height="1" src="http://example.org/wp-content/uploads/image.jpg"' ) );

// Assert all 5 posts are rendered.
$this->assertEquals( 5, substr_count( $content, 'class="single-post-card__title' ) );
Expand Down
12 changes: 12 additions & 0 deletions theme/assets/css/src/components/post-card.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,16 @@
.post-card__subtitle {
color: rgba(var(--mdc-theme-on-surface-rgb, 0, 0, 0), .54);
}

.mdc-card__media {

& img {
bottom: 0;
height: 100%;
object-fit: cover;
position: absolute;
top: 0;
width: 100%;
}
}
}
4 changes: 3 additions & 1 deletion theme/template-parts/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
<a class="mdc-card__link" href="<?php the_permalink(); ?>">
<div class="mdc-card__primary-action post-card__primary-action">
<?php if ( has_post_thumbnail() ) : ?>
<div class="mdc-card__media mdc-card__media--16-9 post-card__media" style="background-image: url(&quot;<?php echo esc_attr( get_the_post_thumbnail_url() ); ?>&quot;);"></div>
<div class="mdc-card__media mdc-card__media--16-9 post-card__media">
<?php the_post_thumbnail(); ?>
</div>
<?php endif; ?>
<div class="post-card__primary">
<?php if ( is_sticky() ) : ?>
Expand Down

0 comments on commit 0520063

Please sign in to comment.