Skip to content

Commit

Permalink
fix: broken svgs and move STABLE config to reserve patches config (#1072
Browse files Browse the repository at this point in the history
)

* fix: fix sorting for some stable assets

* fix: properly configure svgo

otherwise e.g. lighting on frax
will be broken as they overwrite each other
  • Loading branch information
sakulstra authored Sep 2, 2022
1 parent 2a71a8b commit bbc840d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
11 changes: 10 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ module.exports = withBundleAnalyzer({
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ['@svgr/webpack'],
use: [
{
loader: '@svgr/webpack',
options: {
svgoConfig: {
plugins: ['prefixIds'],
},
},
},
],
});
config.experiments = { topLevelAwait: true };
return config;
Expand Down
26 changes: 3 additions & 23 deletions src/hooks/app-data-provider/useAppDataProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import BigNumber from 'bignumber.js';
import React, { useContext } from 'react';
import { useWeb3Context } from 'src/libs/hooks/useWeb3Context';
import { fetchIconSymbolAndName } from 'src/ui-config/reservePatches';
import { fetchIconSymbolAndName, STABLE_ASSETS } from 'src/ui-config/reservePatches';

import { useCurrentTimestamp } from '../useCurrentTimestamp';
import { useProtocolDataContext } from '../useProtocolDataContext';
Expand Down Expand Up @@ -240,29 +240,9 @@ export const AppDataProvider: React.FC = ({ children }) => {

export const useAppDataContext = () => useContext(AppDataContext);

// tokens flagged stable will be sorted on top when no other sorting is selected
const stable = [
'DAI',
'TUSD',
'BUSD',
'GUSD',
'USDC',
'USDT',
'EUROS',
'FEI',
'FRAX',
'PAX',
'USDP',
'SUSD',
'UST',
'EURS',
'JEUR',
'AGEUR',
];

const reserveSortFn = (a: { iconSymbol: string }, b: { iconSymbol: string }) => {
const aIsStable = stable.includes(a.iconSymbol.toUpperCase());
const bIsStable = stable.includes(b.iconSymbol.toUpperCase());
const aIsStable = STABLE_ASSETS.includes(a.iconSymbol.toUpperCase());
const bIsStable = STABLE_ASSETS.includes(b.iconSymbol.toUpperCase());
if (aIsStable && !bIsStable) return -1;
if (!aIsStable && bIsStable) return 1;
return a.iconSymbol.toUpperCase() > b.iconSymbol.toUpperCase() ? 1 : -1;
Expand Down
22 changes: 22 additions & 0 deletions src/ui-config/reservePatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,25 @@ export function fetchIconSymbolAndName({
symbol,
};
}

// tokens flagged stable will be sorted on top when no other sorting is selected
export const STABLE_ASSETS = [
'DAI',
'TUSD',
'BUSD',
'GUSD',
'USDC',
'USDT',
'EUROS',
'FEI',
'FRAX',
'PAX',
'USDP',
'SUSD',
'UST',
'EURS',
'JEUR',
'AGEUR',
'LUSD',
'MAI',
];

0 comments on commit bbc840d

Please sign in to comment.