Skip to content

Commit

Permalink
Writing more code to make states work
Browse files Browse the repository at this point in the history
  • Loading branch information
mehranhydary committed Sep 10, 2024
1 parent b9252a8 commit a6ed253
Showing 1 changed file with 38 additions and 10 deletions.
48 changes: 38 additions & 10 deletions ui/src/components/LimitBox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import styled from 'styled-components'
import { SwapVertical } from '@styled-icons/ionicons-outline/SwapVertical'
import Image from 'next/image'
import { useState } from 'react'

const LimitBox = () => {
return (
Expand Down Expand Up @@ -48,16 +49,43 @@ const MiddleSection = () => (
</Middle>
)

const BottomSection = () => (
<Bottom>
<IncrementBox>
<Increment selected>Market</Increment>
<Increment selected={false}>+1%</Increment>
<Increment selected={false}>+5%</Increment>
<Increment selected={false}>+10%</Increment>
</IncrementBox>
</Bottom>
)
const BottomSection = () => {
const [selectedIncrement, setSelectedIncrement] = useState('Market')

const handleIncrementClick = (increment: string) => {
setSelectedIncrement(increment)
}
return (
<Bottom>
<IncrementBox>
<Increment
selected={selectedIncrement === 'Market'}
onClick={() => handleIncrementClick('Market')}
>
Market
</Increment>
<Increment
selected={selectedIncrement === '+1%'}
onClick={() => handleIncrementClick('+1%')}
>
+1%
</Increment>
<Increment
selected={selectedIncrement === '+5%'}
onClick={() => handleIncrementClick('+5%')}
>
+5%
</Increment>
<Increment
selected={selectedIncrement === '+10%'}
onClick={() => handleIncrementClick('+10%')}
>
+10%
</Increment>
</IncrementBox>
</Bottom>
)
}

export default LimitBox

Expand Down

0 comments on commit a6ed253

Please sign in to comment.