global.tsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. import {css, Global, Theme} from '@emotion/react';
  2. import {IS_ACCEPTANCE_TEST} from 'sentry/constants';
  3. import {prismStyles} from 'sentry/styles/prism';
  4. const styles = (theme: Theme, isDark: boolean) => css`
  5. body {
  6. .sentry-error-embed-wrapper {
  7. z-index: ${theme.zIndex.sentryErrorEmbed};
  8. }
  9. color: ${theme.textColor};
  10. background: ${theme.backgroundSecondary};
  11. }
  12. abbr {
  13. ${theme.tooltipUnderline()};
  14. }
  15. a {
  16. color: ${theme.linkColor};
  17. &:hover {
  18. color: ${theme.linkHoverColor};
  19. }
  20. }
  21. .group-detail:before {
  22. background: ${theme.border};
  23. }
  24. .form-actions {
  25. border-top-color: ${theme.border};
  26. }
  27. pre,
  28. code {
  29. color: ${theme.textColor};
  30. }
  31. pre {
  32. background-color: ${theme.backgroundSecondary};
  33. word-break: break-all;
  34. white-space: pre-wrap;
  35. overflow-x: auto;
  36. }
  37. code {
  38. background-color: transparent;
  39. white-space: pre;
  40. }
  41. ${prismStyles(theme)}
  42. /**
  43. * See https://web.dev/prefers-reduced-motion/
  44. */
  45. @media (prefers-reduced-motion) {
  46. *,
  47. ::before,
  48. ::after {
  49. animation-delay: -1ms !important;
  50. animation-duration: 0ms !important;
  51. animation-iteration-count: 1 !important;
  52. background-attachment: initial !important;
  53. scroll-behavior: auto !important;
  54. transition-duration: 0s !important;
  55. transition-delay: 0s !important;
  56. }
  57. }
  58. ${IS_ACCEPTANCE_TEST
  59. ? css`
  60. input,
  61. select {
  62. caret-color: transparent;
  63. }
  64. `
  65. : ''}
  66. /* Override css in LESS files here as we want to manually control dark mode for now */
  67. ${isDark
  68. ? css`
  69. .box,
  70. .box.box-modal {
  71. background: ${theme.background};
  72. border-color: ${theme.border};
  73. .box-content,
  74. .box-header {
  75. background: ${theme.background};
  76. h1,
  77. h2,
  78. h3,
  79. h4,
  80. h5,
  81. h6 {
  82. color: ${theme.headingColor};
  83. }
  84. a {
  85. color: ${theme.textColor};
  86. }
  87. }
  88. .box-header {
  89. border-bottom-color: ${theme.border};
  90. }
  91. }
  92. .loading .loading-indicator {
  93. border-color: ${theme.backgroundSecondary};
  94. border-left-color: ${theme.purple300};
  95. }
  96. .nav-tabs {
  97. & > li {
  98. &.active {
  99. a {
  100. color: ${theme.textColor} !important;
  101. border-bottom-color: ${theme.active} !important;
  102. }
  103. }
  104. a:hover {
  105. color: ${theme.textColor} !important;
  106. }
  107. }
  108. &.border-bottom {
  109. border-color: ${theme.border};
  110. }
  111. }
  112. ul.crumbs li .table.key-value pre {
  113. color: ${theme.subText};
  114. }
  115. .exception {
  116. border-color: ${theme.innerBorder};
  117. }
  118. .traceback {
  119. border-color: ${theme.border};
  120. ol.context > li {
  121. color: ${theme.subText};
  122. }
  123. &.in-app-traceback {
  124. .frame {
  125. &.leads-to-app {
  126. &.collapsed {
  127. .title {
  128. border-color: ${theme.border};
  129. background: ${theme.background};
  130. }
  131. }
  132. }
  133. }
  134. }
  135. .frame,
  136. .frame.system-frame {
  137. border-top-color: ${theme.border};
  138. &.is-expandable .title:hover {
  139. background-color: ${theme.background};
  140. }
  141. .btn-toggle {
  142. color: ${theme.textColor};
  143. background: transparent;
  144. }
  145. .title {
  146. background-color: ${theme.backgroundSecondary};
  147. }
  148. &.is-expandable .title {
  149. background-color: ${theme.backgroundSecondary};
  150. }
  151. .context {
  152. background: ${theme.background};
  153. }
  154. }
  155. }
  156. .exc-message {
  157. color: ${theme.subText};
  158. }
  159. .group-detail h3 em {
  160. color: ${theme.subText};
  161. }
  162. .event-details-container {
  163. background-color: ${theme.background};
  164. .secondary {
  165. border-left-color: ${theme.border};
  166. }
  167. }
  168. /* Group Details - User context */
  169. .user-widget .avatar {
  170. box-shadow: 0 0 0 5px ${theme.background};
  171. background: ${theme.background};
  172. }
  173. .nav-header a.help-link,
  174. .nav-header span.help-link a {
  175. color: ${theme.subText};
  176. }
  177. /* Global Selection header date picker */
  178. .rdrCalendarWrapper {
  179. background: ${theme.background};
  180. color: ${theme.textColor};
  181. }
  182. .rdrDayDisabled {
  183. background-color: ${theme.backgroundSecondary};
  184. color: ${theme.disabled};
  185. }
  186. .rdrMonthAndYearPickers select {
  187. color: ${theme.textColor};
  188. }
  189. .dropdown-menu {
  190. color: ${theme.textColor};
  191. background-color: ${theme.background} !important;
  192. border: 1px solid ${theme.border};
  193. &:before {
  194. border-bottom-color: ${theme.border};
  195. }
  196. &:after {
  197. border-bottom-color: ${theme.background};
  198. }
  199. &.inverted:before {
  200. border-top-color: ${theme.border};
  201. }
  202. &.inverted:after {
  203. border-top-color: ${theme.background};
  204. }
  205. }
  206. `
  207. : ''}
  208. `;
  209. /**
  210. * Renders an emotion global styles injection component
  211. */
  212. const GlobalStyles = ({theme, isDark}: {isDark: boolean; theme: Theme}) => (
  213. <Global styles={styles(theme, isDark)} />
  214. );
  215. export default GlobalStyles;