Skip to content

Commit

Permalink
Animate transaction notifications & fix styles (#305)
Browse files Browse the repository at this point in the history
* Add disclaimer modal to footer

* Remove duplicate code & unnecessary styles

* Fix formatting noise

* remove un-used css style

* Fix tslint error & add media query for modals

* Nest Media Query

* Add react-transition-group

* Animate notifications with react-transition-group

* Identify issue with notifications getting overridden

* Update RTG (react-transition-group) to v2 & identify keys as animation issue

* Add unique id on successful transactions for unique keys

* update classNames, remove unused import

* Revert removing lodash

* Remove unnecessary test util

* Remove formatting noise

* Remove all formatting noise

* Update CSS & Change notification unique id

* Add unique id for each notification
  • Loading branch information
james-prado authored and dternyak committed Nov 7, 2017
1 parent 4ee38ec commit 2075a41
Show file tree
Hide file tree
Showing 8 changed files with 2,313 additions and 979 deletions.
3 changes: 2 additions & 1 deletion common/actions/notifications/actionCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export function showNotification(
payload: {
level,
msg,
duration
duration,
id: Math.random()
}
};
}
Expand Down
1 change: 1 addition & 0 deletions common/actions/notifications/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type INFINITY = 'infinity';
export interface Notification {
level: NOTIFICATION_LEVEL;
msg: ReactElement<any> | string;
id: number;
duration?: number | INFINITY;
}

Expand Down
22 changes: 22 additions & 0 deletions common/containers/TabSection/Notifications.scss
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,25 @@
}
}
}

.NotificationAnimation{
&-enter {
opacity: 0.01;
&-active {
opacity: 1;
transition: opacity 500ms;
}
}
}

.NotificationAnimation{
&-exit {
opacity: 1;
transform: none;
&-active {
opacity: 0.01;
transform: translateY(100%);
transition: opacity 500ms, transform 500ms;
}
}
}
34 changes: 22 additions & 12 deletions common/containers/TabSection/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,38 @@ import {
} from 'actions/notifications';
import React from 'react';
import { connect } from 'react-redux';
import { TransitionGroup, CSSTransition } from 'react-transition-group';
import NotificationRow from './NotificationRow';
import './Notifications.scss';

interface Props {
notifications: Notification[];
closeNotification: TCloseNotification;
}

const Transition = props => (
<CSSTransition
{...props}
classNames="NotificationAnimation"
timeout={{ enter: 500, exit: 500 }}
/>
);

export class Notifications extends React.Component<Props, {}> {
public render() {
if (!this.props.notifications.length) {
return null;
}
return (
<div className="Notifications">
{this.props.notifications.map((n, i) => (
<NotificationRow
key={`${n.level}-${i}`}
notification={n}
onClose={this.props.closeNotification}
/>
))}
</div>
<TransitionGroup className="Notifications">
{this.props.notifications.map(n => {
return (
<Transition key={n.id}>
<NotificationRow
notification={n}
onClose={this.props.closeNotification}
/>
</Transition>
);
})}
</TransitionGroup>
);
}
}
Expand Down
16 changes: 8 additions & 8 deletions common/containers/Tabs/SendTransaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,14 @@ export class SendTransaction extends React.Component<Props, State> {
onChange={readOnly ? void 0 : this.onGasChange}
/>
{(offline || forceOffline) && (
<div>
<NonceField
value={nonce}
onChange={this.onNonceChange}
placeholder={'0'}
/>
</div>
)}
<div>
<NonceField
value={nonce}
onChange={this.onNonceChange}
placeholder={'0'}
/>
</div>
)}
{unit === 'ether' && (
<DataField
value={data}
Expand Down
1 change: 0 additions & 1 deletion common/sass/styles/overrides/buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
&:hover,
&:focus,
&.focus {
color: white;
text-decoration: none;
opacity: 1;
}
Expand Down
Loading

0 comments on commit 2075a41

Please sign in to comment.