-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: update mobile web trade form for better ux experience on isolated trades #1108
Merged
moo-onthelawn
merged 17 commits into
main
from
mulan/ct-1267-unflagged-update-trade-form-for-mobile-view
Oct 15, 2024
+366
−282
Merged
Changes from 10 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6f7b9c2
drafty
moo-onthelawn 2d0a8d7
lint
moo-onthelawn 3d4e71a
clean up
moo-onthelawn 76f54e3
Merge branch 'main' into mulan/ct-1267-unflagged-update-trade-form-fo…
moo-onthelawn f4df039
polish
moo-onthelawn 7c7488e
uhhh man need to fix two more things
moo-onthelawn f504848
fix stickiness
moo-onthelawn 3a60cb2
Merge branch 'main' into mulan/ct-1267-unflagged-update-trade-form-fo…
moo-onthelawn 4cc56a6
fixed
moo-onthelawn 0d5fb1b
clean up
moo-onthelawn d45e8a0
fix fade
moo-onthelawn 5e040b8
clean up and move into hook
moo-onthelawn 55e4c7c
fix to only render extra container if scrollable
moo-onthelawn 8f1311d
fix delay
moo-onthelawn a4da100
fix tabs again
moo-onthelawn 2855f71
undo change
moo-onthelawn 0f0b009
Merge branch 'main' into mulan/ct-1267-unflagged-update-trade-form-fo…
moo-onthelawn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,85 @@ | ||
import React from 'react'; | ||
|
||
import { OrderSide } from '@dydxprotocol/v4-client-js'; | ||
import { shallowEqual } from 'react-redux'; | ||
import styled, { css } from 'styled-components'; | ||
|
||
import { AbacusOrderSide, TradeInputField } from '@/constants/abacus'; | ||
import { OnboardingState } from '@/constants/account'; | ||
import { STRING_KEYS } from '@/constants/localization'; | ||
|
||
import { useStringGetter } from '@/hooks/useStringGetter'; | ||
|
||
import { Tabs } from '@/components/Tabs'; | ||
|
||
import { getOnboardingState } from '@/state/accountSelectors'; | ||
import { useAppSelector } from '@/state/appTypes'; | ||
import { getTradeSide } from '@/state/inputsSelectors'; | ||
|
||
import abacusStateManager from '@/lib/abacus'; | ||
import { getSimpleStyledOutputType } from '@/lib/genericFunctionalComponentUtils'; | ||
import { getSelectedOrderSide } from '@/lib/tradeData'; | ||
|
||
type ElementProps = { | ||
sharedContent: React.ReactNode; | ||
}; | ||
|
||
type StyleProps = { | ||
className?: string; | ||
}; | ||
|
||
export const TradeSideTabs = ({ sharedContent, className }: ElementProps & StyleProps) => { | ||
const stringGetter = useStringGetter(); | ||
|
||
const onboardingState = useAppSelector(getOnboardingState); | ||
const allowChangingOrderType = onboardingState === OnboardingState.AccountConnected; | ||
|
||
const side = useAppSelector(getTradeSide, shallowEqual); | ||
const selectedOrderSide = getSelectedOrderSide(side); | ||
|
||
const items = [ | ||
{ value: OrderSide.BUY, label: stringGetter({ key: STRING_KEYS.BUY_LONG }) }, | ||
{ value: OrderSide.SELL, label: stringGetter({ key: STRING_KEYS.SELL_SHORT }) }, | ||
]; | ||
|
||
return ( | ||
<$TradeSideTabs | ||
className={className} | ||
fullWidthTabs | ||
dividerStyle="underline" | ||
activeTab={selectedOrderSide} | ||
value={selectedOrderSide} | ||
items={items} | ||
onValueChange={(newSide: OrderSide) => { | ||
abacusStateManager.setTradeValue({ | ||
value: | ||
newSide === OrderSide.BUY | ||
? AbacusOrderSide.Buy.rawValue | ||
: AbacusOrderSide.Sell.rawValue, | ||
field: TradeInputField.side, | ||
}); | ||
}} | ||
disabled={!allowChangingOrderType} | ||
sharedContent={sharedContent} | ||
/> | ||
); | ||
}; | ||
|
||
const tradeSideTabsType = getSimpleStyledOutputType(Tabs, {} as { activeTab: OrderSide }); | ||
|
||
const $TradeSideTabs = styled(Tabs)<{ activeTab: OrderSide }>` | ||
${({ activeTab }) => | ||
activeTab === OrderSide.BUY | ||
? css` | ||
--trigger-active-underline-backgroundColor: var(--color-positive-dark); | ||
--trigger-active-underlineColor: var(--color-positive); | ||
--trigger-active-textColor: var(--color-positive); | ||
--trigger-hover-textColor: var(--color-text-2); | ||
` | ||
: css` | ||
--trigger-active-underline-backgroundColor: var(--color-negative-dark); | ||
--trigger-active-underlineColor: var(--color-negative); | ||
--trigger-active-textColor: var(--color-negative); | ||
--trigger-hover-textColor: var(--color-text-2); | ||
`}; | ||
` as typeof tradeSideTabsType; |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotta imagine this is going to cause pain SOMEWHERE, but I've got no clue where
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh rip good catch - it's preventing the "More" dropdown from showing. Man lemme fix