Skip to content

Commit

Permalink
resize
Browse files Browse the repository at this point in the history
  • Loading branch information
jerronvwh committed Aug 2, 2017
1 parent 8bfe36a commit f510af7
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 11 deletions.
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@
"react-dom": "^15.5.4",
"react-redux": "^5.0.5",
"redux": "^3.6.0",
"webpack": "^2.6.1",
"webpack-dev-server": "^2.4.5"
},
"devDependencies": {
"css-loader": "^0.28.4",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^0.11.2",
"style-loader": "^0.18.2",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1",
"webpack": "^3.4.1"
}
}
33 changes: 31 additions & 2 deletions src/components/GoldenLayoutWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,33 @@ import {Provider} from 'react-redux';
import {IncrementButtonContainer} from './IncrementButton';
import {DecrementButtonContainer} from './DecrementButton';
import {TestComponentContainer} from './TestComponent';
import '../index.styl'

class GoldenLayoutWrapper extends React.Component {
constructor(props) {
super(props);
this.setNode = this.setNode.bind(this);
this.updateDimensions=this.updateDimensions.bind(this);
this.state = {
ht:500,
}
}
setNode(node) {
this.node = node;
}
updateDimensions() {
if (this.node && this.myLayout) {
this.setState({
ht: $(window).height() - this.node.getBoundingClientRect().top-5,
});

this.myLayout.updateSize();
}
}
componentWillUnmount() {
window.removeEventListener("resize", this.updateDimensions);
}

componentDidMount() {
// Build basic golden-layout config
const config = {
Expand Down Expand Up @@ -36,7 +61,7 @@ class GoldenLayoutWrapper extends React.Component {
return Wrapped;
};

var layout = new GoldenLayout(config, '#goldenLayout');
var layout = new GoldenLayout(config, this.node);
layout.registerComponent('IncrementButtonContainer',
wrapComponent(IncrementButtonContainer, this.context.store)
);
Expand All @@ -47,11 +72,15 @@ class GoldenLayoutWrapper extends React.Component {
wrapComponent(TestComponentContainer, this.context.store)
);
layout.init();

window.addEventListener("resize", this.updateDimensions);
this.myLayout=layout;
this.updateDimensions();
}

render() {
return (
<div id="goldenLayout"/>
<div ref={this.setNode} style={{height:this.state.ht+'px'}}/>
);
}
}
Expand Down
8 changes: 1 addition & 7 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@

<html>
<head>
<script type="text/javascript" src="https://golden-layout.com/files/latest/js/goldenlayout.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://golden-layout.com/files/latest/css/goldenlayout-base.css" />
<link type="text/css" rel="stylesheet" href="https://golden-layout.com/assets/css/goldenlayout-dark-theme.css" />

<title>React-Redux with GoldenLayout</title>
<style type="text/css">
.lm_root {height:300px;}
</style>

</head>
<body>
<div id="root"></div>
Expand Down
3 changes: 3 additions & 0 deletions src/index.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import '~golden-layout/src/css/goldenlayout-base.css'
@import '~golden-layout/src/css/goldenlayout-light-theme.css'

26 changes: 25 additions & 1 deletion webpack.config.babel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'path';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import webpack from 'webpack';
import ExtractTextPlugin from 'extract-text-webpack-plugin';

export default () => ({
entry: [
Expand Down Expand Up @@ -43,7 +44,30 @@ export default () => ({
]
}
}]
}]
},
{
test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
loader: 'file-loader?name=fonts/[name].[ext]'
},
{
test: /\.styl$/i,
exclude: /node_modules/,
use: ['style-loader','css-loader','stylus-loader']
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options : { autoprefixer: false, sourceMap: true, importLoaders: 1 }
},
'postcss-loader'
]
})
},
]
},
resolve: {
extensions: ['.js', '.jsx']
Expand Down

0 comments on commit f510af7

Please sign in to comment.