mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-04 10:22:38 +00:00
With the style panel we added a `page` css class alongside the `phb` and `phb3` classes so users can write CSS that targets all pages no matter the base CSS loaded. This wasn't applied to the print page. Funnily enough, the rest of the site uses `.page` just to display the website, and I didn't realize there was a conflict until now because otherwise, the brew is usually hidden in an iFrame.
83 lines
2.2 KiB
JavaScript
83 lines
2.2 KiB
JavaScript
require('./sharePage.less');
|
|
const React = require('react');
|
|
const createClass = require('create-react-class');
|
|
const { Meta } = require('vitreum/headtags');
|
|
|
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
|
const Navbar = require('../../navbar/navbar.jsx');
|
|
const PrintLink = require('../../navbar/print.navitem.jsx');
|
|
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
|
const Account = require('../../navbar/account.navitem.jsx');
|
|
|
|
|
|
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
|
|
|
|
|
|
const SharePage = createClass({
|
|
getDefaultProps : function() {
|
|
return {
|
|
brew : {
|
|
title : '',
|
|
text : '',
|
|
style : '',
|
|
shareId : null,
|
|
createdAt : null,
|
|
updatedAt : null,
|
|
views : 0,
|
|
renderer : ''
|
|
}
|
|
};
|
|
},
|
|
|
|
componentDidMount : function() {
|
|
document.addEventListener('keydown', this.handleControlKeys);
|
|
},
|
|
componentWillUnmount : function() {
|
|
document.removeEventListener('keydown', this.handleControlKeys);
|
|
},
|
|
handleControlKeys : function(e){
|
|
if(!(e.ctrlKey || e.metaKey)) return;
|
|
const P_KEY = 80;
|
|
if(e.keyCode == P_KEY){
|
|
window.open(`/print/${this.props.brew.shareId}?dialog=true`, '_blank').focus();
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
}
|
|
},
|
|
|
|
processShareId : function() {
|
|
return this.props.brew.googleId ?
|
|
this.props.brew.googleId + this.props.brew.shareId :
|
|
this.props.brew.shareId;
|
|
},
|
|
|
|
render : function(){
|
|
return <div className='sharePage sitePage'>
|
|
<Meta name='robots' content='noindex, nofollow' />
|
|
<Navbar>
|
|
<Nav.section>
|
|
<Nav.item className='brewTitle'>{this.props.brew.title}</Nav.item>
|
|
</Nav.section>
|
|
|
|
<Nav.section>
|
|
<PrintLink shareId={this.processShareId()} />
|
|
<Nav.item href={`/source/${this.processShareId()}`} color='teal' icon='fas fa-code'>
|
|
source
|
|
</Nav.item>
|
|
<Nav.item href={`/download/${this.processShareId()}`} color='red' icon='fas fa-download'>
|
|
download
|
|
</Nav.item>
|
|
<RecentNavItem brew={this.props.brew} storageKey='view' />
|
|
<Account />
|
|
</Nav.section>
|
|
</Navbar>
|
|
|
|
<div className='content'>
|
|
<BrewRenderer text={this.props.brew.text} style={this.props.brew.style} renderer={this.props.brew.renderer} />
|
|
</div>
|
|
</div>;
|
|
}
|
|
});
|
|
|
|
module.exports = SharePage;
|