global.tsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. ${
  58. isDark
  59. ? css`
  60. .box,
  61. .box.box-modal {
  62. background: ${theme.background};
  63. border-color: ${theme.border};
  64. .box-content,
  65. .box-header {
  66. background: ${theme.background};
  67. h1,
  68. h2,
  69. h3,
  70. h4,
  71. h5,
  72. h6 {
  73. color: ${theme.headingColor};
  74. }
  75. a {
  76. color: ${theme.textColor};
  77. }
  78. }
  79. .box-header {
  80. border-bottom-color: ${theme.border};
  81. }
  82. }
  83. .loading .loading-indicator {
  84. border-color: ${theme.backgroundSecondary};
  85. border-left-color: ${theme.purple300};
  86. }
  87. .pattern-bg {
  88. opacity: 1;
  89. filter: invert(1) brightness(0.6);
  90. }
  91. .nav-tabs {
  92. & > li {
  93. &.active {
  94. a {
  95. color: ${theme.textColor} !important;
  96. border-bottom-color: ${theme.active} !important;
  97. }
  98. }
  99. a:hover {
  100. color: ${theme.textColor} !important;
  101. }
  102. }
  103. &.border-bottom {
  104. border-color: ${theme.border};
  105. }
  106. }
  107. ul.crumbs li .table.key-value pre {
  108. color: ${theme.subText};
  109. }
  110. .exception {
  111. border-color: ${theme.innerBorder};
  112. }
  113. .traceback {
  114. border-color: ${theme.border};
  115. &.in-app-traceback {
  116. .frame {
  117. &.leads-to-app {
  118. &.collapsed {
  119. .title {
  120. border-color: ${theme.border};
  121. background: ${theme.background};
  122. }
  123. }
  124. }
  125. }
  126. }
  127. .frame,
  128. .frame.system-frame {
  129. border-top-color: ${theme.border};
  130. &.is-expandable .title:hover {
  131. background-color: ${theme.background};
  132. }
  133. .btn-toggle {
  134. color: ${theme.textColor};
  135. background: transparent;
  136. }
  137. .title {
  138. background-color: ${theme.backgroundSecondary};
  139. }
  140. &.is-expandable .title {
  141. background-color: ${theme.backgroundSecondary};
  142. }
  143. .context {
  144. background: ${theme.background};
  145. table.key-value {
  146. border-color: ${theme.border};
  147. td {
  148. border-color: ${theme.border} !important;
  149. }
  150. }
  151. }
  152. }
  153. }
  154. .exc-message {
  155. color: ${theme.subText};
  156. }
  157. .group-detail h3 em {
  158. color: ${theme.subText};
  159. }
  160. .event-details-container {
  161. background-color: ${theme.background};
  162. .secondary {
  163. border-left-color: ${theme.border};
  164. }
  165. }
  166. /* Group Details - User context */
  167. .user-widget .avatar {
  168. box-shadow: 0 0 0 5px ${theme.background};
  169. background: ${theme.background};
  170. }
  171. .nav-header a.help-link,
  172. .nav-header span.help-link a {
  173. color: ${theme.subText};
  174. }
  175. /* Global Selection header date picker */
  176. .rdrCalendarWrapper {
  177. background: ${theme.background};
  178. color: ${theme.textColor};
  179. }
  180. .rdrDayDisabled {
  181. background-color: ${theme.backgroundSecondary};
  182. color: ${theme.disabled};
  183. }
  184. .rdrMonthAndYearPickers select {
  185. color: ${theme.textColor};
  186. }
  187. .dropdown-menu {
  188. color: ${theme.textColor};
  189. background-color: ${theme.background} !important;
  190. border: 1px solid ${theme.border};
  191. &:before {
  192. border-bottom-color: ${theme.border};
  193. }
  194. &:after {
  195. border-bottom-color: ${theme.background};
  196. }
  197. &.inverted:before {
  198. border-top-color: ${theme.border};
  199. }
  200. &.inverted:after {
  201. border-top-color: ${theme.background};
  202. }
  203. }
  204. `
  205. : ''
  206. }
  207. `;
  208. /**
  209. * Renders an emotion global styles injection component
  210. */
  211. function GlobalStyles({theme, isDark}: {isDark: boolean; theme: Theme}) {
  212. return <Global styles={styles(theme, isDark)} />;
  213. }
  214. export default GlobalStyles;