Skip to content

secondaryInitialSize componentDidUpdate #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/javascripts/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function constructLinks() {
<li><NavLink to="/sidebar">Sidebar</NavLink></li>
<li><NavLink to="/events">Events</NavLink></li>
<li><NavLink to="/iframe">iframe</NavLink></li>
<li><NavLink to="/secondaryDefaultSizeChange">Default Size Change</NavLink></li>
</ul>
);
}
Expand Down
48 changes: 48 additions & 0 deletions example/javascripts/components/SecondaryDefaultSizeChange.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from "react";
import SplitterLayout from "../../../index";
import Lorem from "./Lorem";

export default class TogglableSidebarLayout extends React.Component {
constructor(props) {
super(props);
this.toggleSidebar = this.toggleSidebar.bind(this);
this.state = {
activeIndex: 0,
sidebarVisible: true,
};
}

toggleSidebar() {
this.setState((state) => ({ sidebarVisible: !state.sidebarVisible }));
}

handleSidebarItemClick(newVal) {
this.setState((state) => ({ activeIndex: newVal }));
}

render() {
return (
<div style={{display: "flex",height: "100%",width: "100%",justifyContent: "space-between"}}>
<div className="my-sidebar" style={{ flex: 1, height: "100%" }}>
<ul>
{['First View', 'Second View'].map(((li, idx) => (
<li><a onClick={this.handleSidebarItemClick.bind(this, idx)}>{li}</a></li>
)))}
</ul>
</div>
<div style={{ flex: 4, height: "100%" }}>
<SplitterLayout percentage secondaryInitialSize={this.state.activeIndex === 0 ? 25 : 75} vertical={true}>
<div>
<h2>1st Pane</h2>
<Lorem title="1st Pane" />
</div>
<div>
<h2>2nd Pane</h2>
<Lorem title="2nd Pane" />
</div>
</SplitterLayout>
</div>
</div>
);
}
}
2 changes: 2 additions & 0 deletions example/javascripts/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import NestedLayout from './components/NestedLayout';
import TogglableSidebarLayout from './components/TogglableSidebarLayout';
import HorizontalLayoutWithEvents from './components/HorizontalLayoutWithEvents';
import HorizontalLayoutWithIFrame from './components/HorizontalLayoutWithIFrame';
import SecondaryDefaultSizeChange from './components/SecondaryDefaultSizeChange';
import '../../lib/index.css';
import '../stylesheets/index.css';

Expand All @@ -36,6 +37,7 @@ render(
<Route path="/sidebar" component={TogglableSidebarLayout} />
<Route path="/events" component={HorizontalLayoutWithEvents} />
<Route path="/iframe" component={HorizontalLayoutWithIFrame} />
<Route path="/secondaryDefaultSizeChange" component={SecondaryDefaultSizeChange} />
<Route path="*" component={NoMatch} />
</Switch>
</App>
Expand Down
Loading