Skip to content

Commit 2af4b74

Browse files
authored
Merge branch 'develop' into orphaned-assets
2 parents cfb0f20 + a310820 commit 2af4b74

5 files changed

Lines changed: 47 additions & 8 deletions

File tree

client/jest.setup.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ import 'regenerator-runtime/runtime';
55
// See: https://github.com/testing-library/jest-dom
66
// eslint-disable-next-line import/no-extraneous-dependencies
77
import '@testing-library/jest-dom';
8+
9+
global.ResizeObserver = class {
10+
observe() {}
11+
12+
unobserve() {}
13+
14+
disconnect() {}
15+
};

client/modules/IDE/components/PreviewFrame.jsx

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import React, { useRef, useEffect } from 'react';
1+
import React, { useRef, useEffect, useState } from 'react';
22
import PropTypes from 'prop-types';
33
import styled from 'styled-components';
44
import { getConfig } from '../../../utils/getConfig';
55
import { registerFrame } from '../../../utils/dispatcher';
66

77
const Frame = styled.iframe`
8-
min-height: 100%;
9-
min-width: 100%;
8+
display: block;
109
position: ${(props) => (props.fullView ? 'relative' : 'absolute')};
1110
border-width: 0;
1211
`;
1312

1413
function PreviewFrame({ fullView, isOverlayVisible }) {
1514
const iframe = useRef();
15+
const [frameSize, setFrameSize] = useState(null);
1616
const previewUrl = getConfig('PREVIEW_URL');
1717
useEffect(() => {
1818
const unsubscribe = registerFrame(iframe.current.contentWindow, previewUrl);
@@ -21,6 +21,26 @@ function PreviewFrame({ fullView, isOverlayVisible }) {
2121
};
2222
});
2323

24+
useEffect(() => {
25+
const parent = iframe.current?.parentElement;
26+
if (!parent) {
27+
return () => {};
28+
}
29+
const updateSize = () => {
30+
const { width, height } = parent.getBoundingClientRect();
31+
setFrameSize({
32+
width: Math.floor(width),
33+
height: Math.floor(height)
34+
});
35+
};
36+
updateSize();
37+
const observer = new ResizeObserver(updateSize);
38+
observer.observe(parent);
39+
return () => {
40+
observer.disconnect();
41+
};
42+
}, []);
43+
2444
const frameUrl = previewUrl;
2545
const sandboxAttributes = `allow-forms allow-modals allow-pointer-lock allow-popups
2646
allow-same-origin allow-scripts allow-top-navigation-by-user-activation allow-downloads`;
@@ -45,6 +65,11 @@ function PreviewFrame({ fullView, isOverlayVisible }) {
4565
frameBorder="0"
4666
ref={iframe}
4767
fullView={fullView}
68+
style={
69+
frameSize
70+
? { width: frameSize.width, height: frameSize.height }
71+
: undefined
72+
}
4873
/>
4974
</>
5075
);

client/styles/abstracts/_variables.scss

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ $themes: (
108108
preferences-warning-color: $p5js-pink,
109109
primary-text-color: $dark,
110110
progress-bar-active-color: $p5js-active-pink,
111-
progress-bar-background-color: $middle-gray,
111+
progress-bar-background-color: $light,
112+
progress-bar-border-color: $middle-gray,
112113
search-background-color: $lightest,
113114
search-clear-background-color: $light,
114115
search-hover-background-color: $medium-dark,
@@ -205,7 +206,8 @@ $themes: (
205206
preferences-warning-color: $yellow,
206207
primary-text-color: $lightest,
207208
progress-bar-active-color: $p5js-active-pink,
208-
progress-bar-background-color: $middle-gray,
209+
progress-bar-background-color: $darker,
210+
progress-bar-border-color: $middle-gray,
209211
search-background-color: $darker,
210212
search-clear-background-color: $medium-dark,
211213
search-hover-background-color: $p5js-pink,
@@ -300,8 +302,9 @@ $themes: (
300302
preferences-button-background-color: $medium-light,
301303
preferences-warning-color: $yellow,
302304
primary-text-color: $lightest,
303-
progress-bar-active-color: $p5js-active-pink,
304-
progress-bar-background-color: $middle-gray,
305+
progress-bar-active-color: $yellow,
306+
progress-bar-background-color: $darker,
307+
progress-bar-border-color: $middle-light,
305308
search-background-color: $darker,
306309
search-clear-background-color: $medium-dark,
307310
search-hover-background-color: $yellow,

client/styles/components/_asset-size.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
@include themify() {
2222
background-color: getThemifyVariable('progress-bar-background-color');
23+
border-color: getThemifyVariable('progress-bar-border-color');
2324
}
2425
}
2526

server/server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ mongoose.connect(mongoConnectionString, {
8383
socketTimeoutMS: 45000 // 45 seconds timeout
8484
});
8585

86+
const isProduction = process.env.NODE_ENV === 'production';
87+
8688
app.use(
8789
session({
8890
resave: true,
@@ -92,7 +94,7 @@ app.use(
9294
name: 'sessionId',
9395
cookie: {
9496
httpOnly: true,
95-
secure: false,
97+
secure: isProduction,
9698
maxAge: 1000 * 60 * 60 * 24 * 28 // 4 weeks in milliseconds
9799
},
98100
store: MongoStore.create({

0 commit comments

Comments
 (0)