_buttons.scss 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. //
  2. // Buttons
  3. // --------------------------------------------------
  4. // Base styles
  5. // --------------------------------------------------
  6. // Core
  7. .btn {
  8. display: inline-block;
  9. font-weight: $btn-font-weight;
  10. line-height: $btn-line-height;
  11. font-size: $font-size-base;
  12. text-align: center;
  13. vertical-align: middle;
  14. cursor: pointer;
  15. border: none;
  16. @include button-size($btn-padding-y, $btn-padding-x, $font-size-base, $btn-border-radius);
  17. &,
  18. &:active,
  19. &.active {
  20. &:focus,
  21. &.focus {
  22. @include no-focus();
  23. }
  24. }
  25. @include hover-focus {
  26. text-decoration: none;
  27. }
  28. &.focus {
  29. text-decoration: none;
  30. }
  31. &:active,
  32. &.active {
  33. background-image: none;
  34. outline: 0;
  35. }
  36. &.disabled,
  37. &[disabled],
  38. &:disabled {
  39. cursor: $cursor-disabled;
  40. opacity: 0.65;
  41. @include box-shadow(none);
  42. }
  43. }
  44. // Button Sizes
  45. // --------------------------------------------------
  46. // XLarge
  47. .btn-xlarge {
  48. @include button-size($btn-padding-y-xl, $btn-padding-x-xl, $font-size-lg, $btn-border-radius);
  49. font-weight: normal;
  50. padding-bottom: $btn-padding-y-xl - 3;
  51. .gicon {
  52. font-size: 31px;
  53. margin-right: 1rem;
  54. }
  55. }
  56. // Large
  57. .btn-large {
  58. @include button-size($btn-padding-y-lg, $btn-padding-x-lg, $font-size-lg, $btn-border-radius);
  59. font-weight: normal;
  60. }
  61. .btn-small {
  62. @include button-size($btn-padding-y-sm, $btn-padding-x-sm, $font-size-sm, $btn-border-radius);
  63. }
  64. .btn-mini {
  65. @include button-size($btn-padding-y-sm, $btn-padding-x-sm, $font-size-xs, $btn-border-radius);
  66. }
  67. .btn-link {
  68. color: $btn-link-color;
  69. background: transparent;
  70. }
  71. // Set the backgrounds
  72. // -------------------------
  73. .btn-primary {
  74. @include buttonBackground($btn-primary-bg, $btn-primary-bg-hl);
  75. }
  76. .btn-secondary {
  77. @include buttonBackground($btn-secondary-bg, $btn-secondary-bg-hl);
  78. }
  79. // Danger and error appear as red
  80. .btn-danger {
  81. @include buttonBackground($btn-danger-bg, $btn-danger-bg-hl);
  82. }
  83. // Info appears as a neutral blue
  84. .btn-secondary {
  85. @include buttonBackground($btn-secondary-bg, $btn-secondary-bg-hl);
  86. // Inverse appears as dark gray
  87. }
  88. .btn-inverse {
  89. @include buttonBackground($btn-inverse-bg, $btn-inverse-bg-hl, $btn-inverse-text-color, $btn-inverse-text-shadow);
  90. //background: $card-background;
  91. box-shadow: $card-shadow;
  92. //border: 1px solid $tight-form-func-highlight-bg;
  93. }
  94. .btn-transparent {
  95. background-color: transparent;
  96. }
  97. .btn-outline-primary {
  98. @include button-outline-variant($btn-primary-bg);
  99. }
  100. .btn-outline-secondary {
  101. @include button-outline-variant($btn-secondary-bg-hl);
  102. }
  103. .btn-outline-inverse {
  104. @include button-outline-variant($btn-inverse-bg);
  105. }
  106. .btn-outline-danger {
  107. @include button-outline-variant(green);
  108. }
  109. .btn-outline-disabled {
  110. @include button-outline-variant($gray-1);
  111. @include box-shadow(none);
  112. cursor: default;
  113. &:hover,
  114. &:active,
  115. &:active:hover,
  116. &:focus {
  117. color: $gray-1;
  118. background-color: transparent;
  119. border-color: $gray-1;
  120. }
  121. }
  122. // Extra padding
  123. .btn-p-x-2 {
  124. padding-left: 20px;
  125. padding-right: 20px;
  126. }
  127. // No horizontal padding
  128. .btn-p-x-0 {
  129. padding-left: 0;
  130. padding-right: 0;
  131. }
  132. // External services
  133. // Usage:
  134. // <div class="btn btn-service btn-service--facebook">Button text</div>
  135. $btn-service-icon-width: 35px;
  136. .btn-service {
  137. position: relative;
  138. }
  139. @each $service, $data in $external-services {
  140. $serviceBgColor: map-get($data, bgColor);
  141. $serviceBorderColor: map-get($data, borderColor);
  142. .btn-service--#{$service} {
  143. background-color: $serviceBgColor;
  144. border: 1px solid $serviceBorderColor;
  145. .btn-service-icon {
  146. font-size: 24px; // Override
  147. border-right: 1px solid $serviceBorderColor;
  148. }
  149. }
  150. }
  151. .btn-service-icon {
  152. position: absolute;
  153. left: 0;
  154. height: 100%;
  155. top: 0;
  156. padding-left: 0.5rem;
  157. padding-right: 0.5rem;
  158. width: $btn-service-icon-width;
  159. text-align: center;
  160. &::before {
  161. position: relative;
  162. top: 4px;
  163. }
  164. }
  165. .btn-service--grafanacom {
  166. .btn-service-icon {
  167. background-image: url(/public/img/grafana_mask_icon_white.svg);
  168. background-repeat: no-repeat;
  169. background-position: 50%;
  170. background-size: 60%;
  171. }
  172. }
  173. //Toggle button
  174. .toggle-btn {
  175. background: $input-label-bg;
  176. color: $text-color-weak;
  177. box-shadow: $card-shadow;
  178. &:first-child {
  179. border-radius: 2px 0 0 2px;
  180. margin: 0;
  181. }
  182. &:last-child {
  183. border-radius: 0 2px 2px 0;
  184. margin-left: 0 !important;
  185. }
  186. &.active {
  187. background-color: lighten($input-label-bg, 5%);
  188. color: $link-color;
  189. &:hover {
  190. cursor: default;
  191. }
  192. }
  193. }
  194. //Button animations
  195. .btn-loading span {
  196. animation-name: blink;
  197. animation-duration: 1.4s;
  198. animation-iteration-count: infinite;
  199. animation-fill-mode: both;
  200. }
  201. .btn-loading span:nth-child(2) {
  202. animation-delay: 0.2s;
  203. }
  204. .btn-loading span:nth-child(3) {
  205. animation-delay: 0.4s;
  206. }
  207. @keyframes blink {
  208. 0% {
  209. opacity: 0.2;
  210. font-size: 14;
  211. }
  212. 20% {
  213. opacity: 1;
  214. font-size: 18;
  215. }
  216. 100% {
  217. opacity: 0.2;
  218. font-size: 14;
  219. }
  220. }