Skip to content

Commit 7cb48aa

Browse files
Merge pull request #291 from graasp/285/classroomLegend
refactor: add classroom legend, refactor resource and action icons
2 parents 310b433 + 1618b9b commit 7cb48aa

6 files changed

+97
-4
lines changed
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import Icon from '@material-ui/icons/Assessment';
4+
import { withTranslation } from 'react-i18next';
5+
6+
const ActionIcon = ({ className, text, t }) => {
7+
return (
8+
<>
9+
<Icon className={className} />
10+
{text && <span>{t('Actions')}</span>}
11+
</>
12+
);
13+
};
14+
15+
ActionIcon.propTypes = {
16+
className: PropTypes.string,
17+
text: PropTypes.bool,
18+
t: PropTypes.func.isRequired,
19+
};
20+
21+
ActionIcon.defaultProps = {
22+
className: '',
23+
text: false,
24+
};
25+
26+
export default withTranslation()(ActionIcon);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { withStyles } from '@material-ui/core';
4+
import ResourceIcon from './ResourceIcon';
5+
import ActionIcon from './ActionIcon';
6+
7+
const styles = theme => ({
8+
legend: {
9+
display: 'flex',
10+
justifyContent: 'flex-end',
11+
alignItems: 'center',
12+
13+
'& span': {
14+
marginLeft: theme.spacing(0.5),
15+
marginRight: theme.spacing(2),
16+
},
17+
},
18+
});
19+
20+
const ClassroomLegend = ({ classes }) => {
21+
return (
22+
<div className={classes.legend}>
23+
<ResourceIcon text />
24+
<ActionIcon text />
25+
</div>
26+
);
27+
};
28+
29+
ClassroomLegend.propTypes = {
30+
classes: PropTypes.shape({
31+
legend: PropTypes.string.isRequired,
32+
}).isRequired,
33+
};
34+
35+
const StyledComponent = withStyles(styles, { withTheme: true })(
36+
ClassroomLegend
37+
);
38+
39+
export default StyledComponent;

src/components/classrooms/ClassroomScreen.js

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Button from '@material-ui/core/Button';
99
import Toolbar from '@material-ui/core/Toolbar';
1010
import CssBaseline from '@material-ui/core/CssBaseline/CssBaseline';
1111
import AppBar from '@material-ui/core/AppBar/AppBar';
12+
import ClassroomLegend from './ClassroomLegend';
1213
import Styles from '../../Styles';
1314
import Loader from '../common/Loader';
1415
import Main from '../common/Main';
@@ -124,6 +125,7 @@ class ClassroomScreen extends Component {
124125
<Main>
125126
<div className={classes.screen}>
126127
<StudentsTable classroom={classroom} />
128+
<ClassroomLegend />
127129
<ImportDataButton classroomId={classroomId} />
128130
<AddUserInClassroomButton classroomId={classroomId} />
129131
{this.renderBackButton()}

src/components/classrooms/EditUserInClassroomButton.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import Button from '@material-ui/core/Button';
1313
import IconButton from '@material-ui/core/IconButton';
1414
import { withTranslation } from 'react-i18next';
1515
import Typography from '@material-ui/core/Typography';
16-
import ResourceIcon from '@material-ui/icons/AssignmentInd';
17-
import ActionIcon from '@material-ui/icons/Assessment';
1816
import CancelIcon from '@material-ui/icons/Cancel';
1917
import TextField from '@material-ui/core/TextField';
2018
import Dialog from '@material-ui/core/Dialog';
@@ -39,6 +37,8 @@ import {
3937
hasUserResourcesForSpaceInClassroom,
4038
hasUserDataInClassroom,
4139
} from '../../utils/classroom';
40+
import ResourceIcon from './ResourceIcon';
41+
import ActionIcon from './ActionIcon';
4242

4343
const styles = theme => ({
4444
formControl: {
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import Icon from '@material-ui/icons/AssignmentInd';
4+
import { withTranslation } from 'react-i18next';
5+
6+
const ResourceIcon = ({ className, text, t }) => {
7+
return (
8+
<>
9+
<Icon className={className} />
10+
{text && <span>{t('Resources')}</span>}
11+
</>
12+
);
13+
};
14+
15+
ResourceIcon.propTypes = {
16+
className: PropTypes.string,
17+
text: PropTypes.bool,
18+
t: PropTypes.func.isRequired,
19+
};
20+
21+
ResourceIcon.defaultProps = {
22+
className: '',
23+
text: false,
24+
};
25+
26+
export default withTranslation()(ResourceIcon);

src/components/classrooms/StudentsTable.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import TableContainer from '@material-ui/core/TableContainer';
1111
import TablePagination from '@material-ui/core/TablePagination';
1212
import TableRow from '@material-ui/core/TableRow';
1313
import DeleteIcon from '@material-ui/icons/Delete';
14-
import ResourceIcon from '@material-ui/icons/AssignmentInd';
15-
import ActionIcon from '@material-ui/icons/Assessment';
1614
import IconButton from '@material-ui/core/IconButton/IconButton';
1715
import Tooltip from '@material-ui/core/Tooltip';
1816
import Paper from '@material-ui/core/Paper';
@@ -39,6 +37,8 @@ import {
3937
getUserResourcesForSpaceInClassroom,
4038
getUserActionsForSpaceInClassroom,
4139
} from '../../utils/classroom';
40+
import ActionIcon from './ActionIcon';
41+
import ResourceIcon from './ResourceIcon';
4242

4343
const styles = theme => ({
4444
root: {

0 commit comments

Comments
 (0)