Skip to content

Commit

Permalink
Merge pull request #10679 from Martskin/fix-media-object-mixin-flex-mode
Browse files Browse the repository at this point in the history
Addresses Media Object mixin issue in Flex mode. #9038.
  • Loading branch information
ncoden authored Dec 26, 2017
2 parents e4e96b0 + 606f164 commit bb94d37
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 33 deletions.
66 changes: 33 additions & 33 deletions scss/components/_media-object.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ $mediaobject-image-width-stacked: 100% !default;
@if $global-flexbox {
flex-wrap: nowrap;
}

img {
max-width: none;
}

@if $global-flexbox {
&.stack-for-#{$-zf-zero-breakpoint} {
@include breakpoint($-zf-zero-breakpoint only) {
flex-wrap: wrap;
}
}
}

&.stack-for-#{$-zf-zero-breakpoint} .media-object-section {
@include breakpoint($-zf-zero-breakpoint only) {
@include media-object-stack;
}
}
}

/// Adds styles for sections within a media object.
Expand All @@ -50,6 +68,21 @@ $mediaobject-image-width-stacked: 100% !default;
> :last-child {
margin-bottom: 0;
}

@if $global-flexbox {
&.main-section {
flex: 1 1 0px; // sass-lint:disable-line zero-unit
}
}
@else {
&.middle {
vertical-align: middle;
}

&.bottom {
vertical-align: bottom;
}
}
}

/// Adds styles to stack sections of a media object. Apply this to the section elements, not the container.
Expand All @@ -73,42 +106,9 @@ $mediaobject-image-width-stacked: 100% !default;
@mixin foundation-media-object {
.media-object {
@include media-object-container;

img {
max-width: none;
}

@if $global-flexbox {
&.stack-for-#{$-zf-zero-breakpoint} {
@include breakpoint($-zf-zero-breakpoint only) {
flex-wrap: wrap;
}
}
}

&.stack-for-#{$-zf-zero-breakpoint} .media-object-section {
@include breakpoint($-zf-zero-breakpoint only) {
@include media-object-stack;
}
}
}

.media-object-section {
@include media-object-section;

@if $global-flexbox {
&.main-section {
flex: 1 1 0px; // sass-lint:disable-line zero-unit
}
}
@else {
&.middle {
vertical-align: middle;
}

&.bottom {
vertical-align: bottom;
}
}
}
}
56 changes: 56 additions & 0 deletions test/visual/media-object/media-object-mixins-flex-mode.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!doctype html>
<!--[if IE 9]><html class="lt-ie10" lang="en" > <![endif]-->
<html class="no-js" lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Foundation for Sites Testing</title>
<link href="../motion-ui/dist/motion-ui.css" rel="stylesheet" />
<link href="../assets/css/foundation.css" rel="stylesheet" />
</head>
<body>
<div class="grid-container">
<div class="grid-x grid-padding-x">
<div class="cell">
<h1>Media Object: Mixins In Flex Mode</h1>

<p>Media Object created using <code>media-object-container</code> and <code>media-object-section</code> mixins with <code>$global-flexbox: true</code> should behave the same as Media Object created using <code>foundation-media-object</code> mixin with <code>$global-flexbox: true</code>.</p>

<h3>Default</h3>
<div class="media-object">
<div class="media-object-section">
<div class="thumbnail">
<img src= "http://via.placeholder.com/100x100">
</div>
</div>
<div class="media-object-section">
<h4>Dreams feel real while we're in them.</h4>
<p>I'm going to improvise. Listen, there's something you should know about me... about inception. An idea is like a virus, resilient, highly contagious. The smallest seed of an idea can grow. It can grow to define or destroy you.</p>
</div>
</div>

<h3>Stack on Small</h3>
<div class="media-object stack-for-small">
<div class="media-object-section">
<div class="thumbnail">
<img src= "http://via.placeholder.com/600x300">
</div>
</div>
<div class="media-object-section">
<h4>I Can Stack.</h4>
<p>Shrink the browser width to see me stack. I do tricks for dog treats, but I'm not a dog.</p>
</div>
</div>
</div>
</div>
</div>


<script src="../assets/js/vendor.js"></script>
<script src="../assets/js/foundation.js"></script>
<script>
$(document).foundation();
</script>
</body>
</html>

0 comments on commit bb94d37

Please sign in to comment.