You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_combobox.scss 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. /**
  2. * Outputs the selectors and properties for the ComboBox component.
  3. *
  4. * @param {string} $primary-stylename (v-filterselect) - the primary style name for the selectors
  5. * @param {bool} $include-additional-styles - should the mixin output all the different style variations of the component
  6. *
  7. * @group combobox
  8. */
  9. @mixin valo-combobox ($primary-stylename: v-filterselect, $include-additional-styles: contains($v-included-additional-styles, combobox)) {
  10. .#{$primary-stylename} {
  11. position: relative;
  12. width: $v-default-field-width;
  13. @include valo-combobox-style;
  14. white-space: nowrap;
  15. .v-icon {
  16. position: absolute;
  17. pointer-events: none;
  18. }
  19. }
  20. .#{$primary-stylename}-error {
  21. .#{$primary-stylename}-input {
  22. @include valo-textfield-error-style;
  23. }
  24. .#{$primary-stylename}-button {
  25. color: $v-error-indicator-color;
  26. border-color: $v-error-indicator-color;
  27. }
  28. }
  29. .#{$primary-stylename}-suggestpopup {
  30. @include valo-combobox-popup-style;
  31. }
  32. .#{$primary-stylename}-no-input {
  33. @include valo-combobox-no-input-style;
  34. }
  35. @if $include-additional-styles {
  36. .#{$primary-stylename}-borderless {
  37. .#{$primary-stylename}-input {
  38. @include valo-textfield-borderless-style;
  39. }
  40. .#{$primary-stylename}-button {
  41. border: none;
  42. color: inherit;
  43. @include opacity(.5);
  44. }
  45. &.#{$primary-stylename}-prompt .#{$primary-stylename}-input {
  46. @include valo-textfield-prompt-style(transparent);
  47. }
  48. }
  49. .#{$primary-stylename}-align-right input {
  50. text-align: right;
  51. }
  52. .#{$primary-stylename}-align-center input {
  53. text-align: center;
  54. }
  55. .#{$primary-stylename}-tiny {
  56. @include valo-combobox-style($unit-size: $v-unit-size--tiny, $bevel: null, $shadow: null, $gradient: null, $border: null, $border-radius: null, $background-color: null, $states: normal);
  57. font-size: $v-font-size--tiny;
  58. }
  59. .#{$primary-stylename}-compact,
  60. .#{$primary-stylename}-small {
  61. @include valo-combobox-style($unit-size: $v-unit-size--small, $bevel: null, $shadow: null, $gradient: null, $border: null, $border-radius: null, $background-color: null, $states: normal);
  62. }
  63. .#{$primary-stylename}-small {
  64. font-size: $v-font-size--small;
  65. }
  66. .#{$primary-stylename}-large {
  67. @include valo-combobox-style($unit-size: $v-unit-size--large, $bevel: null, $shadow: null, $gradient: null, $border: null, $border-radius: null, $background-color: null, $states: normal);
  68. font-size: $v-font-size--large;
  69. }
  70. .#{$primary-stylename}-huge {
  71. @include valo-combobox-style($unit-size: $v-unit-size--huge, $bevel: null, $shadow: null, $gradient: null, $border: null, $border-radius: null, $background-color: null, $states: normal);
  72. font-size: $v-font-size--huge;
  73. }
  74. }
  75. }
  76. /**
  77. * Outputs the styles for a combobox variant.
  78. *
  79. * @param {size} $unit-size ($v-unit-size) - The sizing of the combobox, which corresponds its height
  80. * @param {color} $font-color (null) - The font color of the combobox. Computed from the $background-color by default.
  81. * @param {number} $font-weight (max(400, $v-font-weight)) - The font weight of the combobox
  82. * @param {size} $font-size (null) - The font size of the combobox. Inherited from the parent by default.
  83. * @param {color} $background-color ($v-textfield-background-color) - The background color of the combobox
  84. * @param {list} $border ($v-textfield-border) - The border of the combobox
  85. * @param {size} $border-radius ($v-textfield-border-radius) - The border-radius of the combobox
  86. * @param {list} $gradient (none) - Valo specific gradient value. See the documentation for $v-gradient.
  87. * @param {list} $bevel ($v-textfield-bevel) - Box-shadow value according to $v-bevel documentation
  88. * @param {list} $shadow ($v-textfield-shadow) - Box-shadow value according to $v-shadow documentation
  89. * @param {list} $states (normal focus disabled) - The combobox states for which to output corresponding styles
  90. *
  91. * @group combobox
  92. */
  93. @mixin valo-combobox-style (
  94. $unit-size: $v-unit-size,
  95. $font-color: null,
  96. $font-weight: max(400, $v-font-weight),
  97. $font-size: null,
  98. $background-color: $v-textfield-background-color,
  99. $border: $v-textfield-border,
  100. $border-radius: $v-textfield-border-radius,
  101. $gradient: none,
  102. $bevel: $v-textfield-bevel,
  103. $shadow: $v-textfield-shadow,
  104. $states: normal focus disabled
  105. ) {
  106. height: $unit-size;
  107. border-radius: $border-radius;
  108. [class*="input"] {
  109. @include valo-combobox-input-style(
  110. $unit-size: $unit-size,
  111. $gradient: $gradient,
  112. $bevel: $bevel,
  113. $shadow: $shadow,
  114. $border: $border,
  115. $border-radius: $border-radius,
  116. $background-color: $background-color,
  117. $font-color: $font-color,
  118. $font-size: $font-size,
  119. $font-weight: $font-weight,
  120. $states: $states);
  121. }
  122. .v-icon + [class*="input"] {
  123. padding-left: $unit-size;
  124. }
  125. img.v-icon {
  126. $padding-width: ceil($unit-size/6);
  127. max-height: $unit-size;
  128. @if $border-radius {
  129. $padding-width: $padding-width + ceil($border-radius/3);
  130. }
  131. margin-left: $padding-width;
  132. }
  133. span.v-icon {
  134. color: valo-font-color($background-color);
  135. width: $unit-size;
  136. line-height: 1;
  137. padding-top: .12em;
  138. }
  139. &[class*="prompt"] > [class*="input"] {
  140. @include valo-textfield-prompt-style($background-color);
  141. }
  142. [class$="button"] {
  143. @include valo-combobox-button-style($unit-size: $unit-size, $bevel: $bevel, $background-color: $background-color, $border-radius: $border-radius, $border: $border);
  144. }
  145. &.v-disabled {
  146. @include opacity($v-textfield-disabled-opacity);
  147. & [class$="button"] {
  148. cursor: default;
  149. pointer-events: none;
  150. &:active:after {
  151. display: none;
  152. }
  153. }
  154. }
  155. &.v-readonly {
  156. [class*="input"] {
  157. @include valo-textfield-readonly-style;
  158. }
  159. [class$="button"] {
  160. cursor: default;
  161. pointer-events: none;
  162. &:active:after {
  163. display: none;
  164. }
  165. }
  166. }
  167. }
  168. /**
  169. * Outputs the styles for a combobox variant input element.
  170. *
  171. * @param {size} $unit-size ($v-unit-size) - The sizing of the input (affects the padding only, width and height are 100%)
  172. * @param {size | list} $padding (null) - The padding of the input. Computed from other parameters by default.
  173. * @param {color} $font-color (null) - The font color of the input. Computed from the $background-color by default.
  174. * @param {number} $font-weight (null) - The font weight of the input. Inherited from the parent by default.
  175. * @param {size} $font-size (null) - The font size of the combobox. Inherited from the parent by default.
  176. * @param {color} $background-color ($v-textfield-background-color) - The background color of the input
  177. * @param {list} $border ($v-textfield-border) - The border of the input
  178. * @param {size} $border-radius ($v-textfield-border-radius) - The border-radius of the input
  179. * @param {list} $gradient (none) - Valo specific gradient value. See the documentation for $v-gradient.
  180. * @param {list} $bevel ($v-textfield-bevel) - Box-shadow value according to $v-bevel documentation
  181. * @param {list} $shadow ($v-textfield-shadow) - Box-shadow value according to $v-shadow documentation
  182. * @param {list} $states (normal focus disabled) - The combobox states for which to output corresponding styles
  183. *
  184. * @group combobox
  185. */
  186. @mixin valo-combobox-input-style (
  187. $unit-size: $v-unit-size,
  188. $padding: null,
  189. $font-color: null,
  190. $font-weight: null,
  191. $font-size: null,
  192. $background-color: $v-textfield-background-color,
  193. $border: $v-textfield-border,
  194. $border-radius: $v-textfield-border-radius,
  195. $gradient: none,
  196. $bevel: $v-bevel,
  197. $shadow: $v-shadow,
  198. $states: normal focus disabled
  199. ) {
  200. @include box-sizing(border-box);
  201. @include valo-textfield-style($unit-size: $unit-size,
  202. $padding: $padding,
  203. $font-color: $font-color,
  204. $font-weight: $font-weight,
  205. $font-size: $font-size,
  206. $background-color: $background-color,
  207. $border: $border,
  208. $border-radius: $border-radius,
  209. $gradient: $gradient,
  210. $bevel: $bevel,
  211. $shadow: $shadow,
  212. $states: $states);
  213. width: 100% !important; // Need to override calculated inline style which is sometimes added
  214. height: 100%;
  215. padding-right: round($unit-size * 1.2);
  216. border-radius: inherit;
  217. }
  218. /**
  219. * Outputs the styles for a combobox variant button element.
  220. *
  221. * @param {size} $unit-size ($v-unit-size) - The sizing of the button, which corresponds its width.
  222. * @param {list} $bevel ($v-textfield-bevel) - Box-shadow value according to $v-bevel documentation
  223. * @param {color} $background-color ($v-textfield-background-color) - The background color of the input, which affects the font color of the button
  224. * @param {size} $border-radius ($v-textfield-border-radius) - The border-radius of the input, which affects the border-radius of the button
  225. * @param {list} $border ($v-textfield-border) - The border of the input, which affects the border of the button
  226. *
  227. * @group combobox
  228. */
  229. @mixin valo-combobox-button-style ($unit-size: $v-unit-size, $bevel: $v-bevel, $background-color: $v-textfield-background-color, $border-radius: $v-border-radius, $border: $v-textfield-border) {
  230. $border-width: first-number($border) or 0;
  231. @include valo-tappable;
  232. position: absolute;
  233. width: $unit-size;
  234. @if $border and $border != none {
  235. top: $border-width;
  236. right: $border-width;
  237. bottom: $border-width;
  238. }
  239. @if type-of($background-color) == color {
  240. @if $border {
  241. border-left: valo-border($color: $background-color, $border: $v-textfield-border, $strength: 0.5);
  242. }
  243. color: mix($background-color, valo-font-color($background-color));
  244. .v-ie8 & {
  245. background-color: $background-color;
  246. }
  247. }
  248. @if $v-border-radius > 0 {
  249. $br: $v-border-radius - $border-width;
  250. border-radius: 0 $br $br 0;
  251. }
  252. &:before {
  253. @include valo-combobox-button-icon-style;
  254. @if $v-animations-enabled {
  255. @include transition(color 140ms);
  256. }
  257. position: absolute;
  258. width: $unit-size;
  259. text-align: center;
  260. top: 50%;
  261. line-height: 1;
  262. margin-top: -.47em;
  263. }
  264. @if $v-hover-styles-enabled and type-of($background-color) == color {
  265. &:hover:before {
  266. color: valo-font-color($background-color);
  267. }
  268. }
  269. &:active:after {
  270. content: "";
  271. position: absolute;
  272. top: 0;
  273. right: 0;
  274. bottom: 0;
  275. left: 0;
  276. border-radius: inherit;
  277. @if type-of($background-color) == color {
  278. @include valo-button-active-style($background-color);
  279. }
  280. }
  281. }
  282. /**
  283. * Outputs the font icon styles for the combobox drop down button.
  284. *
  285. * @group combobox
  286. */
  287. @mixin valo-combobox-button-icon-style {
  288. font-family: ThemeIcons;
  289. content: "\f078";
  290. }
  291. /**
  292. * Outputs the styles for a combobox popup.
  293. *
  294. * @group combobox
  295. */
  296. @mixin valo-combobox-popup-style {
  297. @if $v-animations-enabled {
  298. @if $v-overlay-animate-in {
  299. &[class*="animate-in"] {
  300. @include animation($v-overlay-animate-in);
  301. }
  302. }
  303. // No animate-out since that will currently prevent the dropdown from
  304. // closing when the user selects an item
  305. }
  306. [class$="suggestmenu"] {
  307. @include valo-selection-overlay-style($animate-in: false, $animate-out: false);
  308. @include box-sizing(border-box);
  309. position: relative;
  310. z-index: 1;
  311. &[style*="height"] {
  312. @include box-sizing(content-box);
  313. }
  314. }
  315. margin-top: ceil($v-unit-size/8) !important;
  316. table,
  317. tbody,
  318. tr,
  319. td {
  320. display: block;
  321. }
  322. .gwt-MenuItem {
  323. @include valo-selection-item-style;
  324. }
  325. .gwt-MenuItem-selected {
  326. @include valo-selection-item-selected-style;
  327. }
  328. [class$="status"] {
  329. position: absolute;
  330. right: $v-border-radius;
  331. $bg: scale-color($v-background-color, $lightness: -15%);
  332. background: transparentize($bg, .1);
  333. color: valo-font-color($bg);
  334. border-radius: 0 0 $v-border-radius $v-border-radius;
  335. height: ceil($v-unit-size*0.6);
  336. bottom: -(ceil($v-unit-size*0.6));
  337. font-size: ceil($v-font-size*0.73);
  338. line-height: ceil($v-unit-size*0.6);
  339. padding: 0 ceil($v-unit-size/7);
  340. cursor: default;
  341. pointer-events: none;
  342. @if $v-animations-enabled {
  343. @include animation(valo-animate-in-slide-down 200ms 80ms backwards);
  344. }
  345. > * {
  346. color: valo-font-color($bg);
  347. text-decoration: none;
  348. }
  349. }
  350. div[class*="page"] {
  351. position: absolute;
  352. z-index: 3;
  353. right: 0;
  354. @include opacity(.2);
  355. cursor: pointer;
  356. @include transition( all 200ms );
  357. width: ceil($v-unit-size/1.5);
  358. height: ceil($v-unit-size/1.5);
  359. line-height: ceil($v-unit-size/1.5);
  360. text-align: center;
  361. font-family: ThemeIcons;
  362. @include transform( scale(.8) );
  363. color: valo-font-color($v-background-color);
  364. &:after {
  365. // Extend click target when hovering over (popup width might change between pages)
  366. content: "";
  367. position: absolute;
  368. display: block;
  369. border-radius: 50%;
  370. }
  371. &:hover {
  372. @include opacity(1);
  373. background: rgba($v-background-color, .5);
  374. &:after {
  375. top: -10px;
  376. bottom: -10px;
  377. left: -20px;
  378. right: -20px;
  379. }
  380. }
  381. span {
  382. // Hide text
  383. display: none;
  384. }
  385. }
  386. &:hover div[class*="page"] {
  387. @include transform( scale(1) );
  388. }
  389. div[class*="prev"] {
  390. top: 0;
  391. @include transform-origin( 100% 0% );
  392. border-radius: 0 $v-border-radius 0 $v-border-radius;
  393. &:before {
  394. content: "\f0d8";
  395. }
  396. }
  397. div[class*="next"] {
  398. bottom: 0;
  399. @include transform-origin( 100% 100% );
  400. border-radius: $v-border-radius 0 $v-border-radius 0;
  401. &:before {
  402. content: "\f0d7";
  403. }
  404. }
  405. div[class*="-off"] {
  406. display: none;
  407. }
  408. }
  409. /**
  410. *
  411. *
  412. *
  413. * @group combobox
  414. */
  415. @mixin valo-combobox-no-input-style {
  416. cursor: pointer;
  417. text-shadow: valo-text-shadow();
  418. @if $v-border-radius != $v-textfield-border-radius {
  419. border-radius: $v-border-radius;
  420. }
  421. [class*="input"] {
  422. @include user-select(none);
  423. @include valo-gradient;
  424. cursor: inherit;
  425. @include box-shadow(valo-bevel-and-shadow($bevel: $v-bevel, $shadow: $v-shadow, $gradient: $v-gradient));
  426. @include valo-border-with-gradient($border: $v-border, $color: $v-background-color, $gradient: $v-gradient);
  427. text-shadow: inherit;
  428. text-overflow: ellipsis;
  429. border-radius: inherit;
  430. &:focus {
  431. @include valo-textfield-focus-style($bevel: $v-bevel, $shadow: $v-shadow, $gradient: $v-gradient, $background-color: $v-background-color);
  432. }
  433. }
  434. [class$="button"] {
  435. border-left: none !important;
  436. }
  437. &:hover [class$="button"]:before {
  438. color: inherit;
  439. }
  440. }