0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-01 10:52:46 +00:00

Added a quick build task and created the warnings component

This commit is contained in:
Scott Tolksdorf
2017-01-14 13:53:09 -08:00
parent 306e4f024c
commit 6e86d9c123
8 changed files with 121 additions and 12 deletions

View File

@@ -0,0 +1,56 @@
const React = require('react');
const _ = require('lodash');
const cx = require('classnames');
const Warnings = 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 'OPtimized for Chrome';
}
},
zoom : function(){
if(window.devicePixelRatio !== 1){
return 'You are zoomed';
}
}
},
checkWarnings : function(){
this.setState({
warnings : _.reduce(this.warnings, (r, fn, type) => {
const text = fn();
if(text) r[type] = text;
return r;
}, {})
})
},
render: function(){
if(_.isEmpty(this.state.warnings)) return null;
const errors = _.map(this.state.warnings, (text, idx) => {
return <li key={idx}>{text}</li>
});
return <div className='warnings'>
<i className='fa fa-exclamation-triangle' />
<h3>Rendering Warnings</h3>
<small>If this homebrew is rendering badly if might be because of the following:</small>
<ul>{errors}</ul>
</div>
}
});
module.exports = Warnings;

View File

@@ -0,0 +1,36 @@
.warnings{
position : fixed;
display : inline-block;
z-index : 10001;
padding : 20px;
padding-bottom : 10px;
padding-left : 100px;
right : 0px;
top : @navbarHeight;
background-color : @orange;
color : white;
i{
position : absolute;
left : 30px;
opacity : 0.8;
font-size : 3em;
}
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 : inside;
list-style-type : disc;
li{
line-height : 1.6em;
}
}
}