🚨 Fixed linter warnings
This commit is contained in:
parent
446db0d3a5
commit
f2f6d3d856
7 changed files with 4 additions and 143 deletions
|
@ -1,130 +0,0 @@
|
||||||
import React, { useState } from "react";
|
|
||||||
import PropTypes from "prop-types";
|
|
||||||
import examples from "@freesewing/examples";
|
|
||||||
import rendertest from "@freesewing/rendertest";
|
|
||||||
import i18nPlugin from "@freesewing/plugin-i18n";
|
|
||||||
import Draft from "../Draft";
|
|
||||||
import Design from "../Workbench/Design";
|
|
||||||
import { FormattedMessage } from "react-intl";
|
|
||||||
import IconButton from "@material-ui/core/IconButton";
|
|
||||||
import DesignIcon from "@material-ui/icons/LocationSearching";
|
|
||||||
import CodeIcon from "@material-ui/icons/Code";
|
|
||||||
import ResetIcon from "@material-ui/icons/SettingsBackupRestore";
|
|
||||||
import Prism from "prismjs";
|
|
||||||
|
|
||||||
const Example = props => {
|
|
||||||
const [design, setDesign] = useState(false);
|
|
||||||
const [code, setCode] = useState(false);
|
|
||||||
const [focus, setFocus] = useState(null);
|
|
||||||
|
|
||||||
const raiseEvent = (type, data) => {
|
|
||||||
if (type === "clearFocusAll") return setFocus(null);
|
|
||||||
let f = {};
|
|
||||||
if (focus !== null) f = { ...focus };
|
|
||||||
if (typeof f[data.part] === "undefined")
|
|
||||||
f[data.part] = { paths: [], points: [], coords: [] };
|
|
||||||
if (type === "point") f[data.part].points.push(data.name);
|
|
||||||
else if (type === "path") f[data.part].paths.push(data.name);
|
|
||||||
else if (type === "coords") f[data.part].coords.push(data.coords);
|
|
||||||
else if (type === "clearFocus") {
|
|
||||||
let i = focus[data.part][data.type].indexOf(data.name);
|
|
||||||
f[data.part][data.type].splice(i, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
setFocus(f);
|
|
||||||
};
|
|
||||||
|
|
||||||
let focusCount = 0;
|
|
||||||
if (focus !== null) {
|
|
||||||
for (let p of Object.keys(focus)) {
|
|
||||||
for (let i in focus[p].points) focusCount++;
|
|
||||||
for (let i in focus[p].paths) focusCount++;
|
|
||||||
for (let i in focus[p].coords) focusCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const patterns = {
|
|
||||||
examples,
|
|
||||||
rendertest
|
|
||||||
};
|
|
||||||
const settings = { options: { ...props.options } };
|
|
||||||
if (props.part !== "") settings.only = [props.part];
|
|
||||||
const pattern = new patterns[props.pattern](settings);
|
|
||||||
|
|
||||||
pattern.draft();
|
|
||||||
console.log(props);
|
|
||||||
const patternProps = pattern.getRenderProps();
|
|
||||||
return (
|
|
||||||
<figure className={design ? "design example" : "example"}>
|
|
||||||
<div className="example">
|
|
||||||
<div className="actions">
|
|
||||||
{design ? (
|
|
||||||
<IconButton
|
|
||||||
color="primary"
|
|
||||||
variant="contained"
|
|
||||||
onClick={() => raiseEvent("clearFocusAll", null)}
|
|
||||||
>
|
|
||||||
<ResetIcon />
|
|
||||||
</IconButton>
|
|
||||||
) : null}
|
|
||||||
<IconButton
|
|
||||||
color="inherit"
|
|
||||||
className={design ? "active" : ""}
|
|
||||||
onClick={() => setDesign(!design)}
|
|
||||||
>
|
|
||||||
<DesignIcon color="inherit" />
|
|
||||||
</IconButton>
|
|
||||||
<IconButton
|
|
||||||
color="inherit"
|
|
||||||
className={code ? "active" : ""}
|
|
||||||
onClick={() => setCode(!code)}
|
|
||||||
>
|
|
||||||
<CodeIcon color="inherit" />
|
|
||||||
</IconButton>
|
|
||||||
</div>
|
|
||||||
<Draft
|
|
||||||
{...patternProps}
|
|
||||||
design={design}
|
|
||||||
focus={focus}
|
|
||||||
raiseEvent={raiseEvent}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<figcaption>{props.caption}</figcaption>
|
|
||||||
{design ? (
|
|
||||||
<div className="design">
|
|
||||||
<Design
|
|
||||||
focus={focus}
|
|
||||||
design={design}
|
|
||||||
raiseEvent={raiseEvent}
|
|
||||||
parts={patternProps.parts}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
{code ? (
|
|
||||||
<div className="gatsby-highlight">
|
|
||||||
<pre className="language-js">
|
|
||||||
<code className="language-js">hi</code>
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</figure>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
Example.propTypes = {
|
|
||||||
pattern: PropTypes.string,
|
|
||||||
design: PropTypes.bool,
|
|
||||||
caption: PropTypes.string,
|
|
||||||
part: PropTypes.string,
|
|
||||||
options: PropTypes.obj
|
|
||||||
};
|
|
||||||
|
|
||||||
Example.defaultProps = {
|
|
||||||
pattern: "examples",
|
|
||||||
design: false,
|
|
||||||
caption: "",
|
|
||||||
options: {},
|
|
||||||
part: ""
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Example;
|
|
|
@ -2,10 +2,8 @@ import React, { useState } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import examples from "@freesewing/examples";
|
import examples from "@freesewing/examples";
|
||||||
import rendertest from "@freesewing/rendertest";
|
import rendertest from "@freesewing/rendertest";
|
||||||
import i18nPlugin from "@freesewing/plugin-i18n";
|
|
||||||
import Draft from "../Draft";
|
import Draft from "../Draft";
|
||||||
import Design from "../Workbench/Design";
|
import Design from "../Workbench/Design";
|
||||||
import { FormattedMessage } from "react-intl";
|
|
||||||
import IconButton from "@material-ui/core/IconButton";
|
import IconButton from "@material-ui/core/IconButton";
|
||||||
import ResetIcon from "@material-ui/icons/SettingsBackupRestore";
|
import ResetIcon from "@material-ui/icons/SettingsBackupRestore";
|
||||||
import Switch from "@material-ui/core/Switch";
|
import Switch from "@material-ui/core/Switch";
|
||||||
|
@ -48,12 +46,6 @@ const Example = props => {
|
||||||
if (props.part !== "") settings.only = [props.part];
|
if (props.part !== "") settings.only = [props.part];
|
||||||
const pattern = new patterns[props.pattern](settings);
|
const pattern = new patterns[props.pattern](settings);
|
||||||
|
|
||||||
const style = {
|
|
||||||
thumb: {
|
|
||||||
background: "blue"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
pattern.draft();
|
pattern.draft();
|
||||||
const patternProps = pattern.getRenderProps();
|
const patternProps = pattern.getRenderProps();
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -103,7 +103,6 @@ let methods = {
|
||||||
draftPath_join,
|
draftPath_join,
|
||||||
draftPath_length,
|
draftPath_length,
|
||||||
draftPath_offset,
|
draftPath_offset,
|
||||||
draftPath_ops,
|
|
||||||
draftPath_reverse,
|
draftPath_reverse,
|
||||||
draftPath_shiftalong,
|
draftPath_shiftalong,
|
||||||
draftPath_shiftfractionalong,
|
draftPath_shiftfractionalong,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export default part => {
|
export default part => {
|
||||||
let { Point, points, Snippet, snippets, macro } = part.shorthand();
|
let { Point, points, macro } = part.shorthand();
|
||||||
|
|
||||||
points.from = new Point(10, 10);
|
points.from = new Point(10, 10);
|
||||||
points.to = new Point(90, 40);
|
points.to = new Point(90, 40);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export default part => {
|
export default part => {
|
||||||
let { Point, points, Snippet, snippets, macro } = part.shorthand();
|
let { Point, points, macro } = part.shorthand();
|
||||||
|
|
||||||
points.from = new Point(10, 10);
|
points.from = new Point(10, 10);
|
||||||
points.to = new Point(90, 40);
|
points.to = new Point(90, 40);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export default part => {
|
export default part => {
|
||||||
let { Point, points, Snippet, snippets, macro } = part.shorthand();
|
let { Point, points, macro } = part.shorthand();
|
||||||
|
|
||||||
points.from = new Point(10, 10);
|
points.from = new Point(10, 10);
|
||||||
points.to = new Point(90, 40);
|
points.to = new Point(90, 40);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export default part => {
|
export default part => {
|
||||||
let { Point, points, Path, paths, Snippet, snippets } = part.shorthand();
|
let { Point, points, Path, paths } = part.shorthand();
|
||||||
|
|
||||||
points.sun = new Point(40, 40);
|
points.sun = new Point(40, 40);
|
||||||
points.moon = new Point(70, 40);
|
points.moon = new Point(70, 40);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue