styles.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. //
  2. // Styled components used by both ListBox and GridList
  3. //
  4. import styled from '@emotion/styled';
  5. import {Button} from 'sentry/components/button';
  6. import {space} from 'sentry/styles/space';
  7. export const ListWrap = styled('ul')`
  8. margin: 0;
  9. padding: ${space(0.5)} 0;
  10. /* Add 1px to top padding if preceded by menu header, to account for the header's
  11. shadow border */
  12. [data-menu-has-header='true'] > div > &:first-of-type {
  13. padding-top: calc(${space(0.5)} + 1px);
  14. }
  15. /* Add 1px to bottom padding if succeeded by menu footer, to account for the footer's
  16. shadow border */
  17. [data-menu-has-footer='true'] > div > &:last-of-type {
  18. padding-bottom: calc(${space(0.5)} + 1px);
  19. }
  20. /* Remove top padding if preceded by search input, since search input already has
  21. vertical padding */
  22. input ~ &&:first-of-type,
  23. input ~ div > &&:first-of-type {
  24. padding-top: 0;
  25. }
  26. &:empty {
  27. padding: 0;
  28. }
  29. /* Should scroll if it's in a non-composite select */
  30. :only-of-type {
  31. min-height: 0;
  32. overflow: auto;
  33. }
  34. :focus-visible {
  35. outline: none;
  36. }
  37. `;
  38. export const ListLabel = styled('p')`
  39. display: inline-block;
  40. font-weight: 600;
  41. font-size: ${p => p.theme.fontSizeExtraSmall};
  42. color: ${p => p.theme.subText};
  43. text-transform: uppercase;
  44. white-space: nowrap;
  45. margin: ${space(0.5)} ${space(1.5)};
  46. padding-right: ${space(1)};
  47. `;
  48. export const ListSeparator = styled('div')`
  49. border-top: solid 1px ${p => p.theme.innerBorder};
  50. margin: ${space(0.5)} ${space(1.5)};
  51. :first-child {
  52. display: none;
  53. }
  54. ul:empty + & {
  55. display: none;
  56. }
  57. `;
  58. export const SectionWrap = styled('li')`
  59. list-style-type: none;
  60. `;
  61. export const SectionHeader = styled('div')`
  62. display: flex;
  63. justify-content: space-between;
  64. align-items: center;
  65. box-sizing: content-box;
  66. height: 1.5em;
  67. padding: ${space(0.25)} ${space(1.5)};
  68. /* Remove top padding if this is the first section in a headerless menu (selected
  69. with li:nth-of-type(2) because the first list item is a hidden separator) */
  70. [data-menu-has-header='false']
  71. ul:first-of-type
  72. li[role='presentation']:nth-of-type(2)
  73. > & {
  74. padding-top: 0;
  75. }
  76. `;
  77. export const SectionTitle = styled('p')`
  78. display: inline-block;
  79. font-weight: 600;
  80. font-size: ${p => p.theme.fontSizeExtraSmall};
  81. color: ${p => p.theme.subText};
  82. text-transform: uppercase;
  83. white-space: nowrap;
  84. margin: 0;
  85. padding-right: ${space(4)};
  86. `;
  87. export const SectionToggleButton = styled(Button)<{visible: boolean}>`
  88. padding: 0 ${space(0.5)};
  89. margin: 0 -${space(0.5)} 0 ${space(2)};
  90. font-weight: 400;
  91. font-size: ${p => p.theme.fontSizeSmall};
  92. color: ${p => p.theme.subText};
  93. transition: opacity 0.1s;
  94. &.focus-visible {
  95. opacity: 1;
  96. pointer-events: all;
  97. }
  98. ${p =>
  99. p.visible
  100. ? `
  101. opacity: 1;
  102. pointer-events: all;
  103. `
  104. : `
  105. opacity: 0;
  106. pointer-events: none;
  107. `}
  108. li[role="rowgroup"]:hover &,
  109. li[role="presentation"]:hover & {
  110. opacity: 1;
  111. pointer-events: all;
  112. }
  113. `;
  114. export const SectionSeparator = styled('li')`
  115. list-style-type: none;
  116. border-top: solid 1px ${p => p.theme.innerBorder};
  117. margin: ${space(0.5)} ${space(1.5)};
  118. &:first-of-type {
  119. display: none;
  120. }
  121. `;
  122. export const SectionGroup = styled('ul')`
  123. margin: 0;
  124. padding: 0;
  125. `;
  126. export const CheckWrap = styled('div')<{isSelected: boolean; multiple: boolean}>`
  127. display: flex;
  128. justify-content: center;
  129. align-items: center;
  130. width: 1em;
  131. height: 1.4em;
  132. padding-bottom: 1px;
  133. pointer-events: none;
  134. `;
  135. export const EmptyMessage = styled('p')`
  136. text-align: center;
  137. color: ${p => p.theme.subText};
  138. padding: ${space(1)} ${space(1.5)} ${space(1.5)};
  139. margin: 0;
  140. /* Message should only be displayed when _all_ preceding lists are empty */
  141. display: block;
  142. ul:not(:empty) ~ & {
  143. display: none;
  144. }
  145. `;
  146. export const SizeLimitMessage = styled('li')`
  147. border-top: solid 1px ${p => p.theme.innerBorder};
  148. margin: ${space(0.5)} ${space(1.5)} ${space(0.5)};
  149. padding: ${space(0.75)} ${space(1)} 0;
  150. font-size: ${p => p.theme.fontSizeSmall};
  151. color: ${p => p.theme.subText};
  152. list-style-type: none;
  153. white-space: nowrap;
  154. text-align: center;
  155. `;