segment.ios.scss 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. @import "../../themes/ionic.globals.ios";
  2. // iOS Segment
  3. // --------------------------------------------------
  4. /// @prop - Background of the segment button
  5. $segment-button-ios-background-color: transparent !default;
  6. /// @prop - Background of the activated segment button
  7. $segment-button-ios-background-color-activated: $toolbar-ios-active-color !default;
  8. /// @prop - Text color of the segment button
  9. $segment-button-ios-text-color: color-contrast($colors-ios, $segment-button-ios-background-color-activated) !default;
  10. /// @prop - Transition of the activated segment button
  11. $segment-button-ios-transition-activated: 100ms all linear !default;
  12. /// @prop - Transition of the segment button on hover
  13. $segment-button-ios-transition-hover: 100ms all linear !default;
  14. /// @prop - Transition of the segment button when pressed
  15. $segment-button-ios-transition-active: 100ms all linear !default;
  16. /// @prop - Opacity of the segment button on hover
  17. $segment-button-ios-opacity-hover: .1 !default;
  18. /// @prop - Opacity of the segment button when pressed
  19. $segment-button-ios-opacity-active: .16 !default;
  20. /// @prop - Opacity of the activated segment button
  21. $segment-button-ios-opacity-activated: 1 !default;
  22. /// @prop - Opacity of the disabled segment button
  23. $segment-button-ios-opacity-disabled: .3 !default;
  24. /// @prop - Border width of the segment button
  25. $segment-button-ios-border-width: 1px !default;
  26. /// @prop - Height of the segment button
  27. $segment-button-ios-height: 3.2rem !default;
  28. /// @prop - Line height of the segment button
  29. $segment-button-ios-line-height: 3rem !default;
  30. /// @prop - Font size of the segment button
  31. $segment-button-ios-font-size: 1.3rem !default;
  32. /// @prop - Border radius of the segment button
  33. $segment-button-ios-border-radius: 4px !default;
  34. /// @prop - Size of an icon in the segment button
  35. $segment-button-ios-icon-size: 2.6rem !default;
  36. /// @prop - Line height of an icon in the segment button
  37. $segment-button-ios-icon-line-height: 2.8rem !default;
  38. /// @prop - Max width of the segment button in a toolbar
  39. $segment-button-ios-toolbar-button-max-width: 100px !default;
  40. /// @prop - Height of the segment button in a toolbar
  41. $segment-button-ios-toolbar-button-height: 2.6rem !default;
  42. /// @prop - Line height of the segment button in a toolbar
  43. $segment-button-ios-toolbar-line-height: 2.5rem !default;
  44. /// @prop - Font size of the segment button in a toolbar
  45. $segment-button-ios-toolbar-font-size: 1.2rem !default;
  46. /// @prop - Size of an icon in the segment button in a toolbar
  47. $segment-button-ios-toolbar-icon-size: 2.2rem !default;
  48. /// @prop - Line height of an icon in the segment button in a toolbar
  49. $segment-button-ios-toolbar-icon-line-height: 2.4rem !default;
  50. .segment-ios .segment-button {
  51. flex: 1;
  52. width: 0;
  53. height: $segment-button-ios-height;
  54. border-width: $segment-button-ios-border-width;
  55. border-style: solid;
  56. border-color: $segment-button-ios-background-color-activated;
  57. font-size: $segment-button-ios-font-size;
  58. line-height: $segment-button-ios-line-height;
  59. color: $segment-button-ios-background-color-activated;
  60. background-color: $segment-button-ios-background-color;
  61. ion-icon {
  62. font-size: $segment-button-ios-icon-size;
  63. line-height: $segment-button-ios-icon-line-height;
  64. }
  65. &.segment-activated {
  66. color: $segment-button-ios-text-color;
  67. background-color: $segment-button-ios-background-color-activated;
  68. opacity: $segment-button-ios-opacity-activated;
  69. transition: $segment-button-ios-transition-activated;
  70. }
  71. &:hover:not(.segment-activated) {
  72. background-color: rgba($segment-button-ios-background-color-activated, $segment-button-ios-opacity-hover);
  73. transition: $segment-button-ios-transition-hover;
  74. }
  75. &:active:not(.segment-activated) {
  76. background-color: rgba($segment-button-ios-background-color-activated, $segment-button-ios-opacity-active);
  77. transition: $segment-button-ios-transition-active;
  78. }
  79. &:first-of-type {
  80. @include border-radius($segment-button-ios-border-radius, 0, 0, $segment-button-ios-border-radius);
  81. @include margin-horizontal(null, 0);
  82. }
  83. &:not(:first-of-type) {
  84. border-left-width: 0;
  85. }
  86. &:last-of-type {
  87. @include border-radius(0, $segment-button-ios-border-radius, $segment-button-ios-border-radius, 0);
  88. @include margin-horizontal(0, null);
  89. border-left-width: 0;
  90. }
  91. }
  92. [dir="rtl"] .segment-ios .segment-button {
  93. &:first-of-type {
  94. border-left-width: 0;
  95. }
  96. &:last-of-type {
  97. border-left-width: $segment-button-ios-border-width;
  98. }
  99. }
  100. .segment-ios.segment-disabled {
  101. opacity: .4;
  102. pointer-events: none;
  103. }
  104. .segment-ios .segment-button-disabled {
  105. color: rgba($segment-button-ios-background-color-activated, $segment-button-ios-opacity-disabled);
  106. pointer-events: none;
  107. }
  108. // iOS Segment in Toolbar
  109. // --------------------------------------------------
  110. .toolbar-ios .segment-ios {
  111. @include position(0, 0, 0, 0);
  112. position: absolute;
  113. }
  114. .toolbar-ios .segment-button {
  115. max-width: $segment-button-ios-toolbar-button-max-width;
  116. height: $segment-button-ios-toolbar-button-height;
  117. font-size: $segment-button-ios-toolbar-font-size;
  118. line-height: $segment-button-ios-toolbar-line-height;
  119. ion-icon {
  120. font-size: $segment-button-ios-toolbar-icon-size;
  121. line-height: $segment-button-ios-toolbar-icon-line-height;
  122. }
  123. }
  124. // iOS Segment Button Mixin
  125. // --------------------------------------------------
  126. @mixin ios-segment-button($color-name, $color-base, $color-contrast) {
  127. .segment-ios-#{$color-name} {
  128. .segment-button {
  129. border-color: $color-base;
  130. color: $color-base;
  131. &:hover:not(.segment-activated) {
  132. background-color: rgba($color-base, $segment-button-ios-opacity-hover);
  133. }
  134. &:active:not(.segment-activated) {
  135. background-color: rgba($color-base, $segment-button-ios-opacity-active);
  136. }
  137. &.segment-activated {
  138. color: $color-contrast;
  139. background-color: $color-base;
  140. }
  141. }
  142. .segment-button-disabled {
  143. color: rgba($color-base, $segment-button-ios-opacity-disabled);
  144. }
  145. }
  146. }
  147. // iOS Segment Color Generation
  148. // --------------------------------------------------
  149. @each $color-name, $color-base, $color-contrast in get-colors($colors-ios) {
  150. @include ios-segment-button($color-name, $color-base, $color-contrast);
  151. .toolbar-ios-#{$color-name} .segment-ios .segment-button.segment-activated {
  152. color: $color-base;
  153. }
  154. }