pause gifs until hover
This commit is contained in:
parent
f03fe9f78b
commit
e97a03c5c9
7 changed files with 71 additions and 26 deletions
|
@ -3,6 +3,7 @@ import React from 'react';
|
||||||
import { parseURI } from 'lbry-redux';
|
import { parseURI } from 'lbry-redux';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import Gerbil from './gerbil.png';
|
import Gerbil from './gerbil.png';
|
||||||
|
import FreezeframeWrapper from 'component/fileThumbnail/FreezeframeWrapper';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
thumbnail: ?string,
|
thumbnail: ?string,
|
||||||
|
@ -11,10 +12,17 @@ type Props = {
|
||||||
thumbnailPreview: ?string,
|
thumbnailPreview: ?string,
|
||||||
obscure?: boolean,
|
obscure?: boolean,
|
||||||
small?: boolean,
|
small?: boolean,
|
||||||
|
allowGifs?: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
function ChannelThumbnail(props: Props) {
|
function ChannelThumbnail(props: Props) {
|
||||||
const { thumbnail, uri, className, thumbnailPreview, obscure, small = false } = props;
|
const { thumbnail, uri, className, thumbnailPreview, obscure, small = false, allowGifs = false } = props;
|
||||||
|
const channelThumbnail = thumbnail || thumbnailPreview;
|
||||||
|
|
||||||
|
if (channelThumbnail && channelThumbnail.endsWith('gif') && !allowGifs) {
|
||||||
|
return <FreezeframeWrapper src={channelThumbnail} className="channel-thumbnail" />;
|
||||||
|
}
|
||||||
|
|
||||||
const showThumb = (!obscure && !!thumbnail) || thumbnailPreview;
|
const showThumb = (!obscure && !!thumbnail) || thumbnailPreview;
|
||||||
|
|
||||||
// Generate a random color class based on the first letter of the channel name
|
// Generate a random color class based on the first letter of the channel name
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
import type { Node } from 'react';
|
import type { Node } from 'react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
// import FreezeframeWrapper from './FreezeframeWrapper';
|
import FreezeframeWrapper from './FreezeframeWrapper';
|
||||||
import Placeholder from './placeholder.png';
|
import Placeholder from './placeholder.png';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -11,14 +11,14 @@ type Props = {
|
||||||
|
|
||||||
const className = 'media__thumb';
|
const className = 'media__thumb';
|
||||||
|
|
||||||
class CardMedia extends React.PureComponent<Props> {
|
class FileThumbnail extends React.PureComponent<Props> {
|
||||||
render() {
|
render() {
|
||||||
const { thumbnail, children } = this.props;
|
const { thumbnail, children } = this.props;
|
||||||
|
|
||||||
// Disabling temporarily to see if people complain
|
if (thumbnail && thumbnail.endsWith('gif')) {
|
||||||
// if (thumbnail && thumbnail.endsWith('gif')) {
|
return <FreezeframeWrapper src={thumbnail} className={className} />;
|
||||||
// return <FreezeframeWrapper src={thumbnail} className={className} />;
|
}
|
||||||
// }
|
|
||||||
let url;
|
let url;
|
||||||
// @if TARGET='web'
|
// @if TARGET='web'
|
||||||
// Pass image urls through a compression proxy
|
// Pass image urls through a compression proxy
|
||||||
|
@ -41,4 +41,4 @@ class CardMedia extends React.PureComponent<Props> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CardMedia;
|
export default FileThumbnail;
|
||||||
|
|
|
@ -175,7 +175,7 @@ function TxoList(props: Props) {
|
||||||
title={__(`Transactions`)}
|
title={__(`Transactions`)}
|
||||||
titleActions={
|
titleActions={
|
||||||
<div className="card__actions--inline">
|
<div className="card__actions--inline">
|
||||||
<Button button="secondary" label={__('Refresh')} onClick={() => fetchTxoPage()} />
|
<Button button="alt" label={__('Refresh')} onClick={() => fetchTxoPage()} />
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
isBodyList
|
isBodyList
|
||||||
|
|
|
@ -233,10 +233,20 @@ function ChannelPage(props: Props) {
|
||||||
{/* component that offers select/upload */}
|
{/* component that offers select/upload */}
|
||||||
<div className="channel__primary-info">
|
<div className="channel__primary-info">
|
||||||
{!editing && (
|
{!editing && (
|
||||||
<ChannelThumbnail className="channel__thumbnail--channel-page" uri={uri} obscure={channelIsBlocked} />
|
<ChannelThumbnail
|
||||||
|
className="channel__thumbnail--channel-page"
|
||||||
|
uri={uri}
|
||||||
|
obscure={channelIsBlocked}
|
||||||
|
allowGifs
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
{editing && (
|
{editing && (
|
||||||
<ChannelThumbnail className="channel__thumbnail--channel-page" uri={uri} thumbnailPreview={thumbPreview} />
|
<ChannelThumbnail
|
||||||
|
className="channel__thumbnail--channel-page"
|
||||||
|
uri={uri}
|
||||||
|
thumbnailPreview={thumbPreview}
|
||||||
|
allowGifs
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
<h1 className="channel__title">{title || '@' + channelName}</h1>
|
<h1 className="channel__title">{title || '@' + channelName}</h1>
|
||||||
<div className="channel__meta">
|
<div className="channel__meta">
|
||||||
|
|
|
@ -90,14 +90,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.media__thumb {
|
.media__thumb {
|
||||||
width: var(--file-list-thumbnail-width);
|
$width: var(--file-list-thumbnail-width);
|
||||||
|
width: $width;
|
||||||
|
@include handleClaimListGifThumbnail($width);
|
||||||
|
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
margin-right: var(--spacing-medium);
|
margin-right: var(--spacing-medium);
|
||||||
}
|
}
|
||||||
|
|
||||||
.channel-thumbnail {
|
.channel-thumbnail {
|
||||||
width: 6rem;
|
@include handleChannelGif(6rem);
|
||||||
height: 6rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
@ -115,8 +117,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.channel-thumbnail {
|
.channel-thumbnail {
|
||||||
width: 5rem;
|
@include handleChannelGif(5rem);
|
||||||
height: 5rem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,8 +138,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.channel-thumbnail {
|
.channel-thumbnail {
|
||||||
width: 7.5rem;
|
@include handleChannelGif(7.5rem);
|
||||||
height: 7.5rem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,8 +149,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.channel-thumbnail {
|
.channel-thumbnail {
|
||||||
width: 4rem;
|
@include handleChannelGif(4rem);
|
||||||
height: 4rem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +317,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.claim-preview--tile {
|
.claim-preview--tile {
|
||||||
width: calc((100% - var(--spacing-medium) * 3) / 4);
|
$width: calc((100vw - var(--side-nav-width) - (var(--spacing-large) * 4) - var(--spacing-medium) * 3) / 4);
|
||||||
|
width: $width;
|
||||||
|
@include handleClaimListGifThumbnail($width);
|
||||||
|
|
||||||
margin-bottom: var(--spacing-large);
|
margin-bottom: var(--spacing-large);
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
|
@ -342,7 +344,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: $breakpoint-medium) and (min-width: $breakpoint-small) {
|
@media (max-width: $breakpoint-medium) and (min-width: $breakpoint-small) {
|
||||||
width: calc((100% - var(--spacing-medium) * 2) / 3);
|
$width: calc((100vw - var(--side-nav-width) - (var(--spacing-large) * 4) - var(--spacing-medium) * 2) / 3);
|
||||||
|
width: $width;
|
||||||
|
@include handleClaimListGifThumbnail($width);
|
||||||
|
|
||||||
&:first-child,
|
&:first-child,
|
||||||
&:nth-child(3n + 1) {
|
&:nth-child(3n + 1) {
|
||||||
|
@ -355,7 +359,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: $breakpoint-small) {
|
@media (max-width: $breakpoint-small) {
|
||||||
width: calc((100% - var(--spacing-medium) * 1) / 2);
|
$width: calc((100vw / 2) - var(--spacing-medium) * 2);
|
||||||
|
width: $width;
|
||||||
|
@include handleClaimListGifThumbnail($width);
|
||||||
margin-bottom: var(--spacing-large);
|
margin-bottom: var(--spacing-large);
|
||||||
|
|
||||||
&:first-child,
|
&:first-child,
|
||||||
|
@ -390,8 +396,7 @@
|
||||||
color: var(--color-subtitle);
|
color: var(--color-subtitle);
|
||||||
|
|
||||||
.channel-thumbnail {
|
.channel-thumbnail {
|
||||||
width: 2.1rem;
|
@include handleChannelGif(2.1rem);
|
||||||
height: 2.1rem;
|
|
||||||
margin-right: var(--spacing-small);
|
margin-right: var(--spacing-small);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
margin-top: var(--header-height);
|
margin-top: var(--header-height);
|
||||||
padding: var(--spacing-large);
|
padding: var(--spacing-large); // Unfortunately this is coupled with .claim-preview--tile width calculation
|
||||||
|
|
||||||
@media (max-width: $breakpoint-small) {
|
@media (max-width: $breakpoint-small) {
|
||||||
padding: var(--spacing-small);
|
padding: var(--spacing-small);
|
||||||
|
|
|
@ -17,3 +17,25 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@mixin handleClaimListGifThumbnail($width) {
|
||||||
|
.ff-container {
|
||||||
|
.ff-canvas.ff-canvas-ready,
|
||||||
|
img {
|
||||||
|
height: calc(#{$width} * (9 / 16));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin handleChannelGif($size) {
|
||||||
|
height: $size;
|
||||||
|
width: $size;
|
||||||
|
|
||||||
|
.ff-container {
|
||||||
|
.ff-canvas.ff-canvas-ready,
|
||||||
|
img {
|
||||||
|
height: $size;
|
||||||
|
width: $size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue