Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
# editorconfig-tools is unable to ignore longs strings or urls
max_line_length = off

[*.md]
indent_size = false
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
# datagrid
### `npm start`

Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

### `npm run build`

Builds the app for production to the `build` folder.
15,245 changes: 15,245 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "datagrid",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.9.5",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.45",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-redux": "^7.2.0",
"react-scripts": "3.4.0",
"react-window": "^1.8.5",
"redux": "^4.0.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"redux-devtools-extension": "^2.13.8"
}
}
Binary file added public/favicon.ico
Binary file not shown.
15 changes: 15 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<title>Data Grid</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
9 changes: 9 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
]
}
50 changes: 50 additions & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const toggleVirtualization = () => ({ type: 'TOGGLE_VIRTUALIZATION'});

const checkActive = () => ({ type: 'CHECK_ACTIVE' });

const setDataStore = (data) => ({
type: 'SET_DATA_STORE',
payload: data
});

const setSortValues = (sortArr) => ({
type: 'SET_SORT_VALUES',
payload: sortArr
});

const chooseEyeColor = (choosedEyeColor) => ({
type: 'CHOOSE_EYE_COLOR',
payload: choosedEyeColor
});

const setQueryString = (queryString) => ({
type: 'SET_QUERY_STRING',
payload: queryString
});

const toggleColumn = (column) => ({
type: 'TOGGLE_COLUMN',
payload: column
});

const checkRow = (row) => ({
type: 'CHECK_ROW',
payload: row
});

const removeRows = (rows) => ({
type: 'REMOVE_ROWS',
payload: rows
});

export {
toggleVirtualization,
checkActive,
setDataStore,
setSortValues,
chooseEyeColor,
setQueryString,
toggleColumn,
checkRow,
removeRows
}
Empty file added src/components/app/app.css
Empty file.
30 changes: 30 additions & 0 deletions src/components/app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';

import { Container, Box } from '@material-ui/core';

import ErrorBoundary from '../error-boundary';
import { MyServiceProvider } from '../my-service-context';
import MyService from '../../services/service';
import Table from '../table';
import ControlPanel from '../control-panel';

import './app.css';

const App = () => {
const service = new MyService();

return (
<Container maxWidth='lg'>
<ErrorBoundary>
<MyServiceProvider value={service}>
<Box display='flex' flexDirection='column'>
<ControlPanel />
<Table />
</Box>
</MyServiceProvider>
</ErrorBoundary>
</Container>
);
}

export default App;
3 changes: 3 additions & 0 deletions src/components/app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import App from "./app";

export default App;
48 changes: 48 additions & 0 deletions src/components/column-list/column-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react';

import {
Box,
Typography
} from '@material-ui/core';

import { makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles(theme => ({
columnListItem: {
'&:hover': {
backgroundColor: 'burlywood',
cursor: 'pointer',
}
},
columnList: {
margin: '0px 20px',
padding: '5px 0px',
}
}));

const ColumnList = ({columns, onToggle}) => {
const classes = useStyles();
const togglers = columns.map((col, index) => {
const {label, visible} = col;
const color=visible? 'primary': 'secondary';
return (
<Typography
className={classes.columnListItem}
variant='body2'
color={color}
align='center'
key={label}
onClick={()=>onToggle(index)} >
{label.toUpperCase()}
</Typography>
)
})

return (
<Box display='flex' flexDirection='column' className={classes.columnList}>
{togglers}
</Box>
)
}

export default ColumnList;
3 changes: 3 additions & 0 deletions src/components/column-list/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ColumnList from "./column-list";

export default ColumnList;
6 changes: 6 additions & 0 deletions src/components/control-panel/control-panel.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.control_panel .aside {
position: absolute;
left: 0;
top: 50vh;
background-color: lightsalmon;
}
83 changes: 83 additions & 0 deletions src/components/control-panel/control-panel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React from 'react';
import { connect } from 'react-redux';

import {
TextField,
Box,
IconButton
} from '@material-ui/core';

import DeleteIcon from '@material-ui/icons/Delete';

import SwitchButton from '../switch-button';
import InputSelect from '../input-select';
import ColumnList from '../column-list';

import * as actions from '../../actions';

import './control-panel.css';

const ControlPanel = ({
filters: {
onlyActive,
eyeColor,
queryString,
},
columns,
checkedRows,
isVirtualization,
checkActive,
chooseEyeColor,
setQueryString,
toggleVirtualization,
toggleColumn,
removeRows,
checkRow
}) => {
return (
<Box display='flex' alignItems='center' justifyContent='center' minHeight='100px' className='control_panel'>
<SwitchButton
value={onlyActive}
label='Only active users'
onChange={checkActive} />
<InputSelect
label='Eye Color'
id='mutiple-chip-label'
selectedItems={eyeColor}
onChange={chooseEyeColor}
selectors={['blue', 'brown', 'green']} />
<TextField
label='Search what you want'
variant='outlined'
color='secondary'
value={queryString}
onChange={e => {setQueryString(e.target.value)}} />
<ColumnList className='visible' columns={columns} onToggle={toggleColumn}/>
<SwitchButton
value={isVirtualization}
label='Toggle virtualization'
onChange={toggleVirtualization} />
{checkedRows.length !== 0 ? (
<IconButton size="medium" className='aside' onClick={()=>{
removeRows(checkedRows);
checkRow([]);
}}>
<DeleteIcon fontSize="inherit" />
</IconButton>
) : null}

</Box>
)
}

const mapStateToProps = (state) => {
const {filters, columns, isVirtualization, checkedRows} = state;
return {
filters,
columns,
isVirtualization,
checkedRows
}
};

export default connect(mapStateToProps, actions)(ControlPanel);
3 changes: 3 additions & 0 deletions src/components/control-panel/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ControlPanel from "./control-panel";

export default ControlPanel;
20 changes: 20 additions & 0 deletions src/components/error-boundary/error-boundary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { Component } from 'react';
import ErrorIndicator from '../error-indicator';

export default class ErrorBoundary extends Component {

state = {
hasError: false
}

componentDidCatch() {
this.setState({ hasError: true })
}

render(){
if (this.state.hasError) {
return <ErrorIndicator />
}
return this.props.children;
}
}
3 changes: 3 additions & 0 deletions src/components/error-boundary/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ErrorBoundary from './error-boundary';

export default ErrorBoundary;
7 changes: 7 additions & 0 deletions src/components/error-indicator/error-indicator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

const ErrorIndicator = () => {
return <div>Error</div>
}

export default ErrorIndicator;
3 changes: 3 additions & 0 deletions src/components/error-indicator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ErrorIndicator from "./error-indicator";

export default ErrorIndicator;
Loading