0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-10 20:03:03 +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

@@ -11,6 +11,7 @@
- Fixed realtime renderer not functioning if loaded with malformed html on load (thanks u/RattiganIV re:247) - Fixed realtime renderer not functioning if loaded with malformed html on load (thanks u/RattiganIV re:247)
- Removed a lot of unused files in shared - Removed a lot of unused files in shared
- vitreum v4 now lets me use codemirror as a pure node dependacy - vitreum v4 now lets me use codemirror as a pure node dependacy
- Added a new Render Warning overlay. It detects situations where the brew may not be rendering correctly (wrong browser, browser is zoomed in...) and let's the user know
### Saturday, 03/12/2016 - v2.6.0 ### Saturday, 03/12/2016 - v2.6.0

View File

@@ -5,6 +5,9 @@ const cx = require('classnames');
const Markdown = require('naturalcrit/markdown.js'); const Markdown = require('naturalcrit/markdown.js');
const ErrorBar = require('./errorBar/errorBar.jsx'); const ErrorBar = require('./errorBar/errorBar.jsx');
//TODO: move to the brew renderer
const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx')
const PAGE_HEIGHT = 1056; const PAGE_HEIGHT = 1056;
const PPR_THRESHOLD = 50; const PPR_THRESHOLD = 50;
@@ -132,6 +135,7 @@ const BrewRenderer = React.createClass({
style={{height : this.state.height}}> style={{height : this.state.height}}>
<ErrorBar errors={this.props.errors} /> <ErrorBar errors={this.props.errors} />
<RenderWarnings />
<div className='pages' ref='pages'> <div className='pages' ref='pages'>
{this.renderPages()} {this.renderPages()}

View File

@@ -17,8 +17,6 @@ const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
const Markdown = require('naturalcrit/markdown.js'); const Markdown = require('naturalcrit/markdown.js');
const Warnings = require('homebrewery/warnings/warnings.jsx')
const SAVE_TIMEOUT = 3000; const SAVE_TIMEOUT = 3000;
@@ -213,8 +211,6 @@ const EditPage = React.createClass({
return <div className='editPage page'> return <div className='editPage page'>
{this.renderNavbar()} {this.renderNavbar()}
<Warnings />
<div className='content'> <div className='content'>
<SplitPane onDragFinish={this.handleSplitMove} ref='pane'> <SplitPane onDragFinish={this.handleSplitMove} ref='pane'>
<Editor <Editor

View File

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

View File

@@ -2,19 +2,21 @@
.warnings{ .warnings{
position : fixed; position : fixed;
display : inline-block; display : inline-block;
top : @navbarHeight;
right : 15px;
z-index : 10001; z-index : 10001;
width : 350px;
padding : 20px; padding : 20px;
padding-bottom : 10px; padding-bottom : 10px;
padding-left : 100px; padding-left : 85px;
right : 0px; background-color : @yellow;
top : @navbarHeight;
background-color : @orange;
color : white; color : white;
i{ i{
position : absolute; position: absolute;
left : 30px; left: 24px;
opacity : 0.8; opacity: 0.8;
font-size : 3em; font-size: 2.5em;
top: 24px;
} }
small{ small{
opacity : 0.7; opacity : 0.7;
@@ -27,10 +29,14 @@
ul{ ul{
margin-top : 15px; margin-top : 15px;
font-size : 0.8em; font-size : 0.8em;
list-style-position : inside; list-style-position : outside;
list-style-type : disc; list-style-type : disc;
li{ li{
line-height : 1.6em; line-height : 1.6em;
font-size: 0.8em;
em{
font-weight: 800;
}
} }
} }
} }