From: Geoff Kimball Date: Wed, 13 Jan 2016 04:59:02 +0000 (-0800) Subject: Add flexbox mode to media object X-Git-Tag: v6.2.0-rc.1~72^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6eefc2cee694da75575944ffbe2437c360a9348f;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Add flexbox mode to media object --- diff --git a/docs/pages/media-object.md b/docs/pages/media-object.md index 1dfd39399..39e8fb026 100644 --- a/docs/pages/media-object.md +++ b/docs/pages/media-object.md @@ -22,6 +22,22 @@ A media object is a container with the class `.media-object`, and two or three s ``` +In flexbox mode, the class `.main-section` must be added to your center section in order to properly size it. + +```html +
+
+
+ +
+
+
+

Dreams feel real while we're in them.

+

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.

+
+
+``` + --- ## Section Alignment @@ -48,6 +64,28 @@ Each section aligns to the top by default, but individual sections can also be m ``` +In flexbox mode, you can use the flexbox helper classes instead to get the same result. The `.align-*` classes can be used on the container to align every child section at once, or individual child sections can be aligned with `.align-self-*` classes. + +```html +
+
+
+ +
+
+
+

Why is it so important to dream?

+

So, once we've made the plant, how do we go out? Hope you have something more elegant in mind than shooting me in the head? A kick. What's a kick? This, Ariadne, would be a kick.

+

What is the most resilient parasite? Bacteria? A virus? An intestinal worm? An idea. Resilient... highly contagious. Once an idea has taken hold of the brain it's almost impossible to eradicate. An idea that is fully formed - fully understood - that sticks; right in there somewhere.

+
+
+
+ +
+
+
+``` + --- ### Stack on Small diff --git a/scss/components/_media-object.scss b/scss/components/_media-object.scss index 30e691cd2..814863ae1 100644 --- a/scss/components/_media-object.scss +++ b/scss/components/_media-object.scss @@ -21,30 +21,46 @@ $mediaobject-image-width-stacked: 100% !default; /// Adds styles for a media object container. @mixin media-object-container { margin-bottom: $mediaobject-margin-bottom; - display: block; + display: if($global-flexbox, flex, block); + + @if $global-flexbox { + flex-wrap: nowrap; + } } /// Adds styles for sections within a media object. /// @param {Number} $padding [$mediaobject-section-padding] - Padding between sections. @mixin media-object-section($padding: $mediaobject-section-padding) { - display: table-cell; - vertical-align: top; + @if $global-flexbox { + flex: 0 0 auto; + } + @else { + display: table-cell; + vertical-align: top; + } &:first-child { padding-#{$global-right}: $padding; } - &:last-child:not(+ #{&}:first-child) { + &:last-child:not(:nth-child(2)) { padding-#{$global-left}: $padding; } } /// Adds styles to stack sections of a media object. Apply this to the section elements, not the container. @mixin media-object-stack { - display: block; padding: 0; padding-bottom: $mediaobject-section-padding; + @if $global-flexbox { + flex-basis: 100%; + max-width: 100%; + } + @else { + display: block; + } + img { width: $mediaobject-image-width-stacked; } @@ -58,6 +74,12 @@ $mediaobject-image-width-stacked: 100% !default; max-width: none; } + @if $global-flexbox { + &.stack-for-small { + flex-wrap: wrap; + } + } + &.stack-for-small .media-object-section { @include breakpoint(small only) { @include media-object-stack; @@ -68,7 +90,12 @@ $mediaobject-image-width-stacked: 100% !default; .media-object-section { @include media-object-section; - &.middle { vertical-align: middle; } - &.bottom { vertical-align: bottom; } + @if $global-flexbox { + &.main-section { flex: 1 1 0px; } + } + @else { + &.middle { vertical-align: middle; } + &.bottom { vertical-align: bottom; } + } } }