-
Notifications
You must be signed in to change notification settings - Fork 23
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
Order input component style and code polishing #117
Order input component style and code polishing #117
Conversation
✅ Deploy Preview for chipper-sunburst-578cfe ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
The percentage shortcuts do not work at all now (before the PR they are working (although with bugs, we should fix them separately) and setting the position size).
Maybe hiding the shortcuts for the MVP if they cause a lot of trouble? We don't have the UI defined for them either.
src/app/components/OrderInput.tsx
Outdated
const [customPercentage, setCustomPercentage] = useState(0); | ||
const [isFirstInteraction, setIsFirstInteraction] = useState(true); |
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.
Let's try to not use useState
since we already have redux, and use only redux for state management.
What is the idea for fist interaction? Why is it something different from any other interaction?
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.
Let's try to not use
useState
since we already have redux, and use only redux for state management.What is the idea for fist interaction? Why is it something different from any other interaction?
both these states are the local states of the component. i don't think we should move these state in redux as it is not encouraged Read Here
Reasons why these two states:
customPercentage was needed to handle the current percentage selection through which i am changing the color of the active percentage box and also handling the input state of the component.
isFirstInteraction: whenever we load the dexter app it starts showing error on the inputs even though user has not even entered anything yet. therefore, i am keeping this state as a memory for the input field so it will not show error if user has not yet entered anything in that specific input field.
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.
About isFirstInteraction
, I think it's more user-friendly to show the errors if any exist immediately - quickly explains why the submit button is disabled and directs attention to editing them. Maybe instead we can use different defaults, so they would be valid from the start?
OK for useState
in this case, but (for other cases) I would argue even if the state is local to a component, but requires some network processing or transformation logic - it's better moving them to redux slices, the code will be much more readable easier to test and debug.
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.
maybe we need to come up with some other UX for the inputs? because clearly they don't look good the moment you load Dexter and you are welcomed with 2 big red outlined input fields. We should wait for the user to interact with these input fields then we can show them the errors. (That's my thought behind using isFirstInteraction
)
regarding customPercentage
i was looking for some redux state for current selected percentage but i didn't find any,
we are only using this const size = useAppSelector((state) => state.orderInput.size);
state but it returns the calculated size. And since i didn't find any need to move it to redux because we were not using the current selected percentage anywhere else so i made it a local component state. i can move it to redux if you think we might be needing this state somewhere else.
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.
We should wait for the user to interact with these input fields then we can show them the errors. (That's my thought behind using isFirstInteraction )
Yes, I understand why you introduce the isFirstInteraction
, the alternative suggestion is to leave the validation always active but substitute the defaults with something more reasonable than 0s, so that there wouldn't be an error message right away.
maybe we need to come up with some other UX for the inputs?
a related comment in discord - https://discord.com/channels/1125689933735145503/1146445162508197888/1152192758942023721
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.
About customPercentage
, if we have it, we would need to react to size
input here as well. We can theoretically use only size
in the state, and when the user types in the size itself, the custom percentage would calculate out of it and get updated also, it would be nice to have, but I don't think it's important to have in the MVP and it will take time to develop and test. I would suggest leaving custom percentage being wiped out (as it is now in the main branch) when user either inputs size or clicks percentage shortcuts, because it's simpler.
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.
i will put a placeholder "0" instead of real value, that way we might be able to get rid of isFirstInteraction
Although we are using custom percentage it's just white so we didn't really notice, i made it black in screenshot
we can hide it for now. but this customPercentage
state is also being used by the percentage buttons. so this state would still be there.
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.
It is possible to go without customPercentage
state if when user licks on shortcuts or enters size (aka amount), the custom percentage input clears, that would simplify the code.
It's OK to have the customPercentage
, but if we have it we need to synchronize the size input also - meaning when the user enters the size (amount) itself the custom percentage should also recalculate.
I would even go so far as to remove the shortcuts for the MVP at all - they are buggy and pollute already quite noisy input ui, and we can introduce them again later, more tested and together with the redesign?
@EvgeniiaVak i tried clicking percentage boxes by connecting wallet and they seem to be working (in the sense that the values are changing in position size input) but i don't know if the position size value is being calculated correctly. There seems to be some error coming from the SDK about insufficient liquidity. |
src/app/components/OrderInput.tsx
Outdated
const [customPercentage, setCustomPercentage] = useState(0); | ||
const [isFirstInteraction, setIsFirstInteraction] = useState(true); |
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.
It is possible to go without customPercentage
state if when user licks on shortcuts or enters size (aka amount), the custom percentage input clears, that would simplify the code.
It's OK to have the customPercentage
, but if we have it we need to synchronize the size input also - meaning when the user enters the size (amount) itself the custom percentage should also recalculate.
I would even go so far as to remove the shortcuts for the MVP at all - they are buggy and pollute already quite noisy input ui, and we can introduce them again later, more tested and together with the redesign?
@EvgeniiaVak i tried to revamp the functionality according to my thoughts mixing up with Vlad's design and the older designs on figma. i would suggest to merge it and get feedback from the TG community before working on it further. please review it and let me know about futher changes or tweaks if any. |
@abdulhaseeb13mar I briefly tried it out on https://deploy-preview-117--chipper-sunburst-578cfe.netlify.app/ and noticed 2 things :
I think it's better to remove the balance word from the order input at all, and display it in the pair selector component (like in Vlad's figma). Sorry, I don't have much time this weekend for a more detailed code review, if nobody else reviews by then, I will check tomorrow. |
@EvgeniiaVak I thought about that switching approach, Like Uniswap or pancake swap and some major swaps, they use a switching approach because they do not give i.e ADEX2/XRD pair
That's why the |
Started the discussion on tg - https://t.me/c/1988854086/1/383 |
they were still not working correctly, so i decided to hide them for now, as it was consuming too much time. decided to work on it after the MVP launch or at the end of all tasks. |
I think for our purposes it is OK to show the balances at the top as in the design. Because we work in the context of a selected pair, we can show the balance for both tokens. For Pancake Swap (and other AMMs) the user can normally select from one of many tokens, and therefore you will only show him the balance of the token he currently has selected (as you can't show him balances for all tokens) |
selectTargetToken, | ||
validateSlippageInput, | ||
} from "redux/orderInputSlice"; | ||
import { useEffect } from "react"; |
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.
forgot to move the library import to the top separated by an empty line from the local imports
Have been playing around with this and have a few comments for LIMIT order pages:
|
For the MARKET order page, I think we should change SLIPPAGE to SLIPPAGE LIMIT. As it might look to user that that is the actual slippage they will experience, rather than just a limit for slippage. |
@fliebenberg update on separators - turns out browsers decide on whether to use Changing this setting and reloading the browser made DeXter page using the |
It is fine to revert back to the defaults for the input fields, but then we also need to use the defaults when displaying the amounts. We can add a simple function to read the default separators for the user and then store it and use it in the displayAmount function. |
@fliebenberg By displaying amounts you mean in the order input component, then it's done in your computer settings. I did and for me the amounts there are with If you mean in the |
Yep, I meant in the displayAmount. The simplest way to get the values is to create a locale specific string of a number and that has a decimal and thousands separator and then just read the values from the string. There are several examples on stack-overflow. I will do a PR for this specifically quickly this morning. |
Created a separate issue #159 and PR for reading the separators and saving them in the global store. Somehow, the separators shown in the numbers is still not the same as the separator I need to put in for inputs. E.g. in South Africa, it shows numbers with a . as decimal separator, but yet in the input box it still only accepts a ,. I will need to investigate why this might be a bit more. Would be intersting if others can test it for their locales as well. |
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.
fixes #141
fixes #138
I have left the styles of the components that were not present in figma, we need to decide a relevant design for that.