Skip to content

Commit 0eebd37

Browse files
authored
[playground] Config panel quality fixes (facebook#34611)
Fixed two small issues with the config panel in the compiler playground: 1. Object descriptions were being confined in the config box and most of it would not be visible upon hover 2. Changed it so that "Applied Configs" would only display a valid set of configs, rather than switching between "Invalid Configs" and the set of options. This would be less visually jarring for users as the Output panel already displays errors. Additionally, if users want to see the list of config options but have a currently broken config, they would previously not know how to fix it. Object hover before: <img width="702" height="481" alt="Screenshot 2025-09-26 at 10 41 03 AM" src="https://github.com/user-attachments/assets/b2ddec2f-16ba-41a1-be1f-96211f46764c" /> Hover after: <img width="702" height="481" alt="Screenshot 2025-09-26 at 10 40 37 AM" src="https://github.com/user-attachments/assets/dc713a22-4710-46a8-a5d7-485060cc9074" /> Applied Configs always displays the last valid set of configs: https://github.com/user-attachments/assets/2fb9232f-7388-4488-9b7a-bb48bf09e4ca
1 parent 74dee8e commit 0eebd37

File tree

4 files changed

+349
-338
lines changed

4 files changed

+349
-338
lines changed

compiler/apps/playground/components/Editor/ConfigEditor.tsx

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
import MonacoEditor, {loader, type Monaco} from '@monaco-editor/react';
9-
import {PluginOptions} from 'babel-plugin-react-compiler';
109
import type {editor} from 'monaco-editor';
1110
import * as monaco from 'monaco-editor';
1211
import React, {
@@ -18,9 +17,8 @@ import React, {
1817
} from 'react';
1918
import {Resizable} from 're-resizable';
2019
import {useStore, useStoreDispatch} from '../StoreContext';
21-
import {monacoOptions} from './monacoOptions';
20+
import {monacoConfigOptions} from './monacoOptions';
2221
import {IconChevron} from '../Icons/IconChevron';
23-
import prettyFormat from 'pretty-format';
2422
import {CONFIG_PANEL_TRANSITION} from '../../lib/transitionTypes';
2523

2624
// @ts-expect-error - webpack asset/source loader handles .d.ts files as strings
@@ -29,9 +27,9 @@ import compilerTypeDefs from 'babel-plugin-react-compiler/dist/index.d.ts';
2927
loader.config({monaco});
3028

3129
export default function ConfigEditor({
32-
appliedOptions,
30+
formattedAppliedConfig,
3331
}: {
34-
appliedOptions: PluginOptions | null;
32+
formattedAppliedConfig: string;
3533
}): React.ReactElement {
3634
const [isExpanded, setIsExpanded] = useState(false);
3735

@@ -49,7 +47,7 @@ export default function ConfigEditor({
4947
setIsExpanded(false);
5048
});
5149
}}
52-
appliedOptions={appliedOptions}
50+
formattedAppliedConfig={formattedAppliedConfig}
5351
/>
5452
</div>
5553
<div
@@ -71,10 +69,10 @@ export default function ConfigEditor({
7169

7270
function ExpandedEditor({
7371
onToggle,
74-
appliedOptions,
72+
formattedAppliedConfig,
7573
}: {
76-
onToggle: () => void;
77-
appliedOptions: PluginOptions | null;
74+
onToggle: (expanded: boolean) => void;
75+
formattedAppliedConfig: string;
7876
}): React.ReactElement {
7977
const store = useStore();
8078
const dispatchStore = useStoreDispatch();
@@ -122,13 +120,6 @@ function ExpandedEditor({
122120
});
123121
};
124122

125-
const formattedAppliedOptions = appliedOptions
126-
? prettyFormat(appliedOptions, {
127-
printFunctionName: false,
128-
printBasicPrototype: false,
129-
})
130-
: 'Invalid configs';
131-
132123
return (
133124
<ViewTransition
134125
update={{[CONFIG_PANEL_TRANSITION]: 'slide-in', default: 'none'}}>
@@ -158,7 +149,7 @@ function ExpandedEditor({
158149
Config Overrides
159150
</h2>
160151
</div>
161-
<div className="flex-1 rounded-lg overflow-hidden border border-gray-300">
152+
<div className="flex-1 border border-gray-300">
162153
<MonacoEditor
163154
path={'config.ts'}
164155
language={'typescript'}
@@ -167,16 +158,7 @@ function ExpandedEditor({
167158
onChange={handleChange}
168159
loading={''}
169160
className="monaco-editor-config"
170-
options={{
171-
...monacoOptions,
172-
lineNumbers: 'off',
173-
renderLineHighlight: 'none',
174-
overviewRulerBorder: false,
175-
overviewRulerLanes: 0,
176-
fontSize: 12,
177-
scrollBeyondLastLine: false,
178-
glyphMargin: false,
179-
}}
161+
options={monacoConfigOptions}
180162
/>
181163
</div>
182164
</div>
@@ -186,23 +168,16 @@ function ExpandedEditor({
186168
Applied Configs
187169
</h2>
188170
</div>
189-
<div className="flex-1 rounded-lg overflow-hidden border border-gray-300">
171+
<div className="flex-1 border border-gray-300">
190172
<MonacoEditor
191173
path={'applied-config.js'}
192174
language={'javascript'}
193-
value={formattedAppliedOptions}
175+
value={formattedAppliedConfig}
194176
loading={''}
195177
className="monaco-editor-applied-config"
196178
options={{
197-
...monacoOptions,
198-
lineNumbers: 'off',
199-
renderLineHighlight: 'none',
200-
overviewRulerBorder: false,
201-
overviewRulerLanes: 0,
202-
fontSize: 12,
203-
scrollBeyondLastLine: false,
179+
...monacoConfigOptions,
204180
readOnly: true,
205-
glyphMargin: false,
206181
}}
207182
/>
208183
</div>

0 commit comments

Comments
 (0)