🚧 Work on React components and releases
This commit is contained in:
parent
10fc688be1
commit
9d54e25020
93 changed files with 1253 additions and 1785 deletions
|
@ -1,13 +1,12 @@
|
|||
import React, { useState } from "react";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import withGist from "../withGist";
|
||||
import { patternList } from "@freesewing/patterns";
|
||||
import { FormattedMessage, IntlProvider } from "react-intl";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import { MuiThemeProvider, createMuiTheme } from "@material-ui/core/styles";
|
||||
import { i18n, strings } from "@freesewing/i18n";
|
||||
import Navbar from "../Navbar";
|
||||
import { defaultGist, storage } from "@freesewing/utils";
|
||||
import { defaultGist, storage, partList } from "@freesewing/utils";
|
||||
import { dark, light } from "@freesewing/mui-theme";
|
||||
import Logo from "../Logo";
|
||||
import withLanguage from "../withLanguage";
|
||||
|
@ -21,22 +20,25 @@ const Workbench = props => {
|
|||
const [pattern, setPattern] = useState(false);
|
||||
const [settings, setSettings] = useState(false);
|
||||
const [theme, setTheme] = useState("light");
|
||||
useEffect(
|
||||
() => {
|
||||
if (props.from) props.importGist(props.from);
|
||||
},
|
||||
[props.from]
|
||||
);
|
||||
|
||||
const showLanguageChooser = () => setDisplay("language");
|
||||
const toggleSettings = () => setSettings(!settings);
|
||||
|
||||
const updatePattern = p => {
|
||||
setPattern(p);
|
||||
store.set("pattern", p);
|
||||
};
|
||||
|
||||
const toggleDarkMode = () => {
|
||||
if (theme === "light") setTheme("dark");
|
||||
else setTheme("light");
|
||||
};
|
||||
|
||||
const raiseEvent = (type, data) => {
|
||||
console.log("Event raised", type, data);
|
||||
console.log("FIXME: Event raised", type, data);
|
||||
};
|
||||
|
||||
const navs = {
|
||||
|
@ -87,20 +89,18 @@ const Workbench = props => {
|
|||
main = (
|
||||
<Pattern
|
||||
freesewing={props.freesewing}
|
||||
Pattern={props.pattern}
|
||||
info={props.info}
|
||||
pattern={props.pattern}
|
||||
config={props.config}
|
||||
gist={props.gist}
|
||||
updateGist={props.updateGist}
|
||||
raiseEvent={raiseEvent}
|
||||
units={props.units}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// Load defaults into gist
|
||||
console.log(props);
|
||||
//props.loadGistDefaults({options: props.info.config.options});
|
||||
|
||||
const themes = { dark, light };
|
||||
|
||||
return (
|
||||
<MuiThemeProvider theme={createMuiTheme(themes[theme])}>
|
||||
<div
|
||||
|
@ -116,8 +116,14 @@ const Workbench = props => {
|
|||
};
|
||||
|
||||
Workbench.propTypes = {
|
||||
pattern: PropTypes.oneOf(patternList),
|
||||
units: PropTypes.oneOf(["metric", "imperial"]).isRequired
|
||||
freesewing: PropTypes.object.isRequired,
|
||||
pattern: PropTypes.func.isRequired,
|
||||
config: PropTypes.object.isRequired,
|
||||
from: PropTypes.object
|
||||
};
|
||||
|
||||
Workbench.defaultProps = {
|
||||
from: false
|
||||
};
|
||||
|
||||
export default withLanguage(
|
||||
|
@ -125,5 +131,5 @@ export default withLanguage(
|
|||
gist: defaultGist,
|
||||
store: true
|
||||
}),
|
||||
"nl"
|
||||
"en"
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue