Recommended bar: extra options for ease of discovery

This commit is contained in:
saltrafael 2021-04-06 15:59:12 -03:00 committed by Sean Yesmunt
parent 6ccbbebad9
commit 6718d87848
3 changed files with 159 additions and 20 deletions

View file

@ -17,6 +17,8 @@ import { useIsLargeScreen } from 'effects/use-screensize';
type Props = { type Props = {
uris: Array<string>, uris: Array<string>,
showHeader: boolean,
type: string,
subscribedChannels: Array<Subscription>, subscribedChannels: Array<Subscription>,
doClaimSearch: ({}) => void, doClaimSearch: ({}) => void,
loading: boolean, loading: boolean,
@ -72,6 +74,8 @@ function ClaimListDiscover(props: Props) {
const { const {
doClaimSearch, doClaimSearch,
claimSearchByQuery, claimSearchByQuery,
showHeader = true,
type,
claimSearchByQueryLastPageReached, claimSearchByQueryLastPageReached,
tags, tags,
defaultTags, defaultTags,
@ -503,13 +507,15 @@ function ClaimListDiscover(props: Props) {
</div> </div>
) : ( ) : (
<div> <div>
{showHeader && (
<div className="section__header--actions"> <div className="section__header--actions">
{headerToUse} {headerToUse}
{meta && <div className="section__actions--no-margin">{meta}</div>} {meta && <div className="section__actions--no-margin">{meta}</div>}
</div> </div>
)}
<ClaimList <ClaimList
id={claimSearchCacheQuery} id={claimSearchCacheQuery}
type={type}
loading={loading} loading={loading}
uris={uris || claimSearchResult} uris={uris || claimSearchResult}
onScrollBottom={handleScrollBottom} onScrollBottom={handleScrollBottom}
@ -521,7 +527,7 @@ function ClaimListDiscover(props: Props) {
injectedItem={injectedItem} injectedItem={injectedItem}
showHiddenByUser={showHiddenByUser} showHiddenByUser={showHiddenByUser}
/> />
{loading && new Array(dynamicPageSize).fill(1).map((x, i) => <ClaimPreview key={i} placeholder="loading" />)} {loading && new Array(dynamicPageSize).fill(1).map((x, i) => <ClaimPreview key={i} placeholder="loading" type={type} />)}
</div> </div>
)} )}
</React.Fragment> </React.Fragment>

View file

@ -1,10 +1,13 @@
// @flow // @flow
import { SHOW_ADS, SIMPLE_SITE } from 'config'; import { SHOW_ADS, SIMPLE_SITE } from 'config';
import React from 'react'; import React from 'react';
import classnames from 'classnames';
import ClaimList from 'component/claimList'; import ClaimList from 'component/claimList';
import ClaimListDiscover from 'component/claimListDiscover';
import Ads from 'web/component/ads'; import Ads from 'web/component/ads';
import Card from 'component/common/card'; import Card from 'component/common/card';
import { useIsMobile, useIsMediumScreen } from 'effects/use-screensize'; import { useIsMobile, useIsMediumScreen } from 'effects/use-screensize';
import Button from 'component/button';
type Props = { type Props = {
uri: string, uri: string,
@ -26,6 +29,14 @@ export default function RecommendedContent(props: Props) {
isSearching, isSearching,
isAuthenticated, isAuthenticated,
} = props; } = props;
const [expanded, setExpanded] = React.useState(false);
const [allRelated, setAllRelated] = React.useState(true);
const [moreFrom, setMoreFrom] = React.useState(false);
const [tagList, setTagList] = React.useState(false);
const signingChannel = claim && claim.signing_channel;
const channelName = signingChannel ? signingChannel.name : null;
const claimValue = claim && claim.value;
const tags = claimValue ? claimValue.tags : null;
const isMobile = useIsMobile(); const isMobile = useIsMobile();
const isMedium = useIsMediumScreen(); const isMedium = useIsMediumScreen();
@ -55,7 +66,56 @@ export default function RecommendedContent(props: Props) {
smallTitle={!isMobile && !isMedium} smallTitle={!isMobile && !isMedium}
className="file-page__recommended" className="file-page__recommended"
title={__('Related')} title={__('Related')}
subtitle={
<div
className={classnames({
'related_content-more--contracted': !expanded,
'related_content-more--expanded': expanded,
})}
>
<Button
button="alt"
label={__('All')}
onClick={() => {
setAllRelated(true);
setMoreFrom(false);
setTagList(false);
}}
/>
{channelName && (
<Button
button="alt"
label={__('More from %claim_name%', { claim_name: channelName })}
onClick={() => {
setAllRelated(false);
setMoreFrom(true);
setTagList(false);
}}
/>
)}
{tags &&
(expanded ? (
<Button button="link" label={__('Less')} onClick={() => setExpanded(!expanded)} />
) : (
<Button button="link" label={__('More')} onClick={() => setExpanded(!expanded)} />
))}
{tags &&
tags.map((name) => (
<Button
button="alt"
label={__(`${name}`)}
onClick={() => {
setAllRelated(false);
setMoreFrom(false);
setTagList(name);
}}
/>
))}
</div>
}
body={ body={
<div>
{allRelated && (
<ClaimList <ClaimList
type="small" type="small"
loading={isSearching} loading={isSearching}
@ -74,6 +134,61 @@ export default function RecommendedContent(props: Props) {
} }
empty={__('No related content found')} empty={__('No related content found')}
/> />
)}
{moreFrom && (
<ClaimListDiscover
hideAdvancedFilter={true}
tileLayout={false}
showHeader={false}
type="small"
claimType={['stream']}
orderBy="new"
pageSize={20}
infiniteScroll={false}
hideFilters={true}
channelIds={[signingChannel.claim_id]}
loading={isSearching}
hideMenu={isMobile}
injectedItem={
SHOW_ADS && IS_WEB ? (
SIMPLE_SITE ? (
<Ads small type={'google'} uri={uri} />
) : (
!isAuthenticated && <Ads small type={'video'} />
)
) : (
false
)
}
empty={__('No related content found')}
/>
)}
{tagList && (
<ClaimListDiscover
hideAdvancedFilter={true}
type="small"
claimType={['stream']}
feeAmount="0"
pageSize={20}
infiniteScroll={false}
tags={[tagList]}
loading={isSearching}
hideMenu={isMobile}
injectedItem={
SHOW_ADS && IS_WEB ? (
SIMPLE_SITE ? (
<Ads small type={'google'} uri={uri} />
) : (
!isAuthenticated && <Ads small type={'video'} />
)
) : (
false
)
}
empty={__('No related content found')}
/>
)}
</div>
} }
/> />
); );

View file

@ -255,6 +255,24 @@
color: var(--color-text-subtitle); color: var(--color-text-subtitle);
margin: var(--spacing-s) 0; margin: var(--spacing-s) 0;
font-size: var(--font-body); font-size: var(--font-body);
.button{
margin: calc(var(--spacing-xxs) / 2) calc(var(--spacing-xxs) / 2);
height: calc(var(--height-button) * 2 / 3);
padding: var(--spacing-s);
border-radius: var(--height-input);
font-size: var(--font-small);
}
}
.related_content-more--contracted {
margin: calc(var(--spacing-s) * -1) 0;
height: calc(var(--height-button) * 0.9);
overflow: hidden;
}
.related_content-more--expanded {
margin: calc(var(--spacing-s) * -1) 0;
} }
.card__body { .card__body {