Skip to content

Commit

Permalink
Merge branch 'crt' into feature/revenue-share-participation-widget
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/atlas/src/views/studio/CrtDashboard/tabs/CrtRevenueTab.tsx
  • Loading branch information
WRadoslaw committed Oct 12, 2023
2 parents 84314ce + bb5c9b4 commit 3d0636d
Show file tree
Hide file tree
Showing 20 changed files with 3,281 additions and 1,785 deletions.
2 changes: 2 additions & 0 deletions packages/atlas/atlas.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ analytics:
id: '$VITE_SEGMENT_ID'

legal:
crtTnc: |
This is a temporary placeholder for the Creator Tokens Terms and Conditions. The final version will be added here soon.
termsOfService: |
# Terms of Service
Expand Down
16 changes: 8 additions & 8 deletions packages/atlas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@
"@joystream/prettier-config": "^1.0.0",
"@modyfi/vite-plugin-yaml": "^1.0.3",
"@rollup/plugin-babel": "^6.0.3",
"@storybook/addon-actions": "7.0.7",
"@storybook/addon-docs": "7.0.7",
"@storybook/addon-essentials": "7.0.7",
"@storybook/addon-links": "7.0.7",
"@storybook/addons": "7.0.7",
"@storybook/react-vite": "7.0.7",
"@storybook/theming": "7.0.7",
"@storybook/addon-actions": "7.4.6",
"@storybook/addon-docs": "7.4.6",
"@storybook/addon-essentials": "7.4.6",
"@storybook/addon-links": "7.4.6",
"@storybook/addons": "7.4.6",
"@storybook/react-vite": "7.4.6",
"@storybook/theming": "7.4.6",
"@svgr/cli": "^6.5.1",
"@testing-library/dom": "^8.19.0",
"@testing-library/jest-dom": "^5.16.5",
Expand Down Expand Up @@ -151,7 +151,7 @@
"react-hooks-testing-library": "^0.6.0",
"rimraf": "^3.0.2",
"rollup-plugin-visualizer": "^5.8.3",
"storybook": "7.0.7",
"storybook": "7.4.6",
"style-dictionary": "^3.7.1",
"vite": "^4.3.9",
"vite-plugin-checker": "^0.5.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ const dollarSmallNumberFormatter = new Intl.NumberFormat('en-US', {
maximumSignificantDigits: 3,
})

const formatNumberShort = (num: number): string => {
export const formatNumberShort = (num: number): string => {
return numberCompactFormatter.format(num).replaceAll(',', ' ')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const SignUpModal = () => {
const [emailAlreadyTakenError, setEmailAlreadyTakenError] = useState(false)
const [hasNavigatedBack, setHasNavigatedBack] = useState(false)
const [primaryButtonProps, setPrimaryButtonProps] = useState<DialogButtonProps>({ text: 'Continue' })
const [amountOfTokens, setAmountofTokens] = useState<number>()
const [amountOfTokens] = useState<number>()
const [memberId, setMemberId] = useState<string | null>(null)
const syncState = useRef<'synced' | 'tried' | null>(null)
const ytResponseData = useYppStore((state) => state.ytResponseData)
Expand Down Expand Up @@ -128,7 +128,7 @@ export const SignUpModal = () => {
setAuthModalOpenName(undefined)
setYppModalOpenName('ypp-sync-options')
} else {
setAmountofTokens(amountOfTokens)
amountOfTokens
goToNextStep()
}
},
Expand Down Expand Up @@ -174,7 +174,7 @@ export const SignUpModal = () => {
setAuthModalOpenName(undefined)
setYppModalOpenName('ypp-sync-options')
} else {
setAmountofTokens(amountOfTokens)
amountOfTokens
goToNextStep()
}
},
Expand Down
49 changes: 26 additions & 23 deletions packages/atlas/src/components/_charts/LineChart/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ import { ReactNode } from 'react'

import { cVar, sizes } from '@/styles'

export const defaultChartTheme = {
tooltip: {
container: {
background: cVar('colorBackgroundStrong'),
},
},

axis: {
ticks: {
line: {
stroke: cVar('colorBackgroundAlpha'),
},
text: {
fill: cVar('colorTextMuted'),
font: cVar('typographyDesktopT100'),
},
},
},
grid: {
line: {
stroke: cVar('colorBackgroundAlpha'),
},
},
}

const defaultJoystreamProps: Omit<LineSvgProps, 'data'> = {
isInteractive: true,
useMesh: true,
Expand All @@ -29,29 +54,7 @@ const defaultJoystreamProps: Omit<LineSvgProps, 'data'> = {
tickValues: 6,
},
colors: (d) => d.color,
theme: {
tooltip: {
container: {
background: cVar('colorBackgroundStrong'),
},
},
axis: {
ticks: {
line: {
stroke: cVar('colorBackgroundAlpha'),
},
text: {
fill: cVar('colorTextMuted'),
font: cVar('typographyDesktopT100'),
},
},
},
grid: {
line: {
stroke: cVar('colorBackgroundAlpha'),
},
},
},
theme: defaultChartTheme,
}
export type LineChartProps = {
tooltip?: (point: Point) => ReactNode
Expand Down
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',
}
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 packages/atlas/src/components/_crt/MarketDrawer/MarketDrawer.tsx
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>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type CrtMarketForm = {
price: number
isChecked: boolean
tnc: string
}
Loading

0 comments on commit 3d0636d

Please sign in to comment.