Skip to content

Commit

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

- name: Setup tmate session
uses: mxschmitt/action-tmate@v3

- name: Start docker local env
run: |
npm run env:start
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,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
class="material-design-card__media-actions"
>
Expand Down Expand Up @@ -1226,9 +1230,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
class="material-design-card__media-actions"
>
Expand Down Expand Up @@ -1959,9 +1967,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
class="material-design-card__media-actions"
>
Expand Down Expand Up @@ -2611,9 +2623,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
class="material-design-card__media-actions"
>
Expand Down Expand Up @@ -3344,9 +3360,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
class="material-design-card__media-actions"
>
Expand Down Expand Up @@ -3987,9 +4007,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
class="material-design-card__media-actions"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,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 @@ -175,9 +178,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 @@ -397,9 +403,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 @@ -441,9 +450,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 Down Expand Up @@ -288,9 +291,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 @@ -11190,7 +11190,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 @@ -11506,7 +11505,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 c4b00d8

Please sign in to comment.