mirror of
https://github.com/trezor/trezor-wallet
synced 2025-02-17 18:42:01 +00:00
Created basic components skeleton
This commit is contained in:
parent
09b6299908
commit
00d0fc1ccb
@ -0,0 +1,24 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const Wrapper = styled.div``;
|
||||||
|
|
||||||
|
class Group extends Component {
|
||||||
|
hide() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
show() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Wrapper>
|
||||||
|
Group
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Group;
|
67
src/components/Notification/NotificationGroups/index.js
Normal file
67
src/components/Notification/NotificationGroups/index.js
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import Group from './components/Group';
|
||||||
|
|
||||||
|
const Wrapper = styled.div``;
|
||||||
|
|
||||||
|
class NotificationsGroup extends Component {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.notificationPriority = {
|
||||||
|
error: 0,
|
||||||
|
warning: 1,
|
||||||
|
info: 2,
|
||||||
|
success: 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.notifications = [
|
||||||
|
{ type: 'warning' },
|
||||||
|
{ type: 'error' },
|
||||||
|
{ type: 'info' },
|
||||||
|
{ type: 'error' },
|
||||||
|
{ type: 'warning' },
|
||||||
|
{ type: 'success' },
|
||||||
|
{ type: 'error' },
|
||||||
|
{ type: 'error' },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
getGroupNotifications(notifications, type) {
|
||||||
|
return notifications.filter(item => item.type === type);
|
||||||
|
}
|
||||||
|
|
||||||
|
groupNotifications = (items, key) => items.reduce(
|
||||||
|
(result, item) => ({
|
||||||
|
...result,
|
||||||
|
[item[key]]: [...(result[item[key]] || []), item],
|
||||||
|
}),
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
|
||||||
|
sortByPriority(notifications) {
|
||||||
|
const sorted = Object.keys(notifications).sort((a, b) => {
|
||||||
|
// sort
|
||||||
|
});
|
||||||
|
return sorted;
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { notifications } = this;
|
||||||
|
const notificationGroups = this.groupNotifications(notifications, 'type');
|
||||||
|
const sortedNotifications = this.sortByPriority(notificationGroups);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Wrapper>
|
||||||
|
{sortedNotifications.map(group => (
|
||||||
|
<Group
|
||||||
|
notifications={this.getGroupNotifications(group.type, sortedNotifications)}
|
||||||
|
type={group.type}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NotificationsGroup;
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React } from 'react';
|
||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import styled, { css } from 'styled-components';
|
import styled, { css } from 'styled-components';
|
||||||
|
Loading…
Reference in New Issue
Block a user