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

71 lines
2.5 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 * as CS from 'constants/claim_search';
import Button from 'component/button';
import * as MODALS from 'constants/modal_types';
import { SIMPLE_SITE } from 'config';
2020-02-11 20:04:51 +01:00
type Props = {
name: string,
beginPublish: (string) => void,
doOpenModal: (string, {}) => void,
2020-02-11 20:04:51 +01:00
};
function TopPage(props: Props) {
const { name, beginPublish, doOpenModal } = props;
const [channelActive, setChannelActive] = React.useState(false);
// if the query was actually '@name', still offer repost for 'name'
const queryName = name[0] === '@' ? name.slice(1) : name;
2020-02-11 20:04:51 +01:00
return (
<Page className="topPage-wrapper">
<SearchTopClaim query={name} hideLink setChannelActive={setChannelActive} />
2020-02-11 20:04:51 +01:00
<ClaimListDiscover
name={channelActive ? `@${queryName}` : queryName}
defaultFreshness={CS.FRESH_ALL}
defaultOrderBy={CS.ORDER_BY_TOP}
streamType={SIMPLE_SITE ? CS.CONTENT_ALL : undefined}
meta={
<div className="search__top-links">
<Button button="secondary" onClick={() => doOpenModal(MODALS.REPOST, {})} label={__('Repost Here')} />
2022-02-18 12:34:14 +01:00
<Button button="secondary" onClick={() => beginPublish(queryName)} label={__('Publish Here')} />
</div>
}
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={
2020-11-13 21:25:18 +01:00
<div className="claim-search__menu-group">
<Button
label={queryName}
button="alt"
onClick={() => setChannelActive(false)}
className={classnames('button-toggle', {
'button-toggle--active': !channelActive,
})}
/>
<Button
label={`@${queryName}`}
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;