Created
January 31, 2017 16:31
-
-
Save Hardtack/a1544e48bb77a821904da245adac5082 to your computer and use it in GitHub Desktop.
Alert on click elements in drawer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": [ | |
"es2015", | |
"stage-0", | |
"react" | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Demo</title> | |
<style type="text/css"> | |
/* Ensure layout covers the entire screen. */ | |
html, body { | |
height: 100%; | |
} | |
body { | |
margin: 0; | |
} | |
/* Place drawer and content side by side. */ | |
#root { | |
display: flex; | |
flex-direction: row; | |
padding: 0; | |
margin: 0; | |
box-sizing: border-box; | |
height: 100%; | |
width: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="root"> | |
</div> | |
<script type="text/javascript" src="build/bundle.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Demo", | |
"dependencies": { | |
"react": "^15.0.0", | |
"react-dom": "^15.4.2", | |
"react-mdcw": "git://github.com/Hardtack/react-mdcw.git#fc4d87e696430bf2445dbc5a94031b86c3d0d784" | |
}, | |
"devDependencies": { | |
"babel": "^6.5.2", | |
"babel-core": "^6.22.1", | |
"babel-eslint": "^7.1.1", | |
"babel-loader": "^6.2.10", | |
"babel-preset-es2015": "^6.18.0", | |
"babel-preset-react": "^6.16.0", | |
"babel-preset-stage-0": "^6.22.0", | |
"css-loader": "^0.26.1", | |
"file-loader": "^0.10.0", | |
"style-loader": "^0.13.1", | |
"url-loader": "^0.5.7", | |
"webpack": "^1.14.0", | |
"webpack-dev-server": "^1.16.2" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable */ | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { | |
TemporaryDrawer, | |
Drawer, | |
Content | |
} from 'react-mdcw/lib/drawer/temporary'; | |
import {Button} from 'react-mdcw/lib/button'; | |
import {List, group, item} from 'react-mdcw/lib/list'; | |
import 'material-components-web/dist/material-components-web.css'; | |
class App extends React.Component { | |
state = { | |
drawerOpen: false | |
} | |
handleCloseDrawer = () => { | |
this.setState({ | |
drawerOpen: false | |
}); | |
} | |
handleOpenDrawer = () => { | |
this.setState({ | |
drawerOpen: true | |
}); | |
} | |
handleClickListItem = () => { | |
alert('Clicked!'); | |
} | |
handleClickMenuButton = () => { | |
this.setState({ | |
drawerOpen: true | |
}); | |
} | |
render () { | |
let {drawerOpen} = this.state; | |
return ( | |
<div> | |
<TemporaryDrawer | |
style={{ | |
zIndex: 1 | |
}} | |
open={drawerOpen} | |
onOpenDrawer={this.handleOpenDrawer} | |
onCloseDrawer={this.handleCloseDrawer}> | |
<Drawer> | |
<Content wrap={<group.ListGroup wrap={<div />} />}> | |
<List wrap={<div />}> | |
<item.ListItem | |
wrap={<div />} | |
onClick={this.handleClickListItem}> | |
Foo | |
</item.ListItem> | |
<item.ListItem | |
wrap={<div />} | |
onClick={this.handleClickListItem}> | |
Bar | |
</item.ListItem> | |
<item.ListItem | |
wrap={<div />} | |
onClick={this.handleClickListItem}> | |
Baz | |
</item.ListItem> | |
</List> | |
</Content> | |
</Drawer> | |
</TemporaryDrawer> | |
<div> | |
<Button raised onClick={this.handleClickMenuButton}> | |
Open Menu | |
</Button> | |
</div> | |
</div> | |
); | |
} | |
} | |
ReactDOM.render(<App />, document.getElementById('root')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable */ | |
var path = require('path'); | |
var webpack = require('webpack'); | |
module.exports = { | |
entry: { | |
app: ['./test.js'] | |
}, | |
output: { | |
path: path.resolve(__dirname, 'build'), | |
publicPath: '/build/', | |
filename: 'bundle.js' | |
}, | |
module: { | |
loaders: [ | |
{ | |
exclude: [ | |
/\.html$/, | |
/\.(js|jsx)$/, | |
/\.css$/ | |
], | |
loader: 'url-loader', | |
query: { | |
limit: 10000, | |
name: 'static/media/[name].[hash:8].[ext]' | |
} | |
}, | |
{ | |
test: /\.js$/, | |
exclude: /(node_modules|bower_components)/, | |
loader: 'babel-loader' | |
}, | |
{ | |
test: /\.css$/, | |
loader: 'style-loader!css?importLoaders=1' | |
} | |
] | |
}, | |
devtool: 'source-map' | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment