Skip to content

Commit 588437e

Browse files
committed
fix: Bring embed panes in line with the embed in the GUI
1 parent 1e4993f commit 588437e

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

Diff for: src/components/Embed.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import CopyButton from './CopyButton';
44
import Embedded from './Embedded';
55
import { SyncIcon, XIcon } from '@primer/octicons-react';
66

7+
import { defaultPanes } from '../constants';
8+
79
function TabButton({ children, active, onClick, disabled }) {
810
return (
911
<button
@@ -40,7 +42,7 @@ function Embed({ dispatch, dirty, gistId, gistVersion }) {
4042
dispatch({ type: 'SAVE' });
4143
}, [dirty, gistId, dispatch]);
4244

43-
const [panes, setPanes] = useState(['preview', 'result']);
45+
const [panes, setPanes] = useState(defaultPanes);
4446

4547
const embedUrl =
4648
[location.origin, 'embed', gistId, gistVersion].filter(Boolean).join('/') +

Diff for: src/components/Embedded.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import useParentMessaging from '../hooks/useParentMessaging';
99
import usePlayground from '../hooks/usePlayground';
1010
import Loader from './Loader';
1111

12+
import { defaultPanes } from '../constants';
13+
1214
const SUPPORTED_PANES = {
1315
markup: true,
1416
preview: true,
@@ -46,7 +48,7 @@ function Embedded(props) {
4648
.split(',')
4749
.map((x) => x.trim())
4850
.filter((x) => SUPPORTED_PANES[x])
49-
: ['query', 'preview'];
51+
: defaultPanes;
5052

5153
// TODO: we should add tabs to handle > 2 panes
5254
const areaCount = panes.length;

Diff for: src/constants.js

+2
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,5 @@ export const links = {
113113
url: 'https://testing-library.com/docs/guide-which-query',
114114
},
115115
};
116+
117+
export const defaultPanes = ['preview', 'result'];

Diff for: src/lambda/oembed/oembed.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function handler(event, context, callback) {
5454

5555
// map /gist urls to /embed
5656
const url = pathname.startsWith('/gist/')
57-
? params.url.replace('/gist/', '/embed/')
57+
? `${params.url.replace('/gist/', '/embed/')}?panes=preview,result`
5858
: params.url;
5959

6060
callback(null, {

0 commit comments

Comments
 (0)