From efa2e44937c3e1cd9a17d9817767326b1db65da5 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Fri, 7 Oct 2022 16:26:23 -0500 Subject: [PATCH] comment bounty dialog, styling --- .../contract/bountied-contract-badge.tsx | 66 +++++++++++++------ ...t-bounty.tsx => comment-bounty-dialog.tsx} | 59 ++++++++++------- web/components/contract/contract-tabs.tsx | 2 +- .../contract/liquidity-bounty-panel.tsx | 7 +- 4 files changed, 83 insertions(+), 51 deletions(-) rename web/components/contract/{add-comment-bounty.tsx => comment-bounty-dialog.tsx} (52%) diff --git a/web/components/contract/bountied-contract-badge.tsx b/web/components/contract/bountied-contract-badge.tsx index 79589990..1f371b14 100644 --- a/web/components/contract/bountied-contract-badge.tsx +++ b/web/components/contract/bountied-contract-badge.tsx @@ -1,12 +1,16 @@ +import clsx from 'clsx' +import { useState } from 'react' + import { CurrencyDollarIcon } from '@heroicons/react/outline' import { Contract } from 'common/contract' import { Tooltip } from 'web/components/tooltip' import { formatMoney } from 'common/util/format' import { COMMENT_BOUNTY_AMOUNT } from 'common/economy' +import { CommentBountyDialog } from './comment-bounty-dialog' export function BountiedContractBadge() { return ( - + Bounty ) @@ -18,30 +22,50 @@ export function BountiedContractSmallBadge(props: { }) { const { contract, showAmount } = props const { openCommentBounties } = contract - if (!openCommentBounties) return
- return ( - - - - {showAmount && formatMoney(openCommentBounties)} Bounty - - + const [open, setOpen] = useState(false) + + if (!openCommentBounties && !showAmount) return <> + + const modal = ( + ) -} + if (!openCommentBounties) + return ( + <> + {modal} + setOpen(true)} /> + + ) -export const CommentBountiesTooltipText = ( - creator: string, - openCommentBounties: number -) => - `${creator} may award ${formatMoney( + const tooltip = `${contract.creatorName} may award ${formatMoney( COMMENT_BOUNTY_AMOUNT )} for good comments. ${formatMoney( openCommentBounties )} currently available.` + + return ( + + {modal} + setOpen(true)} + /> + + ) +} + +function SmallBadge(props: { text: string; onClick?: () => void }) { + const { text, onClick } = props + return ( + + ) +} diff --git a/web/components/contract/add-comment-bounty.tsx b/web/components/contract/comment-bounty-dialog.tsx similarity index 52% rename from web/components/contract/add-comment-bounty.tsx rename to web/components/contract/comment-bounty-dialog.tsx index 8b716e71..e5ae4c39 100644 --- a/web/components/contract/add-comment-bounty.tsx +++ b/web/components/contract/comment-bounty-dialog.tsx @@ -8,9 +8,16 @@ import clsx from 'clsx' import { formatMoney } from 'common/util/format' import { COMMENT_BOUNTY_AMOUNT } from 'common/economy' import { Button } from 'web/components/button' +import { Title } from '../title' +import { Col } from '../layout/col' +import { Modal } from '../layout/modal' -export function AddCommentBountyPanel(props: { contract: Contract }) { - const { contract } = props +export function CommentBountyDialog(props: { + contract: Contract + open: boolean + setOpen: (open: boolean) => void +}) { + const { contract, open, setOpen } = props const { id: contractId, slug } = contract const user = useUser() @@ -45,30 +52,34 @@ export function AddCommentBountyPanel(props: { contract: Contract }) { } return ( - <> -
- Add a {formatMoney(amount)} bounty for good comments that the creator - can award.{' '} - {totalAdded > 0 && `(${formatMoney(totalAdded)} currently added)`} -
+ + + - <Row className={'items-center gap-2'}> - <Button - className={clsx('ml-2', isLoading && 'btn-disabled')} - onClick={submit} - disabled={isLoading} - color={'blue'} - > - Add {formatMoney(amount)} bounty - </Button> - <span className={'text-error'}>{error}</span> - </Row> + <div className="mb-4 text-gray-500"> + Add a {formatMoney(amount)} bounty for good comments that the creator + can award.{' '} + {totalAdded > 0 && `(${formatMoney(totalAdded)} currently added)`} + </div> - {isSuccess && amount && ( - <div>Success! Added {formatMoney(amount)} in bounties.</div> - )} + <Row className={'items-center gap-2'}> + <Button + className={clsx('ml-2', isLoading && 'btn-disabled')} + onClick={submit} + disabled={isLoading} + color={'blue'} + > + Add {formatMoney(amount)} bounty + </Button> + <span className={'text-error'}>{error}</span> + </Row> - {isLoading && <div>Processing...</div>} - </> + {isSuccess && amount && ( + <div>Success! Added {formatMoney(amount)} in bounties.</div> + )} + + {isLoading && <div>Processing...</div>} + </Col> + </Modal> ) } diff --git a/web/components/contract/contract-tabs.tsx b/web/components/contract/contract-tabs.tsx index 7b2886aa..8531697b 100644 --- a/web/components/contract/contract-tabs.tsx +++ b/web/components/contract/contract-tabs.tsx @@ -123,7 +123,7 @@ const CommentsTabContent = memo(function CommentsTabContent(props: { const topLevelComments = commentsByParent['_'] ?? [] const sortRow = comments.length > 0 && ( - <Row className="mb-2 items-center"> + <Row className="mb-4 items-center"> <Button size={'xs'} color={'gray-white'} diff --git a/web/components/contract/liquidity-bounty-panel.tsx b/web/components/contract/liquidity-bounty-panel.tsx index 4cc7fd70..347f41b3 100644 --- a/web/components/contract/liquidity-bounty-panel.tsx +++ b/web/components/contract/liquidity-bounty-panel.tsx @@ -16,7 +16,6 @@ import { InfoTooltip } from 'web/components/info-tooltip' import { BETTORS, PRESENT_BET } from 'common/user' import { buildArray } from 'common/util/array' import { useAdmin } from 'web/hooks/use-admin' -import { AddCommentBountyPanel } from 'web/components/contract/add-comment-bounty' export function LiquidityBountyPanel(props: { contract: Contract }) { const { contract } = props @@ -36,13 +35,11 @@ export function LiquidityBountyPanel(props: { contract: Contract }) { const isCreator = user?.id === contract.creatorId const isAdmin = useAdmin() + if (!isCreator && !isAdmin && !showWithdrawal) return <></> + return ( <Tabs tabs={buildArray( - { - title: 'Bounty Comments', - content: <AddCommentBountyPanel contract={contract} />, - }, (isCreator || isAdmin) && isCPMM && { title: (isAdmin ? '[Admin] ' : '') + 'Subsidize',