Skip to content
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

chore: Swap Settings Slippage fast follow #1206

Merged
merged 2 commits into from
Sep 3, 2024
Merged

Conversation

cpcramer
Copy link
Contributor

@cpcramer cpcramer commented Sep 3, 2024

What changed? Why?

Notes to reviewers

How has it been tested?

Copy link

vercel bot commented Sep 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
onchainkit-coverage ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 3, 2024 3:43am
onchainkit-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 3, 2024 3:43am
onchainkit-routes ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 3, 2024 3:43am

const SLIPPAGE_SETTINGS = {
AUTO: 'Auto',
CUSTOM: 'Custom',
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now we are talking

@@ -65,23 +70,22 @@ export function SwapSettingsSlippageInput({
)}
>
<legend className="sr-only">Slippage Setting</legend>
{slippageSettings.map((slippageSetting) => (
{Object.values(SLIPPAGE_SETTINGS).map((setting) => (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting is still a odd word, but I am going to approve it this for now.

type="button"
className={cn(
pressable.default,
color.foreground,
'flex-1 rounded-lg px-3 py-1 font-medium text-sm transition-colors',
isAutoSlippageSetting === (slippageSetting === 'Auto')
// Highlight the button if it is selected
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love the comment

@@ -90,7 +94,7 @@ export function SwapSettingsSlippageInput({
background.default,
border.defaultActive,
'flex h-9 w-24 items-center justify-between rounded-lg border px-2 py-1',
isAutoSlippageSetting && 'opacity-50',
slippageSetting === SLIPPAGE_SETTINGS.AUTO && 'opacity-50',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be the performance perfectionist in me :)
But everytime you have code that is writtend 2+ times, it cost CPU time. No big deal, but when you see those things, you can just write something like

let isSlippageSettingAuto = false;
useEffect(() => {
  isSlippageSettingAuto = slippageSetting === SLIPPAGE_SETTINGS.AUTO;
}, [slippageSetting]); 

and just use isSlippageSettingAuto evreywher. And make the code more elegant and also more efficient.

@Zizzamia Zizzamia merged commit 66a5e0d into main Sep 3, 2024
16 checks passed
@Zizzamia Zizzamia deleted the paul/slipapge-input-ff branch September 3, 2024 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants