Box.scss 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. /**
  2. * Creates a visual theme for a {@link Ext.layout.container.boxOverflow.Scroller Box Scroller}
  3. *
  4. * @param {string} $ui
  5. * The name of the UI being created. Can not included spaces or special punctuation
  6. * (used in CSS class names).
  7. *
  8. * @param {string} $type
  9. * The type of component that this box scroller will be used with. For example 'toolbar'
  10. * or 'tab-bar'
  11. *
  12. * @param {number} [$horizontal-width=16px]
  13. * The width of horizontal scroller buttons
  14. *
  15. * @param {Number} [$horizontal-height=16px]
  16. * The height of horizontal scroller buttons
  17. *
  18. * @param {number} [$vertical-width=16px]
  19. * The width of vertical scroller buttons
  20. *
  21. * @param {Number} [$vertical-height=16px]
  22. * The height of vertical scroller buttons
  23. *
  24. * @param {number/list} [$top-margin=0]
  25. * The margin of the "top" scroller button
  26. *
  27. * @param {number/list} [$right-margin=0]
  28. * The margin of the "right" scroller button
  29. *
  30. * @param {number/list} [$bottom-margin=0]
  31. * The margin of the "bottom" scroller button
  32. *
  33. * @param {number/list} [$left-margin=0]
  34. * The margin of the "left" scroller button
  35. *
  36. * @param {number/list} $top-background-image
  37. * The background-image of the "top" scroller button
  38. *
  39. * @param {number/list} $right-background-image
  40. * The background-image of the "right" scroller button
  41. *
  42. * @param {number/list} $bottom-background-image
  43. * The background-image of the "bottom" scroller button
  44. *
  45. * @param {number/list} $left-background-image
  46. * The background-image of the "left" scroller button
  47. *
  48. * @param {color} $glyph-color
  49. * The color of the scroller button icons
  50. *
  51. * @param {number/list} $top-glyph
  52. * The glyph for the "top" scroller button
  53. *
  54. * @param {number/list} $right-glyph
  55. * The glyph for the "right" scroller button
  56. *
  57. * @param {number/list} $bottom-glyph
  58. * The glyph for the "bottom" scroller button
  59. *
  60. * @param {number/list} $left-glyph
  61. * The glyph for the "left" scroller button
  62. *
  63. * @param {number} [$horizontal-border-color=$base-color]
  64. * The border color of the scroller buttons
  65. *
  66. * @param {number} [$horizontal-border-width=0]
  67. * The border-width of the scroller buttons
  68. *
  69. * @param {number} [$vertical-border-color=$base-color]
  70. * The border-width of the scroller buttons
  71. *
  72. * @param {number} [$vertical-border-width=0]
  73. * The border-width of the scroller buttons
  74. *
  75. * @param {number/list} [$container-padding=0]
  76. * The padding of the container that these scroller buttons will be used in. Used for
  77. * setting margin offsets of the inner layout element to reserve space for the scrollers.
  78. *
  79. * @param {string} [$cursor=pointer]
  80. * The type of cursor to display when the mouse is over a scroller button
  81. *
  82. * @param {string} [$cursor-disabled=default]
  83. * The type of cursor to display when the mouse is over a disabled scroller button
  84. *
  85. * @param {string} [$align=middle]
  86. * Vertical alignment of the scroller buttons, or horizontal align of vertically oriented
  87. * scroller buttons. Can be one of the following values:
  88. *
  89. * - `begin`
  90. * - `middle`
  91. * - `end`
  92. * - `stretch`
  93. *
  94. * @param {string} [$align-offset=0]
  95. * Number of pixels to offset the alignment of the scroller.
  96. * Only applicable when {@link #align} is `middle`.
  97. *
  98. * @param {number} [$opacity=0.6]
  99. * The opacity of the scroller buttons. Only applicable when `$classic` is `false`.
  100. *
  101. * @param {number} [$opacity-over=0.8]
  102. * The opacity of hovered scroller buttons. Only applicable when `$classic` is `false`.
  103. *
  104. * @param {number} [$opacity-pressed=1]
  105. * The opacity of pressed scroller buttons. Only applicable when `$classic` is `false`.
  106. *
  107. * @param {number} [$opacity-disabled=0.25]
  108. * The opacity of disabled scroller buttons. Only applicable when `$classic` is `false`.
  109. *
  110. * @param {boolean} [$classic=false]
  111. * `true` to use classic-style scroller buttons. When `true` scroller buttons are given
  112. * their hover state by changing their background-position, When `false` scroller buttons
  113. * are given their hover state by applying opacity.
  114. *
  115. * @param {boolean} [$include-horizontal=true]
  116. * `true` to include horizontal
  117. *
  118. * @param {boolean} [$include-vertical=true]
  119. * `true` to include vertical
  120. *
  121. * @param {boolean} [$include-background-images=true]
  122. * `true` to include background-images
  123. *
  124. * @member Ext.layout.container.Box
  125. * @private
  126. */
  127. @mixin extjs-box-scroller-ui(
  128. $ui: null,
  129. $type: null,
  130. $horizontal-width: 16px,
  131. $horizontal-height: 16px,
  132. $vertical-width: 16px,
  133. $vertical-height: 16px,
  134. $top-margin: 0,
  135. $right-margin: 0,
  136. $bottom-margin: 0,
  137. $left-margin: 0,
  138. $top-background-image: null,
  139. $right-background-image: null,
  140. $bottom-background-image: null,
  141. $left-background-image: null,
  142. $glyph-color: null,
  143. $top-glyph: null,
  144. $right-glyph: null,
  145. $bottom-glyph: null,
  146. $left-glyph: null,
  147. $horizontal-border-color: $base-color,
  148. $horizontal-border-width: 0,
  149. $vertical-border-color: $base-color,
  150. $vertical-border-width: 0,
  151. $container-padding: 0,
  152. $cursor: pointer,
  153. $cursor-disabled: default,
  154. $align: middle,
  155. $align-offset: 0,
  156. $opacity: 0.5,
  157. $opacity-over: 0.8,
  158. $opacity-pressed: 1,
  159. $opacity-disabled: 0.25,
  160. $classic: false,
  161. $include-horizontal: true,
  162. $include-vertical: true,
  163. $include-background-images: true
  164. ) {
  165. @if is-null($top-background-image) {
  166. $top-background-image: #{$type}/#{$ui}-scroll-top;
  167. }
  168. @if is-null($right-background-image) {
  169. $right-background-image: #{$type}/#{$ui}-scroll-right;
  170. }
  171. @if is-null($bottom-background-image) {
  172. $bottom-background-image: #{$type}/#{$ui}-scroll-bottom;
  173. }
  174. @if is-null($left-background-image) {
  175. $left-background-image: #{$type}/#{$ui}-scroll-left;
  176. }
  177. .#{$prefix}#{$type}-#{$ui}-scroller {
  178. .#{$prefix}box-scroller-body-horizontal {
  179. margin-left: max($horizontal-width + horizontal($left-margin) - left($container-padding), 0);
  180. }
  181. @if $include-rtl {
  182. &.#{$prefix}rtl .#{$prefix}box-scroller-body-horizontal {
  183. margin-left: 0;
  184. margin-right: max($horizontal-width + horizontal($left-margin) - left($container-padding), 0);
  185. }
  186. }
  187. }
  188. .#{$prefix}#{$type}-#{$ui}-vertical-scroller {
  189. .#{$prefix}box-scroller-body-vertical {
  190. margin-top: max($vertical-height + vertical($top-margin) - top($container-padding), 0);
  191. }
  192. }
  193. .#{$prefix}box-scroller-#{$type}-#{$ui} {
  194. cursor: $cursor;
  195. color: $glyph-color;
  196. @if not $classic {
  197. @if $opacity != 1 {
  198. @include opacity($opacity);
  199. }
  200. @if $opacity != 1 or $opacity-over != 1 {
  201. &.#{$prefix}box-scroller-hover {
  202. @include opacity($opacity-over);
  203. }
  204. }
  205. @if $opacity != 1 or $opacity-pressed != 1 {
  206. &.#{$prefix}box-scroller-pressed {
  207. @include opacity($opacity-pressed);
  208. }
  209. }
  210. }
  211. &.#{$prefix}box-scroller-disabled {
  212. @if $opacity-disabled != 1 {
  213. @include opacity($opacity-disabled);
  214. }
  215. @if not is-null($cursor-disabled) {
  216. cursor: $cursor-disabled;
  217. }
  218. }
  219. @if $include-horizontal {
  220. &.#{$prefix}box-scroller-left,
  221. &.#{$prefix}box-scroller-right {
  222. width: $horizontal-width;
  223. @if $align != stretch {
  224. height: $horizontal-height;
  225. }
  226. @if $horizontal-border-width != 0 {
  227. border-style: solid;
  228. border-color: $horizontal-border-color;
  229. border-width: $horizontal-border-width;
  230. }
  231. @if $align == begin {
  232. top: 0;
  233. } @else if $align == middle {
  234. top: 50%;
  235. margin-top: -(floor($horizontal-height / 2)) + $align-offset;
  236. } @else if $align == end {
  237. bottom: 0;
  238. } @else if $align == stretch {
  239. top: 0;
  240. bottom: 0;
  241. }
  242. }
  243. &.#{$prefix}box-scroller-left {
  244. @if $align == middle {
  245. // set all but margin-top to avoid overriding centering margin above
  246. margin-left: left($left-margin);
  247. margin-right: right($left-margin);
  248. margin-bottom: bottom($left-margin);
  249. } @else {
  250. margin: $left-margin;
  251. }
  252. @if $enable-font-icons and ($left-glyph != null) {
  253. @include font-icon($left-glyph, $line-height: $horizontal-height);
  254. } @else if $include-background-images {
  255. background-image: theme-background-image($left-background-image);
  256. }
  257. @if $classic {
  258. background-position: -$horizontal-width 0;
  259. &.#{$prefix}box-scroller-hover {
  260. background-position: 0 0;
  261. }
  262. }
  263. }
  264. &.#{$prefix}box-scroller-right {
  265. @if $align == middle {
  266. // set all but margin-top to avoid overriding centering margin above
  267. margin-left: left($right-margin);
  268. margin-right: right($right-margin);
  269. margin-bottom: bottom($right-margin);
  270. } @else {
  271. margin: $right-margin;
  272. }
  273. @if $enable-font-icons and ($right-glyph != null) {
  274. @include font-icon($right-glyph, $line-height: $horizontal-height);
  275. } @else if $include-background-images {
  276. background-image: theme-background-image($right-background-image);
  277. }
  278. @if $classic {
  279. background-position: 0 0;
  280. &.#{$prefix}box-scroller-hover {
  281. background-position: -$horizontal-width 0;
  282. }
  283. }
  284. }
  285. }
  286. @if $include-vertical {
  287. &.#{$prefix}box-scroller-top,
  288. &.#{$prefix}box-scroller-bottom {
  289. height: $vertical-height;
  290. @if $align != stretch {
  291. width: $vertical-width;
  292. }
  293. @if $vertical-border-width != 0 {
  294. border-style: solid;
  295. border-color: $vertical-border-color;
  296. border-width: $vertical-border-width;
  297. }
  298. @if $align == begin {
  299. left: 0;
  300. } @else if $align == middle {
  301. left: 50%;
  302. margin-left: -(floor($vertical-width / 2)) + $align-offset;
  303. } @else if $align == end {
  304. right: 0;
  305. } @else if $align == stretch {
  306. left: 0;
  307. right: 0;
  308. }
  309. }
  310. &.#{$prefix}box-scroller-top {
  311. @if $align == middle {
  312. // set all but margin-left to avoid overriding centering margin above
  313. margin-top: top($top-margin);
  314. margin-right: right($top-margin);
  315. margin-bottom: bottom($top-margin);
  316. } @else {
  317. margin: $top-margin;
  318. }
  319. @if $enable-font-icons and ($top-glyph != null) {
  320. @include font-icon($top-glyph, $line-height: $vertical-height);
  321. } @else if $include-background-images {
  322. background-image: theme-background-image($top-background-image);
  323. }
  324. @if $classic {
  325. background-position: 0 (-$vertical-height);
  326. &.#{$prefix}box-scroller-hover {
  327. background-position: 0 0;
  328. }
  329. }
  330. }
  331. &.#{$prefix}box-scroller-bottom {
  332. @if $align == middle {
  333. // set all but margin-left to avoid overriding centering margin above
  334. margin-top: top($bottom-margin);
  335. margin-right: right($bottom-margin);
  336. margin-bottom: bottom($bottom-margin);
  337. } @else {
  338. margin: $bottom-margin;
  339. }
  340. @if $enable-font-icons and ($bottom-glyph != null) {
  341. @include font-icon($bottom-glyph, $line-height: $vertical-height);
  342. } @else if $include-background-images {
  343. background-image: theme-background-image($bottom-background-image);
  344. }
  345. @if $classic {
  346. background-position: 0 0;
  347. &.#{$prefix}box-scroller-hover {
  348. background-position: 0 (-$vertical-height);
  349. }
  350. }
  351. }
  352. }
  353. }
  354. }