winning claim style pass

This commit is contained in:
Sean Yesmunt 2020-12-16 13:31:07 -05:00
parent 1aefdba5ab
commit 047e84ac8c
8 changed files with 130 additions and 134 deletions

View file

@ -211,7 +211,9 @@ function CommentList(props: Props) {
<> <>
<CommentCreate uri={uri} /> <CommentCreate uri={uri} />
{!isFetchingComments && hasNoComments && <Empty text={__('That was pretty deep. What do you think?')} />} {!isFetchingComments && hasNoComments && (
<Empty padded text={__('That was pretty deep. What do you think?')} />
)}
<ul className="comments" ref={commentRef}> <ul className="comments" ref={commentRef}>
{comments && {comments &&

View file

@ -1,20 +1,17 @@
// @flow // @flow
import React from 'react'; import React from 'react';
import classnames from 'classnames';
type Props = { type Props = {
text: ?string, text: ?string,
padded?: boolean,
}; };
class Empty extends React.PureComponent<Props> { export default function Empty(props: Props) {
static defaultProps = { const { text = '', padded = false } = props;
text: '',
};
render() {
const { text } = this.props;
return ( return (
<div className="empty__wrap"> <div className={classnames('empty__wrap', { 'empty__wrap--padded': padded })}>
<div> <div>
{text && ( {text && (
<div className="empty__content"> <div className="empty__content">
@ -24,7 +21,4 @@ class Empty extends React.PureComponent<Props> {
</div> </div>
</div> </div>
); );
}
} }
export default Empty;

View file

@ -1,14 +1,20 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doResolveUris, doClearPublish, doPrepareEdit, selectPendingIds } from 'lbry-redux'; import { doResolveUris, doClearPublish, doPrepareEdit, selectPendingIds, makeSelectClaimForUri } from 'lbry-redux';
import { makeSelectWinningUriForQuery } from 'redux/selectors/search'; import { makeSelectWinningUriForQuery, makeSelectIsResolvingWinningUri } from 'redux/selectors/search';
import SearchTopClaim from './view'; import SearchTopClaim from './view';
import { push } from 'connected-react-router'; import { push } from 'connected-react-router';
import * as PAGES from 'constants/pages'; import * as PAGES from 'constants/pages';
const select = (state, props) => ({ const select = (state, props) => {
winningUri: makeSelectWinningUriForQuery(props.query)(state), const winningUri = makeSelectWinningUriForQuery(props.query)(state);
return {
winningUri,
winningClaim: winningUri ? makeSelectClaimForUri(winningUri)(state) : undefined,
isResolvingWinningUri: props.query ? makeSelectIsResolvingWinningUri(props.query)(state) : false,
pendingIds: selectPendingIds(state), pendingIds: selectPendingIds(state),
}); };
};
const perform = dispatch => ({ const perform = dispatch => ({
beginPublish: name => { beginPublish: name => {

View file

@ -10,20 +10,30 @@ import I18nMessage from 'component/i18nMessage';
import { useHistory } from 'react-router'; import { useHistory } from 'react-router';
import LbcSymbol from 'component/common/lbc-symbol'; import LbcSymbol from 'component/common/lbc-symbol';
import { DOMAIN } from 'config'; import { DOMAIN } from 'config';
import Yrbl from 'component/yrbl';
type Props = { type Props = {
query: string, query: string,
winningUri: ?Claim, winningUri: ?string,
doResolveUris: (Array<string>) => void, doResolveUris: (Array<string>) => void,
hideLink?: boolean, hideLink?: boolean,
setChannelActive: boolean => void, setChannelActive: boolean => void,
beginPublish: string => void, beginPublish: string => void,
pendingIds: Array<string>, pendingIds: Array<string>,
isResolvingWinningUri: boolean,
winningClaim: ?Claim,
}; };
export default function SearchTopClaim(props: Props) { export default function SearchTopClaim(props: Props) {
const { doResolveUris, query = '', winningUri, hideLink = false, setChannelActive, beginPublish } = props; const {
doResolveUris,
query = '',
winningUri,
winningClaim,
hideLink = false,
setChannelActive,
beginPublish,
isResolvingWinningUri,
} = props;
const uriFromQuery = `lbry://${query}`; const uriFromQuery = `lbry://${query}`;
const { push } = useHistory(); const { push } = useHistory();
let name; let name;
@ -60,9 +70,12 @@ export default function SearchTopClaim(props: Props) {
} }
}, [doResolveUris, uriFromQuery, channelUriFromQuery]); }, [doResolveUris, uriFromQuery, channelUriFromQuery]);
if (winningUri && !winningClaim && isResolvingWinningUri) {
return null;
}
return ( return (
<section className="search"> <div className="search__header">
<header className="search__header">
{winningUri && ( {winningUri && (
<div className="claim-preview__actions--header"> <div className="claim-preview__actions--header">
<a <a
@ -70,13 +83,7 @@ export default function SearchTopClaim(props: Props) {
href="https://lbry.com/faq/trending" href="https://lbry.com/faq/trending"
title={__('Learn more about LBRY Credits on %DOMAIN%', { DOMAIN })} title={__('Learn more about LBRY Credits on %DOMAIN%', { DOMAIN })}
> >
<I18nMessage <LbcSymbol prefix={__('Most supported')} />
tokens={{
lbc: <LbcSymbol />,
}}
>
Most supported %lbc%
</I18nMessage>
</a> </a>
</div> </div>
)} )}
@ -86,7 +93,6 @@ export default function SearchTopClaim(props: Props) {
hideRepostLabel hideRepostLabel
uri={winningUri} uri={winningUri}
type="large" type="large"
placeholder="publish"
properties={claim => ( properties={claim => (
<span className="claim-preview__custom-properties"> <span className="claim-preview__custom-properties">
<ClaimEffectiveAmount uri={winningUri} /> <ClaimEffectiveAmount uri={winningUri} />
@ -96,29 +102,21 @@ export default function SearchTopClaim(props: Props) {
</div> </div>
)} )}
{!winningUri && uriFromQuery && ( {!winningUri && uriFromQuery && (
<div className="empty empty--centered"> <div className="card card--section help--inline">
<Yrbl
type="happy"
title={__('Whoa!')}
small
subtitle={
<I18nMessage <I18nMessage
tokens={{ tokens={{
repost: ( repost: (
<Button <Button button="link" onClick={() => push(`/$/${PAGES.REPOST_NEW}?to=${name}`)} label={__('Repost')} />
button="link" ),
onClick={() => push(`/$/${PAGES.REPOST_NEW}?to=${name}`)} publish: (
label={__('Repost')} <span>
/> <Button button="link" onClick={() => beginPublish(name)} label={'publish'} />
</span>
), ),
publish: <Button button="link" onClick={() => beginPublish(name)} label={'publish'} />,
name: <strong>name</strong>,
}} }}
> >
You have found the edge of the internet. %repost% or %publish% your stuff here to claim this spot. You have found the edge of the internet. %repost% or %publish% your stuff here to claim this spot.
</I18nMessage> </I18nMessage>
}
/>
</div> </div>
)} )}
{!hideLink && winningUri && ( {!hideLink && winningUri && (
@ -135,7 +133,6 @@ export default function SearchTopClaim(props: Props) {
/> />
</div> </div>
)} )}
</header> </div>
</section>
); );
} }

View file

@ -11,7 +11,6 @@ type Props = {
className?: string, className?: string,
actions?: Node, actions?: Node,
alwaysShow?: boolean, alwaysShow?: boolean,
small: boolean,
}; };
const yrblTypes = { const yrblTypes = {
@ -25,7 +24,7 @@ export default class extends React.PureComponent<Props> {
}; };
render() { render() {
const { title, subtitle, type, className, actions, small, alwaysShow = false } = this.props; const { title, subtitle, type, className, actions, alwaysShow = false } = this.props;
const image = yrblTypes[type]; const image = yrblTypes[type];
@ -33,7 +32,7 @@ export default class extends React.PureComponent<Props> {
<div className="yrbl__wrap"> <div className="yrbl__wrap">
<img <img
alt="Friendly gerbil" alt="Friendly gerbil"
className={classnames(small ? 'yrbl--small' : 'yrbl', className, { className={classnames('yrbl', className, {
'yrbl--always-show': alwaysShow, 'yrbl--always-show': alwaysShow,
})} })}
src={`${image}`} src={`${image}`}

View file

@ -9,6 +9,7 @@ import {
SETTINGS, SETTINGS,
isClaimNsfw, isClaimNsfw,
makeSelectPendingClaimForUri, makeSelectPendingClaimForUri,
makeSelectIsUriResolving,
} from 'lbry-redux'; } from 'lbry-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
@ -143,3 +144,22 @@ export const makeSelectWinningUriForQuery = (query: string) => {
} }
); );
}; };
export const makeSelectIsResolvingWinningUri = (query: string = '') => {
const uriFromQuery = `lbry://${query}`;
let channelUriFromQuery;
try {
const { isChannel } = parseURI(uriFromQuery);
if (!isChannel) {
channelUriFromQuery = `lbry://@${query}`;
}
} catch (e) {}
return createSelector(
makeSelectIsUriResolving(uriFromQuery),
channelUriFromQuery ? makeSelectIsUriResolving(channelUriFromQuery) : () => {},
(claim1IsResolving, claim2IsResolving) => {
return claim1IsResolving || claim2IsResolving;
}
);
};

View file

@ -11,6 +11,10 @@
} }
} }
.empty__wrap--padded {
padding: var(--spacing-xl) 0;
}
.empty__text { .empty__text {
color: var(--color-text-empty); color: var(--color-text-empty);
font-style: italic; font-style: italic;

View file

@ -30,32 +30,6 @@
max-width: 100%; max-width: 100%;
white-space: nowrap; white-space: nowrap;
} }
// This is terrible and should not be removed
.icon {
margin-right: var(--spacing-xs) / 2;
margin-bottom: -0.08rem;
}
}
.media__uri--inline {
@extend .media__uri;
position: relative;
transform: none;
overflow: hidden;
text-overflow: ellipsis;
}
.media__uri--right {
@extend .media__uri;
right: 0;
}
.media__uri--right--yt-badge {
@extend .media__uri--right;
@media (max-width: $breakpoint-small) {
display: none;
}
} }
// M E D I A // M E D I A