/* * Imported ionic mixins for SCSS * ---------------------------------------------------------------------------- * Place here our custom mixins. * Extracted from ionic.mixins.scss * https://github.com/ionic-team/ionic-framework/blob/master/core/src/themes/ionic.mixins.scss */ // Responsive Mixins // -------------------------------------------------- // Creates a fixed width for the grid based on the screen size // --------------------------------------------------------------------------------- @mixin make-grid-widths($widths: $grid-widths, $breakpoints: $screen-breakpoints) { @each $breakpoint, $width in $widths { @include media-breakpoint-up($breakpoint, $breakpoints) { width: $width; } } max-width: 100%; } // Adds padding to the element based on breakpoints // --------------------------------------------------------------------------------- @mixin make-breakpoint-padding($paddings) { @each $breakpoint in map-keys($paddings) { @include media-breakpoint-up($breakpoint) { $padding: map-get($paddings, $breakpoint); @include padding($padding); } } } // Gets the active color's css variable from a variation. Alpha is optional. // -------------------------------------------------------------------------------------------- // Example usage: // current-color(base) => var(--ion-color-base) // current-color(contrast, 0.1) => rgba(var(--ion-color-contrast-rgb), 0.1) // -------------------------------------------------------------------------------------------- @function current-color($variation, $alpha: null) { @if $alpha == null { @return var(--ion-color-#{$variation}); } @else { @return rgba(var(--ion-color-#{$variation}-rgb), #{$alpha}); } } // Mixes a color with black to create its shade. // Default to bootstrap level 6. // -------------------------------------------------------------------------------------------- @function get-color-shade($color, $percent: 48%) { @return mix(#000, $color, $percent); } // Mixes a color with white to create its tint. // Default to bootstrap level -10. // -------------------------------------------------------------------------------------------- @function get-color-tint($color, $percent: 80%) { @return mix(#fff, $color, $percent); } // Converts a color to a comma separated rgb. // -------------------------------------------------------------------------------------------- @function color-to-rgb-list($color) { @return #{red($color)},#{green($color)},#{blue($color)}; } // Ionic Colors // -------------------------------------------------- // Generates the color classes and variables based on the // colors map @mixin generate-color($color-name, $colors) { $base: map-get($colors, $color-name); $light: map-get($base, 'light'); @include generate-color-variants($color-name, $light); body.dark { $dark: map-get($base, 'dark'); $dark: mix($light, white, 40%) !default; @include generate-color-variants($color-name, $dark); } } @mixin generate-color-variants($color-name, $base) { $contrast: get_contrast_color($base); $shade: get-color-shade($base); $tint: get-color-tint($base); --#{$color-name}: #{$base}; --#{$color-name}-shade: #{$shade}; --#{$color-name}-tint: #{$tint}; --#{$color-name}-contrast: #{$contrast}; // Internal ionic use only. --ion-color-#{$color-name}: var(--#{$color-name}); --ion-color-#{$color-name}-base: var(--ion-color-#{$color-name}); --ion-color-#{$color-name}-rgb: #{color-to-rgb-list($base)}; --ion-color-#{$color-name}-contrast: #{$contrast}; --ion-color-#{$color-name}-contrast-rgb: #{color-to-rgb-list($contrast)}; --ion-color-#{$color-name}-shade: #{$shade}; --ion-color-#{$color-name}-tint: #{$tint}; .ion-color-#{$color-name} { --ion-color: var(--ion-color-#{$color-name}); --ion-color-base: var(--ion-color-#{$color-name}-base); --ion-color-rgb: var(--ion-color-#{$color-name}-rgb); --ion-color-contrast: var(--ion-color-#{$color-name}-contrast); --ion-color-contrast-rgb: var(--ion-color-#{$color-name}-contrast-rgb); --ion-color-shade: var(--ion-color-#{$color-name}-shade); --ion-color-tint: var(--ion-color-#{$color-name}-tint); } } @mixin input-cover() { @include position(0, null, null, 0); @include margin(0); position: absolute; width: 100%; height: 100%; border: 0; background: transparent; cursor: pointer; appearance: none; outline: none; &::-moz-focus-inner { border: 0; } } @mixin text-inherit() { font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; letter-spacing: inherit; text-decoration: inherit; text-indent: inherit; text-overflow: inherit; text-transform: inherit; text-align: inherit; white-space: inherit; color: inherit; } @mixin button-state() { @include position(0, 0, 0, 0); position: absolute; content: ""; opacity: 0; } // Font smoothing // -------------------------------------------------- @mixin font-smoothing() { -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; } // Get the key from a map based on the index @function index-to-key($map, $index) { $keys: map-keys($map); @return nth($keys, $index); } // 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 `$screen-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: $screen-breakpoints) { $min: map-get($breakpoints, $name); @return if($name != index-to-key($breakpoints, 1), $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: $screen-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: $screen-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: $screen-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 smallest (first) breakpoint. // The maximum value is reduced by 0.02px to work around the limitations of // `min-` and `max-` prefixes and viewports with fractional widths. // // See https://www.w3.org/TR/mediaqueries-4/#mq-min-max // Uses 0.02px rather than 0.01px to work around a current rounding bug in Safari. // Uses 0.02px rather than 0.01px to work around a current rounding bug in Safari. // See https://bugs.webkit.org/show_bug.cgi?id=178261 // See https://bugs.webkit.org/show_bug.cgi?id=178261 // // >> breakpoint-max(md, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) // 767.98px @function breakpoint-max($name, $breakpoints: $screen-breakpoints) { $max: map-get($breakpoints, $name); @return if($max and $max > 0, $max - .02, 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: $screen-breakpoints) { $max: breakpoint-max($name, $breakpoints); @if $max { @media (max-width: $max) { @content; } } @else { @content; } } // Text Direction - ltr / rtl // // CSS defaults to use the ltr css, and adds [dir=rtl] selectors // to override ltr defaults. // ---------------------------------------------------------- @mixin multi-dir() { @content; // $root: #{&}; // @at-root [dir] { // #{$root} { // @content; // } // } } @mixin rtl() { $root: #{&}; @at-root [dir=rtl] { #{$root} { @content; } } } @mixin ltr() { @content; } // 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, "