From 4da1e1f9ff65f27957a501f7a5f4ffb64082fef4 Mon Sep 17 00:00:00 2001 From: cha0s Date: Thu, 25 Mar 2021 04:15:32 -0500 Subject: [PATCH] feat: ui res --- latus.yml | 6 +-- packages/core/src/client.js | 5 +++ packages/core/src/components/app/index.jsx | 16 ++++---- .../src/components/{ => app}/login/index.jsx | 0 .../src/components/{ => app}/title/index.jsx | 0 .../src/components/{ => app}/title/index.scss | 0 .../{ => app}/title/local/index.jsx | 0 .../{ => app}/title/local/index.scss | 0 .../components/{ => app}/title/main/index.jsx | 0 .../{ => app}/title/main/index.scss | 0 .../{ => app}/title/remote/index.jsx | 0 .../{ => app}/title/remote/index.scss | 0 .../src/components/{ => app}/title/rooted.jpg | Bin .../{ => app}/title/universes/index.jsx | 0 .../{ => app}/title/universes/index.scss | 0 .../title/universes/universe/index.jsx | 0 .../title/universes/universe/index.scss | 0 .../core/src/components/valent-ui/context.js | 3 ++ .../core/src/components/valent-ui/index.jsx | 13 +++--- packages/core/src/index.js | 5 ++- packages/universe/src/components/index.jsx | 37 +++++++----------- 21 files changed, 41 insertions(+), 44 deletions(-) rename packages/core/src/components/{ => app}/login/index.jsx (100%) rename packages/core/src/components/{ => app}/title/index.jsx (100%) rename packages/core/src/components/{ => app}/title/index.scss (100%) rename packages/core/src/components/{ => app}/title/local/index.jsx (100%) rename packages/core/src/components/{ => app}/title/local/index.scss (100%) rename packages/core/src/components/{ => app}/title/main/index.jsx (100%) rename packages/core/src/components/{ => app}/title/main/index.scss (100%) rename packages/core/src/components/{ => app}/title/remote/index.jsx (100%) rename packages/core/src/components/{ => app}/title/remote/index.scss (100%) rename packages/core/src/components/{ => app}/title/rooted.jpg (100%) rename packages/core/src/components/{ => app}/title/universes/index.jsx (100%) rename packages/core/src/components/{ => app}/title/universes/index.scss (100%) rename packages/core/src/components/{ => app}/title/universes/universe/index.jsx (100%) rename packages/core/src/components/{ => app}/title/universes/universe/index.scss (100%) create mode 100644 packages/core/src/components/valent-ui/context.js diff --git a/latus.yml b/latus.yml index 50f7b62..32f5563 100644 --- a/latus.yml +++ b/latus.yml @@ -41,11 +41,7 @@ ], port: 32350, } -'@latus/react': { - providers: [ - '@latus/redux/client', - ], -} +'@latus/react': {} '@latus/redis': {} '@latus/redis/server': { docker: 'cached', diff --git a/packages/core/src/client.js b/packages/core/src/client.js index 8735085..0065f04 100644 --- a/packages/core/src/client.js +++ b/packages/core/src/client.js @@ -2,10 +2,15 @@ import {connectRouter, routerMiddleware} from 'connected-react-router'; import App from './components/app'; import history from './components/app/history'; +import ValentUiContext from './components/valent-ui/context'; export default { hooks: { '@latus/react/components': () => App, + '@latus/react/providers': async (latus) => [ + ValentUiContext.Provider, + {value: latus.get('@humus/core.resolution')}, + ], '@latus/redux/slices': () => ({ router: connectRouter(history), }), diff --git a/packages/core/src/components/app/index.jsx b/packages/core/src/components/app/index.jsx index cf7ba43..7cc1f23 100644 --- a/packages/core/src/components/app/index.jsx +++ b/packages/core/src/components/app/index.jsx @@ -4,7 +4,9 @@ import './index.scss'; import {hot} from 'react-hot-loader'; // import {Universe} from '@humus/universe'; -import {React} from '@latus/react'; +import { + React, +} from '@latus/react'; import {ConnectedRouter} from 'connected-react-router'; import { Redirect, @@ -13,15 +15,13 @@ import { } from 'react-router-dom'; import useIsNative from '../../hooks/use-is-native'; +import Ui from '../valent-ui'; -import Login from '../login'; -import Title from '../title'; +import Login from './login'; +import Title from './title'; import history from './history'; -// const WIDTH = 1600; -// const HEIGHT = 900; - const isLoggedIn = true; const Humus = () => { @@ -34,7 +34,9 @@ const Humus = () => { {isLoggedIn ? : Login} {/* */} - {isNative ? </Route> : <Redirect to="/universe" />} + <Ui> + {isNative ? <Route path="/title"><Title /></Route> : <Redirect to="/universe" />} + </Ui> </Switch> <Route exact path="/"> <Redirect to="/title" /> diff --git a/packages/core/src/components/login/index.jsx b/packages/core/src/components/app/login/index.jsx similarity index 100% rename from packages/core/src/components/login/index.jsx rename to packages/core/src/components/app/login/index.jsx diff --git a/packages/core/src/components/title/index.jsx b/packages/core/src/components/app/title/index.jsx similarity index 100% rename from packages/core/src/components/title/index.jsx rename to packages/core/src/components/app/title/index.jsx diff --git a/packages/core/src/components/title/index.scss b/packages/core/src/components/app/title/index.scss similarity index 100% rename from packages/core/src/components/title/index.scss rename to packages/core/src/components/app/title/index.scss diff --git a/packages/core/src/components/title/local/index.jsx b/packages/core/src/components/app/title/local/index.jsx similarity index 100% rename from packages/core/src/components/title/local/index.jsx rename to packages/core/src/components/app/title/local/index.jsx diff --git a/packages/core/src/components/title/local/index.scss b/packages/core/src/components/app/title/local/index.scss similarity index 100% rename from packages/core/src/components/title/local/index.scss rename to packages/core/src/components/app/title/local/index.scss diff --git a/packages/core/src/components/title/main/index.jsx b/packages/core/src/components/app/title/main/index.jsx similarity index 100% rename from packages/core/src/components/title/main/index.jsx rename to packages/core/src/components/app/title/main/index.jsx diff --git a/packages/core/src/components/title/main/index.scss b/packages/core/src/components/app/title/main/index.scss similarity index 100% rename from packages/core/src/components/title/main/index.scss rename to packages/core/src/components/app/title/main/index.scss diff --git a/packages/core/src/components/title/remote/index.jsx b/packages/core/src/components/app/title/remote/index.jsx similarity index 100% rename from packages/core/src/components/title/remote/index.jsx rename to packages/core/src/components/app/title/remote/index.jsx diff --git a/packages/core/src/components/title/remote/index.scss b/packages/core/src/components/app/title/remote/index.scss similarity index 100% rename from packages/core/src/components/title/remote/index.scss rename to packages/core/src/components/app/title/remote/index.scss diff --git a/packages/core/src/components/title/rooted.jpg b/packages/core/src/components/app/title/rooted.jpg similarity index 100% rename from packages/core/src/components/title/rooted.jpg rename to packages/core/src/components/app/title/rooted.jpg diff --git a/packages/core/src/components/title/universes/index.jsx b/packages/core/src/components/app/title/universes/index.jsx similarity index 100% rename from packages/core/src/components/title/universes/index.jsx rename to packages/core/src/components/app/title/universes/index.jsx diff --git a/packages/core/src/components/title/universes/index.scss b/packages/core/src/components/app/title/universes/index.scss similarity index 100% rename from packages/core/src/components/title/universes/index.scss rename to packages/core/src/components/app/title/universes/index.scss diff --git a/packages/core/src/components/title/universes/universe/index.jsx b/packages/core/src/components/app/title/universes/universe/index.jsx similarity index 100% rename from packages/core/src/components/title/universes/universe/index.jsx rename to packages/core/src/components/app/title/universes/universe/index.jsx diff --git a/packages/core/src/components/title/universes/universe/index.scss b/packages/core/src/components/app/title/universes/universe/index.scss similarity index 100% rename from packages/core/src/components/title/universes/universe/index.scss rename to packages/core/src/components/app/title/universes/universe/index.scss diff --git a/packages/core/src/components/valent-ui/context.js b/packages/core/src/components/valent-ui/context.js new file mode 100644 index 0000000..3ce5856 --- /dev/null +++ b/packages/core/src/components/valent-ui/context.js @@ -0,0 +1,3 @@ +import {createContext} from '@latus/react'; + +export default createContext(undefined); diff --git a/packages/core/src/components/valent-ui/index.jsx b/packages/core/src/components/valent-ui/index.jsx index 2b3d098..89ee944 100644 --- a/packages/core/src/components/valent-ui/index.jsx +++ b/packages/core/src/components/valent-ui/index.jsx @@ -1,11 +1,15 @@ import { PropTypes, React, + useContext, useEffect, useRef, } from '@latus/react'; -const ValentUi = ({children, width, height}) => { +import Context from './context'; + +const ValentUi = ({children}) => { + const [width, height] = useContext(Context); const $ui = useRef(); useEffect(() => { if (!$ui.current) { @@ -45,15 +49,8 @@ const ValentUi = ({children, width, height}) => { ); }; -ValentUi.defaultProps = { - height: 450, - width: 800, -}; - ValentUi.propTypes = { children: PropTypes.node.isRequired, - height: PropTypes.number, - width: PropTypes.number, }; export default ValentUi; diff --git a/packages/core/src/index.js b/packages/core/src/index.js index d987d05..0f9c49c 100644 --- a/packages/core/src/index.js +++ b/packages/core/src/index.js @@ -2,7 +2,7 @@ import {gatherWithLatus} from '@latus/core'; import {selfEntity} from './state'; -export {default as ValentUi} from './components/valent-ui'; +export {default as Ui} from './components/valent-ui'; export * from './hooks'; export * from './state'; @@ -12,6 +12,9 @@ export default { '@avocado/traits/traits': gatherWithLatus( require.context('./traits', false, /\.js$/), ), + '@latus/core/config': () => ({ + resolution: [1600, 900], + }), '@latus/redux/slices': () => ({ selfEntity, }), diff --git a/packages/universe/src/components/index.jsx b/packages/universe/src/components/index.jsx index 50dc164..cbb9feb 100644 --- a/packages/universe/src/components/index.jsx +++ b/packages/universe/src/components/index.jsx @@ -1,5 +1,5 @@ -import {ValentUi} from '@humus/core'; -import {PropTypes, React} from '@latus/react'; +import {Ui} from '@humus/core'; +import {React} from '@latus/react'; import { Route, Switch, @@ -9,29 +9,20 @@ import Overview from './overview'; import PlayRenderable from './play/renderable'; import PlayUi from './play/ui'; -const Universe = ({ - height, - width, -// eslint-disable-next-line arrow-body-style -}) => { - return ( - <Route path="/universe"> +const Universe = () => ( + <Route path="/universe"> + <Switch> + <Route path="/universe/:uuid/play" component={PlayRenderable} /> + </Switch> + <Ui> <Switch> - <Route path="/universe/:uuid/play" component={PlayRenderable} /> + <Route path="/universe/:uuid/play" component={PlayUi} /> + <Route path={['/universe/:uuid', '/universe']} component={Overview} /> </Switch> - <ValentUi width={width} height={height}> - <Switch> - <Route path="/universe/:uuid/play" component={PlayUi} /> - <Route path={['/universe/:uuid', '/universe']} component={Overview} /> - </Switch> - </ValentUi> - </Route> - ); -}; + </Ui> + </Route> +); -Universe.propTypes = { - height: PropTypes.number.isRequired, - width: PropTypes.number.isRequired, -}; +Universe.propTypes = {}; export default Universe;