// There are two ways to use the flexbox module. // If you're using the final version of the spec, // you can use the property mixins as elsewhere in // the css3 module. // // You can also use the flexbox prefixing mixin `flexbox`. // This mixin takes an optional `$version` argument which // allows you to specify which spec version the properties // are using so that they will be prefixed correctly. // // Example: // // .flex-column { // /* For flexbox spec v1 */ // @include flexbox(( // display: box, // box-orient: vertical, // ), $version: 1); // // /* For flexbox spec v2 */ // @include flexbox(( // display: flexbox, // flex-direction: column, // ), $version: 2); // // /* Latest Spec */ // @include flexbox(( // display: flex, // flex-direction: column, // )); // } // // Which compiles to: // // .flex-row { // /* For flexbox spec v1 */ // display: -moz-box; // -moz-box-orient: vertical; // display: -webkit-box; // -webkit-box-orient: vertical; // // /* For flexbox spec v2 */ // display: -ms-flexbox; // -ms-flex-direction: column; // // /* Latest Spec */ // display: -webkit-flex; // -webkit-flex-direction: column; // display: flex; // flex-direction: column; // } @import "compass/support"; $flexbox-support-threshold: $critical-usage-threshold !default; // @private $flexbox-capability-options: ( (full-support: true), (partial-support: true, spec-versions: 3) ); @mixin flexbox($properties, $version: null) { $capability-options: $flexbox-capability-options; @if $version { $capability-options: (partial-support: true, spec-versions: $version); } @include with-each-prefix(flexbox, $flexbox-support-threshold, $capability-options) { // Don't output unprefixed versions when the spec version is not the final version @if $version and $current-prefix or not $version or $version == 3 { @each $prop, $value in $properties { @if $prop == display { display: prefix-identifier($value); } @else { @include prefix-prop($prop, $value); } } } } } @mixin display-flex { @include flexbox((display: flex)); } // Values: row | row-reverse | column | column-reverse @mixin flex-direction($direction) { @include flexbox((flex-direction: $direction)); } // Values: nowrap | wrap | wrap-reverse @mixin flex-wrap($wrap) { @include flexbox((flex-wrap: $wrap)); } // Shorthand for flex-direction and flex-wrap. @mixin flex-flow($flow) { @include flexbox((flex-flow: $flow)); } // Accepts an integer @mixin order($order) { @include flexbox((order: $order)); } // Shorthand for flex-grow, flex-shrink and optionally flex-basis. // Space separated, in that order. @mixin flex($flex) { @include flexbox((flex: $flex)); } // Accepts a number. @mixin flex-grow($flex-grow) { @include flexbox((flex-grow: $flex-grow)); } // Accepts a number. @mixin flex-shrink($flex-shrink) { @include flexbox((flex-shrink: $flex-shrink)); } // Accepts any legal value for the width property. @mixin flex-basis($flex-basis) { @include flexbox((flex-basis: $flex-basis)); } // Legal values: flex-start | flex-end | center | space-between | space-around @mixin justify-content($justify-content) { @include flexbox((justify-content: $justify-content)); } // Legal values: flex-start | flex-end | center | baseline | stretch @mixin align-items($align-items) { @include flexbox((align-items: $align-items)); } // Legal values: auto | flex-start | flex-end | center | baseline | stretch @mixin align-self($align-self) { @include flexbox((align-self: $align-self)); } // Legal values: flex-start | flex-end | center | space-between | space-around | stretch @mixin align-content($align-content) { @include flexbox((align-content: $align-content)); }