Skip to content

Commit d3483d7

Browse files
CompuIvessiddharthkpchristianalfoni
authored
Add/user invite (#3536)
* duplicate header * get all the pieces ther * move Actions into a file * delete dead code * move usermenu container styles to usermenu * make avatar wrap not take extra spac * align avatar with buttons * vertical align menubar * redesign menu + sandbox name * get the right logos top left * adjust alignment * remove debug line * fixed margin issues * overmind-graphql * UI * UI * fix * More UI * Add change link permissions * Add resubscribing * Fix type * Fix link update * Update CircleCI scripts * refactored to effect and cleaned up (#3537) * refactored to effect and cleaned up * clean and add disposeWhere * New changes * Set right connection places * Push * fix effects proxy * WIP * WIP * Polish * Update GraphQL typings * Typing changes * return promise on mutations * Fix ts issues * fix typing * Change prop order * Fixes * Deduplicate yarn.lock * Update cases * Update schema * Quickfix * use endpoint instead of url * fix weird event typing * Move collaborators queries to own folder * move collaborators to folder and add overmind package * try catch loading colalborators * Allow joining of a live session any time * Fix overlay examples * Fix replacing url * Add feature flag Co-authored-by: Siddharth Kshetrapal <[email protected]> Co-authored-by: Christian Alfoni <[email protected]>
1 parent face7ec commit d3483d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2563
-445
lines changed

.circleci/config.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,6 @@ workflows:
376376
- create-docker-image:
377377
requires:
378378
- build-prod
379-
- lint
380-
- typecheck
381-
# - test-integrations
382-
- test-jest
383379
- deploy-production-approval:
384380
type: approval
385381
filters:
@@ -390,6 +386,11 @@ workflows:
390386
requires:
391387
- deploy-production-approval
392388
- create-docker-image
389+
- build-prod
390+
- lint
391+
- typecheck
392+
# - test-integrations
393+
- test-jest
393394
filters:
394395
branches:
395396
only:

.graphqlconfig.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ projects:
55
endpoints:
66
prod: 'https://codesandbox.io/api/graphql'
77
staging: 'https://codesandbox.stream/api/graphql'
8-
dev: 'http://localhost:4000/api/graphql'
8+
dev: 'http://server:4000/api/graphql'

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,12 @@ Thanks goes to these wonderful people
256256

257257
<!-- markdownlint-enable -->
258258
<!-- prettier-ignore-end -->
259-
<!-- ALL-CONTRIBUTORS-LIST:END -->
260-
261259

260+
<!-- ALL-CONTRIBUTORS-LIST:END -->
262261

263262
## Thanks
264263

265264
<a href="https://www.chromaticqa.com/"><img src="https://cdn-images-1.medium.com/letterbox/147/36/50/50/1*oHHjTjInDOBxIuYHDY2gFA.png?source=logoAvatar-d7276495b101---37816ec27d7a" width="120"/></a>
266265

267-
Thanks to [Chromatic](https://www.chromaticqa.com/) for providing the visual testing platform that helps us catch unexpected changes.
266+
Thanks to [Chromatic](https://www.chromaticqa.com/) for providing the visual
267+
testing platform that helps us catch unexpected changes.

packages/app/package.json

+10-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"graphql:replace-schema": "sed -i '' 's/RootQueryType/RootQuery/g' ./src/app/graphql/schema.graphql && sed -i '' 's/RootMutationType/RootMutation/g' ./src/app/graphql/schema.graphql",
1616
"generate:graphql": "graphql get-schema -e prod --project app && yarn graphql:replace-schema && graphql-codegen --config ./scripts/codegen.js",
1717
"generate:graphql:staging": "graphql get-schema -e staging --project app && yarn graphql:replace-schema && graphql-codegen --config ./scripts/codegen.js --staging",
18+
"generate:graphql:dev": "graphql get-schema -e dev --project app && yarn graphql:replace-schema && graphql-codegen --config ./scripts/codegen.js --dev",
1819
"build:embed": "cross-env NODE_ENV=production webpack --config config/webpack.embed.js",
1920
"build:sandbox": "cross-env NODE_ENV=production SANDBOX_ONLY=true node scripts/build.js && yarn copy-assets",
2021
"build:sandpack-sandbox": "cross-env NODE_ENV=production SANDPACK=true SANDBOX_ONLY=true node scripts/build.js && cross-env SANDBOX_ONLY=true yarn copy-assets",
@@ -70,12 +71,13 @@
7071
]
7172
},
7273
"dependencies": {
74+
"@absinthe/socket": "^0.2.1",
7375
"@apollo/react-hooks": "^3.1.3",
7476
"@babel/plugin-transform-destructuring": "^7.5.0",
7577
"@babel/preset-env": "^7.5.5",
78+
"@codesandbox/components": "0.0.1",
7679
"@codesandbox/executors": "^0.1.0",
7780
"@codesandbox/template-icons": "^1.1.0",
78-
"@codesandbox/components": "0.0.1",
7981
"@emmetio/codemirror-plugin": "^0.3.5",
8082
"@sentry/webpack-plugin": "^1.8.0",
8183
"@styled-system/css": "^5.0.23",
@@ -115,16 +117,18 @@
115117
"date-fns-tz": "^1.0.7",
116118
"debug": "^2.6.8",
117119
"dot-object": "^1.9.0",
118-
"downshift": "^1.0.0-rc.14",
120+
"downshift": "^5.0.0",
119121
"eslint-plugin-react-hooks": "1.6.0",
120122
"eslint-plugin-vue": "^4.2.2",
121123
"estree-walker": "^1.0.1",
122124
"file-saver": "^1.3.3",
123125
"fontfaceobserver": "^2.0.13",
126+
"framer-motion": "^1.8.4",
124127
"fuse.js": "^3.2.1",
125128
"geniejs": "^0.5.1",
126129
"glamor": "^2.20.25",
127-
"graphql": "^14.5.8",
130+
"graphql": "^14.6.0",
131+
"graphql-subscriptions-client": "^0.12.0",
128132
"graphql-tag": "^2.10.1",
129133
"gsap": "^1.20.3",
130134
"gulp": "^3.9.1",
@@ -163,9 +167,10 @@
163167
"normalizr": "^3.2.3",
164168
"onigasm": "^2.2.1",
165169
"ot": "^0.0.15",
166-
"overmind": "^22.0.3",
170+
"overmind": "^23.0.0-1582285704974",
167171
"overmind-devtools": "^19.0.0",
168-
"overmind-react": "^23.0.3",
172+
"overmind-graphql": "^3.0.0-1582705151381",
173+
"overmind-react": "^24.0.0-1582285704974",
169174
"phoenix": "^1.4.11",
170175
"postcss": "^7.0.26",
171176
"postcss-selector-parser": "^2.2.3",

packages/app/scripts/codegen.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
const isStaging = process.argv.includes('--staging');
2+
const isDev = process.argv.includes('--dev');
23

3-
const URL = `https://codesandbox.${isStaging ? `stream` : `io`}/api/graphql`;
4+
const host = (() => {
5+
if (isDev) {
6+
return 'http://server:4000';
7+
}
8+
9+
if (isStaging) {
10+
return 'https://codesandbox.stream';
11+
}
12+
13+
return 'https://codesandbox.io';
14+
})();
15+
16+
const URL = `${host}/api/graphql`;
417

518
module.exports = {
619
schema: URL,
7-
documents: [`./src/**/*.gql`, `./src/**/queries.ts`, `./src/**/mutations.ts`],
20+
documents: [
21+
`./src/**/*.gql`,
22+
`./src/app/overmind/effects/gql/**/*.ts`,
23+
`./src/**/queries.ts`,
24+
`./src/**/mutations.ts`,
25+
],
826
overwrite: true,
927
hooks: {
1028
afterAllFileWrite: [`prettier --write`],

packages/app/src/app/components/Overlay/Overlay.tsx

+71-50
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import React, { useState, useEffect } from 'react';
2-
import { useTransition, animated, config } from 'react-spring';
1+
import React, { useState, useLayoutEffect } from 'react';
2+
import { motion } from 'framer-motion';
33
import track from '@codesandbox/common/lib/utils/analytics';
4-
import { Container } from './elements';
4+
import Portal from '@codesandbox/common/lib/components/Portal';
5+
import { Container, ContentContainer } from './elements';
56

67
interface IOverlayProps {
78
event: string;
@@ -11,8 +12,11 @@ interface IOverlayProps {
1112
children: (handleOpen: () => void) => React.ReactNode;
1213
content: React.ComponentType;
1314
noHeightAnimation?: boolean;
15+
width?: number;
1416
}
1517

18+
const POPOVER_WIDTH = 390;
19+
1620
const noop = () => undefined;
1721
export const Overlay: React.FC<IOverlayProps> = ({
1822
event,
@@ -22,33 +26,48 @@ export const Overlay: React.FC<IOverlayProps> = ({
2226
children,
2327
content: Content,
2428
noHeightAnimation = true,
29+
width = POPOVER_WIDTH,
2530
}) => {
2631
const [open, setOpen] = useState(isOpen === undefined ? false : isOpen);
2732
const isControlled = isOpen !== undefined;
2833
const openState = isControlled ? isOpen : open;
34+
const element = React.useRef<HTMLDivElement>();
35+
const bounds = React.useRef<{
36+
top: number;
37+
left: number;
38+
height: number;
39+
width: number;
40+
}>({
41+
top: 0,
42+
left: 0,
43+
width: 0,
44+
height: 0,
45+
});
2946

30-
useEffect(() => {
31-
const handleClick = (e: MouseEvent) => {
32-
if (!e.defaultPrevented && openState) {
33-
if (event) {
34-
track(`Closed ${event}`);
35-
}
36-
if (isControlled) {
37-
if (onClose) {
38-
onClose();
39-
}
40-
} else {
41-
setOpen(false);
42-
}
43-
}
47+
useLayoutEffect(() => {
48+
const posData = element.current.getBoundingClientRect();
49+
bounds.current = {
50+
top: posData.top,
51+
left: posData.left,
52+
width: posData.width,
53+
height: posData.height,
4454
};
55+
}, []);
4556

46-
document.addEventListener('mousedown', handleClick);
47-
48-
return () => {
49-
document.removeEventListener('mousedown', handleClick);
50-
};
51-
}, [isOpen, onClose, event, openState, isControlled]);
57+
const handleClick = () => {
58+
if (openState) {
59+
if (event) {
60+
track(`Closed ${event}`);
61+
}
62+
if (isControlled) {
63+
if (onClose) {
64+
onClose();
65+
}
66+
} else {
67+
setOpen(false);
68+
}
69+
}
70+
};
5271

5372
const handleOpen = () => {
5473
if (event) {
@@ -63,35 +82,37 @@ export const Overlay: React.FC<IOverlayProps> = ({
6382
}
6483
};
6584

66-
const transitions = useTransition(openState, null, {
67-
config: config.default,
68-
from: {
69-
...(noHeightAnimation ? {} : { height: 0 }),
70-
opacity: 0.6,
71-
position: 'absolute',
72-
top: 'calc(100% + 1rem)',
73-
right: 0,
74-
zIndex: 10,
75-
overflow: 'hidden',
76-
boxShadow: '0 3px 3px rgba(0, 0, 0, 0.3)',
77-
},
78-
enter: { ...(noHeightAnimation ? {} : { height: 'auto' }), opacity: 1 },
79-
leave: { ...(noHeightAnimation ? {} : { height: 0 }), opacity: 0 },
80-
});
81-
8285
return (
83-
<Container onMouseDown={e => e.preventDefault()}>
86+
<Container onMouseDown={e => e.stopPropagation()} ref={element}>
8487
{children(handleOpen)}
85-
{transitions.map(({ item, props }, i) =>
86-
item ? (
87-
// eslint-disable-next-line
88-
<animated.div key={i} style={props}>
89-
<Content />
90-
</animated.div>
91-
) : (
92-
// eslint-disable-next-line
93-
<animated.span key={i} style={props} />
94-
)
88+
89+
{openState && (
90+
<Portal>
91+
<ContentContainer onClick={handleClick}>
92+
<motion.div
93+
onClick={e => e.stopPropagation()}
94+
style={{
95+
opacity: 0.6,
96+
position: 'absolute',
97+
zIndex: 10,
98+
overflow: 'hidden',
99+
boxShadow: '0 3px 3px rgba(0, 0, 0, 0.3)',
100+
height: 'auto',
101+
borderRadius: 4,
102+
top: bounds.current.top + bounds.current.height + 8,
103+
left: bounds.current.left + bounds.current.width - width * 0.75,
104+
width,
105+
}}
106+
transition={{
107+
duration: 0.2,
108+
}}
109+
initial={{ y: -5 }}
110+
animate={{ opacity: 1, y: 0 }}
111+
>
112+
<Content />
113+
</motion.div>
114+
</ContentContainer>
115+
</Portal>
95116
)}
96117
</Container>
97118
);
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import styled from 'styled-components';
22

33
export const Container = styled.div`
4+
display: inherit;
45
position: relative;
56
`;
7+
8+
export const ContentContainer = styled.div`
9+
position: fixed;
10+
left: 0;
11+
right: 0;
12+
bottom: 0;
13+
top: 0;
14+
z-index: 10;
15+
`;

0 commit comments

Comments
 (0)