Skip to content

Commit

Permalink
3rd times the charm redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcramer committed Aug 28, 2024
1 parent 126775e commit e1be19d
Show file tree
Hide file tree
Showing 25 changed files with 752 additions and 439 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-rice-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@coinbase/onchainkit": patch
---

- **feat**: Introducing the SwapSettings component, a dropdown that allows you to easily customize slippage during swaps. It features subcomponents for slippage options and includes a toggle icon. by @0xAlec @cpcramer #1051
5 changes: 0 additions & 5 deletions .changeset/clean-mirrors-sparkle.md

This file was deleted.

14 changes: 14 additions & 0 deletions playground/nextjs-app-router/components/demo/Swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import {
SwapAmountInput,
SwapButton,
SwapMessage,
SwapSettings,
SwapSettingsSlippageDescription,
SwapSettingsSlippageInput,
SwapSettingsSlippageTitle,
SwapSettingsSlippageToggle,
SwapToggleButton,
} from '@coinbase/onchainkit/swap';
import type { Token } from '@coinbase/onchainkit/token';
Expand Down Expand Up @@ -87,6 +92,15 @@ function SwapComponent() {
)}
{address ? (
<Swap className="border bg-[#ffffff]" onStatus={handleOnStatus}>
<SwapSettings>
<SwapSettingsSlippageTitle>Max. slippage</SwapSettingsSlippageTitle>
<SwapSettingsSlippageDescription>
Your swap will revert if the prices change by more than the
selected percentage.
</SwapSettingsSlippageDescription>
<SwapSettingsSlippageToggle />
<SwapSettingsSlippageInput />
</SwapSettings>
<SwapAmountInput
label="Sell"
swappableTokens={swappableTokens}
Expand Down
10 changes: 0 additions & 10 deletions site/docs/pages/swap/types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,6 @@ type SwapReact = {
};
```

## `SwapSettingsReact`

```ts
type SwapSettingsReact = {
className?: string; // Optional className override for top div element.
icon?: ReactNode; // Optional icon override
text?: string; // Optional text override
};
```

## `SwapToggleButtonReact`

```ts
Expand Down
19 changes: 0 additions & 19 deletions src/swap/components/SlippageDescription.tsx

This file was deleted.

32 changes: 0 additions & 32 deletions src/swap/components/SlippageInput.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions src/swap/components/SlippageLabel.tsx

This file was deleted.

46 changes: 0 additions & 46 deletions src/swap/components/SlippageLayout.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/swap/components/Swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function Swap({
>
{title}
</h3>
<div>{swapSettings}</div>
{swapSettings}
</div>
{inputs[0]}
<div className="relative h-1">{toggleButton}</div>
Expand Down
Loading

0 comments on commit e1be19d

Please sign in to comment.