Merge pull request #1313 from miikkatu/add-flair-to-snackbar
Add flair to snackbar
This commit is contained in:
commit
dad29b787e
5 changed files with 70 additions and 29 deletions
|
@ -11,6 +11,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
||||||
* Add referral FAQ to Invites screen([#1314](https://github.com/lbryio/lbry-app/pull/1314))
|
* Add referral FAQ to Invites screen([#1314](https://github.com/lbryio/lbry-app/pull/1314))
|
||||||
* Show exact wallet balance on mouse hover over ([#1305](https://github.com/lbryio/lbry-app/pull/1305))
|
* Show exact wallet balance on mouse hover over ([#1305](https://github.com/lbryio/lbry-app/pull/1305))
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Add flair to snackbar ([#1313](https://github.com/lbryio/lbry-app/pull/1313))
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
* Black screen on macOS after maximizing LBRY and then closing ([#1235](https://github.com/lbryio/lbry-app/pull/1235))
|
* Black screen on macOS after maximizing LBRY and then closing ([#1235](https://github.com/lbryio/lbry-app/pull/1235))
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import React from 'react';
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doRemoveSnackBarSnack } from 'redux/actions/app';
|
import { doRemoveSnackBarSnack } from 'redux/actions/app';
|
||||||
import { selectSnackBarSnacks } from 'redux/selectors/app';
|
import { selectSnackBarSnacks } from 'redux/selectors/app';
|
||||||
|
|
|
@ -1,35 +1,48 @@
|
||||||
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
|
|
||||||
class SnackBar extends React.PureComponent {
|
type Props = {
|
||||||
constructor(props) {
|
removeSnack: any => void,
|
||||||
|
snacks: {
|
||||||
|
linkTarget: ?string,
|
||||||
|
linkText: ?string,
|
||||||
|
message: string,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
class SnackBar extends React.PureComponent<Props> {
|
||||||
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this._displayTime = 5; // in seconds
|
this.displayTime = 5; // in seconds
|
||||||
this._hideTimeout = null;
|
this.hideTimeout = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { snacks, removeSnack } = this.props;
|
const { snacks, removeSnack } = this.props;
|
||||||
|
|
||||||
if (!snacks.length) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const snack = snacks[0];
|
const snack = snacks[0];
|
||||||
const { message, linkText, linkTarget } = snack;
|
const { message, linkText, linkTarget } = snack;
|
||||||
|
|
||||||
if (this._hideTimeout === null) {
|
if (this.hideTimeout === null) {
|
||||||
this._hideTimeout = setTimeout(() => {
|
this.hideTimeout = setTimeout(() => {
|
||||||
this._hideTimeout = null;
|
this.hideTimeout = null;
|
||||||
removeSnack();
|
removeSnack();
|
||||||
}, this._displayTime * 1000);
|
}, this.displayTime * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="snack-bar">
|
<div className="snack-bar">
|
||||||
{message}
|
<div className="snack-bar__message">
|
||||||
|
<div>ⓘ</div>
|
||||||
|
<div>{message}</div>
|
||||||
|
</div>
|
||||||
{linkText &&
|
{linkText &&
|
||||||
linkTarget && (
|
linkTarget && (
|
||||||
<Button navigate={linkTarget} className="snack-bar__action" label={linkText} />
|
<Button navigate={linkTarget} className="snack-bar__action" label={linkText} />
|
||||||
|
|
|
@ -102,6 +102,10 @@ $large-breakpoint: 1760px;
|
||||||
--btn-radius: 20px;
|
--btn-radius: 20px;
|
||||||
--btn-height: 36px;
|
--btn-height: 36px;
|
||||||
|
|
||||||
|
/* SnackBar */
|
||||||
|
--snackbar-bg-primary: var(--color-primary);
|
||||||
|
--snackbar-color-primary: var(--text-color-inverse);
|
||||||
|
|
||||||
/* Header */
|
/* Header */
|
||||||
--header-bg: var(--color-white);
|
--header-bg: var(--color-white);
|
||||||
--header-color: var(--color-text);
|
--header-color: var(--color-text);
|
||||||
|
|
|
@ -1,30 +1,51 @@
|
||||||
.snack-bar {
|
.snack-bar {
|
||||||
padding: $spacing-vertical;
|
background-color: var(--snackbar-bg-primary);
|
||||||
position: fixed;
|
border-radius: 10px;
|
||||||
top: $spacing-vertical;
|
box-shadow: var(--box-shadow-layer);
|
||||||
left: 0;
|
color: var(--snackbar-color-primary);
|
||||||
right: 0;
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
min-width: 300px;
|
|
||||||
max-width: var(--snack-bar-width);
|
|
||||||
background: var(--color-dark-overlay);
|
|
||||||
color: #f0f0f0;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
left: 0;
|
||||||
border-radius: 2px;
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
max-width: var(--snack-bar-width);
|
||||||
|
min-width: 300px;
|
||||||
|
opacity: 0.95;
|
||||||
|
padding: 14px 20px 10px 20px;
|
||||||
|
position: fixed;
|
||||||
|
right: 0;
|
||||||
|
top: $spacing-vertical;
|
||||||
transition: all var(--transition-duration) var(--transition-type);
|
transition: all var(--transition-duration) var(--transition-type);
|
||||||
|
width: 100%;
|
||||||
z-index: 10000; /*hack to get it over react modal */
|
z-index: 10000; /*hack to get it over react modal */
|
||||||
}
|
}
|
||||||
|
|
||||||
.snack-bar__action {
|
.snack-bar__action {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
text-transform: uppercase;
|
margin-bottom: 4px;
|
||||||
color: var(--color-primary-light);
|
|
||||||
margin: 0px 0px 0px $spacing-vertical;
|
|
||||||
min-width: min-content;
|
min-width: min-content;
|
||||||
&:hover {
|
text-transform: uppercase;
|
||||||
text-decoration: underline;
|
|
||||||
|
span {
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.snack-bar__message {
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
div {
|
||||||
|
&:nth-of-type(1) {
|
||||||
|
font-size: 30px;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
&:nth-of-type(2) {
|
||||||
|
font-size: 16px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue