_buttons.scss 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. // External services
  155. // Usage:
  156. // <div class="btn btn-service btn-service--facebook">Button text</div>
  157. $btn-service-icon-width: 35px;
  158. .btn-service {
  159. position: relative;
  160. }
  161. @each $service, $data in $external-services {
  162. $serviceBgColor: map-get($data, bgColor);
  163. $serviceBorderColor: map-get($data, borderColor);
  164. .btn-service--#{$service} {
  165. background-color: $serviceBgColor;
  166. border: 1px solid $serviceBorderColor;
  167. .btn-service-icon {
  168. font-size: 24px; // Override
  169. border-right: 1px solid $serviceBorderColor;
  170. }
  171. }
  172. }
  173. .btn-service-icon {
  174. position: absolute;
  175. left: 0;
  176. height: 100%;
  177. top: 0;
  178. padding-left: 0.5rem;
  179. padding-right: 0.5rem;
  180. width: $btn-service-icon-width;
  181. text-align: center;
  182. &::before {
  183. position: relative;
  184. top: 4px;
  185. }
  186. }
  187. .btn-service--grafanacom {
  188. .btn-service-icon {
  189. background-image: url(/public/img/grafana_mask_icon_white.svg);
  190. background-repeat: no-repeat;
  191. background-position: 50%;
  192. background-size: 60%;
  193. }
  194. }
  195. //Toggle button
  196. .toggle-btn {
  197. background: $input-label-bg;
  198. color: $text-color-weak;
  199. box-shadow: $card-shadow;
  200. &:first-child {
  201. border-radius: 2px 0 0 2px;
  202. margin: 0;
  203. }
  204. &:last-child {
  205. border-radius: 0 2px 2px 0;
  206. margin-left: 0 !important;
  207. }
  208. &.active {
  209. background-color: lighten($input-label-bg, 5%);
  210. color: $link-color;
  211. &:hover {
  212. cursor: default;
  213. }
  214. }
  215. }
  216. //Button animations
  217. .btn-loading span {
  218. animation-name: blink;
  219. animation-duration: 1.4s;
  220. animation-iteration-count: infinite;
  221. animation-fill-mode: both;
  222. }
  223. .btn-loading span:nth-child(2) {
  224. animation-delay: 0.2s;
  225. }
  226. .btn-loading span:nth-child(3) {
  227. animation-delay: 0.4s;
  228. }
  229. @keyframes blink {
  230. 0% {
  231. opacity: 0.2;
  232. font-size: 14;
  233. }
  234. 20% {
  235. opacity: 1;
  236. font-size: 18;
  237. }
  238. 100% {
  239. opacity: 0.2;
  240. font-size: 14;
  241. }
  242. }