lbry-desktop/ui/page/top/view.jsx

59 lines
1.8 KiB
React
Raw Normal View History

2020-02-11 20:04:51 +01:00
// @flow
import React from 'react';
import classnames from 'classnames';
2020-02-11 20:04:51 +01:00
import Page from 'component/page';
import ClaimListDiscover from 'component/claimListDiscover';
import ClaimEffectiveAmount from 'component/claimEffectiveAmount';
import SearchTopClaim from 'component/searchTopClaim';
import { ORDER_BY_TOP, FRESH_ALL } from 'constants/claim_search';
import Button from 'component/button';
2020-02-11 20:04:51 +01:00
type Props = {
name: string,
};
function TopPage(props: Props) {
const { name } = props;
const [channelActive, setChannelActive] = React.useState(false);
2020-02-11 20:04:51 +01:00
return (
<Page>
<SearchTopClaim query={name} hideLink />
2020-02-11 20:04:51 +01:00
<ClaimListDiscover
name={channelActive ? `@${name}` : name}
defaultFreshness={FRESH_ALL}
defaultOrderBy={ORDER_BY_TOP}
2020-10-23 20:57:40 +02:00
includeSupportAction
renderProperties={claim => (
<span className="claim-preview__custom-properties">
{claim.meta.is_controlling && <span className="help--inline">{__('Currently winning')}</span>}
<ClaimEffectiveAmount uri={claim.repost_url || claim.canonical_url} />
</span>
)}
header={
<div className="claim-search__top-row">
<Button
label={name}
button="alt"
onClick={() => setChannelActive(false)}
className={classnames('button-toggle', {
'button-toggle--active': !channelActive,
})}
/>
<Button
label={`@${name}`}
button="alt"
onClick={() => setChannelActive(true)}
className={classnames('button-toggle', {
'button-toggle--active': channelActive,
})}
/>
</div>
}
2020-02-11 20:04:51 +01:00
/>
</Page>
);
}
export default TopPage;