global.tsx 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. import type {Theme} from '@emotion/react';
  2. import {css, Global} from '@emotion/react';
  3. import {space} from 'sentry/styles/space';
  4. const prismStyles = (theme: Theme) => css`
  5. :root {
  6. ${theme.prismVariables};
  7. }
  8. /* Use dark Prism theme for code snippets imported from Sentry Docs */
  9. .gatsby-highlight,
  10. .prism-dark {
  11. ${theme.prismDarkVariables};
  12. }
  13. pre[class*='language-'] {
  14. overflow-x: auto;
  15. padding: ${space(1)} ${space(2)};
  16. border-radius: ${theme.borderRadius};
  17. box-shadow: none;
  18. code {
  19. background: unset;
  20. }
  21. }
  22. pre[class*='language-'],
  23. code[class*='language-'] {
  24. color: var(--prism-base);
  25. background: var(--prism-block-background);
  26. font-size: ${theme.codeFontSize};
  27. text-shadow: none;
  28. font-family: ${theme.text.familyMono};
  29. direction: ltr;
  30. text-align: left;
  31. white-space: pre;
  32. word-spacing: normal;
  33. word-break: normal;
  34. -moz-tab-size: 4;
  35. -o-tab-size: 4;
  36. tab-size: 4;
  37. -webkit-hyphens: none;
  38. -moz-hyphens: none;
  39. -ms-hyphens: none;
  40. hyphens: none;
  41. .namespace {
  42. opacity: 0.7;
  43. }
  44. .token.comment,
  45. .token.prolog,
  46. .token.doctype,
  47. .token.cdata {
  48. color: var(--prism-comment);
  49. }
  50. .token.punctuation {
  51. color: var(--prism-punctuation);
  52. }
  53. .token.property,
  54. .token.tag,
  55. .token.boolean,
  56. .token.number,
  57. .token.constant,
  58. .token.symbol,
  59. .token.deleted {
  60. color: var(--prism-property);
  61. }
  62. .token.selector,
  63. .token.attr-name,
  64. .token.string,
  65. .token.char,
  66. .token.builtin,
  67. .token.inserted {
  68. color: var(--prism-selector);
  69. }
  70. .token.operator,
  71. .token.entity,
  72. .token.url,
  73. .language-css .token.string,
  74. .style .token.string {
  75. color: var(--prism-operator);
  76. background: none;
  77. }
  78. .token.atrule,
  79. .token.attr-value,
  80. .token.keyword {
  81. color: var(--prism-keyword);
  82. }
  83. .token.function {
  84. color: var(--prism-function);
  85. }
  86. .token.regex,
  87. .token.important,
  88. .token.variable {
  89. color: var(--prism-variable);
  90. }
  91. .token.important,
  92. .token.bold {
  93. font-weight: ${theme.fontWeightBold};
  94. }
  95. .token.italic {
  96. font-style: italic;
  97. }
  98. .token.entity {
  99. cursor: help;
  100. }
  101. .line-highlight {
  102. position: absolute;
  103. left: -${space(2)};
  104. right: 0;
  105. background: var(--prism-highlight-background);
  106. box-shadow: inset 5px 0 0 var(--prism-highlight-accent);
  107. z-index: 0;
  108. pointer-events: none;
  109. line-height: inherit;
  110. white-space: pre;
  111. }
  112. }
  113. pre[data-line] {
  114. position: relative;
  115. }
  116. pre[class*='language-'] > code[class*='language-'] {
  117. position: relative;
  118. z-index: 1;
  119. }
  120. `;
  121. const styles = (theme: Theme, isDark: boolean) => css`
  122. body {
  123. .sentry-error-embed-wrapper {
  124. z-index: ${theme.zIndex.sentryErrorEmbed};
  125. }
  126. color: ${theme.textColor};
  127. background: ${theme.backgroundSecondary};
  128. }
  129. abbr {
  130. ${theme.tooltipUnderline()};
  131. }
  132. a {
  133. color: ${theme.linkColor};
  134. &:focus-visible,
  135. &:hover {
  136. color: ${theme.linkHoverColor};
  137. }
  138. }
  139. .group-detail:before {
  140. background: ${theme.border};
  141. }
  142. .form-actions {
  143. border-top-color: ${theme.border};
  144. }
  145. pre,
  146. code {
  147. color: ${theme.textColor};
  148. }
  149. pre {
  150. background-color: ${theme.backgroundSecondary};
  151. white-space: pre-wrap;
  152. overflow-x: auto;
  153. }
  154. code {
  155. background-color: transparent;
  156. }
  157. ${prismStyles(theme)}
  158. /**
  159. * See https://web.dev/prefers-reduced-motion/
  160. */
  161. @media (prefers-reduced-motion) {
  162. *,
  163. ::before,
  164. ::after {
  165. animation-delay: -1ms !important;
  166. animation-duration: 0ms !important;
  167. animation-iteration-count: 1 !important;
  168. background-attachment: initial !important;
  169. scroll-behavior: auto !important;
  170. transition-duration: 0s !important;
  171. transition-delay: 0s !important;
  172. }
  173. }
  174. .ReactVirtualized__Grid:focus-visible,
  175. .ReactVirtualized__List:focus-visible {
  176. outline: ${theme.focusBorder} auto 1px;
  177. }
  178. /* Override css in LESS files here as we want to manually control dark mode for now */
  179. ${isDark
  180. ? css`
  181. .box,
  182. .box.box-modal {
  183. background: ${theme.background};
  184. border-color: ${theme.border};
  185. .box-content,
  186. .box-header {
  187. background: ${theme.background};
  188. h1,
  189. h2,
  190. h3,
  191. h4,
  192. h5,
  193. h6 {
  194. color: ${theme.headingColor};
  195. }
  196. a {
  197. color: ${theme.textColor};
  198. }
  199. }
  200. .box-header {
  201. border-bottom-color: ${theme.border};
  202. }
  203. }
  204. .loading .loading-indicator {
  205. border-color: ${theme.backgroundSecondary};
  206. border-left-color: ${theme.purple300};
  207. }
  208. .pattern-bg {
  209. opacity: 1;
  210. filter: invert(1) brightness(0.6);
  211. }
  212. .nav-tabs {
  213. & > li {
  214. &.active {
  215. a {
  216. color: ${theme.textColor} !important;
  217. border-bottom-color: ${theme.active} !important;
  218. }
  219. }
  220. a:hover {
  221. color: ${theme.textColor} !important;
  222. }
  223. }
  224. &.border-bottom {
  225. border-color: ${theme.border};
  226. }
  227. }
  228. ul.crumbs li .table.key-value pre {
  229. color: ${theme.subText};
  230. }
  231. .exception {
  232. border-color: ${theme.innerBorder};
  233. }
  234. .traceback {
  235. border-color: ${theme.border};
  236. &.in-app-traceback {
  237. .frame {
  238. &.leads-to-app {
  239. &.collapsed {
  240. .title {
  241. border-color: ${theme.border};
  242. background: ${theme.background};
  243. }
  244. }
  245. }
  246. }
  247. }
  248. .frame,
  249. .frame.system-frame {
  250. border-top-color: ${theme.border};
  251. &.is-expandable .title:hover {
  252. background-color: ${theme.background};
  253. }
  254. .btn-toggle {
  255. color: ${theme.textColor};
  256. background: transparent;
  257. }
  258. .title {
  259. background-color: ${theme.backgroundSecondary};
  260. }
  261. &.is-expandable .title {
  262. background-color: ${theme.backgroundSecondary};
  263. }
  264. .context {
  265. background: ${theme.background};
  266. table.key-value {
  267. border-color: ${theme.border};
  268. td {
  269. border-color: ${theme.border} !important;
  270. }
  271. }
  272. }
  273. }
  274. }
  275. .exc-message {
  276. color: ${theme.subText};
  277. }
  278. .group-detail h3 em {
  279. color: ${theme.subText};
  280. }
  281. .event-details-container {
  282. background-color: ${theme.background};
  283. .secondary {
  284. border-left-color: ${theme.border};
  285. }
  286. }
  287. /* Group Details - User context */
  288. .user-widget .avatar {
  289. box-shadow: 0 0 0 5px ${theme.background};
  290. background: ${theme.background};
  291. }
  292. .nav-header a.help-link,
  293. .nav-header span.help-link a {
  294. color: ${theme.subText};
  295. }
  296. /* Global Selection header date picker */
  297. .rdrCalendarWrapper {
  298. background: ${theme.background};
  299. color: ${theme.textColor};
  300. }
  301. .rdrDayDisabled {
  302. background-color: ${theme.backgroundSecondary};
  303. color: ${theme.disabled};
  304. }
  305. .rdrMonthAndYearPickers select {
  306. color: ${theme.textColor};
  307. }
  308. .dropdown-menu {
  309. color: ${theme.textColor};
  310. background-color: ${theme.background} !important;
  311. border: 1px solid ${theme.border};
  312. &:before {
  313. border-bottom-color: ${theme.border};
  314. }
  315. &:after {
  316. border-bottom-color: ${theme.background};
  317. }
  318. &.inverted:before {
  319. border-top-color: ${theme.border};
  320. }
  321. &.inverted:after {
  322. border-top-color: ${theme.background};
  323. }
  324. }
  325. `
  326. : ''}
  327. `;
  328. /**
  329. * Renders an emotion global styles injection component
  330. */
  331. function GlobalStyles({theme, isDark}: {isDark: boolean; theme: Theme}) {
  332. return <Global styles={styles(theme, isDark)} />;
  333. }
  334. export default GlobalStyles;