| 1 | // eslint-disable-next-line @typescript-eslint/ban-types |
| 2 | export const Typography: React.FC<React.PropsWithChildren<{}>> = ({ |
| 3 | children, |
| 4 | }) => ( |
| 5 | <div className="typography"> |
| 6 | {children} |
| 7 | <style jsx>{` |
| 8 | .typography { |
| 9 | @apply break-words text-base leading-relaxed; |
| 10 | } |
| 11 | .typography :global(p) { |
| 12 | @apply my-4; |
| 13 | } |
| 14 | .typography :global(h1) { |
| 15 | @apply relative mt-8 mb-5 text-3xl font-bold; |
| 16 | } |
| 17 | .typography :global(h2) { |
| 18 | @apply relative mt-8 mb-5 text-2xl font-bold; |
| 19 | } |
| 20 | .typography :global(h3) { |
| 21 | @apply relative mt-8 mb-4 text-xl font-bold; |
| 22 | } |
| 23 | .typography :global(h4) { |
| 24 | @apply relative mt-6 mb-4 text-lg font-bold; |
| 25 | } |
| 26 | .typography :global(h5) { |
| 27 | @apply relative mt-6 mb-4 text-base font-bold; |
| 28 | } |
| 29 | .typography :global(h6) { |
| 30 | @apply relative mt-6 mb-4 text-sm font-bold text-gray-600; |
| 31 | } |
| 32 | .typography :global(.anchor-link) { |
| 33 | @apply absolute inset-0 my-auto -ml-5 hidden w-5 overflow-hidden whitespace-nowrap bg-left bg-no-repeat; |
| 34 | |
| 35 | background-size: 1rem 1rem; |
| 36 | background-image: url('https://icongr.am/octicons/link.svg?color=718096'); |
| 37 | } |
| 38 | .typography :global(h1:hover > .anchor-link), |
| 39 | .typography :global(h2:hover > .anchor-link), |
| 40 | .typography :global(h3:hover > .anchor-link), |
| 41 | .typography :global(h4:hover > .anchor-link), |
| 42 | .typography :global(h5:hover > .anchor-link), |
| 43 | .typography :global(h6:hover > .anchor-link) { |
| 44 | @apply block; |
| 45 | } |
| 46 | .typography :global(hr) { |
| 47 | @apply my-8; |
| 48 | } |
| 49 | .typography :global(blockquote) { |
| 50 | @apply border-marp-light my-6 border-l-4 pl-5 text-gray-600; |
| 51 | } |
| 52 | .typography :global(blockquote blockquote) { |
| 53 | border-left-width: 3px; |
| 54 | } |
| 55 | .typography :global(blockquote blockquote blockquote) { |
| 56 | @apply border-l-2; |
| 57 | } |
| 58 | .typography :global(ul) { |
| 59 | @apply my-6 ml-8 mr-3 list-disc; |
| 60 | } |
| 61 | .typography :global(ul ul) { |
| 62 | list-style-type: circle; |
| 63 | } |
| 64 | .typography :global(ul ul ul) { |
| 65 | list-style-type: square; |
| 66 | } |
| 67 | .typography :global(ol:not(.code-block)) { |
| 68 | @apply my-6 ml-8 mr-3 list-decimal; |
| 69 | } |
| 70 | .typography :global(ul ul), |
| 71 | .typography :global(ul ol:not(._)), |
| 72 | .typography :global(ol:not(._) ul), |
| 73 | .typography :global(ol:not(._) ol:not(._)) { |
| 74 | @apply my-0 mr-0; |
| 75 | } |
| 76 | .typography :global(li:not(.code-block)) { |
| 77 | @apply my-1; |
| 78 | } |
| 79 | .typography :global(code:not(.code-block)) { |
| 80 | @apply rounded border border-gray-400 bg-gray-200; |
| 81 | |
| 82 | font-size: 0.9em; |
| 83 | padding: 0.15em 0.35em; |
| 84 | } |
| 85 | .typography :global(pre) { |
| 86 | @apply my-6; |
| 87 | } |
| 88 | .typography :global(img) { |
| 89 | @apply inline; |
| 90 | } |
| 91 | .typography :global(figure) { |
| 92 | @apply my-6; |
| 93 | } |
| 94 | .typography :global(figure img) { |
| 95 | @apply mx-auto block; |
| 96 | max-width: min(theme('screens.md'), 100%); |
| 97 | } |
| 98 | .typography :global(figcaption) { |
| 99 | @apply mx-auto my-4 w-11/12 text-center text-sm text-gray-600; |
| 100 | } |
| 101 | .typography :global(table) { |
| 102 | @apply mx-auto my-8 max-w-full; |
| 103 | } |
| 104 | .typography :global(td), |
| 105 | .typography :global(th) { |
| 106 | @apply border-b border-gray-400 p-2 text-sm; |
| 107 | } |
| 108 | .typography :global(thead tr:last-child td), |
| 109 | .typography :global(thead tr:last-child th) { |
| 110 | @apply border-b-2; |
| 111 | } |
| 112 | |
| 113 | @screen sm { |
| 114 | .typography :global(td), |
| 115 | .typography :global(th) { |
| 116 | @apply py-2 px-4; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | @screen md { |
| 121 | .typography :global(td), |
| 122 | .typography :global(th) { |
| 123 | @apply text-base; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | .typography > :global(*:first-child), |
| 128 | .typography > :global(*:first-child *:first-child) { |
| 129 | @apply mt-0; |
| 130 | } |
| 131 | .typography > :global(*:last-child), |
| 132 | .typography > :global(*:last-child *:last-child) { |
| 133 | @apply mb-0; |
| 134 | } |
| 135 | `}</style> |
| 136 | </div> |
| 137 | ) |
| 138 |