Skip to content

Commit

Permalink
Merge pull request #159 from 1Hive/quest-detail-pimpup
Browse files Browse the repository at this point in the history
Quest detail one scroll + creation time +display claim even if bounty…
  • Loading branch information
Corantin committed Feb 3, 2022
2 parents ab5ed53 + 31ab20f commit b14a7f7
Show file tree
Hide file tree
Showing 15 changed files with 210 additions and 125 deletions.
68 changes: 33 additions & 35 deletions packages/react-app/src/collapsable-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,40 +66,38 @@ export function CollapsableBlock(props: Props) {
}, [props, props.children]);

return (
<div>
<pre>
<LineStyled>
<CollapseButtonStyled onClick={() => setVisible(!isVisible)}>
<IconColumnStyled>
{isVisible ? (
<>
<IconDown size="tiny" />
<IconUp size="tiny" />
</>
) : (
<>
<IconUp size="tiny" />
<IconDown size="tiny" />
</>
)}
</IconColumnStyled>
<LabelStyled>
{isVisible ? 'Hide ' : 'Show '}
{props.label}
</LabelStyled>
</CollapseButtonStyled>
{isVisible && (
<CopyButtonStyled
onClick={() => copyCode(content)}
icon={<IconCopy />}
size="small"
label="Copy"
display="icon"
/>
)}
</LineStyled>
{isVisible && content ? <ContentWrapperStyled>{content}</ContentWrapperStyled> : <></>}
</pre>
</div>
<pre>
<LineStyled>
<CollapseButtonStyled onClick={() => setVisible(!isVisible)}>
<IconColumnStyled>
{isVisible ? (
<>
<IconDown size="tiny" />
<IconUp size="tiny" />
</>
) : (
<>
<IconUp size="tiny" />
<IconDown size="tiny" />
</>
)}
</IconColumnStyled>
<LabelStyled>
{isVisible ? 'Hide ' : 'Show '}
{props.label}
</LabelStyled>
</CollapseButtonStyled>
{isVisible && (
<CopyButtonStyled
onClick={() => copyCode(content)}
icon={<IconCopy />}
size="small"
label="Copy"
display="icon"
/>
)}
</LineStyled>
{isVisible && content ? <ContentWrapperStyled>{content}</ContentWrapperStyled> : <></>}
</pre>
);
}
11 changes: 2 additions & 9 deletions packages/react-app/src/components/claim-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Props = {
questData: QuestModel;
newClaim: number;
challengeDeposit: TokenAmountModel;
questTotalBounty?: TokenAmountModel;
questTotalBounty?: TokenAmountModel | null;
};

