_buttons.scss 5.6 KB

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