From 833a7a6afdf22393effe4db7b617f2ea37974a9c Mon Sep 17 00:00:00 2001 From: miikkatu Date: Tue, 17 Apr 2018 08:24:02 +0300 Subject: [PATCH] Add flair to snackbar --- src/renderer/component/snackBar/index.js | 1 - src/renderer/component/snackBar/view.jsx | 33 ++++++++---- src/renderer/scss/_vars.scss | 4 ++ src/renderer/scss/component/_snack-bar.scss | 57 ++++++++++++++------- 4 files changed, 66 insertions(+), 29 deletions(-) diff --git a/src/renderer/component/snackBar/index.js b/src/renderer/component/snackBar/index.js index 9600fdd68..fc5cbf57e 100644 --- a/src/renderer/component/snackBar/index.js +++ b/src/renderer/component/snackBar/index.js @@ -1,4 +1,3 @@ -import React from 'react'; import { connect } from 'react-redux'; import { doRemoveSnackBarSnack } from 'redux/actions/app'; import { selectSnackBarSnacks } from 'redux/selectors/app'; diff --git a/src/renderer/component/snackBar/view.jsx b/src/renderer/component/snackBar/view.jsx index 38867c811..0fdfeef3f 100644 --- a/src/renderer/component/snackBar/view.jsx +++ b/src/renderer/component/snackBar/view.jsx @@ -1,35 +1,48 @@ +// @flow import React from 'react'; import Button from 'component/button'; -class SnackBar extends React.PureComponent { - constructor(props) { +type Props = { + removeSnack: any => void, + snacks: { + linkTarget: ?string, + linkText: ?string, + message: string, + }, +}; + +class SnackBar extends React.PureComponent { + constructor(props: Props) { super(props); - this._displayTime = 5; // in seconds - this._hideTimeout = null; + this.displayTime = 5; // in seconds + this.hideTimeout = null; } render() { const { snacks, removeSnack } = this.props; if (!snacks.length) { - this._hideTimeout = null; // should be unmounting anyway, but be safe? + this.hideTimeout = null; // should be unmounting anyway, but be safe? return null; } const snack = snacks[0]; const { message, linkText, linkTarget } = snack; - if (this._hideTimeout === null) { - this._hideTimeout = setTimeout(() => { - this._hideTimeout = null; + if (this.hideTimeout === null) { + this.hideTimeout = setTimeout(() => { + this.hideTimeout = null; removeSnack(); - }, this._displayTime * 1000); + }, this.displayTime * 1000); } return (
- {message} +
+
+
{message}
+
{linkText && linkTarget && (