Skip to content

Commit

Permalink
Bump and rerun prettier on REPL
Browse files Browse the repository at this point in the history
  • Loading branch information
existentialism committed Oct 3, 2017
1 parent a314f4a commit 97e7332
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 85 deletions.
13 changes: 5 additions & 8 deletions js/repl/AccordionTab.js
@@ -1,7 +1,7 @@
// @flow

import { css } from "emotion";
import React, { Component } from "react";
import React from "react";
import Svg from "./Svg";
import { colors, media } from "./styles";

Expand All @@ -17,9 +17,7 @@ export default function AccordionTab(props: Props) {
return (
<div className={`${styles.AccordionTab} ${props.className || ""}`}>
<div className={styles.HeaderRow} onClick={props.toggleIsExpanded}>
<div className={styles.Label}>
{props.label}
</div>
<div className={styles.Label}>{props.label}</div>
<Svg
className={`${styles.Arrow} ${props.isExpanded
? styles.ArrowExpanded
Expand All @@ -35,10 +33,9 @@ export default function AccordionTab(props: Props) {
Z"
/>
</div>
{props.isExpanded &&
<div className={styles.Content}>
{props.children}
</div>}
{props.isExpanded && (
<div className={styles.Content}>{props.children}</div>
)}
</div>
);
}
Expand Down
10 changes: 2 additions & 8 deletions js/repl/CodeMirrorPanel.js
Expand Up @@ -32,14 +32,8 @@ export default function CodeMirrorPanel(props: Props) {
value={props.code}
/>
</div>
{info &&
<pre className={styles.info}>
{info}
</pre>}
{errorMessage &&
<pre className={styles.error}>
{errorMessage}
</pre>}
{info && <pre className={styles.info}>{info}</pre>}
{errorMessage && <pre className={styles.error}>{errorMessage}</pre>}
</div>
);
}
Expand Down
5 changes: 3 additions & 2 deletions js/repl/PresetLoadingAnimation.js
Expand Up @@ -7,14 +7,15 @@ type PresetLoadingAnimationProps = {

const PresetLoadingAnimation = ({
className = "",
}: PresetLoadingAnimationProps) =>
}: PresetLoadingAnimationProps) => (
<div className={`${className} ${styles.loadingAnimation}`}>
<div className={`${styles.loadingTick} ${styles.loadingTick1}`} />
<div className={`${styles.loadingTick} ${styles.loadingTick2}`} />
<div className={`${styles.loadingTick} ${styles.loadingTick3}`} />
<div className={`${styles.loadingTick} ${styles.loadingTick4}`} />
<div className={`${styles.loadingTick} ${styles.loadingTick5}`} />
</div>;
</div>
);

export default PresetLoadingAnimation;

Expand Down
5 changes: 3 additions & 2 deletions js/repl/Repl.js
Expand Up @@ -141,8 +141,9 @@ class Repl extends React.Component {
<div className={styles.loader}>
<div className={styles.loaderContent}>
{message}
{state.babel.isLoading &&
<PresetLoadingAnimation className={styles.loadingAnimation} />}
{state.babel.isLoading && (
<PresetLoadingAnimation className={styles.loadingAnimation} />
)}
</div>
</div>
);
Expand Down
46 changes: 28 additions & 18 deletions js/repl/ReplOptions.js
Expand Up @@ -46,12 +46,15 @@ type Props = {
runtimePolyfillState: PluginState,
};

const ReplOptions = (props: Props) =>
const ReplOptions = (props: Props) => (
<div className={`${styles.wrapper} ${props.className}`}>
{props.isExpanded
? <ExpandedContainer {...props} />
: <CollapsedContainer {...props} />}
</div>;
{props.isExpanded ? (
<ExpandedContainer {...props} />
) : (
<CollapsedContainer {...props} />
)}
</div>
);

export default ReplOptions;

Expand Down Expand Up @@ -111,29 +114,29 @@ class ExpandedContainer extends Component {
/>
Line Wrap
</label>
{pluginConfigs.map(config =>
{pluginConfigs.map(config => (
<PluginToggle
config={config}
key={config.package}
onSettingChange={onSettingChange}
state={pluginState[config.package]}
/>
)}
))}
</AccordionTab>
<AccordionTab
className={styles.section}
isExpanded={isPresetsTabExpanded}
label="Presets"
toggleIsExpanded={this._togglePresetsTab}
>
{presetPluginConfigs.map(config =>
{presetPluginConfigs.map(config => (
<PluginToggle
config={config}
key={config.package}
onSettingChange={onSettingChange}
state={presetState[config.package]}
/>
)}
))}
</AccordionTab>
<AccordionTab
className={`${styles.section} ${styles.sectionEnv}`}
Expand All @@ -149,9 +152,11 @@ class ExpandedContainer extends Component {
onChange={this._onEnvPresetEnabledChange}
/>

{envPresetState.isLoading
? <PresetLoadingAnimation />
: "Enabled"}
{envPresetState.isLoading ? (
<PresetLoadingAnimation />
) : (
"Enabled"
)}
</label>

<div className={styles.envPresetColumn}>
Expand Down Expand Up @@ -253,10 +258,11 @@ class ExpandedContainer extends Component {
/>
classic repl
</a>
{babelVersion &&
{babelVersion && (
<div className={styles.babelVersion} title={`v${babelVersion}`}>
v{babelVersion}
</div>}
</div>
)}
</div>
<div
className={`${styles.closeButton} ${nestedCloseButton}`}
Expand Down Expand Up @@ -342,7 +348,9 @@ type CollapsedContainerProps = {
onIsExpandedChange: boolean => any,
};

const CollapsedContainer = ({ onIsExpandedChange }: CollapsedContainerProps) =>
const CollapsedContainer = ({
onIsExpandedChange,
}: CollapsedContainerProps) => (
<div className={styles.collapsedContainer}>
<div
className={`${styles.closeButton} ${nestedCloseButton}`}
Expand All @@ -353,7 +361,8 @@ const CollapsedContainer = ({ onIsExpandedChange }: CollapsedContainerProps) =>
path="M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"
/>
</div>
</div>;
</div>
);

type PluginToggleProps = {
config: PluginConfig,
Expand All @@ -367,7 +376,7 @@ const PluginToggle = ({
label,
state,
onSettingChange,
}: PluginToggleProps) =>
}: PluginToggleProps) => (
<label key={config.package} className={styles.settingsLabel}>
<input
checked={state.isEnabled && !state.didError}
Expand All @@ -378,7 +387,8 @@ const PluginToggle = ({
type="checkbox"
/>
{state.isLoading ? <PresetLoadingAnimation /> : label || config.label}
</label>;
</label>
);

// Defined separately from styles due to nesting.
const nestedCloseButton = css({});
Expand Down
5 changes: 3 additions & 2 deletions js/repl/Svg.js
Expand Up @@ -8,10 +8,11 @@ type Props = {
path: string,
};

const Svg = ({ className, path, ...rest }: Props) =>
const Svg = ({ className, path, ...rest }: Props) => (
<svg className={`${styles.svg} ${className}`} viewBox="0 0 24 24" {...rest}>
<path className={styles.path} d={path} />
</svg>;
</svg>
);

const styles = {
svg: css({
Expand Down
48 changes: 25 additions & 23 deletions js/repl/replUtils.js
Expand Up @@ -110,31 +110,33 @@ export const persistedStateToEnvConfig = (
node: envPresetDefaults.node.default,
};

decodeURIComponent(persistedState.targets).split(",").forEach(component => {
try {
const pieces = component.split("-");
const name = pieces[0].toLowerCase();
const value = parseFloat(pieces[1]);

if (name) {
switch (name) {
case "electron":
envConfig.electron = value;
envConfig.isElectronEnabled = true;
break;
case "node":
envConfig.node = value;
envConfig.isNodeEnabled = true;
break;
default:
console.warn(`Unknown env target "${name}" specified`);
break;
decodeURIComponent(persistedState.targets)
.split(",")
.forEach(component => {
try {
const pieces = component.split("-");
const name = pieces[0].toLowerCase();
const value = parseFloat(pieces[1]);

if (name) {
switch (name) {
case "electron":
envConfig.electron = value;
envConfig.isElectronEnabled = true;
break;
case "node":
envConfig.node = value;
envConfig.isNodeEnabled = true;
break;
default:
console.warn(`Unknown env target "${name}" specified`);
break;
}
}
} catch (error) {
console.error("Error parsing env preset configuration", error);
}
} catch (error) {
console.error("Error parsing env preset configuration", error);
}
});
});

return envConfig;
};
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -38,13 +38,13 @@
"eslint-config-babel": "^6.0.0",
"eslint-plugin-flowtype": "^2.35.0",
"eslint-plugin-markdown": "^1.0.0-beta.3",
"eslint-plugin-prettier": "^2.2.0",
"eslint-plugin-prettier": "^2.3.1",
"eslint-plugin-react": "^7.2.1",
"flow-bin": "0.52",
"husky": "^0.14.3",
"lint-staged": "^4.0.3",
"lint-staged": "^4.2.3",
"node-fetch": "^1.7.1",
"prettier": "^1.5.3",
"prettier": "1.7.4",
"remark-cli": "^3.0.0",
"remark-lint-list-item-indent": "^1.0.0",
"remark-lint-no-blockquote-without-caret": "^1.0.0",
Expand Down

0 comments on commit 97e7332

Please sign in to comment.