export default function ClaimList({
Expand Down Expand Up @@ -134,14 +134,7 @@ export default function ClaimList({
<AmountFieldInput
id="amount"
label="Claimed amount"
isLoading={
!claim.claimedAmount.parsedAmount && questTotalBounty === undefined
}
value={
claim.claimedAmount.parsedAmount || !questTotalBounty
? claim.claimedAmount
: questTotalBounty
}
value={claim.claimedAmount}
/>
) : (
<Field label="Claimed amount">All available</Field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function AmountFieldInput({
};

const amountField = (
<FieldInput label={amountLabel} isLoading={isLoading} wide={wide} compact={compact}>
<FieldInput label={amountLabel} wide={wide} compact={compact}>
<AmountTokenWrapperStyled isEdit={isEdit} wide={wide}>
{amount !== undefined &&
(isEdit ? (
Expand All @@ -245,7 +245,6 @@ function AmountFieldInput({
const tokenField = (
<FieldInput
label={tokenLabel}
isLoading={isLoading}
wide={wide}
compact={compact}
tooltip="Token"
Expand Down Expand Up @@ -291,7 +290,7 @@ function AmountFieldInput({
label={label}
tooltip={tooltip}
tooltipDetail={tooltipDetail}
isLoading={false}
isLoading={isLoading}
wide={wide}
compact
direction={!!amountLabel || !!tokenLabel ? 'column' : 'row'}
Expand Down
11 changes: 7 additions & 4 deletions packages/react-app/src/components/field-input/field-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import styled from 'styled-components';
import { IconTooltip } from './icon-tooltip';

const FieldStyled = styled.div`
${({ compact }: any) => (!compact ? `margin-bottom:${GUpx(2)}` : '')};
${({ compact }: any) => (!compact ? `margin-bottom:${GUpx(1)}` : '')};
${({ isLoading, wide }: any) => (isLoading || wide ? `width: 100%;` : 'max-width: 100%;')};
`;

Expand All @@ -30,14 +30,15 @@ const LineStyled = styled.div`

const ContentWrapperStyled = styled.div`
display: flex;
align-items: center;
align-items: ${({ align }: any) => align};
${(props: any) => (!props.compact ? 'min-height: 45px;' : '')}
& > div {
input {
${({ wide }: any) => (wide ? `max-width:none;` : '')}
}
}
flex-direction: ${({ direction }: any) => direction};
padding-left: ${GUpx(0.5)};
`;

const SkeletonWrapperStyled = styled.div`
Expand All @@ -52,9 +53,10 @@ type Props = {
tooltipDetail?: React.ReactNode;
children: React.ReactNode;
id?: string;
isLoading: boolean;
isLoading?: boolean;
wide?: boolean;
direction?: 'row' | 'column';
align?: 'center' | 'baseline' | 'flex-start' | 'flex-end' | 'unset';
};

export function FieldInput({
Expand All @@ -67,6 +69,7 @@ export function FieldInput({
isLoading = false,
wide = false,
direction = 'row',
align = 'center',
}: Props) {
const theme = useTheme();
const labelComponent = label && (
Expand All @@ -86,7 +89,7 @@ export function FieldInput({
<Skeleton />
</SkeletonWrapperStyled>
) : (
<ContentWrapperStyled compact={compact} wide={wide} direction={direction}>
<ContentWrapperStyled compact={compact} wide={wide} direction={direction} align={align}>
{children}
</ContentWrapperStyled>
)}
Expand Down
31 changes: 16 additions & 15 deletions packages/react-app/src/components/field-input/icon-tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Help, IconQuestion, useTheme } from '@1hive/1hive-ui';
import { ReactNode } from 'react';
import { GUpx } from 'src/utils/css.util';
import styled from 'styled-components';
import { Outset } from '../utils/spacer-util';

// #region Styled

Expand Down Expand Up @@ -30,12 +30,15 @@ const TooltipWrapperStyled = styled.div`

const HelpWrapperStyled = styled.div`
width: 16px;
display: inline-block;
margin-left: ${GUpx()};
margin-right: ${GUpx(0.5)};
`;

// #endregion

type Props = {
tooltip: string;
tooltip?: string;
tooltipDetail?: ReactNode;
icon?: ReactNode;
children?: ReactNode;
Expand All @@ -44,18 +47,16 @@ type Props = {
export const IconTooltip = ({ tooltip, tooltipDetail, icon, children }: Props) => {
const theme = useTheme();
return (
<Outset horizontal>
<HelpWrapperStyled className="btn-no-margin">
{tooltipDetail || children ? (
<Help hint={tooltip}>
<TooltipWrapperStyled color={theme.accentContent}>
{tooltipDetail ?? children}
</TooltipWrapperStyled>
</Help>
) : (
<IconSpanStyled title={tooltip}>{icon ?? <IconQuestion size="tiny" />}</IconSpanStyled>
)}
</HelpWrapperStyled>
</Outset>
<HelpWrapperStyled className="btn-no-margin">
{tooltipDetail || children ? (
<Help hint={tooltip ?? tooltipDetail}>
<TooltipWrapperStyled color={theme.accentContent}>
{tooltipDetail ?? children}
</TooltipWrapperStyled>
</Help>
) : (
<IconSpanStyled title={tooltip}>{icon ?? <IconQuestion size="tiny" />}</IconSpanStyled>
)}
</HelpWrapperStyled>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ export default function TextFieldInput({
content={value}
markdownToJsxOptions={(o: any) => ({
...o,
wrapper: 'div',

overrides: {
p: {
component: 'div',
},
pre: {
component: CollapsableBlock,
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const OpenButtonWrapperStyled = styled.div`

type Props = {
claim: ClaimModel;
questTotalBounty?: TokenAmountModel;
questTotalBounty?: TokenAmountModel | null;
onClose?: ModalCallback;
};

Expand Down Expand Up @@ -135,6 +135,7 @@ export default function ExecuteClaimModal({ claim, questTotalBounty, onClose = n
loading ||
!scheduleTimeout ||
claim.state === ENUM_CLAIM_STATE.Challenged ||
questTotalBounty ||
!walletAddress
}
/>
Expand Down
12 changes: 6 additions & 6 deletions packages/react-app/src/components/modals/fund-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ export default function FundModal({ quest, onClose = noop }: Props) {
>
<FormStyled id="form-fund" onSubmit={handleSubmit} ref={formRef}>
<Outset gu16>
<AddressFieldInput
id="address"
label="Quest address"
value={quest.address}
isLoading={loading}
/>
<AmountFieldInputFormik
id="fundAmount"
isEdit
Expand All @@ -147,12 +153,6 @@ export default function FundModal({ quest, onClose = noop }: Props) {
isLoading={loading}
value={values.fundAmount}
/>
<AddressFieldInput
id="address"
label="Quest address"
value={quest.address}
isLoading={loading}
/>
</Outset>
</FormStyled>
</ModalBase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import * as QuestService from '../../services/quest.service';
import { Outset } from '../utils/spacer-util';
import { DisputeModel } from '../../models/dispute.model';
import TextFieldInput from '../field-input/text-field-input';
import { IconTooltip } from '../field-input/icon-tooltip';

// #region StyledComponents

Expand Down Expand Up @@ -65,7 +66,7 @@ const RulingInfoStyled = styled(Info)`
width: 100%;
`;

const OnlySHWarn = styled(Info)`
const OnlyStackholderWarnStyled = styled(Info)`
padding: ${GUpx()};
display: flex;
align-items: center;
Expand Down Expand Up @@ -198,9 +199,22 @@ export default function ResolveChallengeModal({ claim, onClose = noop }: Props)
) : (
<>
Ruling in progress, please come back later...
<LinkStyled href={`https://celeste.1hive.org/#/disputes/${dispute.id}`}>
See dispute
</LinkStyled>
{process.env.NODE_ENV === 'production' ? (
<LinkStyled
external
href={
process.env.NODE_ENV === 'production' &&
`https://celeste.1hive.org/#/disputes/${dispute.id}`
}
>
See dispute
</LinkStyled>
) : (
<IconTooltip
tooltipDetail={`This is a mocked celeste dispute with id ${dispute.id}`}
key={dispute.id}
/>
)}
</>
)}
</FinalRulingStyled>
Expand Down Expand Up @@ -233,10 +247,10 @@ export default function ResolveChallengeModal({ claim, onClose = noop }: Props)
buttons={[
<Fragment key="warnMessage">
{isRuled && !isStackholder && (
<OnlySHWarn mode="warning">
<OnlyStackholderWarnStyled mode="warning">
<IconCaution />
<span> Only a stackholder of this challenge may resolve it</span>
</OnlySHWarn>
</OnlyStackholderWarnStyled>
)}
</Fragment>,
<Button
Expand Down

1 comment on commit b14a7f7

@vercel
Copy link

@vercel vercel bot commented on b14a7f7 Feb 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

Please sign in to comment.