globalStyles.tsx 4.2 KB

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