Skip to content

Commit

Permalink
Prettify everything
Browse files Browse the repository at this point in the history
  • Loading branch information
Pegase745 committed Mar 30, 2018
1 parent f08f674 commit ce24363
Show file tree
Hide file tree
Showing 27 changed files with 452 additions and 325 deletions.
6 changes: 6 additions & 0 deletions .prettierignore
@@ -0,0 +1,6 @@
build/
dist/
node_modules/
static/

src/**/jscodeshift/**/*
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -3,6 +3,7 @@
</p>

[![Build Status](https://travis-ci.org/eveningkid/reacto.svg?branch=master)](https://travis-ci.org/eveningkid/reacto)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

👋 **Interact with your code:** use bricks to play with *props*, *imports* or quickly change a component type.<br />
⚡️ **Package Manager out of the box:** add, upgrade, delete and search dependencies in a flash.<br />
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -24,6 +24,7 @@
"watch:css": "npm run build:css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive",
"test": "node scripts/test.js --env=jsdom",
"lint": "eslint .",
"prettier": "prettier --write '{,!(node_modules)/}**/*.{js,jsx}'",
"electron": "electron .",
"electron:dev": "concurrently \"yarn start\" \"wait-on http://localhost:3000 && yarn run electron\"",
"pack": "yarn build && electron-builder --dir",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Brick/Brick.jsx
Expand Up @@ -14,7 +14,7 @@ class Brick extends React.Component {

handleRemove = () => {
this.props.removeBrick(this.props.brick.id);
}
};

render() {
const { brick } = this.props;
Expand All @@ -30,7 +30,7 @@ class Brick extends React.Component {

<div className="ui">
<Renderer
ref={(element) => this.brickRenderer = element}
ref={element => (this.brickRenderer = element)}
parent={brick}
state={rendererProps}
/>
Expand Down
14 changes: 7 additions & 7 deletions src/components/BrickSelector/BrickSelector.jsx
@@ -1,7 +1,7 @@
import React from 'react';
import { connect } from 'react-redux';
import { connect } from 'react-redux';
import { InputSearch } from '../_ui';
import { EventsManager } from '../../editor/managers';
import { EventsManager } from '../../editor/managers';
import availableBricks from '../../bricks';
import './BrickSelector.css';

Expand All @@ -19,18 +19,18 @@ class BrickSelector extends React.Component {
this.setState({ forceAutoFocus: false });
}, 500);
});
}
};

onAddBrick = (brickName) => {
onAddBrick = brickName => {
if (this.moduleSuggestions.includes(brickName)) {
this.props.addBrick(brickName);
this.setState({ search: '' });
}
}
};

onChange = (search) => {
onChange = search => {
this.setState({ search });
}
};

