aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorAnton Dubik <anton.dubik33@gmail.com>2020-01-28 22:09:49 +0300
committerGitHub <noreply@github.com>2020-01-28 22:09:49 +0300
commitd246305bfa280221efa8ee31cf6a841fbf54f378 (patch)
tree2029301838a09c072a8e4caaa3e6dc6e7a0c1a15 /src/lib
parent51326e543f5f7d468d30e46288e91ef98d77a9d8 (diff)
parent53143dfc36e66e285256706a8ec837e2bd2f8427 (diff)
downloadreact-benzin-d246305bfa280221efa8ee31cf6a841fbf54f378.tar.gz
Merge pull request #1 from Eug-VS/developv1.0.1
BENZIN Release 1.0.1
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/assets/icon.pngbin0 -> 10550 bytes
-rw-r--r--src/lib/assets/icon2.svg8
-rw-r--r--src/lib/components/BenzinThemeProvider/BenzinThemeProvider.js40
-rw-r--r--src/lib/components/ContentSection/ContentSection.js37
-rw-r--r--src/lib/components/Header/Header.js67
-rw-r--r--src/lib/components/SmartList/SmartList.js28
-rw-r--r--src/lib/components/Window/Window.js55
-rw-r--r--src/lib/components/Window/WindowSurface/WindowSurface.js36
-rw-r--r--src/lib/index.js5
9 files changed, 276 insertions, 0 deletions
diff --git a/src/lib/assets/icon.png b/src/lib/assets/icon.png
new file mode 100644
index 0000000..4335637
--- /dev/null
+++ b/src/lib/assets/icon.png
Binary files differ
diff --git a/src/lib/assets/icon2.svg b/src/lib/assets/icon2.svg
new file mode 100644
index 0000000..9c4da7f
--- /dev/null
+++ b/src/lib/assets/icon2.svg
@@ -0,0 +1,8 @@
+<svg width="35" height="46" viewBox="0 0 35 46" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M15 1H32C33.1046 1 34 1.89543 34 3V43C34 44.1046 33.1046 45 32 45H3C1.89543 45 1 44.1046 1 43V15C1 7.26801 7.26801 1 15 1Z" stroke="#FFA726" stroke-width="2"/>
+<rect x="20.5" y="5.5" width="9" height="1" rx="0.5" stroke="#FFA726"/>
+<rect x="1.21947" y="5.65685" width="6.27542" height="1.72458" transform="rotate(-45 1.21947 5.65685)" stroke="#FFA726" stroke-width="1.72458"/>
+<circle cx="24" cy="25" r="5" fill="#FFA726"/>
+<circle cx="14" cy="31" r="5" fill="#FFA726"/>
+<circle cx="14" cy="19" r="5" fill="#FFA726"/>
+</svg>
diff --git a/src/lib/components/BenzinThemeProvider/BenzinThemeProvider.js b/src/lib/components/BenzinThemeProvider/BenzinThemeProvider.js
new file mode 100644
index 0000000..8e52ed4
--- /dev/null
+++ b/src/lib/components/BenzinThemeProvider/BenzinThemeProvider.js
@@ -0,0 +1,40 @@
+import React from 'react';
+import { createMuiTheme, ThemeProvider } from '@material-ui/core/styles';
+import { CssBaseline } from '@material-ui/core';
+import 'typeface-roboto';
+
+
+const benzinTheme = createMuiTheme({
+ palette: {
+ type: 'dark',
+ primary: {
+ main: '#ffa726',
+ },
+ secondary: {
+ main: '#9c27b0',
+ },
+ background: {
+ default: '#121212',
+ paper: '#1e1e1e',
+ elevation1: '#1e1e1e',
+ elevation2: '#232323',
+ elevation3: '#252525',
+ },
+ text: {
+ primary: '#f4f4f4',
+ secondary: 'rgba(255, 255, 255, 0.6)',
+ }
+ },
+});
+
+
+const BenzinThemeProvider = ({ children }) => (
+ <ThemeProvider theme={benzinTheme}>
+ <CssBaseline />
+ {children}
+ </ThemeProvider>
+);
+
+
+export default BenzinThemeProvider;
+
diff --git a/src/lib/components/ContentSection/ContentSection.js b/src/lib/components/ContentSection/ContentSection.js
new file mode 100644
index 0000000..461a9c2
--- /dev/null
+++ b/src/lib/components/ContentSection/ContentSection.js
@@ -0,0 +1,37 @@
+import React from 'react';
+
+import {
+ Typography,
+ Divider,
+ makeStyles
+} from '@material-ui/core';
+
+
+const useStyles = makeStyles(theme => ({
+ content: {
+ padding: theme.spacing(0, 2, 1, 2),
+ marginBottom: theme.spacing(1),
+
+ '& .MuiButton-root': {
+ margin: theme.spacing(1, 2, 2, 0),
+ },
+ },
+}));
+
+const ContentSection = ({ sectionName, children }) => {
+ const classes = useStyles();
+
+ return (
+ <>
+ <Typography variant="h4">{sectionName}</Typography>
+ <Divider variant="middle"/>
+ <Typography component="div" className={classes.content}>
+ {children}
+ </Typography>
+ </>
+ );
+
+};
+
+
+export default ContentSection;
diff --git a/src/lib/components/Header/Header.js b/src/lib/components/Header/Header.js
new file mode 100644
index 0000000..3ade7b3
--- /dev/null
+++ b/src/lib/components/Header/Header.js
@@ -0,0 +1,67 @@
+import React from 'react';
+
+import {
+ AppBar,
+ Tabs,
+ Tab,
+ Typography,
+ Toolbar,
+} from '@material-ui/core';
+
+import { makeStyles } from '@material-ui/core/styles';
+
+
+const useStyles = makeStyles(theme => ({
+ root: {
+ background: theme.palette.background.elevation2,
+ color: theme.palette.text.primary,
+ paddingLeft: theme.spacing(3),
+ },
+ logo: {
+ margin: theme.spacing(0, 3, 0, 1),
+ },
+ tab: {
+ '& .MuiTab-wrapper': {
+ padding: theme.spacing(2),
+ flexDirection: 'row',
+ fontSize: '0.8125rem',
+ '& svg': {
+ marginRight: theme.spacing(1),
+ marginBottom: '0 !important',
+ }
+ }
+ }
+}));
+
+
+const Header = ({ logo, contents, page, setPage }) => {
+ const classes = useStyles();
+
+ const handleChange = (event, newPage) => {
+ setPage(newPage);
+ };
+
+ return (
+ <AppBar position="sticky" className={classes.root}>
+ <Toolbar>
+ {logo.icon}
+ <Typography variant="h5" className={classes.logo} color="primary">
+ {logo.title}
+ </Typography>
+ <Tabs onChange={handleChange} value={page}>
+ {contents && Object.keys(contents).map(item => (
+ <Tab
+ label={item}
+ icon={contents[item]}
+ value={item}
+ className={classes.tab}
+ key={item}
+ />
+ ))}
+ </Tabs>
+ </Toolbar>
+ </AppBar>
+ );
+};
+
+export default Header;
diff --git a/src/lib/components/SmartList/SmartList.js b/src/lib/components/SmartList/SmartList.js
new file mode 100644
index 0000000..b462c47
--- /dev/null
+++ b/src/lib/components/SmartList/SmartList.js
@@ -0,0 +1,28 @@
+import React from 'react';
+
+import { FixedSizeList } from 'react-window';
+import AutoSizer from 'react-virtualized-auto-sizer';
+
+
+const SmartList = ({ itemSize, itemCount, renderItem }) => {
+
+ return (
+ <div style={{ flex: '1 1 auto', overflow: 'hidden' }}>
+ <AutoSizer>
+ {({ width, height }) => (
+ <FixedSizeList
+ height={height}
+ width={width}
+ itemSize={itemSize}
+ itemCount={itemCount}
+ >
+ {renderItem}
+ </FixedSizeList>
+ )}
+ </AutoSizer>
+ </div>
+ );
+};
+
+
+export default SmartList;
diff --git a/src/lib/components/Window/Window.js b/src/lib/components/Window/Window.js
new file mode 100644
index 0000000..027213f
--- /dev/null
+++ b/src/lib/components/Window/Window.js
@@ -0,0 +1,55 @@
+import React from 'react';
+
+import { Typography, Divider, makeStyles } from '@material-ui/core';
+
+import WindowSurface from './WindowSurface/WindowSurface';
+
+
+const useStyles = makeStyles(theme => ({
+ header: {
+ padding: theme.spacing(1, 0, 1, 2),
+ background: theme.palette.background.elevation2,
+ },
+}));
+
+
+const Window = ({ type, name, children }) => {
+ const classes = useStyles();
+
+ const size = {
+ height: '85vh',
+ };
+
+ const position = {
+ bottom: '3vh',
+ };
+
+ if (type === 'primary') {
+ size.width = '63vw';
+ position.left = '2vw';
+ } else if (type === 'secondary') {
+ size.width = '31vw';
+ position.right = '2vw';
+ } else if (type === 'mono') {
+ position.left = '2vw';
+ position.right = '2vw';
+ }
+
+ return (
+ <WindowSurface
+ size={size}
+ position={position}
+ >
+ {name &&
+ <div>
+ <Typography variant="h5" className={classes.header}>{name}</Typography>
+ <Divider />
+ </div>
+ }
+ {children}
+ </WindowSurface>
+ );
+};
+
+
+export default Window;
diff --git a/src/lib/components/Window/WindowSurface/WindowSurface.js b/src/lib/components/Window/WindowSurface/WindowSurface.js
new file mode 100644
index 0000000..7859bf6
--- /dev/null
+++ b/src/lib/components/Window/WindowSurface/WindowSurface.js
@@ -0,0 +1,36 @@
+import React from 'react';
+
+import { Paper, makeStyles } from '@material-ui/core';
+
+
+const useStyles = makeStyles(theme => ({
+ surface: {
+ position: 'absolute',
+ display: 'flex',
+ flexDirection: 'column',
+ overflowY: 'auto',
+ scrollbarColor: `${theme.palette.secondary.dark} ${theme.palette.secondary.light}`,
+
+ '& a.MuiTypography-root': {
+ color: theme.palette.primary.light,
+ },
+ }
+}));
+
+
+const WindowSurface = ({ size, position, children }) => {
+ const classes = useStyles();
+
+ return (
+ <Paper
+ variant="outlined"
+ style={{...size, ...position}}
+ className={classes.surface}
+ >
+ {children}
+ </Paper>
+ )
+};
+
+
+export default WindowSurface;
diff --git a/src/lib/index.js b/src/lib/index.js
new file mode 100644
index 0000000..0476c34
--- /dev/null
+++ b/src/lib/index.js
@@ -0,0 +1,5 @@
+export { default as Window } from './components/Window/Window';
+export { default as Header } from './components/Header/Header';
+export { default as ContentSection } from './components/ContentSection/ContentSection';
+export { default as SmartList } from './components/SmartList/SmartList';
+export { default as BenzinThemeProvider } from './components/BenzinThemeProvider/BenzinThemeProvider';