-
Notifications
You must be signed in to change notification settings - Fork 3
feat: util preview on rebalance #186
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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,32 +1,15 @@ | ||
| import React from 'react'; | ||
| import { formatReadable } from '@/utils/balance'; | ||
| import { MetricPreview } from './MetricPreview'; | ||
|
|
||
| type ApyPreviewProps = { | ||
| currentApy: number; | ||
| previewApy?: number | null; | ||
| }; | ||
|
|
||
| /** | ||
| * Standardized APY preview component. | ||
| * Shows current APY in a fixed position, and appends preview to the right when available. | ||
| * This ensures perfect vertical alignment across all uses. | ||
| * APY preview component. | ||
| * Thin wrapper around MetricPreview for APY-specific usage. | ||
| */ | ||
| export function ApyPreview({ currentApy, previewApy }: ApyPreviewProps) { | ||
| const formattedCurrent = formatReadable(currentApy * 100); | ||
| const formattedPreview = previewApy ? formatReadable(previewApy * 100) : null; | ||
| const hasPreview = Boolean(previewApy && formattedPreview); | ||
|
|
||
| const currentClasses = `text-foreground${hasPreview ? ' line-through opacity-50' : ''}`; | ||
|
|
||
| return ( | ||
| <span className="whitespace-nowrap text-sm font-semibold"> | ||
| <span className={currentClasses}>{formattedCurrent}%</span> | ||
| {hasPreview && ( | ||
| <> | ||
| {' → '} | ||
| <span className="text-foreground">{formattedPreview}%</span> | ||
| </> | ||
| )} | ||
| </span> | ||
| ); | ||
| return <MetricPreview currentValue={currentApy} previewValue={previewApy} label="APY" />; | ||
| } |
This file contains hidden or 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 hidden or 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,51 @@ | ||
| import React from 'react'; | ||
| import { Tooltip } from '@heroui/react'; | ||
| import { TooltipContent } from '@/components/TooltipContent'; | ||
| import { formatReadable } from '@/utils/balance'; | ||
|
|
||
| type MetricPreviewProps = { | ||
| currentValue: number; | ||
| previewValue?: number | null; | ||
| label: string; | ||
| }; | ||
|
|
||
| /** | ||
| * Generic metric preview component. | ||
| * Shows preview value if available, otherwise shows current value. | ||
| * Displays tooltip on hover showing before/after values. | ||
| */ | ||
| export function MetricPreview({ currentValue, previewValue, label }: MetricPreviewProps) { | ||
| const formattedCurrent = formatReadable(currentValue * 100); | ||
| const formattedPreview = previewValue ? formatReadable(previewValue * 100) : null; | ||
| const hasPreview = Boolean(previewValue && formattedPreview); | ||
|
antoncoding marked this conversation as resolved.
|
||
|
|
||
| // Show preview value if available, otherwise show current value | ||
| const displayValue = hasPreview ? formattedPreview : formattedCurrent; | ||
|
|
||
| if (!hasPreview) { | ||
| return ( | ||
| <span className="inline-block min-w-[60px] whitespace-nowrap text-right text-sm text-foreground"> | ||
| {displayValue}% | ||
| </span> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <Tooltip | ||
| classNames={{ | ||
| base: 'p-0 m-0 bg-transparent shadow-sm border-none', | ||
| content: 'p-0 m-0 bg-transparent shadow-sm border-none', | ||
| }} | ||
| content={ | ||
| <TooltipContent | ||
| title={`${label} Change`} | ||
| detail={`${formattedCurrent}% → ${formattedPreview}%`} | ||
| /> | ||
| } | ||
| > | ||
| <span className="inline-block min-w-[60px] cursor-help whitespace-nowrap border-b border-dashed border-gray-400 text-right text-sm text-foreground"> | ||
| {displayValue}% | ||
| </span> | ||
| </Tooltip> | ||
| ); | ||
| } | ||
This file contains hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.