This commit is contained in:
dzannotti 2015-08-07 17:55:59 +01:00
parent 244b897a2e
commit 46e71e7bb3
7 changed files with 62 additions and 59 deletions

View File

@ -1,7 +1,7 @@
import React, { PropTypes, findDOMNode } from 'react';
import LogMonitorEntry from './LogMonitorEntry';
import LogMonitorButton from './LogMonitorButton';
import * as themes from "./themes";
import * as themes from './themes';
const styles = {
container: {
@ -17,7 +17,7 @@ const styles = {
buttonBar: {
paddingLeft: 2
}
}
};
export default class LogMonitor {
constructor() {
@ -116,10 +116,10 @@ export default class LogMonitor {
let theme;
if (typeof this.props.theme === 'string') {
if (typeof themes[this.props.theme] !== 'undefined') {
theme = themes[this.props.theme]
theme = themes[this.props.theme];
} else {
console.warn('DevTools theme ' + this.props.theme + ' not found, defaulting to ocean');
theme = themes.ocean
theme = themes.ocean;
}
} else {
theme = this.props.theme;

View File

@ -8,9 +8,9 @@ const styles = {
paddingRight: 6,
marginTop: 2,
display: 'inline-block',
fontSize: "0.8em"
fontSize: '0.8em'
}
}
};
export default class LogMonitorButton extends React.Component {
constructor(props) {
@ -18,7 +18,7 @@ export default class LogMonitorButton extends React.Component {
this.state = {
hovered: false,
active: false
}
};
}
handleMouseEnter() {
@ -39,7 +39,7 @@ export default class LogMonitorButton extends React.Component {
render() {
let style = {
...styles.base,
...styles.base
};
if (this.state.hovered) {
style = {

View File

@ -1,11 +1,11 @@
import React, { PropTypes } from 'react';
import JSONTree from './JSONTree';
import LogMonitorEntryAction from "./LogMonitorEntryAction";
import LogMonitorEntryAction from './LogMonitorEntryAction';
function colorFromString(theme, token) {
const splitToken = token.split('');
const finalToken = splitToken.concat(splitToken.reverse());
const number = (parseInt(finalToken, 36) + finalToken.length) % 8;
const number = (parseInt(finalToken, 36) + finalToken.length) % 8;
const themeNumber = 'base0' + (number + 8).toString(16).toUpperCase();
return theme[themeNumber];
}
@ -32,7 +32,7 @@ export default class LogMonitorEntry {
let errorText = error;
if (!errorText) {
try {
return <JSONTree theme={this.props.theme} keyName={'state'} data={this.props.select(state)} />
return <JSONTree theme={this.props.theme} keyName={'state'} data={this.props.select(state)} />;
} catch (err) {
errorText = 'Error selecting state.';
}
@ -55,28 +55,28 @@ export default class LogMonitorEntry {
}
render() {
const { index, error, action, state, collapsed } = this.props;
const styleEntry = {
opacity: collapsed ? 0.5 : 1,
color: colorFromString(this.props.theme, action.type),
cursor: (index > 0) ? 'pointer' : 'default'
};
return (
<div style={{textDecoration: collapsed ? 'line-through' : 'none'}}>
<LogMonitorEntryAction
theme={this.props.theme}
collapsed={collapsed}
action={action}
onClick={::this.handleActionClick}
style={{...styles.entry, ...styleEntry}}/>
{!collapsed &&
<div style={{
borderBottom: '1px solid #20262c',
paddingLeft: 15
}}>
{this.printState(state, error)}
</div>
}
const { index, error, action, state, collapsed } = this.props;
const styleEntry = {
opacity: collapsed ? 0.5 : 1,
color: colorFromString(this.props.theme, action.type),
cursor: (index > 0) ? 'pointer' : 'default'
};
return (
<div style={{textDecoration: collapsed ? 'line-through' : 'none'}}>
<LogMonitorEntryAction
theme={this.props.theme}
collapsed={collapsed}
action={action}
onClick={::this.handleActionClick}
style={{...styles.entry, ...styleEntry}}/>
{!collapsed &&
<div style={{
borderBottom: '1px solid #20262c',
paddingLeft: 15
}}>
{this.printState(state, error)}
</div>
}
</div>
);
}

View File

@ -1,4 +1,4 @@
import React from "react";
import React from 'react';
import JSONTree from './JSONTree';
const styles = {
@ -6,7 +6,7 @@ const styles = {
borderTopWidth: 1,
borderBottomWidth: 1,
borderTopStyle: 'solid',
borderBottomStyle: 'solid',
borderBottomStyle: 'solid'
},
actionBar: {
paddingTop: 4,
@ -18,15 +18,18 @@ const styles = {
backgroundColor: '#252c33',
paddingLeft: 15
}
}
};
export default class LogMonitorAction extends React.Component {
renderPayload(payload) {
return (
<div style={styles.payload}>
{ Object.keys(payload).length > 0 ? <JSONTree theme={this.props.theme} keyName={'payload'} data={payload}/> : "" }
{ Object.keys(payload).length > 0 ? <JSONTree theme={this.props.theme} keyName={'payload'} data={payload}/> : '' }
</div>
);
}
render() {
const { type, ...payload } = this.props.action;
return (
@ -42,4 +45,4 @@ export default class LogMonitorAction extends React.Component {
</div>
);
}
}
}

View File

@ -1,2 +1,2 @@
export { default as ocean } from "./ocean";
export { default as monokai } from "./monokai";
export { default as ocean } from './ocean';
export { default as monokai } from './monokai';

View File

@ -1,20 +1,20 @@
export default {
scheme: "Monokai",
author: "Wimer Hazenberg (http://www.monokai.nl)",
base00: "#272822",
base01: "#383830",
base02: "#49483e",
base03: "#75715e",
base04: "#a59f85",
base05: "#f8f8f2",
base06: "#f5f4f1",
base07: "#f9f8f5",
base08: "#f92672",
base09: "#fd971f",
base0A: "#f4bf75",
base0B: "#a6e22e",
base0C: "#a1efe4",
base0D: "#66d9ef",
base0E: "#ae81ff",
base0F: "#cc6633"
scheme: 'Monokai',
author: 'Wimer Hazenberg (http://www.monokai.nl)',
base00: '#272822',
base01: '#383830',
base02: '#49483e',
base03: '#75715e',
base04: '#a59f85',
base05: '#f8f8f2',
base06: '#f5f4f1',
base07: '#f9f8f5',
base08: '#f92672',
base09: '#fd971f',
base0A: '#f4bf75',
base0B: '#a6e22e',
base0C: '#a1efe4',
base0D: '#66d9ef',
base0E: '#ae81ff',
base0F: '#cc6633'
};

View File

@ -17,4 +17,4 @@ export default {
base0D: '#8fa1b3',
base0E: '#b48ead',
base0F: '#ab7967'
}
};