button.scss 5.7 KB

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