input.md.scss 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. @import "../../themes/ionic.globals.md";
  2. // Material Design Input
  3. // --------------------------------------------------
  4. /// @prop - Background color of the input
  5. $text-input-md-background-color: $list-md-background-color !default;
  6. /// @prop - Margin top of the input
  7. $text-input-md-margin-top: $item-md-padding-top !default;
  8. // deprecated
  9. $text-input-md-margin-right: ($item-md-padding-end / 2) !default;
  10. /// @prop - Margin end of the input
  11. $text-input-md-margin-end: $text-input-md-margin-right !default;
  12. /// @prop - Margin bottom of the input
  13. $text-input-md-margin-bottom: $item-md-padding-bottom !default;
  14. // deprecated
  15. $text-input-md-margin-left: ($item-md-padding-start / 2) !default;
  16. /// @prop - Margin start of the input
  17. $text-input-md-margin-start: $text-input-md-margin-left !default;
  18. /// @prop - Width of the icon used to clear the input
  19. $text-input-md-input-clear-icon-width: 30px !default;
  20. /// @prop - Color of the icon used to clear the input
  21. $text-input-md-input-clear-icon-color: #5b5b5b !default;
  22. /// @prop - Icon used to clear the input
  23. $text-input-md-input-clear-icon-svg: "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><polygon fill='" + $text-input-md-input-clear-icon-color + "' points='405,136.798 375.202,107 256,226.202 136.798,107 107,136.798 226.202,256 107,375.202 136.798,405 256,285.798 375.202,405 405,375.202 285.798,256'/></svg>" !default;
  24. /// @prop - Size of the icon used to clear the input
  25. $text-input-md-input-clear-icon-size: 22px !default;
  26. /// @prop - Show the focus highlight when the input has focus
  27. $text-input-md-show-focus-highlight: true !default;
  28. /// @prop - Show the valid highlight when it is valid and has a value
  29. $text-input-md-show-valid-highlight: $text-input-md-show-focus-highlight !default;
  30. /// @prop - Show the invalid highlight when it is invalid and has value
  31. $text-input-md-show-invalid-highlight: $text-input-md-show-focus-highlight !default;
  32. /// @prop - Color of the input highlight
  33. $text-input-md-highlight-color: color($colors-md, primary) !default;
  34. /// @prop - Color of the input highlight when valid
  35. $text-input-md-highlight-color-valid: $text-input-highlight-color-valid !default;
  36. /// @prop - Color of the input highlight when invalid
  37. $text-input-md-highlight-color-invalid: $text-input-highlight-color-invalid !default;
  38. // Material Design Default Input
  39. // --------------------------------------------------
  40. .text-input-md {
  41. @include margin($text-input-md-margin-top, $text-input-md-margin-end, $text-input-md-margin-bottom, $text-input-md-margin-start);
  42. @include padding(0);
  43. width: calc(100% - #{$text-input-md-margin-end} - #{$text-input-md-margin-start});
  44. }
  45. // Material Design Inset Input
  46. // --------------------------------------------------
  47. .input-md .inset-input {
  48. @include padding(($item-md-padding-top / 2), ($item-md-padding-end / 2), ($item-md-padding-bottom / 2), ($item-md-padding-start / 2));
  49. @include margin(($item-md-padding-top / 2), $item-md-padding-end, ($item-md-padding-bottom / 2), $item-md-padding-start);
  50. }
  51. // Material Design Highlighted Input
  52. // --------------------------------------------------
  53. // Input highlight mixin for focus, valid, and invalid states
  54. @mixin md-input-highlight($highlight-color) {
  55. border-bottom-color: $highlight-color;
  56. box-shadow: inset 0 -1px 0 0 $highlight-color;
  57. }
  58. // Show the focus highlight when the input has focus
  59. @if ($text-input-md-show-focus-highlight) {
  60. // In order to get a 2px border we need to add an inset
  61. // box-shadow 1px (this is to avoid the div resizing)
  62. // TODO remove all uses of input-has-focus in v4
  63. .item-md.item-input.item-input-has-focus .item-inner,
  64. .item-md.item-input.input-has-focus .item-inner {
  65. @include md-input-highlight($text-input-md-highlight-color);
  66. }
  67. // The last item in a list has a border on the item, not the
  68. // inner item, so add it to the item itself
  69. .list-md .item-input.item-input-has-focus:last-child,
  70. .list-md .item-input.input-has-focus:last-child {
  71. @include md-input-highlight($text-input-md-highlight-color);
  72. .item-inner {
  73. box-shadow: none;
  74. }
  75. }
  76. }
  77. // Show the valid highlight when it has the .ng-valid class and a value
  78. @if ($text-input-md-show-valid-highlight) {
  79. // TODO remove all uses of input-has-focus in v4
  80. // TODO remove all uses of input-has-value in v4
  81. .item-md.item-input.ng-valid.item-input-has-value:not(.input-has-focus):not(.item-input-has-focus) .item-inner,
  82. .item-md.item-input.ng-valid.input-has-value:not(.input-has-focus):not(.item-input-has-focus) .item-inner {
  83. @include md-input-highlight($text-input-md-highlight-color-valid);
  84. }
  85. .list-md .item-input.ng-valid.item-input-has-value:not(.input-has-focus):not(.item-input-has-focus):last-child,
  86. .list-md .item-input.ng-valid.input-has-value:not(.input-has-focus):not(.item-input-has-focus):last-child {
  87. @include md-input-highlight($text-input-md-highlight-color-valid);
  88. .item-inner {
  89. box-shadow: none;
  90. }
  91. }
  92. }
  93. // Show the invalid highlight when it has the invalid class and has been touched
  94. @if ($text-input-md-show-invalid-highlight) {
  95. .item-md.item-input.ng-invalid.ng-touched:not(.input-has-focus):not(.item-input-has-focus) .item-inner {
  96. @include md-input-highlight($text-input-md-highlight-color-invalid);
  97. }
  98. .list-md .item-input.ng-invalid.ng-touched:not(.input-has-focus):not(.item-input-has-focus):last-child {
  99. @include md-input-highlight($text-input-md-highlight-color-invalid);
  100. .item-inner {
  101. box-shadow: none;
  102. }
  103. }
  104. }
  105. // Material Design Stacked & Floating Inputs
  106. // --------------------------------------------------
  107. .item-label-stacked .text-input-md,
  108. .item-label-floating .text-input-md {
  109. @include margin(8px, null, 8px, 0);
  110. width: calc(100% - #{$text-input-md-margin-end});
  111. }
  112. .item-label-stacked .select-md,
  113. .item-label-floating .select-md {
  114. @include padding(8px, null, 8px, 0);
  115. }
  116. // Material Design Clear Input Icon
  117. // --------------------------------------------------
  118. .input-md[clearInput] {
  119. position: relative;
  120. }
  121. .input-md[clearInput] .text-input {
  122. @include padding-horizontal(null, $text-input-md-input-clear-icon-width);
  123. }
  124. .input-md .text-input-clear-icon {
  125. @include position-horizontal(null, ($item-md-padding-end / 2));
  126. @include svg-background-image($text-input-md-input-clear-icon-svg);
  127. width: $text-input-md-input-clear-icon-width;
  128. background-size: $text-input-md-input-clear-icon-size;
  129. }