globalStyles.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. import {css, Global} from '@emotion/react';
  2. import space from 'sentry/styles/space';
  3. import {Theme} from 'sentry/utils/theme';
  4. const docsStyles = (theme: Theme) => css`
  5. html,
  6. body {
  7. font-family: ${theme.text.family};
  8. font-feature-settings: 'liga';
  9. font-size: ${theme.fontSizeLarge};
  10. color: ${theme.textColor};
  11. }
  12. div,
  13. p,
  14. a,
  15. button {
  16. font-family: ${theme.text.family};
  17. font-size: 1rem;
  18. color: ${theme.textColor};
  19. }
  20. /** Content wraps */
  21. #docs-root {
  22. display: flex;
  23. justify-content: center;
  24. background: ${theme.background};
  25. }
  26. body.sb-show-main {
  27. background: ${theme.background} !important;
  28. }
  29. .sbdocs.sbdocs-wrapper {
  30. padding: calc(${space(4)} * 3) calc(${space(4)} * 2);
  31. justify-content: flex-start;
  32. background: ${theme.background};
  33. }
  34. .sbdocs.sbdocs-content {
  35. position: relative;
  36. max-width: 48em;
  37. }
  38. .sidebar-container {
  39. border-right: solid 1px ${theme.innerBorder};
  40. }
  41. /** Dividers */
  42. .sbdocs.sbdocs-hr {
  43. margin: calc(${space(4)} * 2) 0;
  44. border-top: solid 1px ${theme.border};
  45. }
  46. /** Images */
  47. .sbdocs.sbdocs-img {
  48. width: 100%;
  49. margin: ${space(2)} 0;
  50. }
  51. .sbdocs.sbdocs-img.with-border {
  52. border-radius: ${theme.borderRadius};
  53. border: solid 1px ${theme.border};
  54. }
  55. /** Body text */
  56. .sbdocs.sbdocs-p {
  57. font-family: ${theme.text.family};
  58. font-size: 1rem;
  59. color: ${theme.textColor};
  60. margin: ${space(2)} 0;
  61. }
  62. .sbdocs.small {
  63. font-size: 0.875rem;
  64. color: ${theme.subText};
  65. }
  66. /** Links */
  67. .sbdocs.sbdocs-a {
  68. font-family: ${theme.text.family};
  69. font-size: 1rem;
  70. color: ${theme.blue300};
  71. text-decoration: underline;
  72. text-decoration-color: ${theme.blue100};
  73. margin: 0;
  74. }
  75. .sbdocs.sbdocs-a:hover {
  76. text-decoration-color: ${theme.blue200};
  77. }
  78. .sbdocs.sbdocs-a.gray-link {
  79. color: ${theme.subText};
  80. text-decoration: none;
  81. }
  82. .sbdocs.sbdocs-a.gray-link:hover {
  83. text-decoration: underline;
  84. text-decoration-color: ${theme.gray200};
  85. }
  86. /** Code */
  87. .sbdocs.sbdocs-pre {
  88. overflow: visible;
  89. }
  90. .sbdocs.sbdocs-wrapper *:not(pre) > code {
  91. font-family: ${theme.text.familyMono};
  92. font-size: 1rem;
  93. padding: 0.125rem 0.25rem;
  94. color: ${theme.textColor};
  95. background: ${theme.bodyBackground};
  96. border: solid 1px ${theme.innerBorder};
  97. }
  98. /** Lists */
  99. .sbdocs.sbdocs-ul,
  100. .sbdocs.sbdocs-ol {
  101. margin: ${space(2)} 0;
  102. }
  103. .sbdocs.sbdocs-li,
  104. .sbdocs.sbdocs-li:first-of-type,
  105. .sbdocs.sbdocs-li:last-child {
  106. font-family: ${theme.text.family};
  107. font-size: 1rem;
  108. color: ${theme.textColor};
  109. margin: ${space(1)} 0;
  110. }
  111. ul > .sbdocs.sbdocs-li ul > .sbdocs.sbdocs-li {
  112. list-style-type: circle;
  113. }
  114. ol > .sbdocs.sbdocs-li ol > .sbdocs.sbdocs-li {
  115. list-style-type: lower-alpha;
  116. }
  117. /** Headings */
  118. .sbdocs.sbdocs-h1,
  119. .sbdocs.sbdocs-h2,
  120. .sbdocs.sbdocs-h3,
  121. .sbdocs.sbdocs-h4 {
  122. font-family: ${theme.text.family};
  123. font-weight: 600;
  124. color: ${theme.textColor};
  125. border-bottom: none;
  126. }
  127. .sbdocs.sbdocs-h1 {
  128. font-size: 2.25rem;
  129. letter-spacing: -0.05rem;
  130. margin-bottom: ${space(4)};
  131. }
  132. .sbdocs.sbdocs-h2,
  133. .sbdocs.sbdocs-h2:first-of-type {
  134. font-size: 1.625rem;
  135. letter-spacing: -0.03rem;
  136. margin-top: 0;
  137. margin-bottom: ${space(2)};
  138. }
  139. .sbdocs.sbdocs-h3,
  140. .sbdocs.sbdocs-h3:first-of-type {
  141. font-size: 1.25rem;
  142. letter-spacing: -0.01rem;
  143. margin-top: ${space(4)};
  144. margin-bottom: ${space(1)};
  145. }
  146. .sbdocs.sbdocs-h3:first-of-type {
  147. margin-top: ${space(2)};
  148. }
  149. .sbdocs.sbdocs-h4,
  150. .sbdocs.sbdocs-h4:first-of-type {
  151. font-size: 1rem;
  152. margin-top: ${space(3)};
  153. margin-bottom: ${space(1)};
  154. }
  155. .sbdocs.sbdocs-h4:first-of-type {
  156. margin-top: ${space(2)};
  157. }
  158. `;
  159. export const DocsGlobalStyles = ({theme}: {theme: Theme}) => (
  160. <Global styles={docsStyles(theme)} />
  161. );
  162. const storyStyles = (theme: Theme) => css`
  163. body.sb-show-main {
  164. background: ${theme.background} !important;
  165. }
  166. `;
  167. export const StoryGlobalStyles = ({theme}: {theme: Theme}) => (
  168. <Global styles={storyStyles(theme)} />
  169. );