Skip to content

Commit

Permalink
feat: prefer primary color hex (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
vacekj authored Jan 21, 2025
1 parent eb6abcc commit 951c9c1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/pages/portfolio/ui/assets-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,17 @@ const calculateAssetDistribution = (balances: BalancesResponse[]): DistributionR

// Sort by value percentage in descending order and calculate distribution
const sorted = valuesWithMetadata
.map((item, index) => ({
...item,
percentage: (item.value / totalValue) * 100,
color: `hsl(${(index * GOLDEN_RATIO_ANGLE) % 360}, ${COLOR_SATURATION}%, ${COLOR_LIGHTNESS}%)`,
}))
.map((item, index) => {
const metadata = getMetadataFromBalancesResponse.optional(item.balance);
const primaryColor = metadata?.images[0]?.theme?.primaryColorHex;
return {
...item,
percentage: (item.value / totalValue) * 100,
color:
primaryColor ??
`hsl(${(index * GOLDEN_RATIO_ANGLE) % 360}, ${COLOR_SATURATION}%, ${COLOR_LIGHTNESS}%)`,
};
})
.sort((a, b) => b.percentage - a.percentage);

// Split into main assets and small assets
Expand Down

0 comments on commit 951c9c1

Please sign in to comment.