button.scss 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. }
  77. }
  78. // Link buttons
  79. // -------------------------
  80. // Make a button look and behave like a link
  81. .btn-link {
  82. color: var(--link-ui);
  83. font-weight: normal;
  84. cursor: pointer;
  85. border-radius: 0;
  86. text-decoration: underline;
  87. font-size: inherit;
  88. vertical-align: inherit;
  89. &,
  90. &:active,
  91. &[disabled],
  92. fieldset[disabled] & {
  93. background-color: transparent;
  94. @include box-shadow(none);
  95. }
  96. &:hover,
  97. &:focus {
  98. color: var(--link-ui-hover);
  99. text-decoration: none;
  100. background-color: transparent;
  101. }
  102. &.btn-danger {
  103. color: var(--content-danger);
  104. //since it's a link, override the button states
  105. &:active {
  106. color: var(--content-danger);
  107. background-color: transparent;
  108. }
  109. &:focus-visible {
  110. background-color: transparent;
  111. outline: -webkit-focus-ring-color auto 1px;
  112. }
  113. }
  114. }
  115. .btn-inline-link {
  116. @extend .btn-link;
  117. font-size: inherit;
  118. padding: 0;
  119. vertical-align: inherit;
  120. }
  121. .button-loading {
  122. align-items: center;
  123. display: inline-grid;
  124. grid-template-areas: 'container'; // Define a single grid area
  125. pointer-events: none;
  126. }
  127. .button-loading > * {
  128. grid-area: container; // Position all the direct children within the single grid area
  129. }
  130. .button-loading .spinner-container {
  131. display: flex;
  132. justify-content: center;
  133. align-items: center;
  134. .loading-spinner-small {
  135. border-width: 0.2em;
  136. height: 20px;
  137. width: 20px;
  138. }
  139. .loading-spinner-large {
  140. border-width: 0.2em;
  141. height: 24px;
  142. width: 24px;
  143. }
  144. }
  145. // Hide the text when the spinner is visible
  146. .button-loading > [aria-hidden='true'] {
  147. visibility: hidden;
  148. }
  149. .button-content {
  150. display: inline-flex;
  151. align-items: center;
  152. gap: var(--spacing-04); // Add gap between text and icons
  153. justify-content: center;
  154. .icon-small {
  155. font-size: 20px;
  156. }
  157. .icon-large {
  158. font-size: 24px;
  159. }
  160. }
  161. .icon-button-small {
  162. padding: var(--spacing-01);
  163. }
  164. .icon-button-default {
  165. padding: var(--spacing-04);
  166. }
  167. .icon-button-large {
  168. padding: var(--spacing-05);
  169. }
  170. // Set the visited colour for a link that is styled as a button. This is necessary because we have a generic rule that
  171. // sets the colour of visited links
  172. a[role='button']:visited {
  173. color: var(--bs-btn-color);
  174. }