header-sticky-toggle.pcss.css 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**
  2. * @file
  3. * Sticky Header Toggle Button.
  4. *
  5. * This button shows on the left hand side of the header (in LTR layouts), and
  6. * toggles fixing the header to the top of the viewport.
  7. */
  8. @import "../base/variables.pcss.css";
  9. .sticky-header-toggle {
  10. display: none;
  11. @media (--nav) {
  12. display: flex;
  13. flex-shrink: 0;
  14. align-items: center;
  15. justify-content: center;
  16. width: var(--content-left);
  17. height: var(--sp6);
  18. pointer-events: none;
  19. opacity: 0;
  20. border: 0;
  21. outline: 0;
  22. background-color: var(--color--blue-50);
  23. &:focus {
  24. cursor: pointer;
  25. pointer-events: auto;
  26. opacity: 1;
  27. outline: solid 2px var(--color--white);
  28. outline-offset: -4px;
  29. }
  30. }
  31. }
  32. body:not(.is-always-mobile-nav) .is-fixed .sticky-header-toggle {
  33. @media (--nav) {
  34. visibility: visible;
  35. }
  36. }
  37. body.is-always-mobile-nav .sticky-header-toggle {
  38. @media (--nav) {
  39. visibility: hidden;
  40. }
  41. }
  42. .sticky-header-toggle__icon {
  43. position: relative;
  44. width: var(--sp2);
  45. height: 21px;
  46. transition: opacity 0.2s;
  47. pointer-events: none;
  48. transform-style: preserve-3d;
  49. & > span {
  50. display: block;
  51. height: 0;
  52. /* Intentionally not using CSS logical properties. */
  53. border-top: solid 3px var(--color--white);
  54. &:nth-child(1) {
  55. position: absolute;
  56. inset-block-start: 0;
  57. inset-inline-start: 0;
  58. width: 100%;
  59. height: 0;
  60. transition: transform 0.2s;
  61. background-color: var(--color--white);
  62. }
  63. &:nth-child(2) {
  64. position: absolute;
  65. inset-block-start: 9px;
  66. inset-inline-start: 0;
  67. width: 100%;
  68. height: 0;
  69. transition: opacity 0.2s;
  70. background-color: var(--color--white);
  71. }
  72. &:nth-child(3) {
  73. position: absolute;
  74. inset-block: auto 0;
  75. inset-inline-start: 0;
  76. width: 100%;
  77. height: 0;
  78. transition: transform 0.2s;
  79. background-color: var(--color--white);
  80. }
  81. }
  82. }
  83. .is-fixed .sticky-header-toggle {
  84. cursor: pointer;
  85. pointer-events: auto;
  86. opacity: 1;
  87. }
  88. [aria-checked="true"] .sticky-header-toggle__icon {
  89. & > span:nth-child(1) {
  90. inset-block-start: 9px;
  91. transform: rotate(-45deg);
  92. }
  93. & > span:nth-child(2) {
  94. opacity: 0;
  95. }
  96. & > span:nth-child(3) {
  97. inset-block-start: 9px;
  98. transform: rotate(45deg);
  99. }
  100. }