Skip to content

Free Motion Capture for Everyone 💀✨

TypeScript

add "Paperbase theme to frontend"

Endurance Idehenf5e098a68289
diff --git a/freemocap-ui/.gitignore b/freemocap-ui/.gitignore
index 4d29575d..e8f838c8 100644
--- a/freemocap-ui/.gitignore
+++ b/freemocap-ui/.gitignore
@@ -21,3 +21,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
+
+# Ignore .pems
+*.pem
\ No newline at end of file
diff --git a/freemocap-ui/README.md b/freemocap-ui/README.md
index 623c7096..49fc5387 100644
--- a/freemocap-ui/README.md
+++ b/freemocap-ui/README.md
@@ -42,3 +42,8 @@ You don’t have to ever use `eject`. The curated feature set is suitable for sm
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
+
+
+## Relevant links
+
+- https://web.dev/how-to-use-local-https/
\ No newline at end of file
diff --git a/freemocap-ui/package.json b/freemocap-ui/package.json
index b0d67065..498688c0 100644
--- a/freemocap-ui/package.json
+++ b/freemocap-ui/package.json
@@ -3,7 +3,12 @@
"version": "0.1.0",
"private": true,
"dependencies": {
+ "@emotion/react": "^11.7.1",
+ "@emotion/styled": "^11.6.0",
+ "@mui/icons-material": "^5.2.5",
"@mui/material": "^5.2.8",
+ "@mui/styled-engine": "^5.2.6",
+ "@mui/system": "^5.2.8",
"@reduxjs/toolkit": "^1.7.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
@@ -17,10 +22,13 @@
"react-dom": "^17.0.2",
"react-redux": "^7.2.6",
"react-scripts": "5.0.0",
+ "react-webcam": "^6.0.0",
"typescript": "~4.1.5"
},
"scripts": {
"start": "react-scripts start",
+ "start:https": "HTTPS=true SSL_CRT_FILE=./localhost.pem SSL_KEY_FILE=./localhost-key.pem react-scripts start",
+ "certs": "./scripts/cert.sh",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
diff --git a/freemocap-ui/scripts/cert.sh b/freemocap-ui/scripts/cert.sh
new file mode 100755
index 00000000..619976f2
--- /dev/null
+++ b/freemocap-ui/scripts/cert.sh
@@ -0,0 +1,2 @@
+mkcert -install
+mkcert localhost
diff --git a/freemocap-ui/src/App.tsx b/freemocap-ui/src/App.tsx
index 38ec99fe..238c7a01 100644
--- a/freemocap-ui/src/App.tsx
+++ b/freemocap-ui/src/App.tsx
@@ -1,60 +1,12 @@
import React from 'react';
-import logo from './logo.svg';
-import { Counter } from './features/counter/Counter';
-import './App.css';
import {CssBaseline} from "@mui/material";
+import {Paperbase} from "./layout/Paperbase";
function App() {
return (
<React.Fragment>
<CssBaseline />
- <div className="App">
- <header className="App-header">
- <img src={logo} className="App-logo" alt="logo" />
- <Counter />
- <p>
- Edit <code>src/App.tsx</code> and save to reload.
- </p>
- <span>
- <span>Learn </span>
- <a
- className="App-link"
- href="https://reactjs.org/"
- target="_blank"
- rel="noopener noreferrer"
- >
- React
- </a>
- <span>, </span>
- <a
- className="App-link"
- href="https://redux.js.org/"
- target="_blank"
- rel="noopener noreferrer"
- >
- Redux
- </a>
- <span>, </span>
- <a
- className="App-link"
- href="https://redux-toolkit.js.org/"
- target="_blank"
- rel="noopener noreferrer"
- >
- Redux Toolkit
- </a>
- ,<span> and </span>
- <a
- className="App-link"
- href="https://react-redux.js.org/"
- target="_blank"
- rel="noopener noreferrer"
- >
- React Redux
- </a>
- </span>
- </header>
- </div>
+ <Paperbase />
</React.Fragment>
);
}
diff --git a/freemocap-ui/src/layout/Content.tsx b/freemocap-ui/src/layout/Content.tsx
new file mode 100644
index 00000000..c9cc962f
--- /dev/null
+++ b/freemocap-ui/src/layout/Content.tsx
@@ -0,0 +1,57 @@
+import * as React from 'react';
+import AppBar from '@mui/material/AppBar';
+import Toolbar from '@mui/material/Toolbar';
+import Typography from '@mui/material/Typography';
+import Paper from '@mui/material/Paper';
+import Grid from '@mui/material/Grid';
+import Button from '@mui/material/Button';
+import TextField from '@mui/material/TextField';
+import Tooltip from '@mui/material/Tooltip';
+import IconButton from '@mui/material/IconButton';
+import SearchIcon from '@mui/icons-material/Search';
+import RefreshIcon from '@mui/icons-material/Refresh';
+
+export const Content = function() {
+ return (
+ <Paper sx={{ maxWidth: 936, margin: 'auto', overflow: 'hidden' }}>
+ <AppBar
+ position="static"
+ color="default"
+ elevation={0}
+ sx={{ borderBottom: '1px solid rgba(0, 0, 0, 0.12)' }}
+ >
+ <Toolbar>
+ <Grid container spacing={2} alignItems="center">
+ <Grid item>
+ <SearchIcon color="inherit" sx={{ display: 'block' }} />
+ </Grid>
+ <Grid item xs>
+ <TextField
+ fullWidth
+ placeholder="Search by email address, phone number, or user UID"
+ InputProps={{
+ disableUnderline: true,
+ sx: { fontSize: 'default' },
+ }}
+ variant="standard"
+ />
+ </Grid>
+ <Grid item>
+ <Button variant="contained" sx={{ mr: 1 }}>
+ Add user
+ </Button>
+ <Tooltip title="Reload">
+ <IconButton>
+ <RefreshIcon color="inherit" sx={{ display: 'block' }} />
+ </IconButton>
+ </Tooltip>
+ </Grid>
+ </Grid>
+ </Toolbar>
+ </AppBar>
+ <Typography sx={{ my: 5, mx: 2 }} color="text.secondary" align="center">
+ No users for this project yet
+ </Typography>
+ </Paper>
+ );
+}
\ No newline at end of file
diff --git a/freemocap-ui/src/layout/Copyright.tsx b/freemocap-ui/src/layout/Copyright.tsx
new file mode 100644
index 00000000..fdb9468b
--- /dev/null
+++ b/freemocap-ui/src/layout/Copyright.tsx
@@ -0,0 +1,15 @@
+import Typography from "@mui/material/Typography";
+import Link from "@mui/material/Link";
+import * as React from "react";
+
+export const Copyright = function() {
+ return (
+ <Typography variant="body2" color="text.secondary" align="center">
+ {'Copyright © '}
+ <Link color="inherit" href="https://mui.com/">
+ FreeMoCap
+ </Link>{' '}
+ {new Date().getFullYear()}.
+ </Typography>
+ );
+}
diff --git a/freemocap-ui/src/layout/EmptyContent.tsx b/freemocap-ui/src/layout/EmptyContent.tsx
new file mode 100644
index 00000000..23de9125
--- /dev/null
+++ b/freemocap-ui/src/layout/EmptyContent.tsx
@@ -0,0 +1,16 @@
+import React from 'react';
+import {Paper} from "@mui/material";
+import {Header} from "./Header";
+import Box from "@mui/material/Box";
+
+export const EmptyContent = () => {
+ return (
+ <React.Fragment>
+ <Header title={"Something"} onDrawerToggle={() => {}} />
+ <Box sx={{ py: 6, px: 4, flex: 1, bgcolor: '#eaeff1' }}>
+ <Paper sx={{ maxWidth: 936, margin: 'auto', overflow: 'hidden' }}>
+ </Paper>
+ </Box>
+ </React.Fragment>
+ )
+}
\ No newline at end of file
diff --git a/freemocap-ui/src/layout/Header.tsx b/freemocap-ui/src/layout/Header.tsx
new file mode 100644
index 00000000..5658d558
--- /dev/null
+++ b/freemocap-ui/src/layout/Header.tsx
@@ -0,0 +1,78 @@
+import * as React from 'react';
+import AppBar from '@mui/material/AppBar';
+import Button from '@mui/material/Button';
+import Grid from '@mui/material/Grid';
+import HelpIcon from '@mui/icons-material/Help';
+import IconButton from '@mui/material/IconButton';
+import Link from '@mui/material/Link';
+import MenuIcon from '@mui/icons-material/Menu';
+import Toolbar from '@mui/material/Toolbar';
+import Tooltip from '@mui/material/Tooltip';
+import Typography from '@mui/material/Typography';
+
+const lightColor = 'rgba(255, 255, 255, 0.7)';
+
+interface HeaderProps {
+ onDrawerToggle: () => void;
+ title: string;
+}
+
+export const Header = function(props: HeaderProps) {
+ const { onDrawerToggle } = props;
+
+ return (
+ <React.Fragment>
+ <AppBar color="primary" position="sticky" elevation={0}>
+ <Toolbar>
+ <Grid container spacing={1} alignItems="center">
+ <Grid sx={{ display: { sm: 'none', xs: 'block' } }} item>
+ <IconButton
+ color="inherit"
+ aria-label="open drawer"
+ onClick={onDrawerToggle}
+ edge="start"
+ >
+ <MenuIcon />
+ </IconButton>
+ </Grid>
+ <Grid item xs />
+ <Grid item>
+ {/*<Link*/}
+ {/* href="/"*/}
+ {/* variant="body2"*/}
+ {/* sx={{*/}
+ {/* textDecoration: 'none',*/}
+ {/* color: lightColor,*/}
+ {/* '&:hover': {*/}
+ {/* color: 'common.white',*/}
+ {/* },*/}
+ {/* }}*/}
+ {/* rel="noopener noreferrer"*/}
+ {/* target="_blank"*/}
+ {/*>*/}
+ {/* Go to docs*/}
+ {/*</Link>*/}
+ </Grid>
+ </Grid>
+ </Toolbar>
+ </AppBar>
+ <AppBar
+ component="div"
+ color="primary"
+ position="static"
+ elevation={0}
+ sx={{ zIndex: 0 }}
+ >
+ <Toolbar>
+ <Grid container alignItems="center" spacing={1}>
+ <Grid item xs>
+ <Typography color="inherit" variant="h5" component="h1">
+ {props.title}
+ </Typography>
+ </Grid>
+ </Grid>
+ </Toolbar>
+ </AppBar>
+ </React.Fragment>
+ );
+}
\ No newline at end of file
diff --git a/freemocap-ui/src/layout/Navigator.tsx b/freemocap-ui/src/layout/Navigator.tsx
new file mode 100644
index 00000000..aeeb9f07
--- /dev/null
+++ b/freemocap-ui/src/layout/Navigator.tsx
@@ -0,0 +1,99 @@
+import * as React from 'react';
+import Divider from '@mui/material/Divider';
+import Drawer, { DrawerProps } from '@mui/material/Drawer';
+import List from '@mui/material/List';
+import Box from '@mui/material/Box';
+import ListItem from '@mui/material/ListItem';
+import ListItemButton from '@mui/material/ListItemButton';
+import ListItemIcon from '@mui/material/ListItemIcon';
+import ListItemText from '@mui/material/ListItemText';
+import HomeIcon from '@mui/icons-material/Home';
+import PeopleIcon from '@mui/icons-material/People';
+import DnsRoundedIcon from '@mui/icons-material/DnsRounded';
+import PermMediaOutlinedIcon from '@mui/icons-material/PhotoSizeSelectActual';
+import PublicIcon from '@mui/icons-material/Public';
+import SettingsEthernetIcon from '@mui/icons-material/SettingsEthernet';
+import SettingsInputComponentIcon from '@mui/icons-material/SettingsInputComponent';
+import TimerIcon from '@mui/icons-material/Timer';
+import SettingsIcon from '@mui/icons-material/Settings';
+import PhonelinkSetupIcon from '@mui/icons-material/PhonelinkSetup';
+
+const categories = [
+ {
+ id: 'Build',
+ children: [
+ {
+ id: 'Show Cameras',
+ icon: <PeopleIcon />,
+ active: true,
+ },
+ // { id: 'Database', icon: <DnsRoundedIcon /> },
+ // { id: 'Storage', icon: <PermMediaOutlinedIcon /> },
+ // { id: 'Hosting', icon: <PublicIcon /> },
+ // { id: 'Functions', icon: <SettingsEthernetIcon /> },
+ // {
+ // id: 'Machine learning',
+ // icon: <SettingsInputComponentIcon />,
+ // },
+ ],
+ },
+ // {
+ // id: 'Quality',
+ // children: [
+ // { id: 'Analytics', icon: <SettingsIcon /> },
+ // { id: 'Performance', icon: <TimerIcon /> },
+ // { id: 'Test Lab', icon: <PhonelinkSetupIcon /> },
+ // ],
+ // },
+];
+
+const item = {
+ py: '2px',
+ px: 3,
+ color: 'rgba(255, 255, 255, 0.7)',
+ '&:hover, &:focus': {
+ bgcolor: 'rgba(255, 255, 255, 0.08)',
+ },
+};
+
+const itemCategory = {
+ boxShadow: '0 -1px 0 rgb(255,255,255,0.1) inset',
+ py: 1.5,
+ px: 3,
+};
+
+export const Navigator = function(props: DrawerProps) {
+ const { ...other } = props;
+
+ return (
+ <Drawer variant="permanent" {...other}>
+ <List disablePadding>
+ <ListItem sx={{ ...item, ...itemCategory, fontSize: 22, color: '#fff' }}>
+ FreeMoCap
+ </ListItem>
+ <ListItem sx={{ ...item, ...itemCategory }}>
+ <ListItemIcon>
+ <HomeIcon />
+ </ListItemIcon>
+ <ListItemText>Overview</ListItemText>
+ </ListItem>
+ {categories.map(({ id, children }) => (
+ <Box key={id} sx={{ bgcolor: '#101F33' }}>
+ <ListItem sx={{ py: 2, px: 3 }}>
+ <ListItemText sx={{ color: '#fff' }}>{id}</ListItemText>
+ </ListItem>
+ {children.map(({ id: childId, icon, active }) => (
+ <ListItem disablePadding key={childId}>
+ <ListItemButton selected={active} sx={item}>
+ <ListItemIcon>{icon}</ListItemIcon>
+ <ListItemText>{childId}</ListItemText>
+ </ListItemButton>
+ </ListItem>
+ ))}
+ <Divider sx={{ mt: 2 }} />
+ </Box>
+ ))}
+ </List>
+ </Drawer>
+ );
+}
\ No newline at end of file
diff --git a/freemocap-ui/src/layout/Paperbase.tsx b/freemocap-ui/src/layout/Paperbase.tsx
new file mode 100644
index 00000000..8045f7d6
--- /dev/null
+++ b/freemocap-ui/src/layout/Paperbase.tsx
@@ -0,0 +1,194 @@
+import * as React from 'react';
+import { createTheme, ThemeProvider } from '@mui/material/styles';
+import useMediaQuery from '@mui/material/useMediaQuery';
+import Box from '@mui/material/Box';
+import { Navigator } from './Navigator';
+import {Copyright} from "./Copyright";
+import {EmptyContent} from "./EmptyContent";
+
+
+let theme = createTheme({
+ palette: {
+ primary: {
+ light: '#63ccff',
+ main: '#009be5',
+ dark: '#006db3',
+ },
+ },
+ typography: {
+ h5: {
+ fontWeight: 500,
+ fontSize: 26,
+ letterSpacing: 0.5,
+ },
+ },
+ shape: {
+ borderRadius: 8,
+ },
+ components: {
+ MuiTab: {
+ defaultProps: {
+ disableRipple: true,
+ },
+ },
+ },
+ mixins: {
+ toolbar: {
+ minHeight: 48,
+ },
+ },
+});
+
+theme = {
+ ...theme,
+ components: {
+ MuiDrawer: {
+ styleOverrides: {
+ paper: {
+ backgroundColor: '#081627',
+ },
+ },
+ },
+ MuiButton: {
+ styleOverrides: {
+ root: {
+ textTransform: 'none',
+ },
+ contained: {
+ boxShadow: 'none',
+ '&:active': {
+ boxShadow: 'none',
+ },
+ },
+ },
+ },
+ MuiTabs: {
+ styleOverrides: {
+ root: {
+ marginLeft: theme.spacing(1),
+ },
+ indicator: {
+ height: 3,
+ borderTopLeftRadius: 3,
+ borderTopRightRadius: 3,
+ backgroundColor: theme.palette.common.white,
+ },
+ },
+ },
+ MuiTab: {
+ styleOverrides: {
+ root: {
+ textTransform: 'none',
+ margin: '0 16px',
+ minWidth: 0,
+ padding: 0,
+ [theme.breakpoints.up('md')]: {
+ padding: 0,
+ minWidth: 0,
+ },
+ },
+ },
+ },
+ MuiIconButton: {
+ styleOverrides: {
+ root: {
+ padding: theme.spacing(1),
+ },
+ },
+ },
+ MuiTooltip: {
+ styleOverrides: {
+ tooltip: {
+ borderRadius: 4,
+ },
+ },
+ },
+ MuiDivider: {
+ styleOverrides: {
+ root: {
+ backgroundColor: 'rgb(255,255,255,0.15)',
+ },
+ },
+ },
+ MuiListItemButton: {
+ styleOverrides: {
+ root: {
+ '&.Mui-selected': {
+ color: '#4fc3f7',
+ },
+ },
+ },
+ },
+ MuiListItemText: {
+ styleOverrides: {
+ primary: {
+ fontSize: 14,
+ fontWeight: theme.typography.fontWeightMedium,
+ },
+ },
+ },
+ MuiListItemIcon: {
+ styleOverrides: {
+ root: {
+ color: 'inherit',
+ minWidth: 'auto',
+ marginRight: theme.spacing(2),
+ '& svg': {
+ fontSize: 20,
+ },
+ },
+ },
+ },
+ MuiAvatar: {
+ styleOverrides: {
+ root: {
+ width: 32,
+ height: 32,
+ },
+ },
+ },
+ },
+};
+
+const drawerWidth = 256;
+
+export const Paperbase = function() {
+ const [mobileOpen, setMobileOpen] = React.useState(false);
+ const isSmUp = useMediaQuery(theme.breakpoints.up('sm'));
+
+ const handleDrawerToggle = () => {
+ setMobileOpen(!mobileOpen);
+ };
+
+ return (
+ <ThemeProvider theme={theme}>
+ <Box sx={{ display: 'flex', minHeight: '100vh' }}>
+ <Box
+ component="nav"
+ sx={{ width: { sm: drawerWidth }, flexShrink: { sm: 0 } }}
+ >
+ {isSmUp ? null : (
+ <Navigator
+ PaperProps={{ style: { width: drawerWidth } }}
+ variant="temporary"
+ open={mobileOpen}
+ onClose={handleDrawerToggle}
+ />
+ )}
+ <Navigator
+ PaperProps={{ style: { width: drawerWidth } }}
+ sx={{ display: { sm: 'block', xs: 'none' } }}
+ />
+ </Box>
+ <Box sx={{ flex: 1, display: 'flex', flexDirection: 'column' }}>
+ <Box component="main" sx={{ flex: 1, bgcolor: '#eaeff1' }}>
+ <EmptyContent />
+ </Box>
+ <Box component="footer" sx={{ p: 2, bgcolor: '#eaeff1' }}>
+ <Copyright />
+ </Box>
+ </Box>
+ </Box>
+ </ThemeProvider>
+ );
+}
\ No newline at end of file