Layout scaffolding for Web apps.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

90 lines
1.6 KiB

  1. import NextDocument, {Html, Head as NextHead, Main, NextScript, DocumentContext} from 'next/document';
  2. import { extractCss } from '@tesseract-design/viewfinder-react';
  3. export default class Document extends NextDocument {
  4. static async getInitialProps(ctx: DocumentContext) {
  5. const page = await ctx.renderPage()
  6. const style = extractCss();
  7. const initialProps = await NextDocument.getInitialProps(ctx)
  8. return {
  9. ...initialProps,
  10. ...page,
  11. style,
  12. }
  13. }
  14. render() {
  15. const { style: rawStyle } = this.props as Record<string, unknown>
  16. const style = rawStyle as string
  17. return (
  18. <Html>
  19. <NextHead>
  20. {
  21. style.length > 0
  22. && (
  23. <style
  24. id="_goober_ssr"
  25. dangerouslySetInnerHTML={{ __html: style }}
  26. />
  27. )
  28. }
  29. <style>
  30. {`
  31. :root {
  32. --base-width: 360px;
  33. --color-background: white;
  34. }
  35. html,
  36. body {
  37. padding: 0;
  38. margin: 0;
  39. font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
  40. Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
  41. line-height: 1.75;
  42. }
  43. a {
  44. color: inherit;
  45. text-decoration: none;
  46. }
  47. * {
  48. box-sizing: border-box;
  49. }
  50. @media (prefers-color-scheme: dark) {
  51. :root {
  52. --color-background: black;
  53. }
  54. html {
  55. color-scheme: dark;
  56. }
  57. body {
  58. color: white;
  59. background-color: var(--color-background);
  60. }
  61. }
  62. #__next {
  63. display: contents;
  64. background-color: inherit;
  65. }
  66. `}
  67. </style>
  68. </NextHead>
  69. <body>
  70. <Main />
  71. <NextScript />
  72. </body>
  73. </Html>
  74. )
  75. }
  76. }