mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-20 01:02:48 +00:00
Print page can now load from local storage
This commit is contained in:
50
client/homebrew/pages/printPage/printPage.jsx
Normal file
50
client/homebrew/pages/printPage/printPage.jsx
Normal file
@@ -0,0 +1,50 @@
|
||||
const React = require('react');
|
||||
const _ = require('lodash');
|
||||
const cx = require('classnames');
|
||||
|
||||
//const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
|
||||
|
||||
var Markdown = require('naturalcrit/markdown.js');
|
||||
|
||||
const PrintPage = React.createClass({
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
query : {},
|
||||
brew : {
|
||||
text : '',
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return {
|
||||
brewText: this.props.brew.text
|
||||
};
|
||||
},
|
||||
|
||||
componentDidMount: function() {
|
||||
if(this.props.query.local){
|
||||
this.setState({ brewText : localStorage.getItem(this.props.query.local)});
|
||||
}
|
||||
|
||||
if(this.props.query.dialog) window.print();
|
||||
},
|
||||
|
||||
renderPages : function(){
|
||||
return _.map(this.state.brewText.split('\\page'), (page, index) => {
|
||||
return <div
|
||||
className='phb'
|
||||
id={`p${index + 1}`}
|
||||
dangerouslySetInnerHTML={{__html:Markdown.render(page)}}
|
||||
key={index} />;
|
||||
});
|
||||
},
|
||||
|
||||
render : function(){
|
||||
return <div>
|
||||
{this.renderPages()}
|
||||
</div>
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = PrintPage;
|
||||
3
client/homebrew/pages/printPage/printPage.less
Normal file
3
client/homebrew/pages/printPage/printPage.less
Normal file
@@ -0,0 +1,3 @@
|
||||
.printPage{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user