render() {
return (
Expand Down
10 changes: 3 additions & 7 deletions src/components/Compiler/Compiler.jsx
Expand Up @@ -22,15 +22,11 @@ class Compiler extends React.Component {

return (
<Radio.Group
onChange={(event) => this.props.updateCompiler(event.target.value)}
onChange={event => this.props.updateCompiler(event.target.value)}
value={this.props.compiler}
>
{options.map((option, i) => (
<Radio
key={i}
style={radioStyle}
value={option.value}
>
<Radio key={i} style={radioStyle} value={option.value}>
{option.label}
</Radio>
))}
Expand All @@ -45,7 +41,7 @@ class Compiler extends React.Component {
placement="bottom"
content={this.renderPopover()}
trigger="click"
onVisibleChange={(isOpened) => this.setState({ isOpened })}
onVisibleChange={isOpened => this.setState({ isOpened })}
>
Compiler
</Popover>
Expand Down
Expand Up @@ -51,21 +51,21 @@ class ComponentPreviewRenderer extends React.Component {
this.closeWatcher();
}

watchFor = (props) => {
watchFor = props => {
this.buildPreview(props);
this.closeWatcher();
this.watcher = watch(props.filePath);
this.watcher.on('change', () => this.buildPreview(props));
}
};

closeWatcher = () => {
if (this.watcher) {
this.watcher.close();
this.componentPreview.stop();
}
}
};

buildPreview = async (props) => {
buildPreview = async props => {
this.componentPreview = new ComponentPreview(this.props);

this.setState({ hasCompiled: false }, async () => {
Expand All @@ -79,33 +79,35 @@ class ComponentPreviewRenderer extends React.Component {
this.nonSuccessfulBuild(error);
}
});
}
};

successfulBuild = () => this.setState({ hasError: false, hasCompiled: true });
nonSuccessfulBuild = (error) => this.setState({ hasError: true, error, hasCompiled: true });
nonSuccessfulBuild = error =>
this.setState({ hasError: true, error, hasCompiled: true });

initCompilation = (props) => {
initCompilation = props => {
this.setState({ isOpened: true });

if (this.canCompile()) {
this.watchFor(props);
} else {
this.installCompilerDependencies(props);
}
}
};

canCompile = () => {
return modulesToInstall
.map(moduleName => this.props.packageManager.isInstalled(moduleName))
.filter(isInstalled => isInstalled)
.length === modulesToInstall.length;
}
return (
modulesToInstall
.map(moduleName => this.props.packageManager.isInstalled(moduleName))
.filter(isInstalled => isInstalled).length === modulesToInstall.length
);
};

installCompilerDependencies = async (props) => {
installCompilerDependencies = async props => {
const packageManager = this.props.packageManager;
const options = { isDev: true };

const missingModulesToInstall = modulesToInstall.filter((moduleName) =>{
const missingModulesToInstall = modulesToInstall.filter(moduleName => {
return !packageManager.isInstalled(moduleName);
});

Expand All @@ -115,13 +117,13 @@ class ComponentPreviewRenderer extends React.Component {
}

this.initCompilation(props);
}
};

closePreview = () => {
this.closeWatcher();
this.setState({ isOpened: false });
this.props.updateComponentPreviewFilePath(null);
}
};

render() {
let isReady = false;
Expand All @@ -137,14 +139,13 @@ class ComponentPreviewRenderer extends React.Component {

return (
<div className={classes}>
{this.state.hasCompiled ?
{this.state.hasCompiled ? (
<div className="status" onClick={this.closePreview}>
Close Preview
</div> :
<div className="status">
~ Compiling
</div>
}
) : (
<div className="status">~ Compiling</div>
)}

{this.state.hasError && (
<div className="error">
Expand All @@ -167,7 +168,10 @@ const mapStateToProps = state => ({
});

const mapDispatchToProps = dispatch => ({
updateComponentPreviewFilePath: filePath => dispatch.project.updateComponentPreviewFilePath({ filePath }),
updateComponentPreviewFilePath: filePath =>
dispatch.project.updateComponentPreviewFilePath({ filePath }),
});

export default connect(mapStateToProps, mapDispatchToProps)(ComponentPreviewRenderer);
export default connect(mapStateToProps, mapDispatchToProps)(
ComponentPreviewRenderer
);
12 changes: 6 additions & 6 deletions src/components/Components/Components.jsx
@@ -1,7 +1,6 @@
import React from 'react';
import key from 'uniqid';
import { connect } from 'react-redux';
import { Layout } from 'antd';
import { Brick, BrickSelector } from '..';
import * as utils from '../../utils';
import './Components.css';
Expand All @@ -23,19 +22,20 @@ class Components extends React.Component {
default:
return false;
}
}
};

render() {
const shouldDisplayComponents = this.shouldDisplayComponents();

return (
<div className="Components" style={{ opacity: shouldDisplayComponents ? 1 : 0.5 }}>
<div
className="Components"
style={{ opacity: shouldDisplayComponents ? 1 : 0.5 }}
>
<BrickSelector />

<div className="bricks">
{this.props.bricks.map((brick) =>
<Brick key={key()} brick={brick} />
)}
{this.props.bricks.map(brick => <Brick key={key()} brick={brick} />)}
</div>
</div>
);
Expand Down
24 changes: 16 additions & 8 deletions src/components/Configurator/Configurator.jsx
Expand Up @@ -16,9 +16,9 @@ class Configurator extends React.Component {
}
config()._set(key, value);
this.forceUpdate();
}
};

renderOption = (option) => {
renderOption = option => {
const optionStatus = config()._get(option.path);

switch (option.type) {
Expand All @@ -28,7 +28,9 @@ class Configurator extends React.Component {
<p>{option.name}</p>
<Select
value={optionStatus}
onChange={newValue => this.handleUpdateConfiguration(option.path, newValue)}
onChange={newValue =>
this.handleUpdateConfiguration(option.path, newValue)
}
>
{option.options.map(subOption => (
<Select.Option key={key()} value={subOption}>
Expand All @@ -47,7 +49,9 @@ class Configurator extends React.Component {
type="number"
min={0}
value={optionStatus}
onChange={event => this.handleUpdateConfiguration(option.path, event.target.value)}
onChange={event =>
this.handleUpdateConfiguration(option.path, event.target.value)
}
/>
</List.Entry>
);
Expand All @@ -58,13 +62,17 @@ class Configurator extends React.Component {
<List.Entry
key={key()}
checked={optionStatus}
onCheck={this.handleUpdateConfiguration.bind(this, option.path, !optionStatus)}
onCheck={this.handleUpdateConfiguration.bind(
this,
option.path,
!optionStatus
)}
>
{option.name}
</List.Entry>
);
}
}
};

renderOptions = (title, options) => {
return (
Expand All @@ -73,7 +81,7 @@ class Configurator extends React.Component {
<List>{options.map(this.renderOption)}</List>
</Container>
);
}
};

renderPopover = () => {
return (
Expand All @@ -83,7 +91,7 @@ class Configurator extends React.Component {
)}
</div>
);
}
};

render() {
return (
Expand Down

0 comments on commit ce24363

Please sign in to comment.