Skip to content

Commit 981ca44

Browse files
committed
feat: ✨ display project in iframe if it has url
1 parent 0189683 commit 981ca44

File tree

4 files changed

+171
-85
lines changed

4 files changed

+171
-85
lines changed

package-lock.json

Lines changed: 46 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"react": "^16.7.0-alpha.2",
2929
"react-dom": "^16.7.0-alpha.2",
3030
"react-helmet": "^5.2.0",
31+
"react-spring": "^7.2.1",
3132
"react-typography": "^0.16.18",
3233
"styled-components": "^4.1.3",
3334
"typography": "^0.16.18",

src/components/drawer.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React from 'react'
2+
import styled from 'styled-components/macro'
3+
import { Transition } from 'react-spring'
4+
5+
let Container = styled.div`
6+
position: fixed;
7+
top: 0;
8+
right: 0;
9+
height: 100%;
10+
width: 60%;
11+
background: #fff;
12+
13+
will-change: transform;
14+
`
15+
16+
let Overlay = styled(Container)`
17+
width: 100%;
18+
background: #141a28a8;
19+
`
20+
21+
let Drawer = ({ open, children, onOuterClick }) => (
22+
<Transition
23+
items={open}
24+
from={{ transform: 'translateX(100%)', opacity: 0 }}
25+
enter={{ transform: 'translateX(0)', opacity: 1 }}
26+
leave={{ transform: 'translateX(100%)', opacity: 0 }}
27+
>
28+
{animatedOpen =>
29+
animatedOpen &&
30+
(({ transform, opacity }) => (
31+
<Overlay style={{ opacity }} onClick={onOuterClick}>
32+
<Container style={{ transform }} onClick={e => e.stopPropagation()}>
33+
{children}
34+
</Container>
35+
</Overlay>
36+
))
37+
}
38+
</Transition>
39+
)
40+
41+
export { Drawer }
42+
export default Drawer

0 commit comments

Comments
 (0)