-
Notifications
You must be signed in to change notification settings - Fork 6
/
sidepane.js
56 lines (47 loc) · 1.25 KB
/
sidepane.js
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
/**
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md.
*/
/* global window */
import React, { Component } from 'react';
import { Rnd } from 'react-rnd';
import { connect } from 'react-redux';
import {
setSidePaneWidth
} from '../data/actions';
import './sidepane.css';
const SIDE_PANE_MIN_WIDTH = 200;
const SIDE_PANE_STYLES = {
position: 'relative'
};
class SidePane extends Component {
get maxSidePaneWidth() {
return Math.min( window.innerWidth - 400, window.innerWidth * .8 );
}
render() {
return <div className="ck-inspector-side-pane">
<Rnd
enableResizing={{ left: true }}
disableDragging={true}
minWidth={SIDE_PANE_MIN_WIDTH}
maxWidth={this.maxSidePaneWidth}
style={SIDE_PANE_STYLES}
position={{ x: '100%', y: '100%' }}
size={{
width: this.props.sidePaneWidth,
height: '100%'
}}
onResizeStop={( evt, direction, ref ) => this.props.setSidePaneWidth( ref.style.width )}
>
{this.props.children}
</Rnd>
</div>;
}
}
const mapStateToProps = ( { ui: { sidePaneWidth } } ) => {
return { sidePaneWidth };
};
const mapDispatchToProps = {
setSidePaneWidth
};
export default connect( mapStateToProps, mapDispatchToProps )( SidePane );