Skip to content

Commit

Permalink
add tutorial lo
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhoaidanh committed Oct 18, 2023
1 parent ed11a85 commit a5d949a
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/components/Tutorial/TutorialSwap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,9 @@ const getListSteps = (isLogin: boolean, isSolana: boolean) => {
])
}

const TutorialKeys = {
export const TutorialKeys = {
SHOWED_SWAP_GUIDE: 'showedTutorialSwapGuide',
SHOWED_LO_GUIDE: 'showedTutorialLO',
}

export default memo(function TutorialSwap() {
Expand Down
91 changes: 91 additions & 0 deletions src/components/swapv2/LimitOrder/Tutorial.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { Trans, t } from '@lingui/macro'
import { rgba } from 'polished'
import { ReactNode } from 'react'
import { Check } from 'react-feather'
import { Text } from 'rebass'
import styled from 'styled-components'

import { ButtonPrimary } from 'components/Button'
import Column from 'components/Column'
import Row from 'components/Row'
import { DOCS_LINKS } from 'components/swapv2/LimitOrder/const'
import useTheme from 'hooks/useTheme'
import { ExternalLink } from 'theme'

const Wrapper = styled.div`
width: 100%;
height: 424px;
padding: 20px 16px;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
border-radius: 16px;
background: var(--overlay-oapy-20, rgba(15, 170, 162, 0.2)); // todo
`

const CheckIcon = styled.div`
background-color: ${({ theme }) => rgba(theme.primary, 0.3)};
border-radius: 100%;
padding: 2px;
display: flex;
align-items: center;
`

const ContentItem = ({ text }: { text: ReactNode }) => {
const theme = useTheme()
return (
<Row gap="8px">
<CheckIcon>
<Check color={theme.primary} size={14} />
</CheckIcon>
<Text fontSize={'14px'} color={theme.subText}>
{text}
</Text>
</Row>
)
}
export default function Tutorial({ onClose }: { onClose: () => void }) {
const theme = useTheme()

return (
<Wrapper>
<Column gap="40px">
<Column gap="10px" alignItems="center">
<Text textAlign={'center'} fontWeight={'500'} fontSize={'24px'} color={theme.subText}>
<Trans>Want to try our Limit Orders?</Trans>
</Text>
<Text fontWeight={'700'} fontSize={'24px'} color={theme.subText}>
<Trans>Get started!</Trans>
</Text>
</Column>

<Column gap="12px">
<ContentItem text={t`Place limit orders on thousands of tokens`} />
<ContentItem text={t`Get your orders filled without paying any gas fees`} />
<ContentItem
text={
<Trans>
Cancel and edit orders for{' '}
<Text as="span" fontWeight={'500'} color={theme.primary}>
<Trans>FREE</Trans>
</Text>
</Trans>
}
/>
</Column>
</Column>

<Column gap="16px" width={'100%'}>
<Text fontSize={'14px'} textAlign={'center'} color={theme.subText}>
<Trans>
Learn more about <ExternalLink href={DOCS_LINKS.USER_GUIDE}>KyberSwap Limit Order</ExternalLink>
</Trans>
</Text>
<ButtonPrimary height="40px" width={'100%'} onClick={onClose}>
<Trans>Get started with limit orders</Trans>
</ButtonPrimary>
</Column>
</Wrapper>
)
}
39 changes: 27 additions & 12 deletions src/components/swapv2/LimitOrder/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { t } from '@lingui/macro'
import { memo, useState } from 'react'

import { TutorialKeys } from 'components/Tutorial/TutorialSwap'
import Tutorial from 'components/swapv2/LimitOrder/Tutorial'
import { TRANSACTION_STATE_DEFAULT } from 'constants/index'
import useSyncTokenSymbolToUrl from 'hooks/useSyncTokenSymbolToUrl'
import { useLimitActionHandlers, useLimitState } from 'state/limit/hooks'
Expand All @@ -20,22 +22,35 @@ function LimitOrderComp({ setIsSelectCurrencyManual, isSelectCurrencyManual }: P

useSyncTokenSymbolToUrl(currencyIn, currencyOut, onSelectPair, isSelectCurrencyManual)

const [showTutorial, setShowTutorial] = useState(!localStorage.getItem(TutorialKeys.SHOWED_LO_GUIDE))

// modal and loading
const [flowState, setFlowState] = useState<TransactionFlowState>(TRANSACTION_STATE_DEFAULT)
if (showTutorial)
return (
<Tutorial
onClose={() => {
setShowTutorial(false)
localStorage.setItem(TutorialKeys.SHOWED_LO_GUIDE, '1')
}}
/>
)

return (
<LimitOrderForm
flowState={flowState}
setFlowState={setFlowState}
currencyIn={currencyIn}
currencyOut={currencyOut}
setIsSelectCurrencyManual={setIsSelectCurrencyManual}
note={
currencyOut?.isNative
? t`Note: Once your order is filled, you will receive ${currencyOut?.wrapped.name} (${currencyOut?.wrapped.symbol})`
: undefined
}
/>
<div style={{ padding: '16px' }}>
<LimitOrderForm
flowState={flowState}
setFlowState={setFlowState}
currencyIn={currencyIn}
currencyOut={currencyOut}
setIsSelectCurrencyManual={setIsSelectCurrencyManual}
note={
currencyOut?.isNative
? t`Note: Once your order is filled, you will receive ${currencyOut?.wrapped.name} (${currencyOut?.wrapped.symbol})`
: undefined
}
/>
</div>
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/SwapV3/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export default function Swap() {
<AppBodyWrapped
data-highlight={shouldHighlightSwapBox}
id={TutorialIds.SWAP_FORM}
style={activeTab === TAB.INFO ? { padding: 0 } : undefined}
style={[TAB.INFO, TAB.LIMIT].includes(activeTab) ? { padding: 0 } : undefined}
>
{isSwapPage && (
<PopulatedSwapForm
Expand Down

0 comments on commit a5d949a

Please sign in to comment.