button.scss 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. &.btn-premium-secondary {
  82. @include ol-button-variant(
  83. $color: var(--blue-60),
  84. $background: var(--bg-light-primary),
  85. $border: var(--blue-60),
  86. $hover-background: var(--bg-info-03),
  87. $hover-border: var(--blue-60),
  88. $borderless: false
  89. );
  90. }
  91. }
  92. // Link buttons
  93. // -------------------------
  94. // Make a button look and behave like a link
  95. .btn-link {
  96. color: var(--link-ui);
  97. font-weight: normal;
  98. cursor: pointer;
  99. text-decoration: underline;
  100. font-size: inherit;
  101. vertical-align: inherit;
  102. border-radius: 0;
  103. &,
  104. &:active,
  105. &[disabled],
  106. fieldset[disabled] & {
  107. background-color: transparent;
  108. @include box-shadow(none);
  109. }
  110. &:hover,
  111. &:focus {
  112. color: var(--link-ui-hover);
  113. text-decoration: none;
  114. background-color: transparent;
  115. }
  116. &.btn-danger {
  117. color: var(--content-danger);
  118. // since it's a link, override the button states
  119. &:active {
  120. color: var(--content-danger);
  121. background-color: transparent;
  122. }
  123. &:focus-visible {
  124. background-color: transparent;
  125. outline: -webkit-focus-ring-color auto 1px;
  126. }
  127. }
  128. }
  129. .btn-inline-link {
  130. @extend .btn-link;
  131. font-size: inherit;
  132. padding: 0;
  133. vertical-align: inherit;
  134. }
  135. .button-loading {
  136. align-items: center;
  137. display: inline-grid;
  138. grid-template-areas: 'container'; // Define a single grid area
  139. pointer-events: none;
  140. }
  141. .button-loading > * {
  142. grid-area: container; // Position all the direct children within the single grid area
  143. }
  144. .button-loading .spinner-container {
  145. display: flex;
  146. justify-content: center;
  147. align-items: center;
  148. .loading-spinner-small {
  149. border-width: 0.2em;
  150. height: 1.25rem;
  151. width: 1.25rem;
  152. }
  153. .loading-spinner-large {
  154. border-width: 0.2em;
  155. height: 1.5rem;
  156. width: 1.5rem;
  157. }
  158. }
  159. // Hide the text when the spinner is visible
  160. .button-loading > [aria-hidden='true'] {
  161. visibility: hidden;
  162. }
  163. .button-content {
  164. display: inline-flex;
  165. align-items: center;
  166. gap: var(--spacing-04); // Add gap between text and icons
  167. justify-content: center;
  168. .icon-small {
  169. font-size: 1.25rem;
  170. }
  171. .icon-large {
  172. font-size: 1.5rem;
  173. }
  174. .spinner {
  175. margin: var(--spacing-01);
  176. }
  177. }
  178. .icon-button-small {
  179. padding: var(--spacing-01);
  180. }
  181. .icon-button {
  182. padding: var(--spacing-04);
  183. }
  184. .icon-button-large {
  185. padding: var(--spacing-05);
  186. }
  187. // Set the visited colour for a link that is styled as a button. This is necessary because we have a generic rule that
  188. // sets the colour of visited links
  189. a[role='button']:visited,
  190. a.btn:visited {
  191. color: var(--bs-btn-color);
  192. }
  193. // Copy icon button
  194. .copy-button {
  195. text-decoration: none;
  196. }
  197. .btn-reset {
  198. @include reset-button;
  199. }
  200. .btn-transparent {
  201. background: none !important;
  202. border-radius: 0 !important;
  203. color: inherit !important;
  204. font-weight: 400;
  205. &:hover {
  206. background: none !important;
  207. color: inherit !important;
  208. }
  209. }