mixins.scss 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. @use 'sass:list';
  2. // Button
  3. @mixin ol-button-size(
  4. $font-size,
  5. $line-height,
  6. $padding-y,
  7. $padding-x: var(--spacing-06)
  8. ) {
  9. --bs-btn-font-size: #{$font-size};
  10. --bs-btn-line-height: #{$line-height};
  11. --bs-btn-padding-y: #{$padding-y};
  12. --bs-btn-padding-x: #{$padding-x};
  13. }
  14. @mixin ol-button-variant(
  15. $color,
  16. $background,
  17. $border: $background,
  18. $hover-background: $background,
  19. $hover-border: $hover-background,
  20. $borderless: true,
  21. $disabled-color: $content-disabled,
  22. $disabled-background: $bg-light-disabled,
  23. $disabled-border: $disabled-background,
  24. $active-background: $hover-background
  25. ) {
  26. --bs-btn-color: #{$color};
  27. --bs-btn-bg: #{$background};
  28. --bs-btn-border-color: #{$border};
  29. --bs-btn-hover-color: #{$color};
  30. --bs-btn-hover-bg: #{$hover-background};
  31. --bs-btn-hover-border-color: #{$hover-border};
  32. --bs-btn-active-color: #{$color};
  33. --bs-btn-active-bg: #{$active-background};
  34. --bs-btn-active-border-color: #{$hover-border};
  35. --bs-btn-disabled-color: #{$disabled-color};
  36. --bs-btn-disabled-bg: #{$disabled-background};
  37. --bs-btn-disabled-border-color: #{$disabled-border};
  38. @if $borderless {
  39. --bs-btn-border-width: 0;
  40. }
  41. // Use the default state colors when in a loading state
  42. &[data-ol-loading='true'] {
  43. color: var(--bs-btn-color);
  44. background-color: var(--bs-btn-bg);
  45. border-color: var(--bs-btn-border-color);
  46. opacity: 1;
  47. }
  48. }
  49. @mixin action-button {
  50. font-size: 0;
  51. line-height: 1;
  52. border-radius: 50%;
  53. color: var(--content-primary);
  54. background-color: transparent;
  55. &:hover,
  56. &:active,
  57. &[aria-expanded='true'] {
  58. background-color: rgb($neutral-90, 0.08);
  59. }
  60. }
  61. @mixin editor-switcher-button {
  62. @include ol-button-variant(
  63. $color: var(--green-60),
  64. $background: var(--bg-accent-03),
  65. $border: var(--green-50),
  66. $hover-background: var(--bg-accent-03),
  67. $hover-border: var(--green-40),
  68. $borderless: false
  69. );
  70. }
  71. @mixin reset-button() {
  72. padding: 0;
  73. cursor: pointer;
  74. background: transparent;
  75. border: 0;
  76. appearance: none;
  77. }
  78. @mixin modal-lg {
  79. max-width: 960px;
  80. }
  81. @mixin modal-md {
  82. max-width: 640px;
  83. }
  84. @mixin modal-sm {
  85. max-width: 480px;
  86. }
  87. // Toolbar
  88. @mixin toolbar-sm-height {
  89. height: var(--toolbar-small-height);
  90. }
  91. @mixin toolbar-alt-bg() {
  92. background-color: var(--toolbar-alt-bg-color);
  93. }
  94. @mixin theme($name) {
  95. @if list.index($themes, $name) {
  96. [data-theme='#{$name}'] {
  97. @content;
  98. }
  99. } @else {
  100. @error 'Theme "#{$name}" is not supported. Supported themes are: #{$themes}.';
  101. }
  102. }
  103. @mixin box-shadow-button-input {
  104. box-shadow: inset 0 0 0 2px var(--blue-30);
  105. outline: 2px solid transparent;
  106. }
  107. @mixin animation($animation) {
  108. animation: $animation;
  109. }
  110. @mixin striped($color: rgba(255, 255, 255, 0.15), $angle: 45deg) {
  111. background-image: linear-gradient(
  112. $angle,
  113. $color 25%,
  114. transparent 25%,
  115. transparent 50%,
  116. $color 50%,
  117. $color 75%,
  118. transparent 75%,
  119. transparent
  120. );
  121. }
  122. @mixin mask-image($gradient) {
  123. // mask-image isn't supported without the -webkit prefix on all browsers we support yet
  124. -webkit-mask-image: $gradient;
  125. mask-image: $gradient;
  126. }
  127. @mixin premium-background {
  128. background-image: var(--premium-gradient);
  129. }
  130. @mixin premium-text {
  131. @include premium-background;
  132. background-clip: text;
  133. -webkit-text-fill-color: transparent;
  134. color: var(--white); // Fallback
  135. background-color: var(--blue-70); // Fallback
  136. }
  137. @mixin dark-bg {
  138. --link-color: var(--link-color-dark);
  139. --link-hover-color: var(--link-hover-color-dark);
  140. --link-visited-color: var(--link-visited-color-dark);
  141. }
  142. @mixin themed-links {
  143. --link-color: var(--link-ui-themed);
  144. --link-hover-color: var(--link-ui-hover-themed);
  145. --link-visited-color: var(--link-ui-visited-themed);
  146. }
  147. @mixin triangle($direction, $width, $height, $color) {
  148. position: absolute;
  149. border-color: transparent;
  150. border-style: solid;
  151. width: 0;
  152. height: 0;
  153. @if $direction == top {
  154. border-width: 0 calc(#{$width} / 2) #{$height} calc(#{$width} / 2);
  155. border-bottom-color: $color;
  156. border-left-color: transparent;
  157. border-right-color: transparent;
  158. } @else if $direction == bottom {
  159. border-width: #{$height} calc(#{$width} / 2) 0 calc(#{$width} / 2);
  160. border-top-color: $color;
  161. border-left-color: transparent;
  162. border-right-color: transparent;
  163. } @else if $direction == right {
  164. border-width: calc(#{$height} / 2) 0 calc(#{$height} / 2) #{$width};
  165. border-left-color: $color;
  166. border-top-color: transparent;
  167. border-bottom-color: transparent;
  168. } @else if $direction == left {
  169. border-width: calc(#{$height} / 2) #{$width} calc(#{$height} / 2) 0;
  170. border-right-color: $color;
  171. border-top-color: transparent;
  172. border-bottom-color: transparent;
  173. }
  174. }
  175. // Form validation states
  176. @mixin form-control-validation($color) {
  177. color: $color;
  178. // Color the label and help text
  179. .help-block,
  180. .control-label,
  181. .radio,
  182. .checkbox,
  183. .radio-inline,
  184. .checkbox-inline,
  185. .form-label {
  186. color: $color;
  187. }
  188. .form-control {
  189. border-color: $color;
  190. &:focus {
  191. border-color: $border-active;
  192. }
  193. }
  194. // Optional feedback icon
  195. .form-control-feedback {
  196. color: $color;
  197. }
  198. }
  199. @mixin input-disabled-styles {
  200. background-color: $input-disabled-bg;
  201. border-color: $input-disabled-border-color;
  202. }
  203. @mixin full-viewport-height {
  204. height: 100vh; /* for backwards compatibility */
  205. height: 100dvh; /* needed for mobile devices */
  206. }
  207. @mixin full-height-stacked-page {
  208. @include full-viewport-height;
  209. display: flex;
  210. flex-direction: column;
  211. }