button.scss 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. .btn {
  2. // Focus style for all buttons
  3. --bs-btn-focus-box-shadow: 0 0 0 2px var(--border-active-dark);
  4. &:focus-visible {
  5. background-color: var(--bs-btn-bg);
  6. }
  7. // Sizes
  8. // Default size
  9. @include ol-button-size(
  10. $font-size: var(--font-size-03),
  11. $line-height: var(--line-height-03),
  12. $padding-y: var(--spacing-03)
  13. );
  14. &.btn-lg {
  15. @include ol-button-size(
  16. $font-size: var(--font-size-03),
  17. $line-height: var(--line-height-03),
  18. $padding-y: var(--spacing-05)
  19. );
  20. }
  21. &.btn-sm {
  22. @include ol-button-size(
  23. $font-size: var(--font-size-02),
  24. $line-height: var(--line-height-02),
  25. $padding-y: var(--spacing-01),
  26. $padding-x: var(--spacing-05)
  27. );
  28. }
  29. // Variants
  30. &.btn-primary {
  31. @include ol-button-variant(
  32. $color: var(--content-primary-dark),
  33. $background: var(--bg-accent-01),
  34. $hover-background: var(--bg-accent-02),
  35. $hover-border: var(--bg-accent-02)
  36. );
  37. }
  38. &.btn-secondary {
  39. @include ol-button-variant(
  40. $color: var(--content-primary),
  41. $background: var(--bg-light-primary),
  42. $border: var(--border-primary),
  43. $hover-background: var(--bg-light-tertiary),
  44. $hover-border: var(--border-primary),
  45. $borderless: false
  46. );
  47. }
  48. &.btn-ghost {
  49. @include ol-button-variant(
  50. $color: var(--content-primary),
  51. $background: var(--bg-light-primary),
  52. $hover-background: var(--bg-light-tertiary)
  53. );
  54. }
  55. &.btn-danger {
  56. @include ol-button-variant(
  57. $color: var(--content-primary-dark),
  58. $background: var(--bg-danger-01),
  59. $border: var(--bg-danger-01),
  60. $hover-background: var(--bg-danger-02)
  61. );
  62. }
  63. &.btn-danger-ghost {
  64. @include ol-button-variant(
  65. $color: var(--content-danger),
  66. $background: var(--bg-light-primary),
  67. $hover-background: var(--bg-danger-03)
  68. );
  69. }
  70. &.btn-premium {
  71. @include ol-button-variant(
  72. $color: var(--content-primary-dark),
  73. $background: var(--blue-70)
  74. );
  75. background: var(--premium-gradient);
  76. transition: none;
  77. &:hover {
  78. background: var(--blue-70);
  79. }
  80. }
  81. }
  82. // Link buttons
  83. // -------------------------
  84. // Make a button look and behave like a link
  85. .btn-link {
  86. color: var(--link-ui);
  87. font-weight: normal;
  88. cursor: pointer;
  89. text-decoration: underline;
  90. font-size: inherit;
  91. vertical-align: inherit;
  92. &,
  93. &:active,
  94. &[disabled],
  95. fieldset[disabled] & {
  96. background-color: transparent;
  97. @include box-shadow(none);
  98. }
  99. &:hover,
  100. &:focus {
  101. color: var(--link-ui-hover);
  102. text-decoration: none;
  103. background-color: transparent;
  104. }
  105. &.btn-danger {
  106. color: var(--content-danger);
  107. // since it's a link, override the button states
  108. &:active {
  109. color: var(--content-danger);
  110. background-color: transparent;
  111. }
  112. &:focus-visible {
  113. background-color: transparent;
  114. outline: -webkit-focus-ring-color auto 1px;
  115. }
  116. }
  117. }
  118. .btn-inline-link {
  119. @extend .btn-link;
  120. font-size: inherit;
  121. padding: 0;
  122. vertical-align: inherit;
  123. }
  124. .button-loading {
  125. align-items: center;
  126. display: inline-grid;
  127. grid-template-areas: 'container'; // Define a single grid area
  128. pointer-events: none;
  129. }
  130. .button-loading > * {
  131. grid-area: container; // Position all the direct children within the single grid area
  132. }
  133. .button-loading .spinner-container {
  134. display: flex;
  135. justify-content: center;
  136. align-items: center;
  137. .loading-spinner-small {
  138. border-width: 0.2em;
  139. height: 20px;
  140. width: 20px;
  141. }
  142. .loading-spinner-large {
  143. border-width: 0.2em;
  144. height: 24px;
  145. width: 24px;
  146. }
  147. }
  148. // Hide the text when the spinner is visible
  149. .button-loading > [aria-hidden='true'] {
  150. visibility: hidden;
  151. }
  152. .button-content {
  153. display: inline-flex;
  154. align-items: center;
  155. gap: var(--spacing-04); // Add gap between text and icons
  156. justify-content: center;
  157. .icon-small {
  158. font-size: 20px;
  159. }
  160. .icon-large {
  161. font-size: 24px;
  162. }
  163. .spinner {
  164. margin: var(--spacing-01);
  165. }
  166. }
  167. .icon-button-small {
  168. padding: var(--spacing-01);
  169. }
  170. .icon-button-default {
  171. padding: var(--spacing-04);
  172. }
  173. .icon-button-large {
  174. padding: var(--spacing-05);
  175. }
  176. // Set the visited colour for a link that is styled as a button. This is necessary because we have a generic rule that
  177. // sets the colour of visited links
  178. a[role='button']:visited,
  179. a.btn:visited {
  180. color: var(--bs-btn-color);
  181. }
  182. // Copy icon button
  183. .copy-button {
  184. text-decoration: none;
  185. }
  186. .btn-reset {
  187. @include reset-button;
  188. }
  189. .btn-transparent {
  190. background: none !important;
  191. border-radius: 0 !important;
  192. color: inherit !important;
  193. font-weight: 400;
  194. &:hover {
  195. background: none !important;
  196. color: inherit !important;
  197. }
  198. }