_buttons.scss 3.4 KB

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