@import "ionic.functions"; // Appearance // -------------------------------------------------- @mixin appearance($val) { -moz-appearance: $val; -ms-appearance: $val; -webkit-appearance: $val; appearance: $val; } // Input Placeholder // -------------------------------------------------- @mixin placeholder($color: #999, $text-indent: 0) { &::-moz-placeholder { // Firefox 19+ color: $color; } &:-ms-input-placeholder { color: $color; } &::-webkit-input-placeholder { // Safari placeholder margin issue text-indent: $text-indent; color: $color; } } // Button Icons // -------------------------------------------------- @mixin button-icon($font-size: 1.4em, $line-height: .67, $pointer-events: none, $margin: 0) { font-size: $font-size; line-height: $line-height; pointer-events: $pointer-events; margin: $margin; } // Check that the given map values are in ascending order // --------------------------------------------------------------------------------- @mixin assert-ascending($map, $map-name) { $prev-key: null; $prev-num: null; @each $key, $num in $map { @if $prev-num == null { // Do nothing } @else if not comparable($prev-num, $num) { @warn "Potentially invalid value for #{$map-name}: This map must be in ascending order, but key '#{$key}' has value #{$num} whose unit makes it incomparable to #{$prev-num}, the value of the previous key '#{$prev-key}' !"; } @else if $prev-num >= $num { @warn "Invalid value for #{$map-name}: This map must be in ascending order, but key '#{$key}' has value #{$num} which isn't greater than #{$prev-num}, the value of the previous key '#{$prev-key}' !"; } $prev-key: $key; $prev-num: $num; } } // Check that the first value in the given map starts at 0 // --------------------------------------------------------------------------------- @mixin assert-starts-at-zero($map, $map-name) { $values: map-values($map); $first-value: nth($values, 1); @if $first-value != 0 { @warn "First value in `#{$map-name}` must start at 0, but starts at #{$first-value}."; } } // Breakpoint Mixins // --------------------------------------------------------------------------------- // Breakpoint viewport sizes and media queries. // // Breakpoints are defined as a map of (name: minimum width), order from small to large: // // (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px) // // The map defined in the `$grid-breakpoints` global variable is used as the `$breakpoints` argument by default. // --------------------------------------------------------------------------------- // Minimum breakpoint width. Null for the smallest (first) breakpoint. // // >> breakpoint-min(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) // 576px @function breakpoint-min($name, $breakpoints: $grid-breakpoints) { $min: map-get($breakpoints, $name); @return if($min != 0, $min, null); } // Returns a blank string if smallest breakpoint, otherwise returns the name with a dash infront. // Useful for making responsive utilities. // // >> breakpoint-infix(xs, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) // "" (Returns a blank string) // >> breakpoint-infix(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) // "-sm" @function breakpoint-infix($name, $breakpoints: $grid-breakpoints) { @return if(breakpoint-min($name, $breakpoints) == null, "", "-#{$name}"); } // Media of at least the minimum breakpoint width. No query for the smallest breakpoint. // Makes the @content apply to the given breakpoint and wider. @mixin media-breakpoint-up($name, $breakpoints: $grid-breakpoints) { $min: breakpoint-min($name, $breakpoints); @if $min { @media (min-width: $min) { @content; } } @else { @content; } } // Name of the next breakpoint, or null for the last breakpoint. // // >> breakpoint-next(sm) // md // >> breakpoint-next(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) // md // >> breakpoint-next(sm, $breakpoint-names: (xs sm md lg xl)) // md @function breakpoint-next($name, $breakpoints: $grid-breakpoints, $breakpoint-names: map-keys($breakpoints)) { $n: index($breakpoint-names, $name); @return if($n < length($breakpoint-names), nth($breakpoint-names, $n + 1), null); } // Maximum breakpoint width. Null for the largest (last) breakpoint. // The maximum value is calculated as the minimum of the next one less 0.1. // // >> breakpoint-max(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) // 767px @function breakpoint-max($name, $breakpoints: $grid-breakpoints) { $next: breakpoint-next($name, $breakpoints); @return if($next, breakpoint-min($next, $breakpoints) - 1px, null); } // Media of at most the maximum breakpoint width. No query for the largest breakpoint. // Makes the @content apply to the given breakpoint and narrower. @mixin media-breakpoint-down($name, $breakpoints: $grid-breakpoints) { $max: breakpoint-max($name, $breakpoints); @if $max { @media (max-width: $max) { @content; } } @else { @content; } } @mixin multi-dir() { @if $app-direction == multi { $root: #{&}; @at-root [dir="ltr"], [dir="rtl"] { #{$root} { @content; } } } @else { @content; } } @mixin rtl() { @if $app-direction == multi { $root: #{&}; @at-root [dir="rtl"] { #{$root} { @content; } } } @else if $app-direction == rtl { @content; } } @mixin ltr() { @if $app-direction == multi { $root: #{&}; @at-root [dir="ltr"] { #{$root} { @content; } } } @else if $app-direction == ltr { @content; } } // If deprecated variable exists, use it, otherwise, use alternative // @param {string} $property - property to default // @param {string} $variable - the deprecated variable // ---------------------------------------------------------- @mixin deprecated-variable($property, $variable) { @if $variable == null { @content; } @else { // TODO find variable name @warn "you are using a deprecated variable"; #{$property}: $variable; } } // SVG Background Image Mixin // @param {string} $svg // ---------------------------------------------------------- @mixin svg-background-image($svg, $flip-rtl: false) { $url: url-encode($svg); $viewBox: str-split(str-extract($svg, "viewBox='", "'"), " "); @if $flip-rtl != true or $viewBox == null { @include multi-dir() { background-image: url("data:image/svg+xml;charset=utf-8,#{$url}"); } } @else { $transform: "transform='translate(#{nth($viewBox, 3)}, 0) scale(-1, 1)'"; $flipped-url: $svg; $flipped-url: str-replace($flipped-url, "