-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Combine swap and auction forms (#1147)
* Rename property * Use useStoreShallow * Move swap state into its own directory * Extract the common parts of the swap and dutch auction states * Continue reconfiguring state structure; fix max-width issues * Hide instant-swap-specific items when the swap is not instant: * Tweak language * Continue refactoring state * Move component directory * Rename price -> output * Tweak width * Avoid unnecessary data loads * Tweak reset * Fix tests * Use a smarter submit button * Tweak selectors * Disable the Estimate button when there's no amount * Remove unused paths * Fix property access * Build out rest of UI * Reorganize; delete unused code * Fix typings * Refactor to use class const * Remove all traces of the /swap/auction path * Reorganize * Fix incorrect key prop * Fix step size * Add labels * Add changeset * Add comment * Use more Zustand state in TokenSwapInput; move balances into Zustand * Revert changes for now * Move assets into Zustand * Simplify types * Only put swappable assets in state * Remove unused property * Fix button alignment * Respond to Henry's feedback * Reduce nesting * Refactor to use more idiomatic Tailwind
- Loading branch information
1 parent
e47a04e
commit a241386
Showing
48 changed files
with
601 additions
and
633 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'minifront': minor | ||
--- | ||
|
||
Combine the swap and auction forms |
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
export const RestrictMaxWidth = ({ children }: { children: ReactNode }) => { | ||
return <div className='mx-auto xl:max-w-[1276px]'>{children}</div>; | ||
return <div className='mx-auto w-full max-w-full xl:max-w-[1276px]'>{children}</div>; | ||
}; |
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,61 @@ | ||
import { Slider } from '@penumbra-zone/ui/components/ui/slider'; | ||
import { DURATION_OPTIONS, GDA_RECIPES } from '../../state/swap/constants'; | ||
import { useStoreShallow } from '../../utils/use-store-shallow'; | ||
import { AllSlices } from '../../state'; | ||
|
||
const durationSliderSelector = (state: AllSlices) => ({ | ||
duration: state.swap.duration, | ||
setDuration: state.swap.setDuration, | ||
}); | ||
|
||
export const DurationSlider = () => { | ||
const { duration, setDuration } = useStoreShallow(durationSliderSelector); | ||
|
||
const handleChange = (newValue: number[]) => { | ||
const value = newValue[0]!; // We don't use multiple values in the slider | ||
const option = DURATION_OPTIONS[value]!; | ||
|
||
setDuration(option); | ||
}; | ||
|
||
return ( | ||
<div className='flex flex-col items-center gap-4'> | ||
<div className='flex w-full items-center gap-4'> | ||
<span className='text-xs text-muted-foreground'> | ||
Instant | ||
<br /> | ||
Price | ||
</span> | ||
|
||
<Slider | ||
min={0} | ||
max={DURATION_OPTIONS.length - 1} | ||
value={[DURATION_OPTIONS.indexOf(duration)]} | ||
onValueChange={handleChange} | ||
/> | ||
|
||
<span className='text-right text-xs text-muted-foreground'> | ||
Averaged | ||
<br /> | ||
Price | ||
</span> | ||
</div> | ||
|
||
{duration === 'instant' && ( | ||
<div className='flex flex-col items-center'> | ||
Now | ||
<span className='text-xs text-muted-foreground'>single trade at market price</span> | ||
</div> | ||
)} | ||
|
||
{duration !== 'instant' && ( | ||
<div className='flex flex-col items-center'> | ||
~ {duration}{' '} | ||
<span className='text-xs text-muted-foreground'> | ||
distributed across {GDA_RECIPES[duration].numberOfSubAuctions.toString()} auctions | ||
</span> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; |
38 changes: 0 additions & 38 deletions
38
apps/minifront/src/components/swap/dutch-auction/duration-slider.tsx
This file was deleted.
Oops, something went wrong.
74 changes: 0 additions & 74 deletions
74
apps/minifront/src/components/swap/dutch-auction/dutch-auction-form.tsx
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
apps/minifront/src/components/swap/dutch-auction/dutch-auction-loader.ts
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
apps/minifront/src/components/swap/dutch-auction/index.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.