Skip to content

Commit 8f16c8c

Browse files
committed
fix: Bring embed panes in line with the embed in the GUI
1 parent 0dd614c commit 8f16c8c

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

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('/') +

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;

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'];

src/lambda/oembed/oembed.js

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

5353
// map /gist urls to /embed
5454
const url = pathname.startsWith('/gist/')
55-
? params.url.replace('/gist/', '/embed/')
55+
? `${params.url.replace('/gist/', '/embed/')}?panes=preview,result`
5656
: params.url;
5757

5858
callback(null, {

0 commit comments

Comments
 (0)