You are here

dropbutton.pcss.css in Drupal 10

Dropbutton styles.

File

core/themes/olivero/css/components/dropbutton.pcss.css
View source
  1. /**
  2. * @file
  3. * Dropbutton styles.
  4. */
  5. .dropbutton-wrapper {
  6. --dropbutton--height: var(--sp1-5);
  7. --dropbutton--secondary-bg-color: var(--color--white);
  8. --dropbutton--active-bg-color: var(--color--gray-90);
  9. --dropbutton--outline-color: var(--color--primary-40); /* Minimum 3:1 contrast ratio against --dropbutton--active-bg-color and --dropbutton--secondary-bg-color. */
  10. --dropbutton--border-radius: var(--border-radius);
  11. --dropbutton--font-size: var(--font-size-s);
  12. --dropbutton--text-color: var(--color-text-neutral-medium); /* Minimum 4.5:1 contrast ratio against --dropbutton--active-bg-color and --dropbutton--secondary-bg-color. */
  13. --dropbutton--text-hover-color: var(--color-text-primary-medium); /* Minimum 4.5:1 contrast ratio against --dropbutton--active-bg-color and --dropbutton--secondary-bg-color. */
  14. &.open {
  15. position: relative;
  16. z-index: 100; /* Ensure this appears above all other dropbuttons. */
  17. filter: drop-shadow(0 2px 2px var(--dropbutton--active-bg-color));
  18. }
  19. }
  20. .dropbutton-widget {
  21. position: relative;
  22. width: max-content;
  23. height: var(--dropbutton--height);
  24. padding-inline-end: var(--dropbutton--height);
  25. border-radius: var(--dropbutton--border-radius);
  26. @nest .dropbutton-single & {
  27. padding-inline-end: 0;
  28. }
  29. @nest .dropbutton-wrapper.open & {
  30. border-radius: var(--dropbutton--border-radius) var(--dropbutton--border-radius) 0 0;
  31. }
  32. }
  33. .dropbutton {
  34. height: var(--dropbutton--height);
  35. margin-block: 0;
  36. margin-inline-start: 0;
  37. padding-inline-start: 0;
  38. list-style: none;
  39. font-size: var(--dropbutton--font-size);
  40. }
  41. /* This is the button that expands/collapses the secondary options. */
  42. .dropbutton-toggle button {
  43. position: absolute;
  44. top: 0;
  45. inset-inline-end: 0;
  46. display: flex;
  47. align-items: center;
  48. justify-content: center;
  49. width: var(--dropbutton--height);
  50. height: var(--dropbutton--height);
  51. padding: 0;
  52. cursor: pointer;
  53. border-color: transparent;
  54. border-radius: 0 var(--border-radius) var(--border-radius) 0; /* LTR */
  55. background: var(--dropbutton--active-bg-color);
  56. &:focus {
  57. outline: solid 2px var(--dropbutton--outline-color);
  58. outline-offset: -2px;
  59. }
  60. &:before {
  61. display: block;
  62. width: var(--sp0-5);
  63. height: var(--sp0-5);
  64. content: "";
  65. transform: translateY(-25%) rotate(45deg);
  66. border-right: solid 2px var(--dropbutton--outline-color);
  67. border-bottom: solid 2px var(--dropbutton--outline-color);
  68. @nest .dropbutton-wrapper.open & {
  69. transform: translateY(25%) rotate(225deg);
  70. }
  71. }
  72. &:dir(rtl) {
  73. border-radius: var(--dropbutton--border-radius) 0 0 var(--dropbutton--border-radius);
  74. }
  75. }
  76. /* This is the first
  77. element in the list of actions. */
  78. .dropbutton-action {
  79. &:first-child {
  80. margin-inline-end: 2px;
  81. border: solid 1px transparent;
  82. border-radius: var(--dropbutton--border-radius) 0 0 var(--dropbutton--border-radius); /* LTR */
  83. background: var(--dropbutton--active-bg-color);
  84. &:dir(rtl) {
  85. border: solid 1px transparent;
  86. border-radius: 0 var(--dropbutton--border-radius) var(--dropbutton--border-radius) 0;
  87. }
  88. }
  89. & a {
  90. display: flex;
  91. align-items: center;
  92. margin-bottom: -2px; /* Account for borders. */
  93. padding: 0 9px;
  94. text-decoration: none;
  95. color: var(--dropbutton--text-color);
  96. font-weight: 600;
  97. &:hover {
  98. color: inherit;
  99. }
  100. &:focus {
  101. outline: solid 2px var(--dropbutton--outline-color);
  102. outline-offset: -1px; /* Overlap parent container by 1px. */
  103. }
  104. }
  105. /* Special rules if there is only one action. */
  106. @nest .dropbutton-single & {
  107. &:first-child {
  108. border-right: solid 1px transparent; /* LTR */
  109. border-radius: var(--dropbutton--border-radius);
  110. &:dir(rtl) {
  111. border: solid 1px transparent;
  112. }
  113. }
  114. & a {
  115. justify-content: center;
  116. }
  117. }
  118. }
  119. /* These are the
  120. elements other than the first. */
  121. .secondary-action {
  122. visibility: hidden;
  123. width: calc(100% + var(--dropbutton--height));
  124. border-right: 1px solid var(--dropbutton--active-bg-color);
  125. border-left: 1px solid var(--dropbutton--active-bg-color);
  126. background: var(--dropbutton--secondary-bg-color);
  127. &:last-child {
  128. border-bottom: 1px solid var(--dropbutton--active-bg-color);
  129. }
  130. & a:hover {
  131. color: var(--dropbutton--text-hover-color);
  132. }
  133. @nest .dropbutton-wrapper.open & {
  134. visibility: visible;
  135. }
  136. }