From a7e3cd4623d04de89a850b7ec237da28c72a4b2f Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Sun, 15 Nov 2020 17:30:56 +0100 Subject: [PATCH] feat: Support in Workbench for loading config from gist --- config/changelog.yaml | 6 +++ config/dependencies.yaml | 1 + packages/aaron/example/src/App.js | 7 ++++ packages/albert/example/src/App.js | 7 ++++ packages/benjamin/example/src/App.js | 7 ++++ packages/bent/example/src/App.js | 7 ++++ packages/breanna/example/src/App.js | 7 ++++ packages/brian/example/src/App.js | 7 ++++ packages/bruce/example/src/App.js | 7 ++++ packages/carlita/example/src/App.js | 7 ++++ packages/carlton/example/src/App.js | 7 ++++ packages/cathrin/example/src/App.js | 7 ++++ packages/components/package.json | 1 + packages/components/rollup.config.js | 4 +- packages/components/src/Workbench/index.js | 41 ++++++++++++++++--- .../template/default/example/src/App.js | 8 ++++ packages/diana/example/src/App.js | 7 ++++ packages/examples/example/src/App.js | 7 ++++ packages/florence/example/src/App.js | 7 ++++ packages/florent/example/src/App.js | 7 ++++ packages/holmes/example/src/App.js | 7 ++++ packages/huey/example/src/App.js | 7 ++++ packages/hugo/example/src/App.js | 7 ++++ packages/jaeger/example/src/App.js | 7 ++++ packages/legend/example/src/App.js | 7 ++++ packages/paco/example/src/App.js | 7 ++++ packages/penelope/example/src/App.js | 7 ++++ packages/rendertest/example/src/App.js | 7 ++++ packages/sandy/example/src/App.js | 7 ++++ packages/shin/example/src/App.js | 7 ++++ packages/simon/example/src/App.js | 7 ++++ packages/simone/example/src/App.js | 7 ++++ packages/sven/example/src/App.js | 7 ++++ packages/tamiko/example/src/App.js | 7 ++++ packages/teagan/example/src/App.js | 7 ++++ packages/theo/example/src/App.js | 7 ++++ packages/titan/example/src/App.js | 7 ++++ packages/trayvon/example/src/App.js | 7 ++++ packages/tutorial/example/src/App.js | 7 ++++ packages/wahid/example/src/App.js | 7 ++++ packages/waralee/example/src/App.js | 7 ++++ 41 files changed, 299 insertions(+), 7 deletions(-) diff --git a/config/changelog.yaml b/config/changelog.yaml index c4fe1003513..d8cb8e9a755 100644 --- a/config/changelog.yaml +++ b/config/changelog.yaml @@ -3,6 +3,12 @@ Unreleased: Added: Changed: +2.10.6: + date: 2020-11-15 + Added: + components: + - Workbench now supports loading a pattern configuration from a (github) gist + 2.10.5: date: 2020-11-14 Fixed: diff --git a/config/dependencies.yaml b/config/dependencies.yaml index 0606ba83298..9e5d1bb0c82 100644 --- a/config/dependencies.yaml +++ b/config/dependencies.yaml @@ -68,6 +68,7 @@ css-theme: 'open-color': '^1.7.0' components: peer: + 'axios': '^0.19.2' 'react': '^16.13.1' '@freesewing/pattern-info': '^{{version}}' '@freesewing/mui-theme': '^{{version}}' diff --git a/packages/aaron/example/src/App.js b/packages/aaron/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/aaron/example/src/App.js +++ b/packages/aaron/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/albert/example/src/App.js b/packages/albert/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/albert/example/src/App.js +++ b/packages/albert/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/benjamin/example/src/App.js b/packages/benjamin/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/benjamin/example/src/App.js +++ b/packages/benjamin/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/bent/example/src/App.js b/packages/bent/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/bent/example/src/App.js +++ b/packages/bent/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/breanna/example/src/App.js b/packages/breanna/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/breanna/example/src/App.js +++ b/packages/breanna/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/brian/example/src/App.js b/packages/brian/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/brian/example/src/App.js +++ b/packages/brian/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/bruce/example/src/App.js b/packages/bruce/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/bruce/example/src/App.js +++ b/packages/bruce/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/carlita/example/src/App.js b/packages/carlita/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/carlita/example/src/App.js +++ b/packages/carlita/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/carlton/example/src/App.js b/packages/carlton/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/carlton/example/src/App.js +++ b/packages/carlton/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/cathrin/example/src/App.js b/packages/cathrin/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/cathrin/example/src/App.js +++ b/packages/cathrin/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/components/package.json b/packages/components/package.json index a1fdc937814..9f322ae56d8 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -26,6 +26,7 @@ "watch": "BABEL_ENV=production rollup -c -w -o dist/index.js -f cjs" }, "peerDependencies": { + "axios": "^0.19.2", "react": "^16.13.1", "@freesewing/pattern-info": "^2.10.5", "@freesewing/mui-theme": "^2.10.5", diff --git a/packages/components/rollup.config.js b/packages/components/rollup.config.js index 30fa6bb3084..52d08ebedbb 100644 --- a/packages/components/rollup.config.js +++ b/packages/components/rollup.config.js @@ -34,8 +34,8 @@ const createConfig = (component, module) => { const config = [] // When developing, you can use this to only rebuild the components you're working on -let dev = false -let only = ['Draft', 'Workbench'] +let dev = true +let only = ['Workbench'] for (let component of components) { if (!dev || only.indexOf(component) !== -1) config.push(createConfig(component, false)) // Webpack doesn't handle .mjs very well diff --git a/packages/components/src/Workbench/index.js b/packages/components/src/Workbench/index.js index 8c276a2a869..a4a84547e87 100644 --- a/packages/components/src/Workbench/index.js +++ b/packages/components/src/Workbench/index.js @@ -22,6 +22,8 @@ import UnhideIcon from '@material-ui/icons/ChevronRight' import SampleConfigurator from '../SampleConfigurator' import svgattrPlugin from '@freesewing/plugin-svgattr' import Xport from './Export' +import axios from 'axios' +import yaml from 'yaml' const icons = { draft: , @@ -41,7 +43,8 @@ const Workbench = ({ Pattern, units = 'metric', translations = false, - addTranslations + addTranslations, + recreate = false }) => { const [display, setDisplay] = useState(null) const [theme, setTheme] = useState('light') @@ -51,6 +54,7 @@ const Workbench = ({ const [hideAside, setHideAside] = useState(false) const [design, setDesign] = useState(true) const [focus, setFocus] = useState(null) + const [error, setError] = useState(null) const raiseEvent = (type, data) => { if (type === 'clearFocusAll') { @@ -84,10 +88,37 @@ const Workbench = ({ defaultGist.settings.debug = true useEffect(() => { - let m = getMeasurements() - setMeasurements(m) - updateGist(m, 'settings', 'measurements') - setLanguage(userLanguage) + if (recreate) { + // Recreating from existing pattern config + axios + .get(`https://api.github.com/gists/${recreate.id}`) + .then((res) => { + if (res.data.files['pattern.yaml'].content) { + let g = yaml.parse(res.data.files['pattern.yaml'].content) + if (g.design !== Pattern.config.name) { + setError( + `You tried loading a configuration for ${g.design} into a ${Pattern.config.name} development environment` + ) + setDisplay('error') + } + setMeasurements(g.settings.measurements) + updateGist(g.settings, 'settings') + setLanguage(g.settings.locale) + } else { + setError('This gist does not seem to be a valid pattern configuration') + setDisplay('error') + } + }) + .catch((err) => { + setError(err) + setDisplay('error') + }) + } else { + let m = getMeasurements() + setMeasurements(m) + updateGist(m, 'settings', 'measurements') + setLanguage(userLanguage) + } if (translations) addTranslations(translations) }, []) useEffect(() => { diff --git a/packages/create-freesewing-pattern/template/default/example/src/App.js b/packages/create-freesewing-pattern/template/default/example/src/App.js index 3caa4cabe61..0cf26689710 100644 --- a/packages/create-freesewing-pattern/template/default/example/src/App.js +++ b/packages/create-freesewing-pattern/template/default/example/src/App.js @@ -16,11 +16,19 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split('/') + if (recreate.length === 3 && recreate[0] === 'from') + recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/diana/example/src/App.js b/packages/diana/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/diana/example/src/App.js +++ b/packages/diana/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/examples/example/src/App.js b/packages/examples/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/examples/example/src/App.js +++ b/packages/examples/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/florence/example/src/App.js b/packages/florence/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/florence/example/src/App.js +++ b/packages/florence/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/florent/example/src/App.js b/packages/florent/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/florent/example/src/App.js +++ b/packages/florent/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/holmes/example/src/App.js b/packages/holmes/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/holmes/example/src/App.js +++ b/packages/holmes/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/huey/example/src/App.js b/packages/huey/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/huey/example/src/App.js +++ b/packages/huey/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/hugo/example/src/App.js b/packages/hugo/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/hugo/example/src/App.js +++ b/packages/hugo/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/jaeger/example/src/App.js b/packages/jaeger/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/jaeger/example/src/App.js +++ b/packages/jaeger/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/legend/example/src/App.js b/packages/legend/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/legend/example/src/App.js +++ b/packages/legend/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/paco/example/src/App.js b/packages/paco/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/paco/example/src/App.js +++ b/packages/paco/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/penelope/example/src/App.js b/packages/penelope/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/penelope/example/src/App.js +++ b/packages/penelope/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/rendertest/example/src/App.js b/packages/rendertest/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/rendertest/example/src/App.js +++ b/packages/rendertest/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/sandy/example/src/App.js b/packages/sandy/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/sandy/example/src/App.js +++ b/packages/sandy/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/shin/example/src/App.js b/packages/shin/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/shin/example/src/App.js +++ b/packages/shin/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/simon/example/src/App.js b/packages/simon/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/simon/example/src/App.js +++ b/packages/simon/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/simone/example/src/App.js b/packages/simone/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/simone/example/src/App.js +++ b/packages/simone/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/sven/example/src/App.js b/packages/sven/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/sven/example/src/App.js +++ b/packages/sven/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/tamiko/example/src/App.js b/packages/tamiko/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/tamiko/example/src/App.js +++ b/packages/tamiko/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/teagan/example/src/App.js b/packages/teagan/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/teagan/example/src/App.js +++ b/packages/teagan/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/theo/example/src/App.js b/packages/theo/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/theo/example/src/App.js +++ b/packages/theo/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/titan/example/src/App.js b/packages/titan/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/titan/example/src/App.js +++ b/packages/titan/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/trayvon/example/src/App.js b/packages/trayvon/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/trayvon/example/src/App.js +++ b/packages/trayvon/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/tutorial/example/src/App.js b/packages/tutorial/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/tutorial/example/src/App.js +++ b/packages/tutorial/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/wahid/example/src/App.js b/packages/wahid/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/wahid/example/src/App.js +++ b/packages/wahid/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( ) diff --git a/packages/waralee/example/src/App.js b/packages/waralee/example/src/App.js index 562ad9dabc0..a75d65e2787 100644 --- a/packages/waralee/example/src/App.js +++ b/packages/waralee/example/src/App.js @@ -16,11 +16,18 @@ const App = (props) => { } */ + // Adds support for loading an external pattern configuration + let recreate + if (window) recreate = window.location.pathname.substr(1).split("/") + if (recreate.length === 3 && recreate[0] === 'from') recreate = { from: recreate[1], id: recreate[2] } + else recreate = false + return ( )