Skip to content

Commit 215b949

Browse files
author
Ives van Hoorne
committed
Fix Embed size problems and dependencies
1 parent 87d66fb commit 215b949

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

packages/app/src/embed/components/App/elements.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import styled from 'styled-components';
44
export const Container = styled.div`
55
display: flex;
66
flex-direction: column;
7-
height: 100%;
8-
width: 100%;
7+
height: 100vh;
8+
width: 100vw;
99
color: white;
1010
`;
1111

1212
export const Fullscreen = styled.div`
13-
width: 100%;
14-
height: 100%;
13+
width: 100vw;
14+
height: 100vh;
1515
overflow: hidden;
1616
`;
1717

packages/app/src/embed/components/Sidebar/index.js

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
33

44
import type { Sandbox } from 'common/types';
55

@@ -40,6 +40,20 @@ type Props = {
4040
};
4141

4242
function Sidebar({ sandbox, setCurrentModule, currentModule }: Props) {
43+
const packageJSON = sandbox.modules.find(
44+
m => m.title === 'package.json' && m.directoryShortid == null
45+
);
46+
47+
let npmDependencies = sandbox.npmDependencies;
48+
49+
if (packageJSON) {
50+
try {
51+
npmDependencies = JSON.parse(packageJSON.code).dependencies;
52+
} catch (e) {
53+
console.error(e);
54+
}
55+
}
56+
4357
return (
4458
<Container>
4559
<Item>
@@ -70,22 +84,30 @@ function Sidebar({ sandbox, setCurrentModule, currentModule }: Props) {
7084
<Item>
7185
<Title>Dependencies</Title>
7286

73-
<Subtitle>NPM Dependencies</Subtitle>
74-
{Object.keys(sandbox.npmDependencies).map(dep => (
87+
<Subtitle>npm Dependencies</Subtitle>
88+
{Object.keys(npmDependencies).map(dep => (
7589
<EntryContainer key={dep}>
7690
{dep}
77-
<Version>{sandbox.npmDependencies[dep]}</Version>
91+
<Version>{npmDependencies[dep]}</Version>
7892
</EntryContainer>
7993
))}
8094

81-
<Subtitle>External Resources</Subtitle>
82-
{sandbox.externalResources.map(dep => (
83-
<EntryContainer key={dep}>
84-
<a href={dep} rel="nofollow noopener noreferrer" target="_blank">
85-
{getName(dep)}
86-
</a>
87-
</EntryContainer>
88-
))}
95+
{sandbox.externalResources.length > 0 && (
96+
<React.Fragment>
97+
<Subtitle>External Resources</Subtitle>
98+
{sandbox.externalResources.map(dep => (
99+
<EntryContainer key={dep}>
100+
<a
101+
href={dep}
102+
rel="nofollow noopener noreferrer"
103+
target="_blank"
104+
>
105+
{getName(dep)}
106+
</a>
107+
</EntryContainer>
108+
))}
109+
</React.Fragment>
110+
)}
89111
</Item>
90112

91113
<Item hover>

0 commit comments

Comments
 (0)