_buttons.scss 4.9 KB

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