diff options
| author | Anton Dubik <anton.dubik33@gmail.com> | 2020-01-28 22:09:49 +0300 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-28 22:09:49 +0300 | 
| commit | d246305bfa280221efa8ee31cf6a841fbf54f378 (patch) | |
| tree | 2029301838a09c072a8e4caaa3e6dc6e7a0c1a15 /src | |
| parent | 51326e543f5f7d468d30e46288e91ef98d77a9d8 (diff) | |
| parent | 53143dfc36e66e285256706a8ec837e2bd2f8427 (diff) | |
| download | react-benzin-d246305bfa280221efa8ee31cf6a841fbf54f378.tar.gz | |
Merge pull request #1 from Eug-VS/developv1.0.1
BENZIN Release 1.0.1
Diffstat (limited to 'src')
| -rw-r--r-- | src/index.js | 71 | ||||
| -rw-r--r-- | src/lib/assets/icon.png | bin | 0 -> 10550 bytes | |||
| -rw-r--r-- | src/lib/assets/icon2.svg | 8 | ||||
| -rw-r--r-- | src/lib/components/BenzinThemeProvider/BenzinThemeProvider.js | 40 | ||||
| -rw-r--r-- | src/lib/components/ContentSection/ContentSection.js | 37 | ||||
| -rw-r--r-- | src/lib/components/Header/Header.js | 67 | ||||
| -rw-r--r-- | src/lib/components/SmartList/SmartList.js | 28 | ||||
| -rw-r--r-- | src/lib/components/Window/Window.js | 55 | ||||
| -rw-r--r-- | src/lib/components/Window/WindowSurface/WindowSurface.js | 36 | ||||
| -rw-r--r-- | src/lib/index.js | 5 | 
10 files changed, 347 insertions, 0 deletions
| diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..1aec963 --- /dev/null +++ b/src/index.js @@ -0,0 +1,71 @@ +import React, { useState } from 'react'; +import ReactDOM from 'react-dom'; + +import { makeStyles, Button } from '@material-ui/core'; + +import { +  BenzinThemeProvider, +  Header, +  Window, +  ContentSection, +} from './lib'; + +import icon from './lib/assets/icon.png'; +import icon2 from './lib/assets/icon2.svg'; +import HomeIcon from '@material-ui/icons/Home'; +import PlayCircleFilledWhiteIcon from '@material-ui/icons/PlayCircleFilledWhite'; +import ExploreIcon from '@material-ui/icons/Explore'; +import GitHubIcon from '@material-ui/icons/GitHub'; + + +const useStyles = makeStyles(theme => ({ +  window: { +    padding: theme.spacing(4), +  } +})); + +const headerContents = { +  home: <HomeIcon />, +  'getting started': <PlayCircleFilledWhiteIcon />, +  explore: <ExploreIcon />, +  contribute: <GitHubIcon />, +} + +const Icon1 = <img src={icon} width="32px" height="37px" alt="logo"/> +const Icon2 = <img src={icon2} height="32px" alt="logo"/> + +const App = () => { +  const classes = useStyles(); +  const [page, setPage] = useState('home'); + +  return ( +    <BenzinThemeProvider> +      <Header +        logo={{ +          icon: Icon1, +          title: 'BENZIN', +        }} +        contents={headerContents} +        page={page} +        setPage={setPage} +      /> +      <Window type="mono"> +        <div className={classes.window}> +          <ContentSection sectionName="Out of fuel? You've came to the right place!"> +            <p> Here is some text about BENZIN library. </p> +            <Button variant="contained" color="secondary"> +              Charge me up! +            </Button> +            <Button variant="contained" color="primary"> +              Learn more +            </Button> +          </ContentSection> +        </div> +      </Window> +    </BenzinThemeProvider> +  ); +}; + + +ReactDOM.render(<App />, document.getElementById('root')); + diff --git a/src/lib/assets/icon.png b/src/lib/assets/icon.pngBinary files differ new file mode 100644 index 0000000..4335637 --- /dev/null +++ b/src/lib/assets/icon.png 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'; | 
