globalStyles.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import {css, Global, Theme} from '@emotion/react';
  2. import space from 'sentry/styles/space';
  3. const docsStyles = (theme: Theme) => css`
  4. html {
  5. font-size: 100%;
  6. }
  7. body {
  8. font-family: ${theme.text.family};
  9. font-feature-settings: 'liga';
  10. font-size: ${theme.fontSizeLarge};
  11. color: ${theme.textColor};
  12. }
  13. div,
  14. p,
  15. a,
  16. button {
  17. color: ${theme.textColor};
  18. }
  19. strong {
  20. color: ${theme.headingColor};
  21. }
  22. /** Content wraps */
  23. #docs-root {
  24. display: flex;
  25. justify-content: center;
  26. background: ${theme.background};
  27. }
  28. #root,
  29. .sbdocs.sbdocs-preview {
  30. font-size: ${theme.fontSizeMedium};
  31. }
  32. body.sb-show-main {
  33. background: ${theme.background} !important;
  34. }
  35. .sbdocs.sbdocs-wrapper {
  36. padding: calc(${space(4)} * 3) calc(${space(4)} * 2);
  37. justify-content: flex-start;
  38. background: ${theme.background};
  39. }
  40. .sbdocs.sbdocs-content {
  41. position: relative;
  42. max-width: 48em;
  43. }
  44. .sidebar-container {
  45. border-right: solid 1px ${theme.innerBorder};
  46. }
  47. /** Dividers */
  48. .sbdocs.sbdocs-hr {
  49. margin: calc(${space(4)} * 2) 0;
  50. border-top: solid 1px ${theme.border};
  51. }
  52. /** Images */
  53. .sbdocs.sbdocs-img {
  54. width: 100%;
  55. margin: ${space(2)} 0;
  56. }
  57. .sbdocs.sbdocs-img.with-border {
  58. border-radius: ${theme.borderRadius};
  59. border: solid 1px ${theme.border};
  60. }
  61. /** Body text */
  62. .sbdocs.sbdocs-p {
  63. font-family: ${theme.text.family};
  64. font-size: ${theme.fontSizeLarge};
  65. color: ${theme.textColor};
  66. margin: ${space(1.5)} 0;
  67. }
  68. .sbdocs.small {
  69. font-size: 0.875rem;
  70. color: ${theme.subText};
  71. }
  72. /** Links */
  73. .sbdocs.sbdocs-a {
  74. font-family: ${theme.text.family};
  75. font-size: ${theme.fontSizeLarge};
  76. color: ${theme.blue300};
  77. text-decoration: underline;
  78. text-decoration-color: ${theme.blue100};
  79. margin: 0;
  80. }
  81. .sbdocs.sbdocs-a:hover {
  82. text-decoration-color: ${theme.blue200};
  83. }
  84. .sbdocs.sbdocs-a.gray-link {
  85. color: ${theme.subText};
  86. text-decoration: none;
  87. }
  88. .sbdocs.sbdocs-a.gray-link:hover {
  89. text-decoration: underline;
  90. text-decoration-color: ${theme.gray200};
  91. }
  92. /** Code */
  93. .sbdocs.sbdocs-pre {
  94. overflow: visible;
  95. font-family: ${theme.text.familyMono};
  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. );