mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 13:01:01 +08:00
77 lines
1.6 KiB
SCSS
77 lines
1.6 KiB
SCSS
|
|
// Color Functions
|
|
// --------------------------------------------------
|
|
|
|
@function color-brightness($color-value) {
|
|
@return (red($color-value) * .299 + green($color-value) * .587 + blue($color-value) * .114) / 255 * 100%;
|
|
}
|
|
|
|
|
|
@function color-inverse($color-value, $dark: #000, $light: #fff) {
|
|
$brightness: color-brightness($color-value);
|
|
$red: red($color-value);
|
|
$green: green($color-value);
|
|
|
|
@if ($brightness > 79) {
|
|
@return $dark;
|
|
}
|
|
|
|
@if ($green > 240) {
|
|
@return $dark;
|
|
}
|
|
|
|
@if ($red > 220 and $green > 180) {
|
|
@return $dark;
|
|
}
|
|
|
|
@return $light;
|
|
}
|
|
|
|
|
|
@function toolbar-button-inverse($color-value) {
|
|
@return color-inverse($color-value, $dark: $toolbar-md-button-color, $light: #fff);
|
|
}
|
|
|
|
|
|
@function color-shade($color-value, $amount:8%) {
|
|
$lightness: lightness($color-value);
|
|
|
|
$shade: #fff;
|
|
|
|
@if ($lightness > 50) {
|
|
$shade: #000;
|
|
}
|
|
|
|
@return mix($shade, $color-value, $amount);
|
|
}
|
|
|
|
|
|
// Copy Colors Map
|
|
// --------------------------------------------------
|
|
|
|
@function copy-colors($colors-map) {
|
|
@return map-merge($colors-map, ());
|
|
}
|
|
|
|
|
|
// String Replace Function
|
|
// --------------------------------------------------
|
|
|
|
@function str-replace($string, $search, $replace: "") {
|
|
$index: str-index($string, $search);
|
|
|
|
@if $index {
|
|
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
|
|
}
|
|
|
|
@return $string;
|
|
}
|
|
|
|
|
|
// URL Encode Function
|
|
// --------------------------------------------------
|
|
|
|
@function url-encode($val) {
|
|
@return str-replace($val, " ", "%20");
|
|
}
|