-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* swap deposit feature --------- Co-authored-by: Adam Clarke <[email protected]> Co-authored-by: Oluwakorede Fashokun <[email protected]>
- Loading branch information
1 parent
2882aa8
commit 49e7f5f
Showing
65 changed files
with
2,220 additions
and
570 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules/ | ||
.vscode/ | ||
.vscode/ | ||
.DS_Store |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,116 @@ | ||
import Image from 'next/image' | ||
import { useCallback, useReducer } from 'react' | ||
import styled, { css } from 'styled-components' | ||
|
||
import { StyledCaretDownIcon } from './Select' | ||
|
||
type BigToggleProps<T extends string> = { | ||
value: T | ||
options: T[] | ||
onOptionClick(value: T): void | ||
iconMap?: Record<T, string> | ||
} | ||
|
||
const BigToggle = <T extends string>({ | ||
options, | ||
value, | ||
onOptionClick, | ||
iconMap, | ||
}: BigToggleProps<T>) => { | ||
const [expanded, toggleExpanded] = useReducer((s) => !s, false) | ||
|
||
const handleOptionClick = useCallback( | ||
(option: T) => () => { | ||
onOptionClick(option) | ||
toggleExpanded() | ||
}, | ||
[onOptionClick] | ||
) | ||
|
||
return ( | ||
<BigToggleContainer> | ||
<BigToggleButton onClick={toggleExpanded}> | ||
{iconMap?.[value] && <Image alt={value} src={iconMap[value]} width={15} height={15} />} | ||
{value} | ||
<StyledCaretDownIcon $flip={expanded} style={{ marginLeft: 7 }} /> | ||
</BigToggleButton> | ||
{expanded && ( | ||
<BigToggleListContainer> | ||
{options | ||
.filter((o) => o !== value) | ||
.map((option) => ( | ||
<BigToggleListOption key={option} onClick={handleOptionClick(option)}> | ||
{iconMap?.[option] && ( | ||
<Image alt={option} src={iconMap[option]} width={15} height={15} /> | ||
)} | ||
{option} | ||
</BigToggleListOption> | ||
))} | ||
</BigToggleListContainer> | ||
)} | ||
</BigToggleContainer> | ||
) | ||
} | ||
|
||
const BigToggleContainer = styled.div` | ||
position: relative; | ||
` | ||
|
||
const BigToggleButton = styled.button` | ||
display: flex; | ||
align-items: center; | ||
border-radius: 40px; | ||
padding: 7px; | ||
font-size: 16px; | ||
cursor: pointer; | ||
line-height: 1; | ||
img { | ||
margin-right: 7px; | ||
} | ||
${(props) => css` | ||
border: ${props.theme.colors.selectedTheme.newTheme.button.default.border}; | ||
background-color: ${props.theme.colors.selectedTheme.newTheme.button.default.background}; | ||
color: ${props.theme.colors.selectedTheme.newTheme.button.default.color}; | ||
`} | ||
` | ||
|
||
const BigToggleListContainer = styled.div` | ||
position: absolute; | ||
top: 40px; | ||
border: ${(props) => props.theme.colors.selectedTheme.newTheme.button.default.border}; | ||
border-radius: 8px; | ||
overflow: hidden; | ||
width: 100%; | ||
` | ||
|
||
const BigToggleListOption = styled.button` | ||
border: none; | ||
width: 100%; | ||
padding: 7px; | ||
cursor: pointer; | ||
line-height: 1; | ||
display: flex; | ||
img { | ||
margin-right: 7px; | ||
} | ||
${(props) => css` | ||
background-color: ${props.theme.colors.selectedTheme.newTheme.button.default.background}; | ||
color: ${props.theme.colors.selectedTheme.newTheme.button.default.color}; | ||
font-size: 16px; | ||
&:not(:last-of-type) { | ||
border-bottom: ${props.theme.colors.selectedTheme.newTheme.button.default.border}; | ||
} | ||
&:hover { | ||
background-color: ${props.theme.colors.selectedTheme.newTheme.button.default.hover | ||
.background}; | ||
} | ||
`} | ||
` | ||
|
||
export default BigToggle |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import Image from 'next/image' | ||
import { useCallback, useReducer } from 'react' | ||
import styled from 'styled-components' | ||
|
||
import { StyledCaretDownIcon } from 'components/Select' | ||
import { HOURS_TOGGLE_HEIGHT, zIndex } from 'constants/ui' | ||
|
||
type SmallToggleProps<T extends string> = { | ||
value: T | ||
options: T[] | ||
getLabelByValue?: (value: T) => string | ||
iconMap?: Record<T, string> | ||
onOptionClick: (value: T) => void | ||
} | ||
|
||
const SmallToggle = <T extends string>({ | ||
value, | ||
options, | ||
getLabelByValue, | ||
iconMap, | ||
onOptionClick, | ||
}: SmallToggleProps<T>) => { | ||
const [open, toggleOpen] = useReducer((o) => !o, false) | ||
|
||
const handleOptionClick = useCallback( | ||
(option: T) => () => { | ||
onOptionClick(option) | ||
toggleOpen() | ||
}, | ||
[onOptionClick, toggleOpen] | ||
) | ||
|
||
return ( | ||
<ToggleContainer open={open}> | ||
<ToggleTable $open={open}> | ||
<ToggleTableHeader onClick={toggleOpen}> | ||
{iconMap?.[value] && <Image alt={value} src={iconMap[value]} width={11} height={11} />} | ||
{getLabelByValue?.(value) ?? value} | ||
<StyledCaretDownIcon width={12} $flip={open} style={{ marginLeft: 2 }} /> | ||
</ToggleTableHeader> | ||
{open && ( | ||
<ToggleTableRows> | ||
{options | ||
.filter((o) => o !== value) | ||
.map((option) => ( | ||
<ToggleTableRow key={option} onClick={handleOptionClick(option)}> | ||
{iconMap?.[option] && ( | ||
<Image alt={value} src={iconMap[option]} width={11} height={11} /> | ||
)} | ||
{option} | ||
</ToggleTableRow> | ||
))} | ||
</ToggleTableRows> | ||
)} | ||
</ToggleTable> | ||
</ToggleContainer> | ||
) | ||
} | ||
|
||
const ToggleTableRow = styled.div` | ||
display: flex; | ||
align-items: center; | ||
margin: auto; | ||
padding: 1.5px 6px; | ||
height: ${HOURS_TOGGLE_HEIGHT}; | ||
background: ${(props) => props.theme.colors.selectedTheme.newTheme.pill.gray.background}; | ||
:last-child { | ||
border-radius: 0px 0px 9px 9px; | ||
} | ||
img { | ||
margin-right: 3px; | ||
} | ||
:hover { | ||
color: ${(props) => props.theme.colors.selectedTheme.newTheme.text.primary}; | ||
background: ${(props) => | ||
props.theme.colors.selectedTheme.newTheme.pill['gray'].hover.background}; | ||
:last-child { | ||
border-radius: 0px 0px 9px 9px; | ||
} | ||
} | ||
` | ||
|
||
const ToggleTableRows = styled.div` | ||
width: 100%; | ||
position: absolute; | ||
top: 20px; | ||
color: ${(props) => props.theme.colors.selectedTheme.newTheme.text.secondary}; | ||
z-index: ${zIndex.HEADER}; | ||
` | ||
|
||
const ToggleTableHeader = styled.div` | ||
display: flex; | ||
justify-content: space-evenly; | ||
align-items: center; | ||
padding: 3px 5px; | ||
font-size: 12px; | ||
img { | ||
margin-right: 3px; | ||
} | ||
` | ||
|
||
const ToggleTable = styled.div<{ $open?: boolean }>` | ||
display: flex; | ||
flex-direction: column; | ||
background: ${(props) => props.theme.colors.selectedTheme.newTheme.pill['gray'].background}; | ||
color: ${(props) => props.theme.colors.selectedTheme.newTheme.text.primary}; | ||
border-radius: 9px; | ||
font-size: 12px; | ||
font-family: ${(props) => props.theme.fonts.bold}; | ||
${(props) => props.$open && `border-radius: 9px 9px 0px 0px;`} | ||
` | ||
|
||
const ToggleContainer = styled.div<{ open: boolean }>` | ||
margin-left: 8px; | ||
cursor: pointer; | ||
position: relative; | ||
` | ||
|
||
export default SmallToggle |
Oops, something went wrong.