lbry-desktop/ui/component/fileDescription/view.jsx

87 lines
2.7 KiB
React
Raw Normal View History

// @flow
import * as ICONS from 'constants/icons';
import * as MODALS from 'constants/modal_types';
2020-09-30 22:46:20 +02:00
import React from 'react';
import classnames from 'classnames';
import { formatCredits } from 'util/format-credits';
import MarkdownPreview from 'component/common/markdown-preview';
import ClaimTags from 'component/claimTags';
2020-09-30 22:46:20 +02:00
import Button from 'component/button';
2020-10-23 00:11:22 +02:00
import LbcSymbol from 'component/common/lbc-symbol';
import FileDetails from 'component/fileDetails';
import FileValues from 'component/fileValues';
import { useIsMobile } from 'effects/use-screensize';
type Props = {
uri: string,
expandOverride: boolean,
// redux
description?: string,
amount: number,
hasSupport?: boolean,
isEmpty: boolean,
claimIsMine: boolean,
2020-10-23 00:11:22 +02:00
pendingAmount: number,
doOpenModal: (id: string, {}) => void,
};
export default function FileDescription(props: Props) {
const { uri, description, amount, hasSupport, isEmpty, doOpenModal, claimIsMine, expandOverride } = props;
const isMobile = useIsMobile();
2020-09-30 22:46:20 +02:00
const [expanded, setExpanded] = React.useState(false);
2020-10-23 00:11:22 +02:00
const [showCreditDetails, setShowCreditDetails] = React.useState(false);
2020-10-23 00:11:22 +02:00
const formattedAmount = formatCredits(amount, 2, true);
if (isEmpty) {
2020-09-30 22:46:20 +02:00
return <span className="empty">{__('Empty claim or metadata info.')}</span>;
}
2020-09-30 22:46:20 +02:00
return (
<>
2020-09-30 22:46:20 +02:00
<div
className={classnames({
'media__info-text--contracted media__info-text--fade': !expanded && !expandOverride,
'media__info-text--expanded': expanded,
})}
2020-09-30 22:46:20 +02:00
>
{isMobile && <ClaimTags uri={uri} type="large" />}
<div className="mediaInfo__description">
{description && (
<MarkdownPreview className="markdown-preview--description" content={description} simpleLinks />
)}
{!isMobile && <ClaimTags uri={uri} type="large" />}
<FileDetails uri={uri} />
</div>
2020-09-30 22:46:20 +02:00
</div>
2020-10-23 00:11:22 +02:00
<div className="card__bottom-actions">
wip wip wip - everything but publish, autoplay, and styling collection publishing add channel to collection publish cleanup wip bump clear mass add after success move collection item management controls redirect replace to published collection id bump playlist selector on create bump use new collection add ui element bump wip gitignore add content json wip bump context add to playlist basic collections page style pass wip wip: edits, buttons, styles... change fileAuthor to claimAuthor update, pending bugfixes, delete modal progress, collection header, other bugfixes bump cleaning show page bugfix builtin collection headers no playlists, no grid title wip style tweaks use normal looking claim previews for collection tiles add collection changes style library previews collection menulist for delete/view on library delete modal works for unpublished rearrange collection publish tabs clean up collection publishing and items show on odysee begin collectoin edit header and css renaming better thumbnails bump fix collection publish redirect view collection in menu does something copy and thumbs list previews, pending, context menus, list page enter to add collection, lists page empty state playable lists only, delete feature, bump put fileListDownloaded back better collection titles improve collection claim details fix horiz more icon fix up channel page style, copy, bump refactor preview overlay properties, fix reposts showing as floppydisk add watch later toast, small overlay properties on wunderbar results, fix collection actions buttons bump cleanup cleaning, refactoring bump preview thumb styling, cleanup support discover page lists search sync, bump bump, fix sync more enforce builtin order for now new lists page empty state try to indicate unpublished edits in lists bump fix autoplay and linting consts, fix autoplay bugs fixes cleanup fix, bump lists experimental ui, fixes refactor listIndex out hack in collection fallback thumb bump
2021-02-06 08:03:51 +01:00
{!expandOverride && (
<Button button="link" label={expanded ? __('Less') : __('More')} onClick={() => setExpanded(!expanded)} />
2020-10-23 00:11:22 +02:00
)}
<div className="section__actions--no-margin">
{claimIsMine && hasSupport && (
<Button
button="link"
className="expandable__button"
icon={ICONS.UNLOCK}
aria-label={__('Unlock tips')}
onClick={() => doOpenModal(MODALS.LIQUIDATE_SUPPORTS, { uri })}
/>
)}
<Button button="link" onClick={() => setShowCreditDetails(!showCreditDetails)}>
<LbcSymbol postfix={showCreditDetails ? __('Hide') : formattedAmount} />
</Button>
</div>
2020-10-23 00:11:22 +02:00
</div>
{showCreditDetails && <FileValues uri={uri} />}
</>
2020-09-30 22:46:20 +02:00
);
}