0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-10 15:42:39 +00:00

renamed render warnings and now built into the brewrenderer

This commit is contained in:
Scott Tolksdorf
2017-01-14 14:20:42 -08:00
parent 6e86d9c123
commit 5fe7c7a6d8
5 changed files with 36 additions and 27 deletions

View File

@@ -0,0 +1,58 @@
const React = require('react');
const _ = require('lodash');
const cx = require('classnames');
const RenderWarnings = React.createClass({
getInitialState: function() {
return {
warnings: {}
};
},
componentDidMount: function() {
this.checkWarnings();
//TODO: Setup event for window zoom
},
warnings : {
chrome : function(){
const isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
if(!isChrome){
return <li key='chrome'>
<em>Built for Chrome </em> <br />
Other browsers do not support key features this site uses.
</li>;
}
},
zoom : function(){
if(window.devicePixelRatio !== 1){
return <li key='zoom'>
<em>Your browser is zoomed. </em> <br />
This can cause content to jump columns.
</li>;
}
}
},
checkWarnings : function(){
this.setState({
warnings : _.reduce(this.warnings, (r, fn, type) => {
const element = fn();
if(element) r[type] = element;
return r;
}, {})
})
},
render: function(){
if(_.isEmpty(this.state.warnings)) return null;
return <div className='renderWarnings'>
<i className='fa fa-exclamation-triangle' />
<h3>Render Warnings</h3>
<small>If this homebrew is rendering badly if might be because of the following:</small>
<ul>{_.values(this.state.warnings)}</ul>
</div>
}
});
module.exports = RenderWarnings;

View File

@@ -0,0 +1,42 @@
.warnings{
position : fixed;
display : inline-block;
top : @navbarHeight;
right : 15px;
z-index : 10001;
width : 350px;
padding : 20px;
padding-bottom : 10px;
padding-left : 85px;
background-color : @yellow;
color : white;
i{
position: absolute;
left: 24px;
opacity: 0.8;
font-size: 2.5em;
top: 24px;
}
small{
opacity : 0.7;
font-size : 0.6em;
}
h3{
font-size : 1.1em;
font-weight : 800;
}
ul{
margin-top : 15px;
font-size : 0.8em;
list-style-position : outside;
list-style-type : disc;
li{
line-height : 1.6em;
font-size: 0.8em;
em{
font-weight: 800;
}
}
}
}