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
66 lines (57 loc) · 1.6 KB
/
elements.js
File metadata and controls
66 lines (57 loc) · 1.6 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
import styled from 'styled-components';
export const RESIZER_WIDTH = 16;
export const KNOB_WIDTH = 4;
/**
* We leave a bit more room for the user to grab around the resize area, this defines
* how much room that actually is
*/
export const RESIZER_GRAB_EXTRA_WIDTH = 4;
export const Container = styled.div`
width: 100%;
height: 100%;
.Resizer {
/* 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);
background-color: ${props => props.theme.colors.separator.background};
width: ${RESIZER_WIDTH}px;
display: block;
height: 100%;
cursor: ew-resize;
z-index: 50;
}
.Resizer::after {
content: '';
display: flex;
background: ${props => props.theme.colors.separator.foreground};
border-radius: 50px;
position: absolute;
width: ${KNOB_WIDTH}px;
height: 41px;
top: calc(50% - 20px);
margin-left: ${Math.floor(RESIZER_WIDTH / 2 - KNOB_WIDTH / 2)}px;
opacity: 1;
}
.Resizer::before {
content: '';
position: absolute;
top: 0;
bottom: 0;
margin-left: -${RESIZER_GRAB_EXTRA_WIDTH}px;
width: ${RESIZER_WIDTH + RESIZER_GRAB_EXTRA_WIDTH * 2}px;
z-index: 50;
}
.Pane {
transition: ${props => (props.isDragging ? null : 'width 200ms ease')};
overflow: hidden;
}
`;
export const PaneContainer = styled.div`
display: flex;
flex-direction: column;
height: 100%;
`;