_buttons.less 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Button variants
  2. //
  3. // Easily pump out default styles, as well as :hover, :focus, :active,
  4. // and disabled options for all buttons
  5. #button-variant(@background, @border, @hover-background: darken(@background, 7.5%), @hover-border: darken(@border, 10%), @active-background: darken(@background, 10%), @active-border: darken(@border, 12.5%)) {
  6. color: color-yiq(@background);
  7. #gradient-bg(@background);
  8. border-color: @border;
  9. #box-shadow(@btn-box-shadow);
  10. #hover({
  11. color: color-yiq(@hover-background);
  12. #gradient-bg(@hover-background);
  13. border-color: @hover-border;
  14. });
  15. &:focus,
  16. &.focus {
  17. color: color-yiq(@hover-background);
  18. #gradient-bg(@hover-background);
  19. border-color: @hover-border;
  20. & when (@enable-shadows) {
  21. #box-shadow(@btn-box-shadow, 0 0 0 @btn-focus-width fade(mix(color-yiq(@background), @border, 15%), 50%));
  22. }
  23. & when not (@enable-shadows) {
  24. // Avoid using mixin so we can pass custom focus shadow properly
  25. box-shadow: 0 0 0 @btn-focus-width fade(mix(color-yiq(@background), @border, 15%), 50%);
  26. }
  27. }
  28. // Disabled comes first so active can properly restyle
  29. &.disabled,
  30. &:disabled {
  31. color: color-yiq(@background);
  32. background-color: @background;
  33. border-color: @border;
  34. // Remove CSS gradients if they're enabled
  35. & when (@enable-gradients) {
  36. background-image: none;
  37. }
  38. }
  39. &:not(:disabled):not(.disabled):active,
  40. &:not(:disabled):not(.disabled).active,
  41. .show > &.dropdown-toggle {
  42. color: color-yiq(@active-background);
  43. background-color: @active-background;
  44. & when (@enable-gradients) {
  45. background-image: none; // Remove the gradient for the pressed/active state
  46. }
  47. border-color: @active-border;
  48. &:focus {
  49. & when (@enable-shadows) and not (@btn-active-box-shadow = none) {
  50. #box-shadow(@btn-active-box-shadow, 0 0 0 @btn-focus-width fade(mix(color-yiq(@background), @border, 15%), 50%));
  51. }
  52. & when not (@enable-shadows) or (@btn-active-box-shadow = none) {
  53. // Avoid using mixin so we can pass custom focus shadow properly
  54. box-shadow: 0 0 0 @btn-focus-width fade(mix(color-yiq(@background), @border, 15%), 50%);
  55. }
  56. }
  57. }
  58. }
  59. #button-outline-variant(@color, @color-hover: color-yiq(@color), @active-background: @color, @active-border: @color) {
  60. color: @color;
  61. border-color: @color;
  62. #hover({
  63. color: @color-hover;
  64. background-color: @active-background;
  65. border-color: @active-border;
  66. });
  67. &:focus,
  68. &.focus {
  69. box-shadow: 0 0 0 @btn-focus-width fade(@color, 50%);
  70. }
  71. &.disabled,
  72. &:disabled {
  73. color: @color;
  74. background-color: transparent;
  75. }
  76. &:not(:disabled):not(.disabled):active,
  77. &:not(:disabled):not(.disabled).active,
  78. .show > &.dropdown-toggle {
  79. color: color-yiq(@active-background);
  80. background-color: @active-background;
  81. border-color: @active-border;
  82. &:focus {
  83. & when (@enable-shadows) and not (@btn-active-box-shadow = none) {
  84. #box-shadow(@btn-active-box-shadow, 0 0 0 @btn-focus-width fade(@color, 50%));
  85. }
  86. & when not (@enable-shadows) or (@btn-active-box-shadow = none) {
  87. // Avoid using mixin so we can pass custom focus shadow properly
  88. box-shadow: 0 0 0 @btn-focus-width fade(@color, 50%);
  89. }
  90. }
  91. }
  92. }
  93. // Button sizes
  94. #button-size(@padding-y, @padding-x, @font-size, @line-height, @border-radius) {
  95. padding: @padding-y @padding-x;
  96. #font-size(@font-size);
  97. line-height: @line-height;
  98. // Manually declare to provide an override to the browser default
  99. #border-radius(@border-radius, 0);
  100. }