0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-31 21:42:44 +00:00
Files
homebrewery/client/homebrew/pages/printPage/printPage.jsx
Trevor Buckner 22a9799674 Update vitreum (#946)
- Updates Vitreum to v6.0.1 + some custom fixes.
  - Stylesheets must be imported with `require('./sheet.less');` but can also can now share stylesheets between jsx components.
  - Should eliminate a lot of security concerns with older nested dependencies.
  - Changed a lot of files to make this work
- Also removes dependency on PicoRouter in favor of React-Router
2020-05-19 01:36:31 -04:00

54 lines
1.1 KiB
JavaScript

require('./printPage.less');
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const { Meta } = require('vitreum/headtags');
const Markdown = require('naturalcrit/markdown.js');
const PrintPage = createClass({
getDefaultProps : function() {
return {
query : {},
brew : {
text : '',
}
};
},
getInitialState : function() {
return {
brewText : this.props.brew.text
};
},
componentDidMount : function() {
if(this.props.query.local){
this.setState((prevState, prevProps)=>({
brewText : localStorage.getItem(prevProps.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>
<Meta name='robots' content='noindex, nofollow' />
{this.renderPages()}
</div>;
}
});
module.exports = PrintPage;