global.tsx 5.7 KB

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