typography.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. module.exports = ({ theme }) => ({
  2. DEFAULT: {
  3. css: {
  4. '--tw-prose-body': theme('colors.zinc.700'),
  5. '--tw-prose-headings': theme('colors.white'),
  6. '--tw-prose-links': theme('colors.link'),
  7. '--tw-prose-links-hover': theme('colors.link'),
  8. '--tw-prose-links-underline': theme('colors.link / 0.3'),
  9. '--tw-prose-bold': theme('colors.zinc.900'),
  10. '--tw-prose-counters': theme('colors.zinc.500'),
  11. '--tw-prose-bullets': theme('colors.zinc.300'),
  12. '--tw-prose-hr': theme('colors.zinc.900 / 0.05'),
  13. '--tw-prose-quotes': theme('colors.zinc.900'),
  14. '--tw-prose-quote-borders': theme('colors.zinc.200'),
  15. '--tw-prose-captions': theme('colors.zinc.500'),
  16. '--tw-prose-code': theme('colors.zinc.900'),
  17. '--tw-prose-code-bg': theme('colors.zinc.100'),
  18. '--tw-prose-code-ring': theme('colors.zinc.300'),
  19. '--tw-prose-th-borders': theme('colors.zinc.300'),
  20. '--tw-prose-td-borders': theme('colors.zinc.200'),
  21. '--tw-prose-invert-body': theme('colors.zinc.400'),
  22. '--tw-prose-invert-headings': theme('colors.white'),
  23. '--tw-prose-invert-links': theme('colors.link'),
  24. '--tw-prose-invert-links-hover': theme('colors.link'),
  25. '--tw-prose-invert-links-underline': theme('colors.link / 0.3'),
  26. '--tw-prose-invert-bold': theme('colors.white'),
  27. '--tw-prose-invert-counters': theme('colors.zinc.400'),
  28. '--tw-prose-invert-bullets': theme('colors.zinc.600'),
  29. '--tw-prose-invert-hr': theme('colors.white / 0.05'),
  30. '--tw-prose-invert-quotes': theme('colors.zinc.100'),
  31. '--tw-prose-invert-quote-borders': theme('colors.zinc.700'),
  32. '--tw-prose-invert-captions': theme('colors.zinc.400'),
  33. '--tw-prose-invert-code': theme('colors.white'),
  34. '--tw-prose-invert-code-bg': theme('colors.zinc.700 / 0.15'),
  35. '--tw-prose-invert-code-ring': theme('colors.white / 0.1'),
  36. '--tw-prose-invert-th-borders': theme('colors.zinc.600'),
  37. '--tw-prose-invert-td-borders': theme('colors.zinc.700'),
  38. // Base
  39. color: 'var(--tw-prose-body)',
  40. fontSize: theme('fontSize.sm')[0],
  41. lineHeight: theme('lineHeight.7'),
  42. // Layout
  43. '> *': {
  44. maxWidth: theme('maxWidth.2xl'),
  45. marginLeft: 'auto',
  46. marginRight: 'auto',
  47. '@screen lg': {
  48. maxWidth: theme('maxWidth.3xl'),
  49. marginLeft: `calc(50% - min(50%, ${theme('maxWidth.lg')}))`,
  50. marginRight: `calc(50% - min(50%, ${theme('maxWidth.lg')}))`,
  51. },
  52. },
  53. // Text
  54. p: {
  55. marginTop: theme('spacing.6'),
  56. marginBottom: theme('spacing.6'),
  57. },
  58. '[class~="lead"]': {
  59. fontSize: theme('fontSize.base')[0],
  60. ...theme('fontSize.base')[1],
  61. },
  62. // Lists
  63. ol: {
  64. listStyleType: 'decimal',
  65. marginTop: theme('spacing.5'),
  66. marginBottom: theme('spacing.5'),
  67. paddingLeft: '1.625rem',
  68. },
  69. 'ol[type="A"]': {
  70. listStyleType: 'upper-alpha',
  71. },
  72. 'ol[type="a"]': {
  73. listStyleType: 'lower-alpha',
  74. },
  75. 'ol[type="A" s]': {
  76. listStyleType: 'upper-alpha',
  77. },
  78. 'ol[type="a" s]': {
  79. listStyleType: 'lower-alpha',
  80. },
  81. 'ol[type="I"]': {
  82. listStyleType: 'upper-roman',
  83. },
  84. 'ol[type="i"]': {
  85. listStyleType: 'lower-roman',
  86. },
  87. 'ol[type="I" s]': {
  88. listStyleType: 'upper-roman',
  89. },
  90. 'ol[type="i" s]': {
  91. listStyleType: 'lower-roman',
  92. },
  93. 'ol[type="1"]': {
  94. listStyleType: 'decimal',
  95. },
  96. ul: {
  97. listStyleType: 'disc',
  98. marginTop: theme('spacing.5'),
  99. marginBottom: theme('spacing.5'),
  100. paddingLeft: '1.625rem',
  101. },
  102. li: {
  103. marginTop: theme('spacing.2'),
  104. marginBottom: theme('spacing.2'),
  105. },
  106. ':is(ol, ul) > li': {
  107. paddingLeft: theme('spacing[1.5]'),
  108. },
  109. 'ol > li::marker': {
  110. fontWeight: '400',
  111. color: 'var(--tw-prose-counters)',
  112. },
  113. 'ul > li::marker': {
  114. color: 'var(--tw-prose-bullets)',
  115. },
  116. '> ul > li p': {
  117. marginTop: theme('spacing.3'),
  118. marginBottom: theme('spacing.3'),
  119. },
  120. '> ul > li > *:first-child': {
  121. marginTop: theme('spacing.5'),
  122. },
  123. '> ul > li > *:last-child': {
  124. marginBottom: theme('spacing.5'),
  125. },
  126. '> ol > li > *:first-child': {
  127. marginTop: theme('spacing.5'),
  128. },
  129. '> ol > li > *:last-child': {
  130. marginBottom: theme('spacing.5'),
  131. },
  132. 'ul ul, ul ol, ol ul, ol ol': {
  133. marginTop: theme('spacing.3'),
  134. marginBottom: theme('spacing.3'),
  135. },
  136. // Horizontal rules
  137. hr: {
  138. borderColor: 'var(--tw-prose-hr)',
  139. borderTopWidth: 1,
  140. marginTop: theme('spacing.16'),
  141. marginBottom: theme('spacing.16'),
  142. maxWidth: 'none',
  143. marginLeft: `calc(-1 * ${theme('spacing.4')})`,
  144. marginRight: `calc(-1 * ${theme('spacing.4')})`,
  145. '@screen sm': {
  146. marginLeft: `calc(-1 * ${theme('spacing.6')})`,
  147. marginRight: `calc(-1 * ${theme('spacing.6')})`,
  148. },
  149. '@screen lg': {
  150. marginLeft: `calc(-1 * ${theme('spacing.8')})`,
  151. marginRight: `calc(-1 * ${theme('spacing.8')})`,
  152. },
  153. },
  154. // Quotes
  155. blockquote: {
  156. fontWeight: '500',
  157. fontStyle: 'italic',
  158. color: 'var(--tw-prose-quotes)',
  159. borderLeftWidth: '0.25rem',
  160. borderLeftColor: 'var(--tw-prose-quote-borders)',
  161. quotes: '"\\201C""\\201D""\\2018""\\2019"',
  162. marginTop: theme('spacing.8'),
  163. marginBottom: theme('spacing.8'),
  164. paddingLeft: theme('spacing.5'),
  165. },
  166. 'blockquote p:first-of-type::before': {
  167. content: 'open-quote',
  168. },
  169. 'blockquote p:last-of-type::after': {
  170. content: 'close-quote',
  171. },
  172. // Headings
  173. h1: {
  174. color: 'var(--tw-prose-headings)',
  175. fontWeight: '700',
  176. fontSize: theme('fontSize.2xl')[0],
  177. ...theme('fontSize.2xl')[1],
  178. marginBottom: theme('spacing.2'),
  179. },
  180. h2: {
  181. color: 'var(--tw-prose-headings)',
  182. fontWeight: '600',
  183. fontSize: theme('fontSize.lg')[0],
  184. ...theme('fontSize.lg')[1],
  185. marginTop: theme('spacing.16'),
  186. marginBottom: theme('spacing.2'),
  187. },
  188. h3: {
  189. color: 'var(--tw-prose-headings)',
  190. fontSize: theme('fontSize.base')[0],
  191. ...theme('fontSize.base')[1],
  192. fontWeight: '600',
  193. marginTop: theme('spacing.10'),
  194. marginBottom: theme('spacing.2'),
  195. },
  196. // Media
  197. 'img, video, figure': {
  198. marginTop: theme('spacing.8'),
  199. marginBottom: theme('spacing.8'),
  200. },
  201. 'figure > *': {
  202. marginTop: '0',
  203. marginBottom: '0',
  204. },
  205. figcaption: {
  206. color: 'var(--tw-prose-captions)',
  207. fontSize: theme('fontSize.xs')[0],
  208. ...theme('fontSize.xs')[1],
  209. marginTop: theme('spacing.2'),
  210. },
  211. // Tables
  212. table: {
  213. width: '100%',
  214. tableLayout: 'auto',
  215. textAlign: 'left',
  216. marginTop: theme('spacing.8'),
  217. marginBottom: theme('spacing.8'),
  218. lineHeight: theme('lineHeight.6'),
  219. },
  220. thead: {
  221. borderBottomWidth: '1px',
  222. borderBottomColor: 'var(--tw-prose-th-borders)',
  223. },
  224. 'thead th': {
  225. color: 'var(--tw-prose-headings)',
  226. fontWeight: '600',
  227. verticalAlign: 'bottom',
  228. paddingRight: theme('spacing.2'),
  229. paddingBottom: theme('spacing.2'),
  230. paddingLeft: theme('spacing.2'),
  231. textAlign: 'left'
  232. },
  233. 'thead th:first-child': {
  234. paddingLeft: '0',
  235. },
  236. 'thead th:last-child': {
  237. paddingRight: '0',
  238. },
  239. 'tbody tr': {
  240. borderBottomWidth: '1px',
  241. borderBottomColor: 'var(--tw-prose-td-borders)',
  242. },
  243. 'tbody tr:last-child': {
  244. borderBottomWidth: '0',
  245. },
  246. 'tbody td': {
  247. // verticalAlign: 'baseline',
  248. textAlign: 'left'
  249. },
  250. tfoot: {
  251. borderTopWidth: '1px',
  252. borderTopColor: 'var(--tw-prose-th-borders)',
  253. },
  254. 'tfoot td': {
  255. verticalAlign: 'top',
  256. },
  257. ':is(tbody, tfoot) td': {
  258. paddingTop: theme('spacing.2'),
  259. paddingRight: theme('spacing.2'),
  260. paddingBottom: theme('spacing.2'),
  261. paddingLeft: theme('spacing.2'),
  262. },
  263. ':is(tbody, tfoot) td:first-child': {
  264. paddingLeft: '0',
  265. },
  266. ':is(tbody, tfoot) td:last-child': {
  267. paddingRight: '0',
  268. },
  269. // Inline elements
  270. a: {
  271. color: 'var(--tw-prose-links)',
  272. textDecoration: 'underline transparent',
  273. fontWeight: '500',
  274. transitionProperty: 'color, text-decoration-color',
  275. transitionDuration: theme('transitionDuration.DEFAULT'),
  276. transitionTimingFunction: theme('transitionTimingFunction.DEFAULT'),
  277. '&:hover': {
  278. color: 'var(--tw-prose-links-hover)',
  279. textDecorationColor: 'var(--tw-prose-links-underline)',
  280. },
  281. },
  282. ':is(h1, h2, h3) a': {
  283. fontWeight: 'inherit',
  284. },
  285. strong: {
  286. color: 'var(--tw-prose-bold)',
  287. fontWeight: '600',
  288. },
  289. ':is(a, blockquote, thead th) strong': {
  290. color: 'inherit',
  291. },
  292. code: {
  293. color: 'var(--tw-prose-code)',
  294. borderRadius: theme('borderRadius.lg'),
  295. paddingTop: theme('padding.1'),
  296. paddingRight: theme('padding[1.5]'),
  297. paddingBottom: theme('padding.1'),
  298. paddingLeft: theme('padding[1.5]'),
  299. boxShadow: 'inset 0 0 0 1px var(--tw-prose-code-ring)',
  300. backgroundColor: 'var(--tw-prose-code-bg)',
  301. fontSize: theme('fontSize.2xs'),
  302. },
  303. ':is(a, h1, h2, h3, blockquote, thead th) code': {
  304. color: 'inherit',
  305. },
  306. 'h2 code': {
  307. fontSize: theme('fontSize.base')[0],
  308. fontWeight: 'inherit',
  309. },
  310. 'h3 code': {
  311. fontSize: theme('fontSize.sm')[0],
  312. fontWeight: 'inherit',
  313. },
  314. // Overrides
  315. ':is(h1, h2, h3) + *': {
  316. marginTop: '0',
  317. },
  318. '> :first-child': {
  319. marginTop: '0 !important',
  320. },
  321. '> :last-child': {
  322. marginBottom: '0 !important',
  323. },
  324. },
  325. },
  326. invert: {
  327. css: {
  328. '--tw-prose-body': 'var(--tw-prose-invert-body)',
  329. '--tw-prose-headings': 'var(--tw-prose-invert-headings)',
  330. '--tw-prose-links': 'var(--tw-prose-invert-links)',
  331. '--tw-prose-links-hover': 'var(--tw-prose-invert-links-hover)',
  332. '--tw-prose-links-underline': 'var(--tw-prose-invert-links-underline)',
  333. '--tw-prose-bold': 'var(--tw-prose-invert-bold)',
  334. '--tw-prose-counters': 'var(--tw-prose-invert-counters)',
  335. '--tw-prose-bullets': 'var(--tw-prose-invert-bullets)',
  336. '--tw-prose-hr': 'var(--tw-prose-invert-hr)',
  337. '--tw-prose-quotes': 'var(--tw-prose-invert-quotes)',
  338. '--tw-prose-quote-borders': 'var(--tw-prose-invert-quote-borders)',
  339. '--tw-prose-captions': 'var(--tw-prose-invert-captions)',
  340. '--tw-prose-code': 'var(--tw-prose-invert-code)',
  341. '--tw-prose-code-bg': 'var(--tw-prose-invert-code-bg)',
  342. '--tw-prose-code-ring': 'var(--tw-prose-invert-code-ring)',
  343. '--tw-prose-th-borders': 'var(--tw-prose-invert-th-borders)',
  344. '--tw-prose-td-borders': 'var(--tw-prose-invert-td-borders)',
  345. },
  346. },
  347. })