From 26c076710facea31830d5a7a0834b754832f56ff Mon Sep 17 00:00:00 2001 From: Sergio Betanzos Date: Tue, 25 Aug 2020 21:59:35 +0200 Subject: [PATCH] F #3951: Update internal grid layout (#165) * Fix sidebar component * Add responsive sidebar * Update internal grid layout --- src/fireedge/src/public/app.js | 4 +- src/fireedge/src/public/assets/theme.js | 23 +++- .../src/public/components/Footer/index.js | 16 +-- .../src/public/components/Footer/styles.js | 19 ++++ .../components/FormControl/InputCode.js | 9 +- .../components/FormControl/SubmitButton.js | 19 +++- .../public/components/HOC/InternalLayout.js | 49 +++++++-- .../src/public/components/Header/User.js | 34 +++--- .../src/public/components/Header/Zone.js | 20 ++-- .../components/Sidebar/SidebarCollapseItem.js | 52 +++++++++ .../public/components/Sidebar/SidebarLink.js | 63 +++++++++++ .../src/public/components/Sidebar/index.js | 101 ++++++------------ .../src/public/components/Sidebar/styles.js | 39 +++++-- .../src/public/containers/Dashboard/index.js | 17 ++- .../src/public/containers/Login/FormUser.js | 1 + .../src/public/containers/Login/styles.js | 3 +- .../public/containers/TestApi/ResponseForm.js | 23 ++-- .../src/public/containers/TestApi/index.js | 6 +- src/fireedge/src/public/router/endpoints.js | 2 + src/fireedge/src/public/router/index.js | 63 +++++------ src/fireedge/src/public/scss/content.scss | 18 ---- src/fireedge/src/public/scss/footer.scss | 29 ----- src/fireedge/src/public/scss/login.scss | 14 --- src/fireedge/src/public/scss/main.scss | 29 ----- src/fireedge/src/public/scss/menu.scss | 34 ------ 25 files changed, 369 insertions(+), 318 deletions(-) create mode 100644 src/fireedge/src/public/components/Footer/styles.js create mode 100644 src/fireedge/src/public/components/Sidebar/SidebarCollapseItem.js create mode 100644 src/fireedge/src/public/components/Sidebar/SidebarLink.js delete mode 100644 src/fireedge/src/public/scss/content.scss delete mode 100644 src/fireedge/src/public/scss/footer.scss delete mode 100644 src/fireedge/src/public/scss/login.scss delete mode 100644 src/fireedge/src/public/scss/menu.scss diff --git a/src/fireedge/src/public/app.js b/src/fireedge/src/public/app.js index ecee3936f5..31dd644b60 100644 --- a/src/fireedge/src/public/app.js +++ b/src/fireedge/src/public/app.js @@ -13,7 +13,7 @@ /* limitations under the License. */ /* -------------------------------------------------------------------------- */ -import React from 'react'; +import React, { useEffect } from 'react'; import { StaticRouter, BrowserRouter } from 'react-router-dom'; import { Provider } from 'react-redux'; import PropTypes from 'prop-types'; @@ -25,7 +25,7 @@ import { TranslateProvider } from 'client/components/HOC'; import Router from 'client/router'; const App = ({ location, context, store }) => { - React.useEffect(() => { + useEffect(() => { const jssStyles = document.querySelector('#jss-server-side'); if (jssStyles) { jssStyles.parentElement.removeChild(jssStyles); diff --git a/src/fireedge/src/public/assets/theme.js b/src/fireedge/src/public/assets/theme.js index dea919bb62..5eedfe133f 100644 --- a/src/fireedge/src/public/assets/theme.js +++ b/src/fireedge/src/public/assets/theme.js @@ -1,10 +1,31 @@ import { createMuiTheme, responsiveFontSizes } from '@material-ui/core'; +const defaultBreakpoints = { + xs: 0, + sm: 600, + md: 960, + lg: 1280, + xl: 1920, + // DEVICES + tablet: 640, + laptop: 1024, + desktop: 1280 +}; + const theme = createMuiTheme({ typography: { fontFamily: ['Ubuntu', 'Lato'].join(',') }, overrides: { + MuiDrawer: { + paper: { + width: 360, + overflow: 'hidden', + [`@media (max-width: ${defaultBreakpoints.tablet}px)`]: { + width: '100%' + } + } + }, MuiFormControl: { root: { margin: '.5rem 0' @@ -47,7 +68,7 @@ const theme = createMuiTheme({ MuiCssBaseline: { '@global': { body: { - height: '100vh' + // height: '100vh' } // '@font-face': [UbuntuFont] } diff --git a/src/fireedge/src/public/components/Footer/index.js b/src/fireedge/src/public/components/Footer/index.js index 49138f4db1..cc11e4d636 100644 --- a/src/fireedge/src/public/components/Footer/index.js +++ b/src/fireedge/src/public/components/Footer/index.js @@ -14,22 +14,24 @@ /* -------------------------------------------------------------------------- */ import React from 'react'; -import { Box, Link, useTheme } from '@material-ui/core'; -import classnames from 'classnames'; +import { Box, Link } from '@material-ui/core'; +import footerStyles from 'client/components/Footer/styles'; import { by } from 'client/constants'; const { text, url } = by; -const Footer = () => { - const theme = useTheme(); +const Footer = React.memo(() => { + const classes = footerStyles(); return ( - + {`❤️ by `} - {text} + + {text} + ); -}; +}); export default Footer; diff --git a/src/fireedge/src/public/components/Footer/styles.js b/src/fireedge/src/public/components/Footer/styles.js new file mode 100644 index 0000000000..a616d4e49f --- /dev/null +++ b/src/fireedge/src/public/components/Footer/styles.js @@ -0,0 +1,19 @@ +import { makeStyles } from '@material-ui/core'; + +export default makeStyles(theme => ({ + footer: { + color: theme.palette.primary.light, + position: 'fixed', + bottom: 0, + left: 'auto', + right: 0, + width: '100%', + zIndex: 1100, + backgroundColor: theme.palette.grey[800], + textAlign: 'center', + padding: 5 + }, + link: { + color: theme.palette.primary.light + } +})); diff --git a/src/fireedge/src/public/components/FormControl/InputCode.js b/src/fireedge/src/public/components/FormControl/InputCode.js index eb964b5298..0a0454d0cb 100644 --- a/src/fireedge/src/public/components/FormControl/InputCode.js +++ b/src/fireedge/src/public/components/FormControl/InputCode.js @@ -13,7 +13,7 @@ const InputCode = ({ code, language, ...props }) => { }; return ( - + { mode="json" theme="github" width="100%" - maxLines={Infinity} - minLines={50} + height="100%" + // maxLines={Infinity} + minLines={10} onChange={handleChange} - name="UNIQUE_ID_OF_DIV" + name="form-control-code" showPrintMargin={false} editorProps={{ $blockScrolling: true }} setOptions={{ diff --git a/src/fireedge/src/public/components/FormControl/SubmitButton.js b/src/fireedge/src/public/components/FormControl/SubmitButton.js index 2ffc0c23e3..7c7635df3b 100644 --- a/src/fireedge/src/public/components/FormControl/SubmitButton.js +++ b/src/fireedge/src/public/components/FormControl/SubmitButton.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import { makeStyles, CircularProgress, Button } from '@material-ui/core'; @@ -12,7 +13,7 @@ const useStyles = makeStyles(theme => ({ } })); -export default function ButtonSubmit({ isSubmitting, label, ...rest }) { +const ButtonSubmit = ({ isSubmitting, label, ...rest }) => { const classes = useStyles(); return ( @@ -25,7 +26,19 @@ export default function ButtonSubmit({ isSubmitting, label, ...rest }) { {...rest} > {isSubmitting && } - {!isSubmitting && (label ?? )} + {!isSubmitting && } ); -} +}; + +ButtonSubmit.propTypes = { + isSubmitting: PropTypes.bool, + label: PropTypes.string +}; + +ButtonSubmit.defaultProps = { + isSubmitting: false, + label: CONSTANT.default.Submit +}; + +export default ButtonSubmit; diff --git a/src/fireedge/src/public/components/HOC/InternalLayout.js b/src/fireedge/src/public/components/HOC/InternalLayout.js index 7f6c0be120..e6042f167e 100644 --- a/src/fireedge/src/public/components/HOC/InternalLayout.js +++ b/src/fireedge/src/public/components/HOC/InternalLayout.js @@ -16,16 +16,45 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { Box, Container } from '@material-ui/core'; +import { makeStyles, Box, Container } from '@material-ui/core'; import { Skeleton } from '@material-ui/lab'; import useAuth from 'client/hooks/useAuth'; import useOpenNebula from 'client/hooks/useOpennebula'; import Header from 'client/components/Header'; import Footer from 'client/components/Footer'; -import Sidebar from 'client/components/Sidebar'; + +const internalStyles = makeStyles(theme => ({ + root: { + display: 'flex', + width: '100%' + }, + main: { + paddingTop: 64, + paddingBottom: 30, + height: '100vh', + width: '100vw' + }, + scrollable: { + paddingTop: theme.spacing(2), + paddingBottom: theme.spacing(2), + height: '100%', + overflow: 'auto', + '&::-webkit-scrollbar': { + width: 14 + }, + '&::-webkit-scrollbar-thumb': { + backgroundClip: 'content-box', + border: '4px solid transparent', + borderRadius: 7, + boxShadow: 'inset 0 0 0 10px', + color: theme.palette.primary.light + } + } +})); const InternalLayout = ({ children, title }) => { + const classes = internalStyles(); const { groups } = useOpenNebula(); const { authUser } = useAuth(); @@ -39,17 +68,15 @@ const InternalLayout = ({ children, title }) => { ) : ( - + <>
- - - {children} - + + + {children} + +