forked from Joystream/atlas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'crt' into fix/crt-follow-up
# Conflicts: # packages/atlas/src/components/CrtPreviewLayout/CrtPreviewLayout.tsx # packages/atlas/src/components/_crt/CrtStatusWidget/CrtStatusWidget.tsx # packages/atlas/src/views/viewer/ChannelView/ChannelViewTabs/ChannelToken.tsx
- Loading branch information
Showing
18 changed files
with
649 additions
and
345 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
packages/atlas/src/api/queries/__generated__/creatorTokens.generated.tsx
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
packages/atlas/src/api/queries/__generated__/fragments.generated.tsx
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
packages/atlas/src/components/_crt/AmmModalTemplates/AmmModalFormTemplate.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { ReactNode } from 'react' | ||
import { Control, Controller, Validate } from 'react-hook-form' | ||
|
||
import { FlexBox } from '@/components/FlexBox' | ||
import { Information } from '@/components/Information' | ||
import { Text } from '@/components/Text' | ||
import { TextButton } from '@/components/_buttons/Button' | ||
import { FormField } from '@/components/_inputs/FormField' | ||
import { TokenInput } from '@/components/_inputs/TokenInput' | ||
import { useTokenPrice } from '@/providers/joystream' | ||
|
||
type AmmModalFormTemplateProps = { | ||
validation?: Validate<number> | ||
maxValue?: number | ||
pricePerUnit?: number | ||
control: Control<{ tokens: number }> | ||
details?: { | ||
title: string | ||
content: ReactNode | ||
tooltipText?: string | ||
}[] | ||
error?: string | ||
} | ||
|
||
export const AmmModalFormTemplate = ({ | ||
validation, | ||
maxValue, | ||
pricePerUnit, | ||
details, | ||
control, | ||
error, | ||
}: AmmModalFormTemplateProps) => { | ||
const { convertTokensToUSD } = useTokenPrice() | ||
|
||
return ( | ||
<FlexBox flow="column" gap={8}> | ||
<Controller | ||
name="tokens" | ||
control={control} | ||
rules={{ | ||
validate: { | ||
...(validation ? { valid: validation } : {}), | ||
}, | ||
}} | ||
render={({ field }) => ( | ||
<FormField error={error}> | ||
<TokenInput | ||
value={field.value} | ||
onChange={field.onChange} | ||
placeholder="0" | ||
nodeEnd={ | ||
<FlexBox gap={2} alignItems="baseline"> | ||
{pricePerUnit ? ( | ||
<Text variant="t300" as="p" color="colorTextMuted"> | ||
${convertTokensToUSD((field.value || 0) * pricePerUnit)?.toFixed(2)} | ||
</Text> | ||
) : null} | ||
{maxValue ? <TextButton onClick={() => field.onChange(maxValue)}>Max</TextButton> : null} | ||
</FlexBox> | ||
} | ||
/> | ||
</FormField> | ||
)} | ||
/> | ||
<FlexBox flow="column" gap={2}> | ||
{details?.map((row, i) => ( | ||
<FlexBox key={row.title} alignItems="center" justifyContent="space-between"> | ||
<FlexBox width="auto" alignItems="center"> | ||
<Text variant={i + 1 === details.length ? 't200-strong' : 't200'} as="span" color="colorText"> | ||
{row.title} | ||
</Text> | ||
{row.tooltipText ? <Information text={row.tooltipText} /> : null} | ||
</FlexBox> | ||
{row.content} | ||
</FlexBox> | ||
))} | ||
</FlexBox> | ||
</FlexBox> | ||
) | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/atlas/src/components/_crt/AmmModalTemplates/AmmModalSummaryTemplate.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ReactNode } from 'react' | ||
|
||
import { FlexBox } from '@/components/FlexBox' | ||
import { Information } from '@/components/Information' | ||
import { Text } from '@/components/Text' | ||
|
||
type AmmModalSummaryTemplateProps = { | ||
details?: { | ||
title: string | ||
content: ReactNode | ||
tooltipText?: string | ||
}[] | ||
} | ||
|
||
export const AmmModalSummaryTemplate = ({ details }: AmmModalSummaryTemplateProps) => { | ||
return ( | ||
<FlexBox flow="column" gap={5}> | ||
{details?.map((row, i) => ( | ||
<FlexBox key={row.title} alignItems="center" justifyContent="space-between"> | ||
<FlexBox width="auto" alignItems="center"> | ||
<Text variant={i + 1 === details.length ? 't200-strong' : 't200'} as="span" color="colorText"> | ||
{row.title} | ||
</Text> | ||
{row.tooltipText ? <Information text={row.tooltipText} /> : null} | ||
</FlexBox> | ||
{row.content} | ||
</FlexBox> | ||
))} | ||
</FlexBox> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './AmmModalFormTemplate' |
20 changes: 20 additions & 0 deletions
20
packages/atlas/src/components/_crt/BuyFromMarketButton/BuyFromMarketButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useState } from 'react' | ||
|
||
import { Button } from '@/components/_buttons/Button' | ||
import { BuyMarketTokenModal } from '@/components/_crt/BuyMarketTokenModal' | ||
|
||
type BuyFromMarketButtonProps = { | ||
tokenId: string | ||
} | ||
|
||
export const BuyFromMarketButton = ({ tokenId }: BuyFromMarketButtonProps) => { | ||
const [showModal, setShowModal] = useState(false) | ||
return ( | ||
<> | ||
<BuyMarketTokenModal tokenId={tokenId} show={showModal} onClose={() => setShowModal(false)} /> | ||
<Button size="large" onClick={() => setShowModal(true)}> | ||
Buy | ||
</Button> | ||
</> | ||
) | ||
} |
Oops, something went wrong.