globalStyles.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. }
  96. .sbdocs.sbdocs-wrapper *:not(pre) > code {
  97. font-family: ${theme.text.familyMono};
  98. font-size: ${theme.fontSizeLarge};
  99. padding: 0.125rem 0.25rem;
  100. color: ${theme.textColor};
  101. background: ${theme.bodyBackground};
  102. border: solid 1px ${theme.innerBorder};
  103. }
  104. /** Lists */
  105. .sbdocs.sbdocs-ul,
  106. .sbdocs.sbdocs-ol {
  107. margin: ${space(2)} 0;
  108. }
  109. .sbdocs.sbdocs-li,
  110. .sbdocs.sbdocs-li:first-of-type,
  111. .sbdocs.sbdocs-li:last-child {
  112. font-family: ${theme.text.family};
  113. font-size: ${theme.fontSizeLarge};
  114. color: ${theme.textColor};
  115. margin: ${space(1)} 0;
  116. }
  117. ul > .sbdocs.sbdocs-li ul > .sbdocs.sbdocs-li {
  118. list-style-type: circle;
  119. }
  120. ol > .sbdocs.sbdocs-li ol > .sbdocs.sbdocs-li {
  121. list-style-type: lower-alpha;
  122. }
  123. /** Headings */
  124. .sbdocs.sbdocs-h1,
  125. .sbdocs.sbdocs-h2,
  126. .sbdocs.sbdocs-h3,
  127. .sbdocs.sbdocs-h4 {
  128. font-family: ${theme.text.family};
  129. font-weight: 600;
  130. color: ${theme.headingColor};
  131. border-bottom: none;
  132. }
  133. .sbdocs.sbdocs-h1 {
  134. font-size: 2.25rem;
  135. letter-spacing: -0.02em;
  136. margin-bottom: ${space(3)};
  137. }
  138. .sbdocs.sbdocs-h2,
  139. .sbdocs.sbdocs-h2:first-of-type {
  140. font-size: 1.625rem;
  141. letter-spacing: -0.012em;
  142. margin-top: 0;
  143. margin-bottom: ${space(2)};
  144. }
  145. .sbdocs.sbdocs-h3,
  146. .sbdocs.sbdocs-h3:first-of-type {
  147. font-size: 1.25rem;
  148. letter-spacing: -0.004em;
  149. margin-top: ${space(4)};
  150. margin-bottom: ${space(1)};
  151. }
  152. .sbdocs.sbdocs-h3:first-of-type {
  153. margin-top: ${space(2)};
  154. }
  155. .sbdocs.sbdocs-h4,
  156. .sbdocs.sbdocs-h4:first-of-type {
  157. font-size: 1rem;
  158. margin-top: ${space(3)};
  159. margin-bottom: ${space(1)};
  160. }
  161. .sbdocs.sbdocs-h4:first-of-type {
  162. margin-top: ${space(2)};
  163. }
  164. `;
  165. export const DocsGlobalStyles = ({theme}: {theme: Theme}) => (
  166. <Global styles={docsStyles(theme)} />
  167. );
  168. const storyStyles = (theme: Theme) => css`
  169. body.sb-show-main {
  170. background: ${theme.background} !important;
  171. }
  172. `;
  173. export const StoryGlobalStyles = ({theme}: {theme: Theme}) => (
  174. <Global styles={storyStyles(theme)} />
  175. );