HM-84. Добавлена страница с пользователями (#55)
This commit is contained in:
9
src/components/users-table/UserAvatarCell.css
Normal file
9
src/components/users-table/UserAvatarCell.css
Normal file
@ -0,0 +1,9 @@
|
||||
.UserAvatarCell__wrapper {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 50%;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-origin: border-box;
|
||||
background-size: cover;
|
||||
}
|
||||
25
src/components/users-table/UserAvatarCell.js
Normal file
25
src/components/users-table/UserAvatarCell.js
Normal file
@ -0,0 +1,25 @@
|
||||
import Component from '../component';
|
||||
import './UserAvatarCell.css';
|
||||
|
||||
class UserAvatarCell extends Component {
|
||||
constructor (parentNode, url) {
|
||||
super(null, parentNode);
|
||||
|
||||
const cell = this.createElement({
|
||||
tagName: 'td',
|
||||
parentNode: this.mainNode,
|
||||
});
|
||||
|
||||
const div = this.createElement({
|
||||
tagName: 'div',
|
||||
parentNode: cell,
|
||||
options: {
|
||||
className: 'UserAvatarCell__wrapper',
|
||||
}
|
||||
});
|
||||
|
||||
div.style.backgroundImage = `url('${url}')`;
|
||||
}
|
||||
}
|
||||
|
||||
export default UserAvatarCell;
|
||||
15
src/components/users-table/UsersTable.js
Normal file
15
src/components/users-table/UsersTable.js
Normal file
@ -0,0 +1,15 @@
|
||||
import Table from '../table';
|
||||
import {USERS_COLS} from '../../consts';
|
||||
import UsersTableRow from './UsersTableRow';
|
||||
|
||||
class UsersTable extends Table {
|
||||
constructor (parentNode) {
|
||||
super(parentNode, USERS_COLS);
|
||||
}
|
||||
|
||||
renderRow = (parentNode, cols, row) => {
|
||||
return this.createComponent(UsersTableRow, parentNode, cols, row);
|
||||
}
|
||||
}
|
||||
|
||||
export default UsersTable;
|
||||
23
src/components/users-table/UsersTableRow.js
Normal file
23
src/components/users-table/UsersTableRow.js
Normal file
@ -0,0 +1,23 @@
|
||||
import Component from '../component';
|
||||
import TableCellOverflow from '../table-cell-overflow';
|
||||
import UserAvatarCell from './UserAvatarCell';
|
||||
|
||||
const makeYesOrNo = (value) => {
|
||||
return value ? 'Да' : 'Нет';
|
||||
};
|
||||
|
||||
class UsersTableRow extends Component {
|
||||
constructor (parentNode, cols, row) {
|
||||
super(null, parentNode);
|
||||
|
||||
this.cols = cols.map((col) => {
|
||||
if (col.id === 'avatar') {
|
||||
return this.createComponent(UserAvatarCell, this.mainNode, row[col.id]);
|
||||
}
|
||||
const text = col.id === 'is_admin' ? makeYesOrNo(row[col.id]) : row[col.id];
|
||||
return this.createComponent(TableCellOverflow, this.mainNode, text);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default UsersTableRow;
|
||||
3
src/components/users-table/index.js
Normal file
3
src/components/users-table/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
import UsersTable from './UsersTable';
|
||||
|
||||
export default UsersTable;
|
||||
Reference in New Issue
Block a user