_buttons.scss 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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 tab-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. }
  70. // Set the backgrounds
  71. // -------------------------
  72. .btn-primary {
  73. @include buttonBackground($btn-primary-bg, $btn-primary-bg-hl);
  74. }
  75. .btn-secondary {
  76. @include buttonBackground($btn-secondary-bg, $btn-secondary-bg-hl);
  77. }
  78. // Warning appears are orange
  79. .btn-warning {
  80. @include buttonBackground($btn-warning-bg, $btn-warning-bg-hl);
  81. }
  82. // Danger and error appear as red
  83. .btn-danger {
  84. @include buttonBackground($btn-danger-bg, $btn-danger-bg-hl);
  85. }
  86. // Success appears as green
  87. .btn-success {
  88. @include buttonBackground($btn-success-bg, $btn-success-bg-hl);
  89. &--processing {
  90. @include button-outline-variant($gray-1);
  91. @include box-shadow(none);
  92. cursor: default;
  93. &:hover,
  94. &:active,
  95. &:active:hover,
  96. &:focus,
  97. &:disabled {
  98. color: $gray-1;
  99. background-color: transparent;
  100. border-color: $gray-1;
  101. }
  102. }
  103. }
  104. // Info appears as a neutral blue
  105. .btn-secondary {
  106. @include buttonBackground($btn-secondary-bg, $btn-secondary-bg-hl);
  107. // Inverse appears as dark gray
  108. }
  109. .btn-inverse {
  110. @include buttonBackground($btn-inverse-bg, $btn-inverse-bg-hl, $btn-inverse-text-color, $btn-inverse-text-shadow);
  111. //background: $card-background;
  112. box-shadow: $card-shadow;
  113. //border: 1px solid $tight-form-func-highlight-bg;
  114. }
  115. .btn-transparent {
  116. background-color: transparent;
  117. }
  118. .btn-outline-primary {
  119. @include button-outline-variant($btn-primary-bg);
  120. }
  121. .btn-outline-secondary {
  122. @include button-outline-variant($btn-secondary-bg);
  123. }
  124. .btn-outline-inverse {
  125. @include button-outline-variant($btn-inverse-bg);
  126. }
  127. .btn-outline-success {
  128. @include button-outline-variant($btn-success-bg);
  129. }
  130. .btn-outline-warning {
  131. @include button-outline-variant($btn-warning-bg);
  132. }
  133. .btn-outline-danger {
  134. @include button-outline-variant($btn-danger-bg);
  135. }
  136. .btn-outline-disabled {
  137. @include button-outline-variant($gray-1);
  138. @include box-shadow(none);
  139. cursor: default;
  140. &:hover,
  141. &:active,
  142. &:active:hover,
  143. &:focus {
  144. color: $gray-1;
  145. background-color: transparent;
  146. border-color: $gray-1;
  147. }
  148. }
  149. // Extra padding
  150. .btn-p-x-2 {
  151. padding-left: 20px;
  152. padding-right: 20px;
  153. }
  154. // No horizontal padding
  155. .btn-p-x-0 {
  156. padding-left: 0;
  157. padding-right: 0;
  158. }
  159. // External services
  160. // Usage:
  161. // <div class="btn btn-service btn-service--facebook">Button text</div>
  162. $btn-service-icon-width: 35px;
  163. .btn-service {
  164. position: relative;
  165. }
  166. @each $service, $data in $external-services {
  167. $serviceBgColor: map-get($data, bgColor);
  168. $serviceBorderColor: map-get($data, borderColor);
  169. .btn-service--#{$service} {
  170. background-color: $serviceBgColor;
  171. border: 1px solid $serviceBorderColor;
  172. .btn-service-icon {
  173. font-size: 24px; // Override
  174. border-right: 1px solid $serviceBorderColor;
  175. }
  176. }
  177. }
  178. .btn-service-icon {
  179. position: absolute;
  180. left: 0;
  181. height: 100%;
  182. top: 0;
  183. padding-left: 0.5rem;
  184. padding-right: 0.5rem;
  185. width: $btn-service-icon-width;
  186. text-align: center;
  187. &::before {
  188. position: relative;
  189. top: 4px;
  190. }
  191. }
  192. .btn-service--grafanacom {
  193. .btn-service-icon {
  194. background-image: url(/public/img/grafana_mask_icon_white.svg);
  195. background-repeat: no-repeat;
  196. background-position: 50%;
  197. background-size: 60%;
  198. }
  199. }
  200. //Toggle button
  201. .toggle-btn {
  202. background: $input-label-bg;
  203. color: $text-color-weak;
  204. box-shadow: $card-shadow;
  205. &:first-child {
  206. border-radius: 2px 0 0 2px;
  207. margin: 0;
  208. }
  209. &:last-child {
  210. border-radius: 0 2px 2px 0;
  211. margin-left: 0 !important;
  212. }
  213. &.active {
  214. background-color: lighten($input-label-bg, 5%);
  215. color: $link-color;
  216. &:hover {
  217. cursor: default;
  218. }
  219. }
  220. }
  221. //Button animations
  222. .btn-loading span {
  223. animation-name: blink;
  224. animation-duration: 1.4s;
  225. animation-iteration-count: infinite;
  226. animation-fill-mode: both;
  227. }
  228. .btn-loading span:nth-child(2) {
  229. animation-delay: 0.2s;
  230. }
  231. .btn-loading span:nth-child(3) {
  232. animation-delay: 0.4s;
  233. }
  234. @keyframes blink {
  235. 0% {
  236. opacity: 0.2;
  237. font-size: 14;
  238. }
  239. 20% {
  240. opacity: 1;
  241. font-size: 18;
  242. }
  243. 100% {
  244. opacity: 0.2;
  245. font-size: 14;
  246. }
  247. }