我正在嘗試使用反應材料設計創建響應式側欄,但無法找到實現它的方法。如何使用React的Material UI創建響應邊欄組件?
側邊欄打開時,頁面內容應該有響應,邊欄不應該疊加在頁面內容上。
它應該看起來像https://blackrockdigital.github.io/startbootstrap-simple-sidebar/。
到目前爲止的代碼是:
import React from 'react';
import Drawer from 'material-ui/Drawer';
import AppBar from 'material-ui/AppBar';
import RaisedButton from 'material-ui/RaisedButton';
import Layout from 'material-ui/RaisedButton';
export default class DrawerOpenRightExample extends React.Component {
constructor(props) {
super(props);
this.state = {open: false};
}
handleToggle(){
this.setState({open: !this.state.open});
}
render() {
return (
<div>
<container>
//will have a form here
<RaisedButton
label="Toggle Drawer"
onTouchTap={this.handleToggle.bind(this)}
/>
</container>
<Drawer width={400} openSecondary={true} open={this.state.open} >
<AppBar title="AppBar" />
</Drawer>
</div>
);
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>