searchbar.ios.scss 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. @import "../../themes/ionic.globals.ios";
  2. // iOS Searchbar
  3. // --------------------------------------------------
  4. /// @prop - Padding top/bottom of the searchbar
  5. $searchbar-ios-padding-vertical: 0 !default;
  6. /// @prop - Padding start/end of the searchbar
  7. $searchbar-ios-padding-horizontal: 8px !default;
  8. /// @prop - Background of the searchbar
  9. $searchbar-ios-background-color: rgba(0, 0, 0, .2) !default;
  10. /// @prop - Border color of the searchbar
  11. $searchbar-ios-border-color: rgba(0, 0, 0, .05) !default;
  12. /// @prop - Minimum height of the searchbar
  13. $searchbar-ios-min-height: 44px !default;
  14. /// @prop - Color of the searchbar input search icon
  15. $searchbar-ios-input-search-icon-color: rgba(0, 0, 0, .5) !default;
  16. /// @prop - Svg for the searchbar input search icon
  17. $searchbar-ios-input-search-icon-svg: "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 13'><path fill='fg-color' d='M5,1c2.2,0,4,1.8,4,4S7.2,9,5,9S1,7.2,1,5S2.8,1,5,1 M5,0C2.2,0,0,2.2,0,5s2.2,5,5,5s5-2.2,5-5S7.8,0,5,0 L5,0z'/><line stroke='fg-color' stroke-miterlimit='10' x1='12.6' y1='12.6' x2='8.2' y2='8.2'/></svg>" !default;
  18. /// @prop - Size of the searchbar input search icon
  19. $searchbar-ios-input-search-icon-size: 13px !default;
  20. /// @prop - Height of the searchbar input
  21. $searchbar-ios-input-height: 3rem !default;
  22. /// @prop - Color of the searchbar input placeholder
  23. $searchbar-ios-input-placeholder-color: rgba(0, 0, 0, .5) !default;
  24. /// @prop - Color of the searchbar input text
  25. $searchbar-ios-input-text-color: #000 !default;
  26. /// @prop - Background of the searchbar input
  27. $searchbar-ios-input-background-color: #fff !default;
  28. /// @prop - Transition of the searchbar input
  29. $searchbar-ios-input-transition: all 300ms ease !default;
  30. /// @prop - Transition of the searchbar input cancel button
  31. $searchbar-ios-cancel-transition: all 300ms ease !default;
  32. /// @prop - Color of the searchbar input clear icon
  33. $searchbar-ios-input-clear-icon-color: rgba(0, 0, 0, .5) !default;
  34. /// @prop - Svg for the searchbar input clear icon
  35. $searchbar-ios-input-clear-icon-svg: "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><path fill='fg-color' d='M403.1,108.9c-81.2-81.2-212.9-81.2-294.2,0s-81.2,212.9,0,294.2c81.2,81.2,212.9,81.2,294.2,0S484.3,190.1,403.1,108.9z M352,340.2L340.2,352l-84.4-84.2l-84,83.8L160,339.8l84-83.8l-84-83.8l11.8-11.8l84,83.8l84.4-84.2l11.8,11.8L267.6,256L352,340.2z'/></svg>" !default;
  36. /// @prop - Size of the searchbar input clear icon
  37. $searchbar-ios-input-clear-icon-size: 18px !default;
  38. /// @prop - Background of the searchbar input inside of a toolbar
  39. $searchbar-ios-toolbar-input-background: rgba(0, 0, 0, .08) !default;
  40. // Searchbar
  41. // -----------------------------------------
  42. .searchbar-ios {
  43. @include padding($searchbar-ios-padding-vertical, $searchbar-ios-padding-horizontal);
  44. min-height: $searchbar-ios-min-height;
  45. border-top: $hairlines-width solid transparent;
  46. border-bottom: $hairlines-width solid $searchbar-ios-border-color;
  47. background: $searchbar-ios-background-color;
  48. }
  49. // Searchbar Mixin for Icons
  50. // -----------------------------------------
  51. @mixin ios-searchbar-icon($svg-icon, $fg-color) {
  52. $svg: str-replace($svg-icon, 'fg-color', $fg-color);
  53. @include svg-background-image($svg, true);
  54. }
  55. // Searchbar Search Icon
  56. // -----------------------------------------
  57. .searchbar-ios .searchbar-search-icon {
  58. @include position(9px, null, null, 9px);
  59. @include ios-searchbar-icon($searchbar-ios-input-search-icon-svg, $searchbar-ios-input-search-icon-color);
  60. @include margin-horizontal(calc(50% - 60px), null);
  61. position: absolute;
  62. width: $searchbar-ios-input-search-icon-size + 1;
  63. height: $searchbar-ios-input-search-icon-size + 1;
  64. background-repeat: no-repeat;
  65. background-size: $searchbar-ios-input-search-icon-size;
  66. }
  67. // Searchbar Input Field
  68. // -----------------------------------------
  69. .searchbar-ios .searchbar-input {
  70. @include placeholder($searchbar-ios-input-placeholder-color);
  71. @include padding(0, 28px);
  72. @include border-radius(5px);
  73. height: $searchbar-ios-input-height;
  74. font-size: 1.4rem;
  75. font-weight: 400;
  76. color: $searchbar-ios-input-text-color;
  77. background-color: $searchbar-ios-input-background-color;
  78. }
  79. // Searchbar Clear Input Icon
  80. // -----------------------------------------
  81. .searchbar-ios .searchbar-clear-icon {
  82. @include position(0, 0, null, null);
  83. @include ios-searchbar-icon($searchbar-ios-input-clear-icon-svg, $searchbar-ios-input-clear-icon-color);
  84. @include background-position(center);
  85. position: absolute;
  86. width: 30px;
  87. height: 100%;
  88. background-repeat: no-repeat;
  89. background-size: $searchbar-ios-input-clear-icon-size;
  90. }
  91. // Searchbar Cancel (iOS only)
  92. // -----------------------------------------
  93. .searchbar-ios .searchbar-ios-cancel {
  94. @include padding(0, 0, 0, 8px);
  95. @include margin-horizontal(0, null);
  96. display: none;
  97. flex-shrink: 0;
  98. height: 30px;
  99. cursor: pointer;
  100. }
  101. // Searchbar Left Aligned (iOS only)
  102. // -----------------------------------------
  103. .searchbar-ios.searchbar-left-aligned .searchbar-search-icon {
  104. @include margin-horizontal(0, null);
  105. }
  106. .searchbar-ios.searchbar-left-aligned .searchbar-input {
  107. @include padding-horizontal(30px, null);
  108. }
  109. // Searchbar Has Focus
  110. // -----------------------------------------
  111. .searchbar-ios.searchbar-show-cancel.searchbar-has-focus .searchbar-ios-cancel {
  112. display: block;
  113. }
  114. // Searchbar in Toolbar
  115. // -----------------------------------------
  116. .toolbar .searchbar-ios {
  117. border-bottom-width: 0;
  118. background: transparent;
  119. }
  120. .toolbar .searchbar-ios .searchbar-input {
  121. background: $searchbar-ios-toolbar-input-background;
  122. }
  123. .toolbar .searchbar-ios .searchbar-ios-cancel {
  124. @include padding(0);
  125. }
  126. .toolbar .searchbar-ios.searchbar-has-focus .searchbar-ios-cancel {
  127. @include padding-horizontal(8px, null);
  128. }
  129. // Searchbar Cancel (MD only)
  130. // -----------------------------------------
  131. .searchbar-ios .searchbar-md-cancel {
  132. display: none;
  133. }
  134. // Generate Default Search Bar Colors
  135. // --------------------------------------------------
  136. @each $color-name, $color-base, $color-contrast in get-colors($colors-ios) {
  137. $fg-color: rgba($color-contrast, .5);
  138. .searchbar-ios-#{$color-name} .searchbar-ios-cancel {
  139. color: $color-base;
  140. }
  141. .searchbar-ios-#{$color-name} .searchbar-ios-cancel:hover:not(.disable-hover) {
  142. color: color-shade($color-base);
  143. }
  144. .toolbar-ios-#{$color-name} .searchbar-ios .searchbar-search-icon {
  145. @include ios-searchbar-icon($searchbar-ios-input-search-icon-svg, $fg-color);
  146. }
  147. .toolbar-ios-#{$color-name} .searchbar-ios .searchbar-input {
  148. @include placeholder($fg-color);
  149. color: $color-contrast;
  150. background: rgba($color-contrast, .08);
  151. }
  152. .toolbar-ios-#{$color-name} .searchbar-ios .searchbar-clear-icon {
  153. @include ios-searchbar-icon($searchbar-ios-input-clear-icon-svg, $fg-color);
  154. }
  155. .toolbar-ios-#{$color-name} .searchbar-ios .searchbar-ios-cancel {
  156. color: color-contrast($colors-ios, $color-base, ios);
  157. }
  158. }
  159. // Searchbar animation
  160. // -----------------------------------------
  161. .searchbar-ios.searchbar-animated.searchbar-show-cancel .searchbar-ios-cancel {
  162. display: block;
  163. }
  164. .searchbar-ios.searchbar-animated .searchbar-search-icon,
  165. .searchbar-ios.searchbar-animated .searchbar-input {
  166. transition: $searchbar-ios-input-transition;
  167. }
  168. .searchbar-animated.searchbar-has-focus .searchbar-ios-cancel {
  169. opacity: 1;
  170. pointer-events: auto;
  171. }
  172. .searchbar-animated .searchbar-ios-cancel {
  173. @include margin-horizontal(null, -100%);
  174. @include transform(translate3d(0, 0, 0));
  175. opacity: 0;
  176. transition: $searchbar-ios-cancel-transition;
  177. pointer-events: none;
  178. }