[chore] added prettier
This commit is contained in:
@@ -8,10 +8,7 @@ import { actionColor } from 'styles/constants.scss';
|
||||
* Binary toggle switch component
|
||||
*/
|
||||
|
||||
const Switch = observer(({
|
||||
checked,
|
||||
...props
|
||||
}) => {
|
||||
const Switch = observer(({ checked, ...props }) => {
|
||||
const scale = '18';
|
||||
const colors = {
|
||||
success: actionColor,
|
||||
@@ -19,9 +16,8 @@ const Switch = observer(({
|
||||
};
|
||||
const borderColor = actionColor;
|
||||
|
||||
|
||||
const color = checked ? colors.success : borderColor
|
||||
const transform = checked ? `translateX(${scale * 0.5}px)` : 'translateX(0)'
|
||||
const color = checked ? colors.success : borderColor;
|
||||
const transform = checked ? `translateX(${scale * 0.5}px)` : 'translateX(0)';
|
||||
|
||||
const sx = {
|
||||
root: {
|
||||
@@ -32,7 +28,7 @@ const Switch = observer(({
|
||||
backgroundColor: checked ? 'currentcolor' : null,
|
||||
borderRadius: 99999,
|
||||
boxShadow: 'inset 0 0 0 2px',
|
||||
cursor: 'pointer'
|
||||
cursor: 'pointer',
|
||||
},
|
||||
dot: {
|
||||
width: scale,
|
||||
@@ -44,29 +40,30 @@ const Switch = observer(({
|
||||
boxShadow: 'inset 0 0 0 2px',
|
||||
borderRadius: 99999,
|
||||
color,
|
||||
backgroundColor: colors.white
|
||||
}
|
||||
}
|
||||
backgroundColor: colors.white,
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
<Base
|
||||
{...props}
|
||||
className='Switch'
|
||||
role='checkbox'
|
||||
className="Switch"
|
||||
role="checkbox"
|
||||
aria-checked={checked}
|
||||
baseStyle={sx.root}>
|
||||
baseStyle={sx.root}
|
||||
>
|
||||
<div style={sx.dot} />
|
||||
</Base>
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
Switch.propTypes = {
|
||||
/** Sets the Switch to an active style */
|
||||
checked: React.PropTypes.bool
|
||||
}
|
||||
checked: React.PropTypes.bool,
|
||||
};
|
||||
|
||||
Switch.contextTypes = {
|
||||
rebass: React.PropTypes.object
|
||||
}
|
||||
rebass: React.PropTypes.object,
|
||||
};
|
||||
|
||||
export default Switch;
|
||||
|
||||
@@ -2,15 +2,14 @@ import React from 'react';
|
||||
import { observer } from 'mobx-react';
|
||||
import Helmet from 'react-helmet';
|
||||
|
||||
@observer
|
||||
class Application extends React.Component {
|
||||
@observer class Application extends React.Component {
|
||||
static childContextTypes = {
|
||||
rebass: React.PropTypes.object,
|
||||
}
|
||||
};
|
||||
|
||||
static propTypes = {
|
||||
children: React.PropTypes.node.isRequired,
|
||||
}
|
||||
};
|
||||
|
||||
getChildContext() {
|
||||
return {
|
||||
@@ -25,13 +24,7 @@ class Application extends React.Component {
|
||||
|
||||
// fontSizes: [64, 48, 28, 20, 18, 16, 14],
|
||||
bold: 500,
|
||||
scale: [
|
||||
0,
|
||||
8,
|
||||
18,
|
||||
36,
|
||||
72,
|
||||
],
|
||||
scale: [0, 8, 18, 36, 72],
|
||||
Input: {
|
||||
// borderBottom: '1px solid #eee',
|
||||
},
|
||||
@@ -43,9 +36,7 @@ class Application extends React.Component {
|
||||
ButtonOutline: {
|
||||
color: '#000',
|
||||
},
|
||||
InlineForm: {
|
||||
|
||||
},
|
||||
InlineForm: {},
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -55,14 +46,14 @@ class Application extends React.Component {
|
||||
<div style={{ width: '100%', height: '100%', display: 'flex', flex: 1 }}>
|
||||
<Helmet
|
||||
title="Atlas"
|
||||
meta={ [
|
||||
meta={[
|
||||
{
|
||||
name: 'viewport',
|
||||
content: 'width=device-width, initial-scale=1.0',
|
||||
},
|
||||
] }
|
||||
]}
|
||||
/>
|
||||
{ this.props.children }
|
||||
{this.props.children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ class CacheStore {
|
||||
_.defer(() => localStorage.setItem(CACHE_STORE, this.asJson));
|
||||
};
|
||||
|
||||
@action cacheList = (data) => {
|
||||
data.forEach((item) => this.cacheWithId(item.id, item));
|
||||
@action cacheList = data => {
|
||||
data.forEach(item => this.cacheWithId(item.id, item));
|
||||
};
|
||||
|
||||
@action fetchFromCache = (id) => {
|
||||
@action fetchFromCache = id => {
|
||||
return this.cache[id];
|
||||
}
|
||||
};
|
||||
|
||||
constructor() {
|
||||
// Rehydrate
|
||||
@@ -37,6 +37,4 @@ class CacheStore {
|
||||
}
|
||||
|
||||
export default CacheStore;
|
||||
export {
|
||||
CACHE_STORE,
|
||||
};
|
||||
export { CACHE_STORE };
|
||||
|
||||
@@ -27,6 +27,4 @@ class UiStore {
|
||||
}
|
||||
|
||||
export default UiStore;
|
||||
export {
|
||||
UI_STORE,
|
||||
};
|
||||
export { UI_STORE };
|
||||
|
||||
@@ -40,7 +40,7 @@ class UserStore {
|
||||
const state = Math.random().toString(36).substring(7);
|
||||
this.oauthState = state;
|
||||
return this.oauthState;
|
||||
}
|
||||
};
|
||||
|
||||
@action authWithSlack = async (code, state, redirectTo) => {
|
||||
if (state !== this.oauthState) {
|
||||
@@ -60,7 +60,7 @@ class UserStore {
|
||||
this.team = res.data.team;
|
||||
this.token = res.data.accessToken;
|
||||
browserHistory.replace(redirectTo || '/');
|
||||
}
|
||||
};
|
||||
|
||||
constructor() {
|
||||
// Rehydrate
|
||||
@@ -73,6 +73,4 @@ class UserStore {
|
||||
}
|
||||
|
||||
export default UserStore;
|
||||
export {
|
||||
USER_STORE,
|
||||
};
|
||||
export { USER_STORE };
|
||||
|
||||
@@ -7,7 +7,7 @@ import constants from '../constants';
|
||||
const isIterable = object =>
|
||||
object != null && typeof object[Symbol.iterator] === 'function';
|
||||
|
||||
const cacheResponse = (data) => {
|
||||
const cacheResponse = data => {
|
||||
if (isIterable(data)) {
|
||||
stores.cache.cacheList(data);
|
||||
} else {
|
||||
@@ -51,59 +51,58 @@ class ApiClient {
|
||||
// Handle request promises and return a new promise
|
||||
return new Promise((resolve, reject) => {
|
||||
request
|
||||
.then((response) => {
|
||||
// Handle successful responses
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return response;
|
||||
}
|
||||
.then(response => {
|
||||
// Handle successful responses
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return response;
|
||||
}
|
||||
|
||||
// Handle 404
|
||||
if (response.status === 404) {
|
||||
return browserHistory.push('/404');
|
||||
}
|
||||
// Handle 404
|
||||
if (response.status === 404) {
|
||||
return browserHistory.push('/404');
|
||||
}
|
||||
|
||||
// Handle 401, log out user
|
||||
if (response.status === 401) {
|
||||
return stores.user.logout();
|
||||
}
|
||||
// Handle 401, log out user
|
||||
if (response.status === 401) {
|
||||
return stores.user.logout();
|
||||
}
|
||||
|
||||
// Handle failed responses
|
||||
const error = {};
|
||||
error.statusCode = response.status;
|
||||
error.response = response;
|
||||
throw error;
|
||||
})
|
||||
.then((response) => {
|
||||
return response.json();
|
||||
})
|
||||
.then((json) => {
|
||||
// Cache responses
|
||||
if (options.cache) {
|
||||
cacheResponse(json.data);
|
||||
}
|
||||
resolve(json);
|
||||
})
|
||||
.catch(error => {
|
||||
error.response.json()
|
||||
// Handle failed responses
|
||||
const error = {};
|
||||
error.statusCode = response.status;
|
||||
error.response = response;
|
||||
throw error;
|
||||
})
|
||||
.then(response => {
|
||||
return response.json();
|
||||
})
|
||||
.then(json => {
|
||||
error.data = json;
|
||||
reject(error);
|
||||
// Cache responses
|
||||
if (options.cache) {
|
||||
cacheResponse(json.data);
|
||||
}
|
||||
resolve(json);
|
||||
})
|
||||
.catch(error => {
|
||||
error.response.json().then(json => {
|
||||
error.data = json;
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
get = (path, data, options) => {
|
||||
return this.fetch(path, 'GET', data, options);
|
||||
}
|
||||
};
|
||||
|
||||
post = (path, data, options) => {
|
||||
return this.fetch(path, 'POST', data, options);
|
||||
}
|
||||
};
|
||||
|
||||
// Helpers
|
||||
|
||||
constructQueryString = (data) => {
|
||||
constructQueryString = data => {
|
||||
return _.map(data, (v, k) => {
|
||||
return `${encodeURIComponent(k)}=${encodeURIComponent(v)}`;
|
||||
}).join('&');
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
export default (type, ...argNames) => {
|
||||
return function(...args) {
|
||||
let action = { type }
|
||||
let action = { type };
|
||||
argNames.forEach((arg, index) => {
|
||||
action[argNames[index]] = args[index]
|
||||
})
|
||||
return action
|
||||
}
|
||||
}
|
||||
action[argNames[index]] = args[index];
|
||||
});
|
||||
return action;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import emojiMapping from './emoji-mapping.json';
|
||||
|
||||
const EMOJI_REGEX = /:([A-Za-z0-9_\-\+]+?):/gm;
|
||||
|
||||
const emojify = (text='') => {
|
||||
const emojify = (text = '') => {
|
||||
const emojis = text.match(EMOJI_REGEX) || [];
|
||||
let emojifiedText = text;
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@ const Renderer = sanitizedRenderer(marked.Renderer);
|
||||
const renderer = new Renderer();
|
||||
renderer.code = (code, language) => {
|
||||
const validLang = !!(language && highlight.getLanguage(language));
|
||||
const highlighted = validLang ? highlight.highlight(language, code).value : _.escape(code);
|
||||
const highlighted = validLang
|
||||
? highlight.highlight(language, code).value
|
||||
: _.escape(code);
|
||||
return `<pre><code class="hljs ${_.escape(language)}">${highlighted}</code></pre>`;
|
||||
};
|
||||
renderer.heading = (text, level) => {
|
||||
@@ -25,10 +27,10 @@ renderer.heading = (text, level) => {
|
||||
`;
|
||||
};
|
||||
|
||||
const convertToMarkdown = (text) => {
|
||||
const convertToMarkdown = text => {
|
||||
// Add TOC
|
||||
text = toc.insert(text || '', {
|
||||
slugify: (heading) => {
|
||||
slugify: heading => {
|
||||
// FIXME: E.g. `&` gets messed up
|
||||
const headingSlug = _.escape(slug(heading));
|
||||
return headingSlug;
|
||||
@@ -46,6 +48,4 @@ const convertToMarkdown = (text) => {
|
||||
});
|
||||
};
|
||||
|
||||
export {
|
||||
convertToMarkdown,
|
||||
};
|
||||
export { convertToMarkdown };
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
const randomInteger = (min, max) => {
|
||||
return Math.floor(Math.random()*(max-min+1)+min);
|
||||
}
|
||||
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||
};
|
||||
|
||||
export {
|
||||
randomInteger
|
||||
};
|
||||
export { randomInteger };
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
const snap = (children) => {
|
||||
const snap = children => {
|
||||
const component = renderer.create(children);
|
||||
expect(component).toMatchSnapshot();
|
||||
};
|
||||
|
||||
export {
|
||||
snap,
|
||||
};
|
||||
export { snap };
|
||||
|
||||
Reference in New Issue
Block a user