update channel links on file page

This commit is contained in:
Sean Yesmunt 2019-07-21 22:05:37 -04:00
parent cd1ce38687
commit 36f561085e
10 changed files with 49 additions and 18 deletions

View file

@ -36,6 +36,7 @@
"object-curly-spacing": 0, "object-curly-spacing": 0,
"one-var": 0, "one-var": 0,
"prefer-promise-reject-errors": 0, "prefer-promise-reject-errors": 0,
"react/jsx-indent": 0,
"react-hooks/exhaustive-deps": "warn", "react-hooks/exhaustive-deps": "warn",
"react-hooks/rules-of-hooks": "error", "react-hooks/rules-of-hooks": "error",
"space-before-function-paren": ["error", "never"], "space-before-function-paren": ["error", "never"],

View file

@ -64,6 +64,7 @@ function ClaimPreview(props: Props) {
const abandoned = !isResolvingUri && !claim; const abandoned = !isResolvingUri && !claim;
const claimsInChannel = (claim && claim.meta.claims_in_channel) || 0; const claimsInChannel = (claim && claim.meta.claims_in_channel) || 0;
const showPublishLink = abandoned && placeholder === 'publish'; const showPublishLink = abandoned && placeholder === 'publish';
const minimal = type === 'small' || type === 'tooltip';
let isValid; let isValid;
try { try {
@ -75,7 +76,7 @@ function ClaimPreview(props: Props) {
const isChannel = isValid ? parseURI(uri).isChannel : false; const isChannel = isValid ? parseURI(uri).isChannel : false;
let shouldHide = let shouldHide =
placeholder !== 'loading' && ((abandoned && !showPublishLink) || (!claimIsMine && obscureNsfw && nsfw)); placeholder !== 'loading' && ((abandoned && !showPublishLink) || (!claimIsMine && obscureNsfw && nsfw) || !claim);
// This will be replaced once blocking is done at the wallet server level // This will be replaced once blocking is done at the wallet server level
if (claim && !shouldHide && blackListedOutpoints) { if (claim && !shouldHide && blackListedOutpoints) {
@ -133,7 +134,7 @@ function ClaimPreview(props: Props) {
onClick={pending || type === 'inline' ? undefined : onClick} onClick={pending || type === 'inline' ? undefined : onClick}
onContextMenu={handleContextMenu} onContextMenu={handleContextMenu}
className={classnames('claim-preview', { className={classnames('claim-preview', {
'claim-preview--small': type === 'small', 'claim-preview--small': minimal,
'claim-preview--large': type === 'large', 'claim-preview--large': type === 'large',
'claim-preview--inline': type === 'inline', 'claim-preview--inline': type === 'inline',
'claim-preview--visited': !isChannel && hasVisitedUri, 'claim-preview--visited': !isChannel && hasVisitedUri,
@ -146,7 +147,7 @@ function ClaimPreview(props: Props) {
<div className="claim-preview-title"> <div className="claim-preview-title">
{claim ? <TruncatedText text={title || claim.name} lines={1} /> : <span>{__('Nothing here')}</span>} {claim ? <TruncatedText text={title || claim.name} lines={1} /> : <span>{__('Nothing here')}</span>}
</div> </div>
{type !== 'small' && ( {!minimal && (
<div> <div>
{isChannel && <SubscribeButton uri={uri.startsWith('lbry://') ? uri : `lbry://${uri}`} />} {isChannel && <SubscribeButton uri={uri.startsWith('lbry://') ? uri : `lbry://${uri}`} />}
{!isChannel && <FileProperties uri={uri} />} {!isChannel && <FileProperties uri={uri} />}
@ -160,7 +161,7 @@ function ClaimPreview(props: Props) {
{!isResolvingUri && ( {!isResolvingUri && (
<div> <div>
{claim ? ( {claim ? (
<UriIndicator uri={uri} link /> <UriIndicator uri={uri} link addTooltip={!minimal} />
) : ( ) : (
<Fragment> <Fragment>
<div>{__('Publish something and claim this spot!')}</div> <div>{__('Publish something and claim this spot!')}</div>

View file

@ -57,7 +57,7 @@ export default class RecommendedContent extends React.PureComponent<Props> {
loading={isSearching} loading={isSearching}
uris={recommendedContent} uris={recommendedContent}
header={__('Related')} header={__('Related')}
empty={<div className="empty">{__('No related content found')}</div>} empty={__('No related content found')}
/> />
</section> </section>
); );

View file

@ -10,6 +10,7 @@ type Props = {
channelUri: ?string, channelUri: ?string,
link: ?boolean, link: ?boolean,
claim: ?Claim, claim: ?Claim,
addTooltip: boolean,
// Lint thinks we aren't using these, even though we are. // Lint thinks we aren't using these, even though we are.
// Possibly because the resolve function is an arrow function that is passed in props? // Possibly because the resolve function is an arrow function that is passed in props?
resolveUri: string => void, resolveUri: string => void,
@ -17,6 +18,10 @@ type Props = {
}; };
class UriIndicator extends React.PureComponent<Props> { class UriIndicator extends React.PureComponent<Props> {
static defaultProps = {
addTooltip: true,
};
componentDidMount() { componentDidMount() {
this.resolve(this.props); this.resolve(this.props);
} }
@ -34,7 +39,7 @@ class UriIndicator extends React.PureComponent<Props> {
}; };
render() { render() {
const { link, isResolvingUri, claim } = this.props; const { link, isResolvingUri, claim, addTooltip } = this.props;
if (!claim) { if (!claim) {
return <span className="empty">{isResolvingUri ? 'Validating...' : 'Unused'}</span>; return <span className="empty">{isResolvingUri ? 'Validating...' : 'Unused'}</span>;
@ -51,9 +56,12 @@ class UriIndicator extends React.PureComponent<Props> {
if (channelClaim) { if (channelClaim) {
const { name, claim_id: claimId } = channelClaim; const { name, claim_id: claimId } = channelClaim;
let channelLink; let channelLink;
if (claim.is_channel_signature_valid) {
// Disabling now because it mostly causes issues
// Add this back to ensure we only add links to signed channels
// if (claim.is_channel_signature_valid) {
channelLink = link ? buildURI({ channelName: name, claimId }) : false; channelLink = link ? buildURI({ channelName: name, claimId }) : false;
} // }
const inner = <span className="channel-name">{name}</span>; const inner = <span className="channel-name">{name}</span>;
@ -61,9 +69,15 @@ class UriIndicator extends React.PureComponent<Props> {
return inner; return inner;
} }
const Wrapper = addTooltip
? ({ children }) => (
<Tooltip label={<ClaimPreview uri={channelLink} type="tooltip" placeholder={false} />}>{children}</Tooltip>
)
: 'span';
return ( return (
<Button className="button--uri-indicator" navigate={channelLink}> <Button className="button--uri-indicator" navigate={channelLink}>
<Tooltip label={<ClaimPreview uri={channelLink} type="small" />}>{inner}</Tooltip> <Wrapper>{inner}</Wrapper>
</Button> </Button>
); );
} else { } else {

View file

@ -226,7 +226,7 @@ class FilePage extends React.Component<Props> {
<div className="media__subtitle"> <div className="media__subtitle">
<div className="media__actions media__actions--between"> <div className="media__actions media__actions--between">
<DateTime uri={uri} show={DateTime.SHOW_DATE} /> <DateTime uri={uri} show={DateTime.SHOW_DATE} />
{'claimIsMine' && ( {claimIsMine && (
<span> <span>
{viewCount} {viewCount !== 1 ? __('Views') : __('View')} {viewCount} {viewCount !== 1 ? __('Views') : __('View')}
</span> </span>
@ -285,7 +285,13 @@ class FilePage extends React.Component<Props> {
</div> </div>
</div> </div>
<hr />
{channelUri ? (
<ClaimPreview uri={channelUri} type="inline" /> <ClaimPreview uri={channelUri} type="inline" />
) : (
<div className="claim-preview--inline claim-preview-title">{__('Anonymous')}</div>
)}
<div className="media__info--large"> <div className="media__info--large">
<FileDetails uri={uri} /> <FileDetails uri={uri} />

View file

@ -107,6 +107,10 @@
.claim-preview { .claim-preview {
border-bottom: 1px solid rgba($lbry-teal-5, 0.1); border-bottom: 1px solid rgba($lbry-teal-5, 0.1);
&:only-of-type {
border: none;
}
[data-mode='dark'] & { [data-mode='dark'] & {
color: $lbry-white; color: $lbry-white;
border-color: var(--dm-color-04); border-color: var(--dm-color-04);
@ -179,7 +183,6 @@
padding: 0; padding: 0;
padding-top: var(--spacing-large); padding-top: var(--spacing-large);
border-bottom: none; border-bottom: none;
border-top: 1px solid $lbry-gray-1;
.channel-thumbnail { .channel-thumbnail {
width: var(--channel-thumbnail-width--small); width: var(--channel-thumbnail-width--small);

View file

@ -60,7 +60,6 @@ fieldset-section {
label { label {
width: auto; width: auto;
text-transform: none; text-transform: none;
font-size: var(--font-multiplier-medium);
} }
} }
@ -83,6 +82,7 @@ radio-element {
color: lighten($lbry-black, 20%); color: lighten($lbry-black, 20%);
margin-bottom: 0; margin-bottom: 0;
margin-left: var(--spacing-miniscule); margin-left: var(--spacing-miniscule);
font-size: var(--font-body);
} }
} }

View file

@ -76,7 +76,6 @@
} }
} }
// TODO: dark
[data-mode='dark'] & { [data-mode='dark'] & {
&:hover { &:hover {
color: $lbry-teal-3; color: $lbry-teal-3;

View file

@ -70,6 +70,10 @@
.media__actions--between { .media__actions--between {
justify-content: space-between; justify-content: space-between;
&:last-of-type:not(:only-of-type) {
margin-bottom: var(--spacing-large);
}
} }
.media__actions--nowrap { .media__actions--nowrap {
@ -84,7 +88,6 @@
.media__action-group--large { .media__action-group--large {
display: flex; display: flex;
margin-bottom: var(--spacing-medium);
font-size: var(--font-multiplier-medium); font-size: var(--font-multiplier-medium);
> * { > * {

View file

@ -39,6 +39,10 @@
color: lighten($lbry-black, 20%); color: lighten($lbry-black, 20%);
margin-top: var(--spacing-small); margin-top: var(--spacing-small);
.icon {
stroke: $lbry-gray-5;
}
&:hover { &:hover {
color: $lbry-teal-4; color: $lbry-teal-4;
.icon { .icon {
@ -57,7 +61,7 @@
color: var(--dm-color-01); color: var(--dm-color-01);
svg { svg {
color: var(--dm-color-01); stroke: var(--dm-color-01);
} }
&:hover, &:hover,
@ -65,7 +69,7 @@
color: $lbry-teal-4; color: $lbry-teal-4;
.icon { .icon {
color: $lbry-teal-4; stroke: $lbry-teal-4;
} }
} }
} }