forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelements.js
More file actions
141 lines (127 loc) · 2.85 KB
/
elements.js
File metadata and controls
141 lines (127 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import styled, { css, keyframes } from 'styled-components';
const introduction = {
slideFromLeft: keyframes(css`
0% {
margin-left: -12px;
background: #fff;
opacity: 1;
}
50% {
margin-left: 12px;
background: #fff;
opacity: 1;
}
100% {
margin-left: 4px;
background: #fff;
opacity: 1;
}
`),
slideFromRight: keyframes(css`
0% {
margin-left: 4px;
background: #fff;
opacity: 1;
}
50% {
margin-left: -20px;
background: #fff;
opacity: 1;
}
100% {
margin-left: -12px;
background: #fff;
opacity: 1;
}
`),
fade: keyframes(css`
0% {
opacity: 1;
background: #fff;
}
100% {
opacity: 0.6;
background: #242424;
}
`),
};
const notIntroducedYetStyles = css`
margin-left: ${props => (props.fullSize ? 4 : -12)}px;
background: #fff;
opacity: 1;
`;
const introductionAnimation = css`
animation: ${props =>
props.fullSize
? introduction.slideFromRight
: introduction.slideFromLeft}
1s,
${introduction.fade} 1s 1s;
animation-fill-mode: forwards, forwards;
`;
export const Container = styled.div`
width: 100%;
height: 100%;
.Resizer {
z-index: 99;
/* Safari, sigh.
Quote: We recently encountered this and discovered that promoting the
affected element to a composite layer with translateZ in CSS fixed
the issue without needing extra JavaScript.
— https://stackoverflow.com/a/21947628/1501871
*/
transform: translateZ(0);
}
.Resizer::after {
content: '';
background: #242424;
border-radius: 50px;
border: 1px solid #fff;
transition: margin 500ms, height 150ms, top 150ms ease;
position: absolute;
width: 5px;
height: ${props => (props.isDragging ? 32 : 40)}px;
top: ${props =>
props.isDragging ? `calc(50% - 16px)` : `calc(50% - 20px)`};
margin-left: ${props => (props.fullSize ? -12 : 4)}px;
opacity: ${props => (props.isDragging ? 0.6 : 0.4)};
/* intro animations */
${props => {
if (props.hasBeenIntroduced) return null;
if (props.hasAttention) return introductionAnimation;
return notIntroducedYetStyles;
}}
}
.Resizer:hover::after {
opacity: 0.6;
}
/* Big tap area - 48*2 by 48*/
.Resizer::before {
content: '';
position: absolute;
width: calc(48px * 2);
height: 64px;
top: calc(50% - 32px);
left: -48px;
}
.Resizer {
cursor: ew-resize;
}
.Pane {
transition: ${props => (props.isDragging ? null : 'width 200ms ease')};
overflow: hidden;
}
`;
export const PaneContainer = styled.div`
display: flex;
flex-direction: column;
height: 100%;
`;
export const PointerOverlay = styled.div`
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 99;
`;