2
0

_userbar.scss 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. @use 'sass:map';
  2. @use 'sass:math';
  3. @use 'sass:string';
  4. // =============================================================================
  5. // Variables
  6. // =============================================================================
  7. $size-home-button: 3.5em;
  8. $position: 2em;
  9. $box-shadow-props:
  10. 0 0 1px 0 rgba(107, 214, 230, 1),
  11. 0 1px 10px 0 rgba(107, 214, 230, 0.7);
  12. $max-items: 12;
  13. $userbar-radius: 6px;
  14. $userbar-z-index: 9999;
  15. // Possible positions for the userbar to exist in. These are set through the
  16. // {% wagtailuserbar 'bottom-left' %} template tag.
  17. $positions: (
  18. 'top-left': (
  19. 'vertical': 'top',
  20. 'horizontal': 'left',
  21. ),
  22. 'top-right': (
  23. 'vertical': 'top',
  24. 'horizontal': 'right',
  25. ),
  26. 'bottom-left': (
  27. 'vertical': 'bottom',
  28. 'horizontal': 'left',
  29. ),
  30. 'bottom-right': (
  31. 'vertical': 'bottom',
  32. 'horizontal': 'right',
  33. ),
  34. );
  35. // =============================================================================
  36. // Wagtail userbar proper
  37. // =============================================================================
  38. .w-userbar {
  39. position: fixed;
  40. z-index: $userbar-z-index;
  41. font-size: initial;
  42. line-height: initial;
  43. margin: 0;
  44. padding: 0;
  45. // Stop hiding the userbar once stylesheets are loaded.
  46. // stylelint-disable-next-line declaration-no-important
  47. display: block !important;
  48. border: 0;
  49. width: auto;
  50. height: auto;
  51. &-icon {
  52. @include svg-icon(2em);
  53. }
  54. }
  55. @media print {
  56. .w-userbar {
  57. display: none;
  58. }
  59. }
  60. .w-userbar-trigger {
  61. display: flex;
  62. align-items: center;
  63. justify-content: center;
  64. width: $size-home-button;
  65. height: $size-home-button;
  66. margin: 0;
  67. background-color: theme('colors.white.DEFAULT');
  68. border: 2px solid transparent;
  69. border-radius: 50%;
  70. padding: 0;
  71. cursor: pointer;
  72. box-shadow: $box-shadow-props;
  73. transition: all 0.2s ease-in-out;
  74. font-size: 1rem;
  75. text-decoration: none;
  76. position: relative;
  77. .w-userbar-axe-count {
  78. display: flex;
  79. justify-content: center;
  80. align-items: center;
  81. background-color: theme('colors.critical.200');
  82. border-radius: theme('borderRadius.full');
  83. color: theme('colors.text-button');
  84. font-size: theme('fontSize.14');
  85. line-height: theme('lineHeight.none');
  86. height: theme('spacing.5');
  87. width: theme('spacing.5');
  88. position: absolute;
  89. inset-inline-end: -5px;
  90. top: -5px;
  91. @media (forced-colors: active) {
  92. border: theme('spacing.px') solid ButtonText;
  93. }
  94. }
  95. &:focus {
  96. outline: theme('colors.focus') solid 3px;
  97. }
  98. }
  99. .w-userbar-items {
  100. display: block;
  101. list-style: none;
  102. position: absolute;
  103. margin: 0;
  104. min-width: 210px;
  105. visibility: hidden;
  106. font-family: theme('fontFamily.sans');
  107. font-size: 0.875rem;
  108. padding-inline-start: 0;
  109. text-decoration: none;
  110. .w-userbar--active & {
  111. visibility: visible;
  112. }
  113. }
  114. .w-userbar-nav {
  115. background: transparent;
  116. padding: 0;
  117. margin: 0;
  118. display: block;
  119. .w-action {
  120. background: transparent;
  121. }
  122. }
  123. .w-userbar__item {
  124. margin: 0;
  125. background-color: theme('colors.surface-menus');
  126. opacity: 0;
  127. overflow: hidden;
  128. transition-duration: 0.125s;
  129. transition-timing-function: cubic-bezier(0.55, 0, 0.1, 1);
  130. font-family: theme('fontFamily.sans');
  131. font-size: 1rem;
  132. text-decoration: none;
  133. @media (prefers-reduced-motion: reduce) {
  134. transition: none;
  135. // Force disable transitions for all items
  136. transition-delay: 0s;
  137. }
  138. &:first-child {
  139. border-start-start-radius: $userbar-radius;
  140. border-start-end-radius: $userbar-radius;
  141. }
  142. &:last-child {
  143. border-end-end-radius: $userbar-radius;
  144. border-end-start-radius: $userbar-radius;
  145. }
  146. a,
  147. .w-action,
  148. button {
  149. color: theme('colors.text-label-menus-default');
  150. display: block;
  151. text-decoration: none;
  152. transform: none;
  153. transition: none;
  154. margin: 0;
  155. font-size: 0.875rem;
  156. &:hover,
  157. &:focus {
  158. color: theme('colors.text-label-menus-default');
  159. background-color: theme('colors.surface-menu-item-active');
  160. }
  161. &:focus {
  162. outline: theme('colors.focus') solid 3px;
  163. }
  164. &-icon {
  165. @include svg-icon(1em, middle);
  166. margin-inline-end: 0.5em;
  167. fill: currentColor;
  168. opacity: 0.4;
  169. }
  170. .w-a11y-result__count {
  171. margin-inline-end: theme('spacing.2');
  172. }
  173. }
  174. a,
  175. button {
  176. font-size: 0.875rem;
  177. text-align: start;
  178. padding: theme('spacing.[3.5]');
  179. }
  180. button {
  181. border: 0;
  182. width: 100%;
  183. background-color: transparent;
  184. outline: none;
  185. display: flex;
  186. align-items: center;
  187. }
  188. }
  189. .w-dialog--userbar {
  190. // Display off to the side of the page rather than in the middle.
  191. inset-inline-start: auto;
  192. font-family: theme('fontFamily.sans');
  193. padding-inline-end: 2rem;
  194. z-index: $userbar-z-index;
  195. .w-dialog__close-button {
  196. $size: theme('spacing.6');
  197. width: $size;
  198. height: $size;
  199. top: calc(-1 * $size / 2);
  200. inset-inline-end: calc(-1 * $size / 2);
  201. border-radius: theme('borderRadius.full');
  202. border: 2px solid theme('colors.icon-primary');
  203. background: theme('colors.surface-page');
  204. }
  205. .w-dialog__close-icon {
  206. color: theme('colors.text-context');
  207. }
  208. .w-dialog__content {
  209. padding: 0;
  210. min-height: unset;
  211. max-height: 60vh;
  212. font-size: theme('fontSize.14');
  213. }
  214. .w-dialog__header {
  215. display: flex;
  216. align-items: center;
  217. justify-content: space-between;
  218. }
  219. .w-dialog__body {
  220. padding: 0 theme('spacing.[7.5]') theme('spacing.[7.5]');
  221. display: flex;
  222. flex-direction: column;
  223. gap: theme('spacing.[2.5]');
  224. }
  225. .w-dialog__title {
  226. @apply w-h3;
  227. color: theme('colors.text-context');
  228. padding: theme('spacing.[7.5]');
  229. margin-bottom: 0;
  230. }
  231. .w-dialog__subtitle {
  232. @apply w-body-text;
  233. padding-inline-end: theme('spacing.[7.5]');
  234. display: flex;
  235. align-items: center;
  236. gap: theme('spacing.2');
  237. margin-bottom: 0;
  238. }
  239. }
  240. //Media for Windows High Contrast
  241. @media (forced-colors: active) {
  242. .w-userbar-icon {
  243. fill: LinkText;
  244. }
  245. .w-userbar__item {
  246. border: 1px solid ButtonText;
  247. }
  248. }
  249. // =============================================================================
  250. // Userbar positional classes (tl, tr, bl, br)
  251. // =============================================================================
  252. @each $pos, $attrs in $positions {
  253. $vertical: map.get($attrs, vertical);
  254. $horizontal: map.get($attrs, horizontal);
  255. .w-userbar--#{$pos} {
  256. #{$vertical}: $position;
  257. #{$horizontal}: $position;
  258. .w-userbar-items {
  259. #{$vertical}: 100%;
  260. #{$horizontal}: 0;
  261. padding-#{$vertical}: theme('spacing.2');
  262. }
  263. .w-userbar__item {
  264. @if $vertical == 'bottom' {
  265. transform: translateY(1em);
  266. } @else {
  267. transform: translateY(-1em);
  268. }
  269. }
  270. &.w-userbar--active .w-userbar__item {
  271. @for $i from 1 through $max-items {
  272. @if $vertical == 'bottom' {
  273. &:nth-last-child(#{$i}) {
  274. transition-delay: 0.05s * $i;
  275. }
  276. }
  277. @if $vertical == 'top' {
  278. &:nth-child(#{$i}) {
  279. transition-delay: 0.05s * $i;
  280. }
  281. }
  282. }
  283. }
  284. }
  285. }
  286. // =============================================================================
  287. // States
  288. // =============================================================================
  289. // Active state for the list items comes last.
  290. .w-userbar--active .w-userbar__item {
  291. transform: translateY(0);
  292. opacity: 1;
  293. }