🚧 Work on components
This commit is contained in:
parent
b9b6556319
commit
71f9075fca
10 changed files with 227 additions and 11 deletions
|
@ -17,6 +17,7 @@
|
|||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"nodebuild": "BABEL_ENV=production rollup -c -o dist/index.js -f cjs",
|
||||
"watch": "BABEL_ENV=production rollup -c -w -o dist/index.js -f cjs",
|
||||
"build": "npm run clean && npm run nodebuild",
|
||||
"test": "echo \"components: No tests configured. Perhaps you'd like to do this?\" && exit 0",
|
||||
"pubtest": "npm publish --registry http://localhost:6662",
|
||||
|
@ -34,7 +35,7 @@
|
|||
"@material-ui/icons": "^3.0.2",
|
||||
"@material-ui/lab": "^3.0.0-alpha.30",
|
||||
"prop-types": "15.7.2",
|
||||
"react": "^16.4.1",
|
||||
"react": "^16.8",
|
||||
"react-intl": "^2.8.0",
|
||||
"typeface-roboto-condensed": "latest"
|
||||
},
|
||||
|
|
22
packages/components/src/Icon/icons.js
Normal file
22
packages/components/src/Icon/icons.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
const gitter =
|
||||
"M8.501 4.001H10.5V24H8.501V4.001zm6.999 0V24h-2V4.001h2zM3.5 0h2.001v15H3.5V0zm15 4.001h2V15h-2V4.001z";
|
||||
|
||||
const github =
|
||||
"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12";
|
||||
|
||||
const twitter =
|
||||
"M23.954 4.569c-.885.389-1.83.654-2.825.775 1.014-.611 1.794-1.574 2.163-2.723-.951.555-2.005.959-3.127 1.184-.896-.959-2.173-1.559-3.591-1.559-2.717 0-4.92 2.203-4.92 4.917 0 .39.045.765.127 1.124C7.691 8.094 4.066 6.13 1.64 3.161c-.427.722-.666 1.561-.666 2.475 0 1.71.87 3.213 2.188 4.096-.807-.026-1.566-.248-2.228-.616v.061c0 2.385 1.693 4.374 3.946 4.827-.413.111-.849.171-1.296.171-.314 0-.615-.03-.916-.086.631 1.953 2.445 3.377 4.604 3.417-1.68 1.319-3.809 2.105-6.102 2.105-.39 0-.779-.023-1.17-.067 2.189 1.394 4.768 2.209 7.557 2.209 9.054 0 13.999-7.496 13.999-13.986 0-.209 0-.42-.015-.63.961-.689 1.8-1.56 2.46-2.548l-.047-.02z";
|
||||
|
||||
const instagram =
|
||||
"M12 0C8.74 0 8.333.015 7.053.072 5.775.132 4.905.333 4.14.63c-.789.306-1.459.717-2.126 1.384S.935 3.35.63 4.14C.333 4.905.131 5.775.072 7.053.012 8.333 0 8.74 0 12s.015 3.667.072 4.947c.06 1.277.261 2.148.558 2.913.306.788.717 1.459 1.384 2.126.667.666 1.336 1.079 2.126 1.384.766.296 1.636.499 2.913.558C8.333 23.988 8.74 24 12 24s3.667-.015 4.947-.072c1.277-.06 2.148-.262 2.913-.558.788-.306 1.459-.718 2.126-1.384.666-.667 1.079-1.335 1.384-2.126.296-.765.499-1.636.558-2.913.06-1.28.072-1.687.072-4.947s-.015-3.667-.072-4.947c-.06-1.277-.262-2.149-.558-2.913-.306-.789-.718-1.459-1.384-2.126C21.319 1.347 20.651.935 19.86.63c-.765-.297-1.636-.499-2.913-.558C15.667.012 15.26 0 12 0zm0 2.16c3.203 0 3.585.016 4.85.071 1.17.055 1.805.249 2.227.415.562.217.96.477 1.382.896.419.42.679.819.896 1.381.164.422.36 1.057.413 2.227.057 1.266.07 1.646.07 4.85s-.015 3.585-.074 4.85c-.061 1.17-.256 1.805-.421 2.227-.224.562-.479.96-.899 1.382-.419.419-.824.679-1.38.896-.42.164-1.065.36-2.235.413-1.274.057-1.649.07-4.859.07-3.211 0-3.586-.015-4.859-.074-1.171-.061-1.816-.256-2.236-.421-.569-.224-.96-.479-1.379-.899-.421-.419-.69-.824-.9-1.38-.165-.42-.359-1.065-.42-2.235-.045-1.26-.061-1.649-.061-4.844 0-3.196.016-3.586.061-4.861.061-1.17.255-1.814.42-2.234.21-.57.479-.96.9-1.381.419-.419.81-.689 1.379-.898.42-.166 1.051-.361 2.221-.421 1.275-.045 1.65-.06 4.859-.06l.045.03zm0 3.678c-3.405 0-6.162 2.76-6.162 6.162 0 3.405 2.76 6.162 6.162 6.162 3.405 0 6.162-2.76 6.162-6.162 0-3.405-2.76-6.162-6.162-6.162zM12 16c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4zm7.846-10.405c0 .795-.646 1.44-1.44 1.44-.795 0-1.44-.646-1.44-1.44 0-.794.646-1.439 1.44-1.439.793-.001 1.44.645 1.44 1.439z";
|
||||
|
||||
const google =
|
||||
"M 12.25009,0 C 7.5567085,0 3.5033589,2.69334 1.530043,6.613315 0.71674427,8.240005 0.25,10.06676 0.25,12.00009 c 0,1.93333 0.46674427,3.759905 1.280043,5.386595 C 3.5033589,21.30666 7.5567085,24 12.25009,24 c 3.239959,0 5.959944,-1.066635 7.94668,-2.906575 2.266629,-2.093365 3.573349,-5.173415 3.573349,-8.826735 0,-0.98666 -0.08023,-1.70661 -0.253496,-2.453265 l -11.266533,0 0,4.45322 6.613137,0 c -0.133283,1.106705 -0.853233,2.77333 -2.453266,3.89327 -1.013315,0.706675 -2.373243,1.199975 -4.159871,1.199975 -3.173318,0 -5.8666835,-2.09327 -6.826777,-4.986605 -0.2533286,-0.746655 -0.399991,-1.54657 -0.399991,-2.373195 0,-0.82672 0.1467055,-1.62672 0.386706,-2.373375 C 6.3834495,6.73338 9.076772,4.63993 12.25009,4.63993 c 2.253301,0 3.773228,0.973465 4.639932,1.786855 L 20.27666,3.12004 C 18.196718,1.186705 15.490049,0 12.25009,0 Z";
|
||||
|
||||
export default {
|
||||
gitter,
|
||||
github,
|
||||
twitter,
|
||||
instagram,
|
||||
google
|
||||
};
|
37
packages/components/src/Icon/index.js
Normal file
37
packages/components/src/Icon/index.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import icons from "./icons";
|
||||
|
||||
const Icon = props => {
|
||||
return (
|
||||
<svg
|
||||
className={props.classes}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width={props.size}
|
||||
height={props.size}
|
||||
viewBox={props.viewBox}
|
||||
>
|
||||
<path
|
||||
stroke="none"
|
||||
fill={props.color ? props.color : "currentColor"}
|
||||
d={icons[props.icon]}
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
|
||||
Icon.propTypes = {
|
||||
size: PropTypes.number,
|
||||
viewBox: PropTypes.string,
|
||||
pathString: PropTypes.string.isRequired
|
||||
};
|
||||
|
||||
Icon.defaultProps = {
|
||||
size: 24,
|
||||
viewBox: "0 0 24 24",
|
||||
className: "",
|
||||
icon: "github",
|
||||
color: false
|
||||
};
|
||||
|
||||
export default Icon;
|
|
@ -27,14 +27,22 @@ const Navbar = props => {
|
|||
);
|
||||
};
|
||||
|
||||
let homeProps = {
|
||||
href: "#home"
|
||||
};
|
||||
if (typeof props.home === "function") homeProps.onClick = props.home;
|
||||
else homeProps.href = props.home;
|
||||
|
||||
return (
|
||||
<header className="navbar">
|
||||
<div>
|
||||
<div className="logo">
|
||||
<a href={props.home}>{props.logo}</a>
|
||||
<a id="home" {...homeProps}>
|
||||
{props.logo}
|
||||
</a>
|
||||
</div>
|
||||
<div className="emblem">
|
||||
<a href={props.home}>{props.emblem}</a>
|
||||
<a {...homeProps}>{props.emblem}</a>
|
||||
</div>
|
||||
{Object.keys(props.navs.left).map(key =>
|
||||
renderNav(key, props.navs.left[key])
|
||||
|
|
|
@ -6,6 +6,7 @@ const LanguageChooser = props => {
|
|||
const styles = {
|
||||
container: {
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
height: "calc(100vh - 64px)",
|
||||
width: "100%"
|
||||
},
|
||||
|
@ -37,7 +38,7 @@ const LanguageChooser = props => {
|
|||
variant="contained"
|
||||
onClick={() => changeLanguage(lang)}
|
||||
>
|
||||
{languages[lang][lang]}
|
||||
{languages[lang]}
|
||||
</Button>
|
||||
);
|
||||
})}
|
||||
|
|
|
@ -4,13 +4,15 @@ import { defaultGist } from "@freesewing/utils";
|
|||
import DraftConfigurator from "../../DraftConfigurator";
|
||||
|
||||
const Pattern = props => {
|
||||
//let pattern = new props.Pattern();
|
||||
|
||||
let pattern = new props.Pattern(props.gist);
|
||||
return (
|
||||
<div className="fs-sa">
|
||||
<section>
|
||||
<div dangerouslySetInnerHTML={{ __hmtl: pattern.draft().render() }} />
|
||||
<h2>gist</h2>
|
||||
<pre>{JSON.stringify(props.gist, null, 2)}</pre>
|
||||
</section>
|
||||
|
||||
<aside>
|
||||
<div className="sticky">
|
||||
<DraftConfigurator
|
||||
|
|
30
packages/components/src/Workbench/Welcome/bak
Normal file
30
packages/components/src/Workbench/Welcome/bak
Normal file
|
@ -0,0 +1,30 @@
|
|||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import Logo from "../../Logo";
|
||||
import FormattedMessage from "react-intl";
|
||||
import Button from "@material-ui/core/Button";
|
||||
|
||||
const Welcome = props => {
|
||||
|
||||
const style = {
|
||||
textAlign: "center"
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="fs-sa">
|
||||
<section style={{style}}>
|
||||
<div><Logo size={250} /></div>
|
||||
<h1><FormattedMessage id="app.welcome" /></h1>
|
||||
<p><FormattedMessage id="cfp.devDocsAvailableAt" /> <a href="https://freesewing.dev/">freesewing.dev</a></p>
|
||||
<p><FormattedMessage id="cfp.talkToUs" />: <a href="https://gitter.im/freesewing/freesewing/">gitter.im/freesewing</a></p>
|
||||
<Button
|
||||
variant="outlined"
|
||||
size="large"
|
||||
onClick={() => props.setDisplay('pattern')}
|
||||
><FormattedMessage id="app.docs" /></Button>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Welcome;
|
100
packages/components/src/Workbench/Welcome/index.js
Normal file
100
packages/components/src/Workbench/Welcome/index.js
Normal file
|
@ -0,0 +1,100 @@
|
|||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import Logo from "../../Logo";
|
||||
import { FormattedMessage, FormattedHTMLMessage } from "react-intl";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import IconButton from "@material-ui/core/IconButton";
|
||||
import Icon from "../../Icon";
|
||||
|
||||
const Welcome = props => {
|
||||
const styles = {
|
||||
container: {
|
||||
textAlign: "center",
|
||||
maxWidth: "500px",
|
||||
margin: "2vh auto"
|
||||
},
|
||||
title: {
|
||||
fontFamily: "Roboto Condensed"
|
||||
},
|
||||
button: {
|
||||
margin: "0.5rem"
|
||||
},
|
||||
bigButton: {
|
||||
margin: "0.5rem",
|
||||
width: "calc(100% - 1rem)"
|
||||
},
|
||||
footer: {
|
||||
fontFamily: "Roboto Condensed",
|
||||
position: "fixed",
|
||||
bottom: "10px",
|
||||
left: 0,
|
||||
width: "100%",
|
||||
fontSize: "90%"
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="fs-sa">
|
||||
<section style={styles.container}>
|
||||
<div>
|
||||
<Logo size={250} />
|
||||
</div>
|
||||
<h1 style={styles.title}>
|
||||
<FormattedMessage id="app.welcome" />
|
||||
</h1>
|
||||
<p>
|
||||
<FormattedMessage id="cfp.renderInBrowser" />
|
||||
<br />
|
||||
<FormattedMessage id="cfp.weWillReRender" />
|
||||
</p>
|
||||
<Button
|
||||
style={styles.bigButton}
|
||||
variant="contained"
|
||||
size="large"
|
||||
color="primary"
|
||||
onClick={() => props.setDisplay("pattern")}
|
||||
>
|
||||
<FormattedMessage id="cfp.renderYourPattern" />
|
||||
</Button>
|
||||
<footer style={styles.footer}>
|
||||
<Button
|
||||
style={styles.button}
|
||||
href={
|
||||
"https://" +
|
||||
props.language +
|
||||
".freesewing.dev/pkg/create-freesewing-pattern"
|
||||
}
|
||||
color="primary"
|
||||
onClick={() => props.setDisplay("pattern")}
|
||||
>
|
||||
<FormattedMessage id="app.docs" />
|
||||
</Button>
|
||||
<Button
|
||||
style={styles.button}
|
||||
href="https://gitter.im/freesewing/freesewing"
|
||||
color="primary"
|
||||
onClick={() => props.setDisplay("pattern")}
|
||||
>
|
||||
<FormattedMessage id="app.askForHelp" />
|
||||
</Button>
|
||||
<p>
|
||||
<IconButton href="https://twitter.com/freesewing_org">
|
||||
<Icon icon="twitter" color="#00aced" />
|
||||
</IconButton>
|
||||
<IconButton href="https://twitter.com/freesewing_org">
|
||||
<Icon icon="github" color="#666" />
|
||||
</IconButton>
|
||||
<IconButton href="https://twitter.com/freesewing_org">
|
||||
<Icon icon="instagram" color="#e1306c" />
|
||||
</IconButton>
|
||||
</p>
|
||||
<p>
|
||||
<FormattedHTMLMessage id="app.txt-footer" />
|
||||
</p>
|
||||
</footer>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Welcome;
|
9
packages/components/src/Workbench/Welcome/stories.js
Normal file
9
packages/components/src/Workbench/Welcome/stories.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
import React from "react";
|
||||
import { storiesOf } from "@storybook/react";
|
||||
import Welcome from ".";
|
||||
|
||||
const props = {
|
||||
language: "en"
|
||||
};
|
||||
|
||||
storiesOf("Welcome", module).add("Basic", () => <Welcome {...props} />);
|
|
@ -13,10 +13,11 @@ import withLanguage from "../withLanguage";
|
|||
import LanguageIcon from "@material-ui/icons/Translate";
|
||||
import DarkModeIcon from "@material-ui/icons/Brightness3";
|
||||
import LanguageChooser from "./LanguageChooser";
|
||||
import Pattern from "./Pattern";
|
||||
import ShowPattern from "./Pattern";
|
||||
import Welcome from "./Welcome";
|
||||
|
||||
const Workbench = props => {
|
||||
const [display, setDisplay] = useState("pattern");
|
||||
const [display, setDisplay] = useState("welcome");
|
||||
const [pattern, setPattern] = useState(false);
|
||||
const [settings, setSettings] = useState(false);
|
||||
const [theme, setTheme] = useState("light");
|
||||
|
@ -82,9 +83,9 @@ const Workbench = props => {
|
|||
/>
|
||||
);
|
||||
break;
|
||||
default:
|
||||
case "pattern":
|
||||
main = (
|
||||
<Pattern
|
||||
<ShowPattern
|
||||
freesewing={props.freesewing}
|
||||
Pattern={props.Pattern}
|
||||
config={props.config}
|
||||
|
@ -94,6 +95,9 @@ const Workbench = props => {
|
|||
units={props.units}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
default:
|
||||
main = <Welcome language={props.language} setDisplay={setDisplay} />;
|
||||
}
|
||||
|
||||
const themes = { dark, light };
|
||||
|
@ -105,7 +109,9 @@ const Workbench = props => {
|
|||
theme === "light" ? "theme-wrapper light" : "theme-wrapper dark"
|
||||
}
|
||||
>
|
||||
<Navbar navs={navs} />
|
||||
{display !== "welcome" ? (
|
||||
<Navbar navs={navs} home={() => setDisplay("welcome")} />
|
||||
) : null}
|
||||
{main}
|
||||
</div>
|
||||
</MuiThemeProvider>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue