a zip code crypto-currency system good for red ONLY

ionic.functions.scss 8.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. // Color Functions
  2. // --------------------------------------------------
  3. @function color-error($color-value, $color-name: null) {
  4. $error-msg: "
  5. The value `#{$color-value}` must be a color.
  6. If you are setting the value as a map make sure
  7. both the base and contrast are defined as colors.
  8. For example:
  9. $colors: (
  10. primary: #327eff,
  11. secondary: (base: #32db64, contrast: #000),
  12. );";
  13. // If there was a name passed it means the value doesn't exist
  14. // so error that the value isn't defined
  15. @if ($color-name) {
  16. $error-msg: "
  17. The map color `#{$color-name}` is not defined.
  18. Please make sure the color exists in your
  19. `$colors` map.
  20. For example:
  21. $colors: (
  22. #{$color-name}: #327eff
  23. );";
  24. }
  25. @error $error-msg;
  26. @return null;
  27. }
  28. @function color-brightness($color-value) {
  29. @if (type-of($color-value) != color) {
  30. @return color-error($color-value);
  31. }
  32. @return (red($color-value) * .299 + green($color-value) * .587 + blue($color-value) * .114) / 255 * 100%;
  33. }
  34. @function color-inverse($color-value, $dark: #000, $light: #fff) {
  35. @if (type-of($color-value) != color) {
  36. @return color-error($color-value);
  37. }
  38. $brightness: color-brightness($color-value);
  39. $red: red($color-value);
  40. $green: green($color-value);
  41. @if ($brightness > 79) {
  42. @return $dark;
  43. }
  44. @if ($green > 240) {
  45. @return $dark;
  46. }
  47. @if ($red > 220 and $green > 180) {
  48. @return $dark;
  49. }
  50. @return $light;
  51. }
  52. // Pass dark and light colors based on the mode
  53. // this is mostly used for toolbar buttons/titles
  54. //
  55. // @param {String} $color-value - color to get the inverse of
  56. // @param {Boolean} $custom-contrast-mode - the mode to use
  57. // in order to pass the custom colors
  58. //
  59. // @return {Color}
  60. // --------------------------------------------------
  61. @function mode-inverse($color-value, $custom-contrast-mode) {
  62. $dark: #000;
  63. $light: #fff;
  64. @if ($custom-contrast-mode == md) {
  65. $dark: #424242;
  66. $light: #fff;
  67. } @else if ($custom-contrast-mode == ios) {
  68. $dark: color($colors-ios, primary);
  69. $light: #fff;
  70. }
  71. @return color-inverse($color-value, $dark, $light);
  72. }
  73. @function color-shade($color-value, $amount:8%) {
  74. @if (type-of($color-value) != color) {
  75. @return color-error($color-value);
  76. }
  77. $lightness: lightness($color-value);
  78. $shade: #fff;
  79. @if ($lightness > 50) {
  80. $shade: #000;
  81. }
  82. @return mix($shade, $color-value, $amount);
  83. }
  84. // Copy Colors Map
  85. // --------------------------------------------------
  86. @function copy-colors($colors-map) {
  87. @return map-merge($colors-map, ());
  88. }
  89. // String Replace Function
  90. // --------------------------------------------------
  91. @function str-replace($string, $search, $replace: "") {
  92. $index: str-index($string, $search);
  93. @if $index {
  94. @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
  95. }
  96. @return $string;
  97. }
  98. // String Split Function
  99. // --------------------------------------------------
  100. @function str-split($string, $separator) {
  101. // empty array/list
  102. $split-arr: ();
  103. // first index of separator in string
  104. $index: str-index($string, $separator);
  105. // loop through string
  106. @while $index != null {
  107. // get the substring from the first character to the separator
  108. $item: str-slice($string, 1, $index - 1);
  109. // push item to array
  110. $split-arr: append($split-arr, $item);
  111. // remove item and separator from string
  112. $string: str-slice($string, $index + 1);
  113. // find new index of separator
  114. $index: str-index($string, $separator);
  115. }
  116. // add the remaining string to list (the last item)
  117. $split-arr: append($split-arr, $string);
  118. @return $split-arr;
  119. }
  120. // Str extract between start and end
  121. // --------------------------------------------------
  122. @function str-extract($string, $start, $end) {
  123. $start-index: str-index($string, $start);
  124. @if $start-index {
  125. $post: str-slice($string, $start-index + str-length($start));
  126. $end-index: str-index($post, $end);
  127. @if $end-index {
  128. @return str-slice($post, 1, $end-index - 1);
  129. }
  130. }
  131. @return null;
  132. }
  133. // URL Encode Function
  134. // --------------------------------------------------
  135. @function url-encode($val) {
  136. $spaces: str-replace($val, " ", "%20");
  137. $encoded: str-replace($spaces, "#", "%23");
  138. @return $encoded;
  139. }
  140. // Fetch nested keys
  141. // @param {Map} $map - Map
  142. // @param {Arglist} $keys - Keys to fetch
  143. // @return {*}
  144. // --------------------------------------------------
  145. @function map-fetch($map, $keys...) {
  146. @each $key in $keys {
  147. $map: map-get($map, $key);
  148. }
  149. @return $map;
  150. }
  151. // Fetch map color value
  152. // @param {Map} $map - Map
  153. // @param {String} $color-name - Color name to get
  154. // @param {String} $color-key - Color key (optional), default base
  155. // @return {Color}
  156. // --------------------------------------------------
  157. @function color($map, $color-name, $color-key:null) {
  158. // Get the value from $color-name in the map
  159. // this can be of type color or a map
  160. $color-value: map-get($map, $color-name);
  161. // If we were given a map we need to grab the value
  162. // of the key that is passed or the base key
  163. @if(type-of($color-value) == map) {
  164. @if($color-key) {
  165. $color-value: map-fetch($map, $color-name, $color-key);
  166. } @else {
  167. $color-value: map-fetch($map, $color-name, base);
  168. }
  169. }
  170. // If the value is a color then return the value
  171. // otherwise we need to error with the name
  172. @if (type-of($color-value) == color) {
  173. @return $color-value;
  174. }
  175. @return color-error($color-value, $color-name);
  176. }
  177. // Get the color map key based on the value
  178. // if it doesn't exist then return the value
  179. // --------------------------------------------------
  180. @function color-key($colors, $value) {
  181. @each $color-name, $color-value in $colors {
  182. $base-value: color($colors, $color-name);
  183. @if ($base-value == $value) {
  184. @return map-get($colors, $color-name);
  185. }
  186. }
  187. @return $value;
  188. }
  189. // Fetch map color contrast
  190. // @param {Map} $colors - colors map
  191. // @param {String} $value - color value or color name
  192. //
  193. // Example values
  194. // --------------------------------------------------
  195. // primary | #327eff | #444
  196. // map key | map value | hex color not in map
  197. // --------------------------------------------------
  198. //
  199. // @param {Boolean} $custom-contrast-mode - use custom
  200. // contrast function
  201. // @return {Color}
  202. // --------------------------------------------------
  203. @function color-contrast($colors, $value, $custom-contrast-mode: null) {
  204. $color-value: null;
  205. // If the value is a color (e.g. #fff)
  206. // we need to call color-key to see if
  207. // it exists in the color map or not
  208. @if (type-of($value) == color) {
  209. $color-value: color-key($colors, $value);
  210. } @else {
  211. // If the value is a string (e.g. primary)
  212. // we want to get the value from the map
  213. // where it is the key
  214. $color-value: map-get($colors, $value);
  215. }
  216. // If the value is a map then get the contrast
  217. // from the map (e.g. (base: #327eff, contrast: blue))
  218. @if (type-of($color-value) == map) {
  219. // If the map has the contrast key then use that
  220. // otherwise it is a map with just a base so get
  221. // the inverse of that base color
  222. @if map-has-key($color-value, contrast) {
  223. $color-value: map-get($color-value, contrast);
  224. } @else {
  225. $color-value: color-inverse(map-get($color-value, base));
  226. }
  227. } @elseif ($custom-contrast-mode) {
  228. // If a mode was passed we need to call
  229. // the custom inverse function to get the inverse
  230. // color based on the mode
  231. $color-value: mode-inverse($color-value, $custom-contrast-mode);
  232. } @else {
  233. // Otherwise we were passed a color and can use the
  234. // function to get the inverse of that color
  235. // (e.g. #f4f4f4)
  236. $color-value: color-inverse($color-value);
  237. }
  238. // If the final value being returned is not a color
  239. // we should error
  240. @if (type-of($color-value) != color) {
  241. @return color-error($color-value);
  242. }
  243. @return $color-value;
  244. }
  245. // Create a list using the colors map
  246. // @param {Map} $colors - colors map
  247. // @return {List} $color-name, $color-base, $color-contrast
  248. // ----------------------------------------------------------
  249. @function get-colors($colors, $custom-contrast-mode: null) {
  250. $colors-list: ();
  251. @each $color-name, $color-value in $colors {
  252. $color-base: null;
  253. $color-contrast: null;
  254. @if(type-of($color-value) == map) {
  255. $color-base: map-get($color-value, base);
  256. $color-contrast: map-get($color-value, contrast);
  257. } @else {
  258. $color-base: $color-value;
  259. $color-contrast: color-contrast($colors, $color-value, $custom-contrast-mode);
  260. }
  261. $colors-list: append($colors-list, ($color-name, $color-base, $color-contrast), comma);
  262. }
  263. @return $colors-list;
  264. }