Button.scss 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. /**
  2. * generates base style rules for both tabs and buttons
  3. *
  4. * @param {string} [$base-cls='button']
  5. *
  6. * @param {string} [$btn-display=inline-block]
  7. *
  8. * @param {boolean} [$include-arrows=true]
  9. *
  10. * @param {boolean} [$flexbox=true]
  11. *
  12. * @member Ext.button.Button
  13. * @private
  14. */
  15. @mixin extjs-button-base(
  16. $base-cls: 'btn',
  17. $btn-display: inline-block,
  18. $include-arrows: true,
  19. $flexbox: true
  20. ) {
  21. .#{$prefix}#{$base-cls} {
  22. display: $btn-display;
  23. outline: 0;
  24. cursor: pointer;
  25. white-space: nowrap;
  26. text-decoration: none;
  27. vertical-align: top;
  28. overflow: hidden;
  29. // buttons are position:relative because they may contain an absolutely positioned
  30. // pseudo element for imitating box-shadow in IE8 when used in a segmented button
  31. // see extjs-button-ui
  32. position: relative;
  33. > .#{$prefix}frame {
  34. height: 100%;
  35. width: 100%;
  36. }
  37. }
  38. .#{$prefix}#{$base-cls}-wrap {
  39. height: 100%;
  40. width: 100%;
  41. @if $flexbox {
  42. @include ext-box;
  43. @include ext-box-align(stretch);
  44. &.#{$prefix}btn-arrow-bottom,
  45. &.#{$prefix}btn-split-bottom {
  46. @include ext-box-orient(vertical);
  47. }
  48. @if $include-ie {
  49. .#{$prefix}ie9m & {
  50. display: table;
  51. border-spacing: 0;
  52. }
  53. }
  54. } @else {
  55. display: table;
  56. border-spacing: 0;
  57. }
  58. }
  59. .#{$prefix}#{$base-cls}-button {
  60. white-space: nowrap;
  61. line-height: 0;
  62. // this element must be position:relative so that the split line can be absolutely
  63. // positioned inside of it
  64. position: relative;
  65. @if $flexbox {
  66. @include ext-box;
  67. @include ext-box-align(center);
  68. @include ext-box-flex;
  69. &.#{$prefix}#{$base-cls}-icon-top,
  70. &.#{$prefix}#{$base-cls}-icon-bottom {
  71. @include ext-box-orient(vertical);
  72. @include ext-box-align(stretch);
  73. @include ext-box-pack(center);
  74. @if $include-ie {
  75. // Button is not correctly sized horizontally in IE10 and 11
  76. // when icon is placed above/below
  77. .#{$prefix}ie10p & {
  78. overflow: hidden;
  79. }
  80. }
  81. }
  82. @if $include-ie {
  83. .#{$prefix}ie9m & {
  84. display: table-cell;
  85. vertical-align: middle;
  86. }
  87. }
  88. } @else {
  89. display: table-cell;
  90. vertical-align: middle;
  91. }
  92. }
  93. .#{$prefix}#{$base-cls}-inner {
  94. overflow: hidden;
  95. text-overflow: ellipsis;
  96. @if $flexbox {
  97. -ms-flex-negative: 1;
  98. display: block;
  99. @if $include-ie {
  100. .#{$prefix}ie9m & {
  101. display: inline-block;
  102. vertical-align: middle;
  103. }
  104. }
  105. } @else {
  106. display: inline-block;
  107. vertical-align: middle;
  108. }
  109. .#{$prefix}#{$base-cls}-icon.#{$prefix}#{$base-cls}-no-text > & {
  110. display: none;
  111. }
  112. }
  113. .#{$prefix}#{$base-cls}-icon-el {
  114. display: none;
  115. vertical-align: middle;
  116. text-align: center;
  117. background-position: center center;
  118. background-repeat: no-repeat;
  119. @if $flexbox {
  120. flex-shrink: 0;
  121. .#{$prefix}#{$base-cls}-icon > & {
  122. display: block;
  123. }
  124. @if $include-ie {
  125. .#{$prefix}ie9m .#{$prefix}#{$base-cls}-icon-left > &,
  126. .#{$prefix}ie9m .#{$prefix}#{$base-cls}-icon-right > & {
  127. display: inline-block;
  128. }
  129. }
  130. } @else {
  131. .#{$prefix}#{$base-cls}-icon > & {
  132. display: inline-block;
  133. }
  134. .#{$prefix}#{$base-cls}-icon-top > &,
  135. .#{$prefix}#{$base-cls}-icon-bottom > & {
  136. display: block;
  137. }
  138. }
  139. }
  140. .#{$prefix}#{$base-cls}-button-center {
  141. @if $include-ie {
  142. .#{$prefix}ie9m & {
  143. text-align: center;
  144. }
  145. }
  146. @if $flexbox {
  147. @include ext-box-pack(center);
  148. }
  149. &.#{$prefix}#{$base-cls}-icon-top,
  150. &.#{$prefix}#{$base-cls}-icon-bottom {
  151. text-align: center;
  152. }
  153. }
  154. .#{$prefix}#{$base-cls}-button-left {
  155. text-align: left;
  156. @if $flexbox {
  157. @include ext-box-pack(start);
  158. }
  159. }
  160. @if $include-rtl {
  161. .#{$prefix}rtl.#{$prefix}#{$base-cls}-button-left {
  162. text-align: right;
  163. }
  164. }
  165. .#{$prefix}#{$base-cls}-button-right {
  166. text-align: right;
  167. @if $flexbox {
  168. @include ext-box-pack(end);
  169. }
  170. }
  171. @if $include-rtl {
  172. .#{$prefix}rtl.#{$prefix}#{$base-cls}-button-right {
  173. text-align: left;
  174. }
  175. }
  176. @if $include-arrows {
  177. .#{$prefix}#{$base-cls}-arrow:after,
  178. .#{$prefix}#{$base-cls}-split:after {
  179. display: block;
  180. background-repeat: no-repeat;
  181. content: '';
  182. // pseudo elements don't match wildcard selectors, so ".x-border-box *" will not apply
  183. // to this element
  184. box-sizing: border-box;
  185. -moz-box-sizing: border-box;
  186. -ms-box-sizing: border-box;
  187. -webkit-box-sizing: border-box;
  188. text-align: center;
  189. }
  190. .#{$prefix}#{$base-cls}-arrow-right:after,
  191. .#{$prefix}#{$base-cls}-split-right:after {
  192. background-position: right center;
  193. @if $flexbox {
  194. @include ext-box;
  195. @include ext-box-align(center);
  196. @include ext-box-pack(center);
  197. @if $include-ie {
  198. .#{$prefix}ie9m & {
  199. display: table-cell;
  200. vertical-align: middle;
  201. }
  202. }
  203. } @else {
  204. display: table-cell;
  205. vertical-align: middle;
  206. }
  207. }
  208. @if $include-rtl {
  209. .#{$prefix}rtl {
  210. &.#{$prefix}#{$base-cls}-arrow-right:after,
  211. &.#{$prefix}#{$base-cls}-split-right:after {
  212. background-position: left center;
  213. }
  214. }
  215. }
  216. .#{$prefix}#{$base-cls}-arrow-bottom:after,
  217. .#{$prefix}#{$base-cls}-split-bottom:after {
  218. background-position: center bottom;
  219. // when this pseudo el is display:table-row (with no table-cell inside) in needs
  220. // content other than emtpy or space in order to render in some browsers (IE8-11),
  221. // so use non-breaking space
  222. content: '\00a0';
  223. // line-height:0 prevents the pseudo el from inheriting line-height and being
  224. // taller than specified by $icon-size.
  225. line-height: 0;
  226. @if $flexbox {
  227. @if $include-ie {
  228. .#{$prefix}ie9m & {
  229. display: table-row;
  230. }
  231. }
  232. } @else {
  233. display: table-row;
  234. }
  235. }
  236. // placeholder pseudo element for split line when line is not contained in arrow image
  237. .#{$prefix}#{$base-cls}-split-right > .#{$prefix}btn-button:after {
  238. position: absolute;
  239. display: block;
  240. top: -100%;
  241. right: 0;
  242. height: 300%;
  243. content: '';
  244. }
  245. @if $include-rtl {
  246. .#{$prefix}rtl.#{$prefix}#{$base-cls}-split-right > .#{$prefix}btn-button:after {
  247. left: 0;
  248. right: auto;
  249. }
  250. }
  251. // placeholder pseudo element for split line when line is not contained in arrow image
  252. .#{$prefix}#{$base-cls}-split-bottom > .#{$prefix}btn-button:after {
  253. position: absolute;
  254. display: block;
  255. bottom: 0;
  256. left: -100%;
  257. font-size: 0;
  258. width: 300%;
  259. content: '';
  260. }
  261. }
  262. .#{$prefix}#{$base-cls}-mc {
  263. // buttons and tabs can have a focus outline on the btnWrap element. The default
  264. // overflow:hidden styling of the frame body hides the outline, so override it to
  265. // overflow:visible.
  266. overflow: visible;
  267. }
  268. }