Skip to content

Commit

Permalink
Merge pull request #26 from perpetual-protocol/main
Browse files Browse the repository at this point in the history
Merge from main
  • Loading branch information
lsps9150414 authored May 24, 2021
2 parents 875341b + ec7625e commit 88f9890
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ yarn-error.log*

/src/types
/script/tmp
/.nova
2 changes: 1 addition & 1 deletion src/component/UserAgreementModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function UserAgreementModal() {
>
 Docs 
</ExternalLink>
to know more
to know more.
</Text>
<br />
<Text>
Expand Down
2 changes: 1 addition & 1 deletion src/page/Home/component/Trade/Leverage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Leverage() {
return useMemo(
() => (
<FormControl id="leverages">
<SmallFormLabel>Leverages</SmallFormLabel>
<SmallFormLabel>Leverage</SmallFormLabel>
<Box px={10} pt={4} pb={8} bg="blackAlpha.50" borderRadius="xl">
<Slider
onChange={handleOnChange}
Expand Down
23 changes: 19 additions & 4 deletions src/page/Home/component/Trade/Slippage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import {
NumberInput,
NumberInputField,
NumberInputStepper,
InputRightElement,
Text,
} from "@chakra-ui/react"
import { useCallback, useMemo } from "react"
import React, { useCallback, useMemo } from "react"

import SmallFormLabel from "component/SmallFormLabel"
import { Trade } from "container/trade"
Expand All @@ -23,27 +25,40 @@ function Slippage() {
},
[setSlippage],
)

return useMemo(
() => (
<FormControl id="slippage">
<SmallFormLabel>Slippage (%)</SmallFormLabel>
<NumberInput
allowMouseWheel
value={slippage}
min={0}
step={0.1}
max={100}
clampValueOnBlur={false}
onChange={handleOnChange}
value={slippage}
focusInputOnChange={true}
>
<NumberInputField />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
<InputRightElement w="54px" mr={4}>
<Text
w="100%"
textAlign="center"
fontWeight="bold"
fontSize="xs"
color="gray.500"
textTransform="uppercase"
>
%
</Text>
</InputRightElement>
</NumberInput>
<FormHelperText>
To use custom slippage please input manually. It also apply to closing position and margin
To use custom slippage, please input manually. It also applies to closing position and margin
adjustment.
</FormHelperText>
</FormControl>
Expand Down
14 changes: 13 additions & 1 deletion src/page/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { Tab, TabList, TabPanel, TabPanels, Tabs } from "@chakra-ui/react"
import { useState } from "react"
import { useEffect, useState } from "react"

import { Connection } from "container/connection"
import GetStarted from "./component/GetStarted"
import Position from "./component/Position"
import TradeComponent from "./component/Trade"

const Home = () => {
// NOTE: Focus the trade tab once wallet is connected.
const [tabIndex, setTabIndex] = useState(0)
const { account } = Connection.useContainer()
useEffect(() => {
if (account) {
setTabIndex(1)
} else {
setTabIndex(0)
}
}, [account])

return (
<>
{/* Tabs */}
Expand Down

0 comments on commit 88f9890

Please sign in to comment.