From 71a86a586a2de2437a393613770dbc8d640867cc Mon Sep 17 00:00:00 2001 From: cha0s Date: Sat, 19 Mar 2022 21:37:30 -0500 Subject: [PATCH] feat: sidebar --- packages/core/src/components/persea/index.jsx | 29 +++----- .../src/components/persea/index.module.scss | 2 +- .../src/components/persea/resource/index.jsx | 36 ++++++++++ .../persea/resource/index.module.scss | 16 +++++ .../persea/{ => resource}/login/index.jsx | 4 -- .../{ => resource}/login/index.module.scss | 16 ++--- .../persea/sidebar/content/index.jsx | 27 +++++++ .../persea/sidebar/content/index.module.scss | 14 ++++ .../components/persea/sidebar/icon/index.jsx | 41 +++++++++++ .../persea/sidebar/icon/index.module.scss | 32 +++++++++ .../components/persea/sidebar/icons/index.jsx | 21 ++++++ .../persea/sidebar/icons/index.module.scss | 5 ++ .../src/components/persea/sidebar/index.jsx | 58 +++++++++++++++ .../persea/sidebar/index.module.scss | 10 +++ .../src/components/project/bottom/index.jsx | 33 --------- .../project/bottom/index.module.scss | 46 ------------ .../components/project/bottom/settings.svg | 1 - .../project/organization/img/map.png | Bin 5617 -> 0 bytes packages/core/src/hooks/use-local-storage.js | 18 +++++ packages/core/src/index.js | 9 ++- .../core/src/sidebar/organization/content.jsx | 29 ++++++++ .../sidebar/organization/content.module.scss | 6 ++ .../sidebar/organization/icon_document.svg | 48 +++++++++++++ .../core/src/sidebar/organization/index.js | 8 +++ .../organization}/organization/actions.jsx | 0 .../organization/img/collapse-all.svg | 0 .../organization}/organization/img/image.png | Bin .../organization/img/joystick.png | Bin .../organization/organization/img}/map.png | Bin .../organization}/organization/img/music.png | Bin .../organization/img/new-file.svg | 0 .../organization/img/new-folder.svg | 0 .../organization}/organization/img/note.png | Bin .../organization/img/question.png | Bin .../organization}/organization/img/script.png | Bin .../organization}/organization/img/sound.png | Bin .../organization}/organization/index.jsx | 7 +- .../organization}/organization/index.scss | 68 +++++++++--------- .../core/src/sidebar/projects/content.jsx | 49 +++++++++++++ .../src/sidebar/projects/content.module.scss | 44 ++++++++++++ .../core/src/sidebar/projects/icon_books.svg | 49 +++++++++++++ packages/core/src/sidebar/projects/index.js | 8 +++ packages/core/src/state/index.js | 3 + packages/core/src/state/project.js | 29 ++++++++ packages/core/src/state/projects.js | 4 +- 45 files changed, 614 insertions(+), 156 deletions(-) create mode 100644 packages/core/src/components/persea/resource/index.jsx create mode 100644 packages/core/src/components/persea/resource/index.module.scss rename packages/core/src/components/persea/{ => resource}/login/index.jsx (78%) rename packages/core/src/components/persea/{ => resource}/login/index.module.scss (82%) create mode 100644 packages/core/src/components/persea/sidebar/content/index.jsx create mode 100644 packages/core/src/components/persea/sidebar/content/index.module.scss create mode 100644 packages/core/src/components/persea/sidebar/icon/index.jsx create mode 100644 packages/core/src/components/persea/sidebar/icon/index.module.scss create mode 100644 packages/core/src/components/persea/sidebar/icons/index.jsx create mode 100644 packages/core/src/components/persea/sidebar/icons/index.module.scss create mode 100644 packages/core/src/components/persea/sidebar/index.jsx create mode 100644 packages/core/src/components/persea/sidebar/index.module.scss delete mode 100644 packages/core/src/components/project/bottom/index.jsx delete mode 100644 packages/core/src/components/project/bottom/index.module.scss delete mode 100644 packages/core/src/components/project/bottom/settings.svg delete mode 100644 packages/core/src/components/project/organization/img/map.png create mode 100644 packages/core/src/hooks/use-local-storage.js create mode 100644 packages/core/src/sidebar/organization/content.jsx create mode 100644 packages/core/src/sidebar/organization/content.module.scss create mode 100644 packages/core/src/sidebar/organization/icon_document.svg create mode 100644 packages/core/src/sidebar/organization/index.js rename packages/core/src/{components/project => sidebar/organization}/organization/actions.jsx (100%) rename packages/core/src/{components/project => sidebar/organization}/organization/img/collapse-all.svg (100%) rename packages/core/src/{components/project => sidebar/organization}/organization/img/image.png (100%) rename packages/core/src/{components/project => sidebar/organization}/organization/img/joystick.png (100%) rename packages/core/src/{components/project/bottom => sidebar/organization/organization/img}/map.png (100%) rename packages/core/src/{components/project => sidebar/organization}/organization/img/music.png (100%) rename packages/core/src/{components/project => sidebar/organization}/organization/img/new-file.svg (100%) rename packages/core/src/{components/project => sidebar/organization}/organization/img/new-folder.svg (100%) rename packages/core/src/{components/project => sidebar/organization}/organization/img/note.png (100%) rename packages/core/src/{components/project => sidebar/organization}/organization/img/question.png (100%) rename packages/core/src/{components/project => sidebar/organization}/organization/img/script.png (100%) rename packages/core/src/{components/project => sidebar/organization}/organization/img/sound.png (100%) rename packages/core/src/{components/project => sidebar/organization}/organization/index.jsx (96%) rename packages/core/src/{components/project => sidebar/organization}/organization/index.scss (51%) create mode 100644 packages/core/src/sidebar/projects/content.jsx create mode 100644 packages/core/src/sidebar/projects/content.module.scss create mode 100644 packages/core/src/sidebar/projects/icon_books.svg create mode 100644 packages/core/src/sidebar/projects/index.js create mode 100644 packages/core/src/state/project.js diff --git a/packages/core/src/components/persea/index.jsx b/packages/core/src/components/persea/index.jsx index e4a1a38..c0d0bc8 100644 --- a/packages/core/src/components/persea/index.jsx +++ b/packages/core/src/components/persea/index.jsx @@ -2,36 +2,23 @@ import { React, hot, } from '@flecks/react'; -// import { -// Navigate, -// Route, -// Routes, -// } from '@flecks/react/router'; -// import {useSelector} from '@flecks/redux'; -// import {userIdSelector} from '@flecks/user'; import './global.scss'; import styles from './index.module.scss'; -// import Dashboard from '../dashboard'; -import Login from './login'; -// import ProjectRoute from '../project/route'; +import useLocalStorage from '../../hooks/use-local-storage'; +import Resource from './resource'; +import Sidebar from './sidebar'; -// eslint-disable-next-line arrow-body-style -const Persea = () => { - // const isLoggedIn = useSelector(userIdSelector); +function Persea() { + const [expanded, setExpanded] = useLocalStorage('@persea/core/expanded', true); return (
- - {/* - } /> - : } /> - } /> - } /> - */} + +
); -}; +} Persea.displayName = 'Persea'; diff --git a/packages/core/src/components/persea/index.module.scss b/packages/core/src/components/persea/index.module.scss index b1586c3..0384176 100644 --- a/packages/core/src/components/persea/index.module.scss +++ b/packages/core/src/components/persea/index.module.scss @@ -1,5 +1,5 @@ - .persea { + display: flex; height: 100vh; width: 100vw; } diff --git a/packages/core/src/components/persea/resource/index.jsx b/packages/core/src/components/persea/resource/index.jsx new file mode 100644 index 0000000..589baf4 --- /dev/null +++ b/packages/core/src/components/persea/resource/index.jsx @@ -0,0 +1,36 @@ +import {classnames, PropTypes, React} from '@flecks/react'; +import {useSelector} from '@flecks/redux'; + +import styles from './index.module.scss'; + +import {projectsSelector} from '../../../state/projects'; +import Login from './login'; + +function Resource({expanded}) { + const {structure} = useSelector(projectsSelector); + const projects = Object.entries(structure); + return ( +
+ { + projects.length > 0 + ?

{projects.length}

+ : ( +
+

You must log in to access your projects.

+ +
+ ) + } +
+ ); +} + +Resource.defaultProps = {}; + +Resource.displayName = 'Resource'; + +Resource.propTypes = { + expanded: PropTypes.bool.isRequired, +}; + +export default Resource; diff --git a/packages/core/src/components/persea/resource/index.module.scss b/packages/core/src/components/persea/resource/index.module.scss new file mode 100644 index 0000000..efbb350 --- /dev/null +++ b/packages/core/src/components/persea/resource/index.module.scss @@ -0,0 +1,16 @@ +.resource { + background-color: #1a1a1a; + height: 100%; + width: calc(100% - 3rem); + + &.expanded { + width: calc(100% - 25rem); + } + + .login { + p { + margin: 3em; + text-align: center; + } + } +} diff --git a/packages/core/src/components/persea/login/index.jsx b/packages/core/src/components/persea/resource/login/index.jsx similarity index 78% rename from packages/core/src/components/persea/login/index.jsx rename to packages/core/src/components/persea/resource/login/index.jsx index 6c0872c..49030c0 100644 --- a/packages/core/src/components/persea/login/index.jsx +++ b/packages/core/src/components/persea/resource/login/index.jsx @@ -6,10 +6,6 @@ import styles from './index.module.scss'; function Login() { return (
-
-

Sign in

-

You must sign in to continue

-
); diff --git a/packages/core/src/components/persea/login/index.module.scss b/packages/core/src/components/persea/resource/login/index.module.scss similarity index 82% rename from packages/core/src/components/persea/login/index.module.scss rename to packages/core/src/components/persea/resource/login/index.module.scss index 6c34019..f3ca7ff 100644 --- a/packages/core/src/components/persea/login/index.module.scss +++ b/packages/core/src/components/persea/resource/login/index.module.scss @@ -1,16 +1,6 @@ .login { margin: auto; max-width: 60%; - padding-top: 5%; - - > div { - text-align: center; - padding-bottom: 2em; - - h2 { - padding-bottom: 1em; - } - } form { background-color: #272727; @@ -38,6 +28,7 @@ div { align-items: center; display: flex; + flex-wrap: wrap; justify-content: space-between; [type="checkbox"] { @@ -48,8 +39,9 @@ } label { - display: block; + display: inline-block; flex-direction: row; + width: auto; input, span { margin: 0; @@ -57,7 +49,7 @@ } a { - padding: 1em 1em 1em 0; + padding: 1em; text-decoration: none; white-space: nowrap; } diff --git a/packages/core/src/components/persea/sidebar/content/index.jsx b/packages/core/src/components/persea/sidebar/content/index.jsx new file mode 100644 index 0000000..a3aab29 --- /dev/null +++ b/packages/core/src/components/persea/sidebar/content/index.jsx @@ -0,0 +1,27 @@ +import {PropTypes, React} from '@flecks/react'; + +import styles from './index.module.scss'; + +function Content({Content, name}) { + return ( +
+ {Content && ( + <> +

{name}

+ {Content} + + )} +
+ ); +} + +Content.defaultProps = {}; + +Content.displayName = 'Content'; + +Content.propTypes = { + Content: PropTypes.node.isRequired, + name: PropTypes.string.isRequired, +}; + +export default Content; diff --git a/packages/core/src/components/persea/sidebar/content/index.module.scss b/packages/core/src/components/persea/sidebar/content/index.module.scss new file mode 100644 index 0000000..f75a84b --- /dev/null +++ b/packages/core/src/components/persea/sidebar/content/index.module.scss @@ -0,0 +1,14 @@ +.content { + background-color: #272727; + height: 100%; + overflow: auto; + width: calc(100% - 3rem); +} + +.name { + color: #ccc; + font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; + font-size: 0.8em; + padding: 1em; + text-transform: uppercase; +} diff --git a/packages/core/src/components/persea/sidebar/icon/index.jsx b/packages/core/src/components/persea/sidebar/icon/index.jsx new file mode 100644 index 0000000..811f8b1 --- /dev/null +++ b/packages/core/src/components/persea/sidebar/icon/index.jsx @@ -0,0 +1,41 @@ +import {classnames, PropTypes, React} from '@flecks/react'; + +import styles from './index.module.scss'; + +function Icon({ + className, + isActive, + name, + onClick, +}) { + return ( +