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 feature/revenue-share-participation-widget
# Conflicts: # packages/atlas/src/views/studio/CrtDashboard/tabs/CrtRevenueTab.tsx
- Loading branch information
Showing
20 changed files
with
3,281 additions
and
1,785 deletions.
There are no files selected for viewing
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
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
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
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
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
49 changes: 49 additions & 0 deletions
49
packages/atlas/src/components/_crt/MarketDrawer/MarketDrawer.stories.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,49 @@ | ||
import { ApolloProvider } from '@apollo/client' | ||
import { Meta, StoryFn } from '@storybook/react' | ||
|
||
import { createApolloClient } from '@/api' | ||
import { CrtMarketSaleViewProps, MarketDrawer } from '@/components/_crt/MarketDrawer' | ||
import { AuthProvider } from '@/providers/auth/auth.provider' | ||
import { ConfirmationModalProvider } from '@/providers/confirmationModal' | ||
import { JoystreamProvider } from '@/providers/joystream/joystream.provider' | ||
import { OverlayManagerProvider } from '@/providers/overlayManager' | ||
import { SegmentAnalyticsProvider } from '@/providers/segmentAnalytics/segment.provider' | ||
import { UserProvider } from '@/providers/user/user.provider' | ||
import { WalletProvider } from '@/providers/wallet/wallet.provider' | ||
|
||
export default { | ||
title: 'crt/CrtMarket', | ||
component: MarketDrawer, | ||
decorators: [ | ||
(Story) => ( | ||
<JoystreamProvider> | ||
<ApolloProvider client={createApolloClient()}> | ||
<WalletProvider> | ||
<SegmentAnalyticsProvider> | ||
<ConfirmationModalProvider> | ||
<AuthProvider> | ||
<UserProvider> | ||
<OverlayManagerProvider> | ||
<Story /> | ||
</OverlayManagerProvider> | ||
</UserProvider> | ||
</AuthProvider> | ||
</ConfirmationModalProvider> | ||
</SegmentAnalyticsProvider> | ||
</WalletProvider> | ||
</ApolloProvider> | ||
</JoystreamProvider> | ||
), | ||
], | ||
} as Meta<CrtMarketSaleViewProps> | ||
|
||
const Template: StoryFn<CrtMarketSaleViewProps> = (args) => <MarketDrawer {...args} /> | ||
|
||
export const Default = Template.bind({}) | ||
Default.args = { | ||
show: true, | ||
onClose: () => { | ||
return null | ||
}, | ||
tokenName: 'JBC', | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/atlas/src/components/_crt/MarketDrawer/MarketDrawer.styles.ts
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,13 @@ | ||
import styled from '@emotion/styled' | ||
|
||
import { sizes } from '@/styles' | ||
import { Divider } from '@/views/global/NftSaleBottomDrawer/NftForm/AcceptTerms/AcceptTerms.styles' | ||
|
||
export const ChartBox = styled.div` | ||
height: 300px; | ||
width: 100%; | ||
` | ||
|
||
export const HDivider = styled(Divider)` | ||
margin: ${sizes(4)} 0; | ||
` |
108 changes: 108 additions & 0 deletions
108
packages/atlas/src/components/_crt/MarketDrawer/MarketDrawer.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,108 @@ | ||
import { useCallback, useRef, useState } from 'react' | ||
import { flushSync } from 'react-dom' | ||
import { CSSTransition, SwitchTransition } from 'react-transition-group' | ||
|
||
import { ActionDialogButtonProps } from '@/components/ActionBar' | ||
import { CrtDrawer } from '@/components/CrtDrawer' | ||
import { CrtMarketForm } from '@/components/_crt/MarketDrawer/MarketDrawer.types' | ||
import { MarketDrawerPreview } from '@/components/_crt/MarketDrawer/MarketDrawerPreview' | ||
import { MarketStep } from '@/components/_crt/MarketDrawer/steps/MarketStep' | ||
import { SaleSummaryStep } from '@/components/_crt/MarketDrawer/steps/SaleSummaryStep' | ||
import { atlasConfig } from '@/config' | ||
import { transitions } from '@/styles' | ||
|
||
enum MARKET_STEPS { | ||
market, | ||
saleSummary, | ||
} | ||
const marketStepsNames: string[] = ['Market', 'Sale summary'] | ||
|
||
export type CrtMarketSaleViewProps = { | ||
tokenName: string | ||
show: boolean | ||
onClose: () => void | ||
} | ||
|
||
export const MarketDrawer = ({ show, onClose, tokenName }: CrtMarketSaleViewProps) => { | ||
const [activeStep, setActiveStep] = useState(MARKET_STEPS.market) | ||
const [marketData, setMarketData] = useState<CrtMarketForm>({ | ||
price: 0, | ||
tnc: atlasConfig.legal.crtTnc, | ||
isChecked: true, | ||
}) | ||
const [primaryButtonProps, setPrimaryButtonProps] = useState<ActionDialogButtonProps>({ text: 'Continue' }) | ||
const [secondaryButtonProps, setSecondaryButtonProps] = useState<ActionDialogButtonProps>({ text: 'Back' }) | ||
const [isGoingBack, setIsGoingBack] = useState(false) | ||
const nodeRef = useRef<HTMLDivElement>(null) | ||
|
||
const handleNextStep = useCallback( | ||
({ price, tnc }: CrtMarketForm) => { | ||
setMarketData({ ...marketData, price, tnc }) | ||
setActiveStep(MARKET_STEPS.saleSummary) | ||
}, | ||
[marketData] | ||
) | ||
|
||
const handleBackClick = useCallback(() => { | ||
flushSync(() => { | ||
setIsGoingBack(true) | ||
}) | ||
setActiveStep(MARKET_STEPS.market) | ||
}, []) | ||
|
||
const stepContent = () => { | ||
switch (activeStep) { | ||
case MARKET_STEPS.market: | ||
return ( | ||
<MarketStep | ||
setPrimaryButtonProps={setPrimaryButtonProps} | ||
setSecondaryButtonProps={setSecondaryButtonProps} | ||
tokenName={tokenName} | ||
onClose={onClose} | ||
formDefaultValue={marketData} | ||
onNextStep={handleNextStep} | ||
/> | ||
) | ||
case MARKET_STEPS.saleSummary: | ||
return ( | ||
<SaleSummaryStep | ||
price={marketData.price} | ||
tnc={marketData.tnc} | ||
setPrimaryButtonProps={setPrimaryButtonProps} | ||
setSecondaryButtonProps={setSecondaryButtonProps} | ||
handleBackClick={handleBackClick} | ||
/> | ||
) | ||
} | ||
} | ||
|
||
return ( | ||
<CrtDrawer | ||
steps={marketStepsNames} | ||
activeStep={activeStep} | ||
actionBar={{ | ||
isNoneCrypto: true, | ||
primaryButton: primaryButtonProps, | ||
secondaryButton: secondaryButtonProps, | ||
}} | ||
isOpen={show} | ||
onClose={onClose} | ||
preview={<MarketDrawerPreview startingPrice={marketData.price || 0} tokenName={tokenName} />} | ||
> | ||
<SwitchTransition mode="out-in"> | ||
<CSSTransition | ||
key={activeStep} | ||
nodeRef={nodeRef} | ||
timeout={100} | ||
addEndListener={(done) => { | ||
nodeRef.current?.addEventListener('transitionend', done, false) | ||
}} | ||
onEntered={() => setIsGoingBack(false)} | ||
classNames={isGoingBack ? transitions.names.backwardSlideSwitch : transitions.names.forwardSlideSwitch} | ||
> | ||
<div ref={nodeRef}>{stepContent()}</div> | ||
</CSSTransition> | ||
</SwitchTransition> | ||
</CrtDrawer> | ||
) | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/atlas/src/components/_crt/MarketDrawer/MarketDrawer.types.ts
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,5 @@ | ||
export type CrtMarketForm = { | ||
price: number | ||
isChecked: boolean | ||
tnc: string | ||
} |
Oops, something went wrong.