Skip to content

Commit eca22f0

Browse files
authored
Update site dependencies (#129)
* Make sandbox component SSR-safe * Update dependencies GIT_VALID_PII_OVERRIDE * Add comment about dev bug in the editor component * Move global styles to global CSS file New versions of Next.js aren't working with <styled jsx global> well. Instead of debugging, this commit moves those global styles to our global.css file. Also changes around some border colors in dark mode to reduce their prominence. Tested by poking around in dev mode and release mode. * Revert docsearch/react change
1 parent 8dc2e66 commit eca22f0

7 files changed

Lines changed: 5782 additions & 1355 deletions

File tree

components/Sandbox.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import { Controlled as CodeMirror } from 'react-codemirror2';
32
import { useRouter } from 'next/router';
43
import Markdoc from '@markdoc/markdoc';
54
import { getSchema } from '@markdoc/next.js/runtime';
@@ -89,9 +88,14 @@ export function useMarkdocCode(code) {
8988
return { ast, content, config, errors };
9089
}
9190

91+
// NOTE: In development mode, you may see two CodeMirror editors rendered, one
92+
// on top of another. I don't know why this happens, but it does not occur in
93+
// production builds. You can verify this by running `npm run build && npm run
94+
// start`.
9295
function EditorInternal({ code, onChange, options, errors, cursor }) {
9396
const ref = React.useRef();
9497
const [key, setKey] = React.useState(0);
98+
const [CodeMirror, setCodeMirror] = React.useState(null);
9599

96100
const codeMirrorOptions = React.useMemo(
97101
() => ({
@@ -149,14 +153,20 @@ function EditorInternal({ code, onChange, options, errors, cursor }) {
149153
}, [errors]);
150154

151155
React.useEffect(() => {
156+
const { Controlled } = require('react-codemirror2');
152157
require('codemirror/mode/markdown/markdown');
153158
require('codemirror/mode/javascript/javascript');
154159
require('codemirror/mode/xml/xml');
155160
require('codemirror/addon/selection/mark-selection');
156161
require('./codemirror/markdoc.js');
162+
setCodeMirror(() => Controlled);
157163
setKey((k) => k + 1);
158164
}, []);
159165

166+
if (!CodeMirror) {
167+
return null;
168+
}
169+
160170
return (
161171
<>
162172
<CodeMirror

components/Shell/Footer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export function Footer({ children: links, landing }) {
139139
display: block;
140140
width: 100%;
141141
border: none;
142-
border-bottom: 1px solid var(--dark);
142+
border-bottom: 1px solid var(--page-border);
143143
}
144144
145145
.try-link {

components/Shell/TopNav.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function TopNav({ children }) {
8585
margin: 0 auto;
8686
align-items: center;
8787
justify-content: space-between;
88-
border-bottom: 1px solid var(--dark);
88+
border-bottom: 1px solid var(--page-border);
8989
padding: 1rem 2rem 1.1rem;
9090
font-size: 15px;
9191
font-family: var(--sans);

0 commit comments

Comments
 (0)