Skip to content

Commit

Permalink
better resizing with react-resizable
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmorris committed Feb 25, 2017
1 parent 5c712e0 commit e5bad75
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 33 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"gh-pages": "^0.12.0",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-resizable": "^1.6.0",
"react-router": "^3.0.2"
},
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions src/About.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
background-color: white;
padding: 10px;
border-radius: 10px;
border-style: solid;
background-color: rgb(252, 253, 255);
border-color: rgb(220, 240, 255);
}
34 changes: 4 additions & 30 deletions src/Songsim.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,12 @@
margin: 10px;
}

.matrixPane {
overflow: auto;
resize: both;
.react-resizable-handle {
bottom: -20px !important;
right: -20px !important;
background-size: 10px !important;
}

.lyricsPane {
}

.matrixPane {
/*
border-style: solid;
*/
width: 300px;
}

/* TODO: Gonna probably need a solution outside of vanilla CSS. The resize
* property doesn't allow resizing to a smaller value than the initial width.
*/
@media (max-width: 800px) {
.matrixPane {
border-color: red;
}
}

@media (max-width: 1100px) {
.matrixPane {
border-color: green;
}
}

@media (min-width: 1100px) {
.matrixPane {
border-color: aqua;
}
}
10 changes: 7 additions & 3 deletions src/Songsim.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component } from 'react';
import {Link} from 'react-router';
import { ResizableBox } from 'react-resizable';

import './Songsim.css';

Expand Down Expand Up @@ -211,7 +212,7 @@ class Songsim extends Component {
// TODO: this method is getting pretty huge
var rowcols = this.focal_rowcols;
var rows = rowcols[0], cols = rowcols[1];
var radios = Object.keys(MODE).map(this.renderRadio)
var radios = Object.keys(MODE).map(this.renderRadio);
var matrix;
if (!this.state.verse) {
matrix = <DummyMatrix />;
Expand Down Expand Up @@ -241,13 +242,16 @@ class Songsim extends Component {
<p>Custom: {JSON.stringify(this.state.verse.isCustom())}</p>
</div>);
}
var defaultMatrixSize = 400; // TODO: have this flow from above (and calculate from screen.height or something)
return (
<div>

<div className="mainContainer">
<div className="matrixPane">
<ResizableBox width={defaultMatrixSize} height={defaultMatrixSize}
lockAspectRatio={true}
>
{matrix}
</div>
</ResizableBox>

<div className="lyricsPane">
<LyricsPane verse={this.state.verse || CustomVerse.BlankVerse()}
Expand Down
2 changes: 2 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ body {
margin: 0;
padding: 0;
font-family: sans-serif;
/*
background-color: rgb(240, 240, 240) !important;
*/
}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import About from './About.js';
import {Router, Route, hashHistory} from 'react-router';
import './index.css';

import 'react-resizable/css/styles.css';
import 'bootstrap/dist/css/bootstrap.css';
//import 'bootstrap/dist/css/bootstrap-theme.css';

Expand Down

0 comments on commit e5bad75

Please sign in to comment.