Skip to content

Commit

Permalink
Merge branch 'main' of github.com:curvefi/curve-frontend into refacto…
Browse files Browse the repository at this point in the history
…r/imports
  • Loading branch information
DanielSchiavini committed Jan 17, 2025
2 parents d5505cb + a56b6d9 commit be82bca
Show file tree
Hide file tree
Showing 19 changed files with 299 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const DetailInfoLeverage = ({
<DetailInfoLeverageExpected
loading={expectedLoading}
total={expectedCollateral?.totalCollateral}
swapToSymbol={borrowed_token?.symbol}
swapToSymbol={collateral_token?.symbol}
/>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function getColor(design: DesignSystem, data: LendingSnapshot[], type: GraphType
if (!data.length) return undefined
const first = data[0][`${type}_apy`]
const last = data[data.length - 1][`${type}_apy`]
return design.Text.TextColors[last === first ? 'Info' : last < first ? 'Error' : 'Success']
return design.Layer.Feedback[last === first ? 'Info' : last < first ? 'Error' : 'Success']
}

/** Center the y-axis around the first value */
Expand Down
2 changes: 1 addition & 1 deletion apps/main/src/lib/curvejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const helpers = {
// curve
const network = {
fetchAllPoolsList: async (curve: CurveApi, network: NetworkConfig) => {
log('fetchAllPoolsList', curve.chainId, network)
log('fetchAllPoolsList', curve.chainId)
// must call api in this order, must use api to get non-cached version of gaugeStatus
const useApi = network.useApi
await Promise.allSettled([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Box from '@mui/material/Box'
import Alert from '@mui/material/Alert'
import { CheckedIcon } from '@ui-kit/shared/icons/CheckedIcon'
import { MenuSectionHeader } from '@ui-kit/shared/ui/MenuSectionHeader'
import AlertTitle from '@mui/material/AlertTitle'

enum ChainType {
test = 'test',
Expand Down Expand Up @@ -86,7 +87,7 @@ export function ChainList<TChainId extends number>({
))
) : (
<Alert variant="filled" severity="info" sx={{ marginTop: 3 }}>
{t`No networks found`}
<AlertTitle>{t`No networks found`}</AlertTitle>
</Alert>
)}
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Snackbar from '@mui/material/Snackbar'
import Alert from '@mui/material/Alert'
import { Duration } from '@ui-kit/themes/design/0_primitives'
import Container from '@mui/material/Container'
import AlertTitle from '@mui/material/AlertTitle'

export type ChainOption<TChainId> = {
chainId: TChainId
Expand Down Expand Up @@ -63,7 +64,7 @@ export const ChainSwitcher = <TChainId extends number>({
>
<Container sx={{ justifyContent: 'end', marginTop: 4 }}>
<Alert variant="filled" severity="warning" data-testid="alert-eth-only">
{t`This application is only available on the Ethereum Mainnet`}
<AlertTitle>{t`This application is only available on the Ethereum Mainnet`}</AlertTitle>
</Alert>
</Container>
</Snackbar>
Expand Down
43 changes: 14 additions & 29 deletions packages/curve-ui-kit/src/lib/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,35 +90,20 @@ export function log(
const logger = logMethod(status)

const hasDefinedStatus = status && Object.values(LogStatus).includes(status as LogStatus)

if (hasDefinedStatus) {
const [formattedKeyString, keyStyles] = formatKeyArray(keyArray)
logger(
`%cDApp%c @ %c${timestamp}%c -> %c${status}%c\n${formattedKeyString}${args.length > 0 ? '%c: ' : ''}%c`,
'background: #1e63e9; color: white; padding: 2px 4px; border-radius: 3px;',
'color: #666; font-weight: bold;',
'color: #2196F3;',
'color: #666;',
getStatusStyle(status),
'color: #4CAF50; font-weight: bold;',
...keyStyles,
...(args.length > 0 ? ['color: 666;'] : []),
'color: inherit;',
...args,
)
} else {
const [formattedKeyString, keyStyles] = formatKeyArray(keyArray)
logger(
`%cDApp%c @ %c${timestamp}%c ->\n${formattedKeyString}${args.length > 0 ? '%c: ' : ''}%c`,
'background: #1e63e9; color: white; padding: 2px 4px; border-radius: 3px;',
'color: #666; font-weight: bold;',
'color: #2196F3;',
'color: #666;',
...keyStyles,
'color: inherit;',
...args,
)
}
const [formattedKeyString, keyStyles] = formatKeyArray(keyArray)
const restArgs = hasDefinedStatus ? args : [status, ...args]
const argsFormat = restArgs.length && `%c (%c${restArgs.map((i) => JSON.stringify(i)).join(', ')}%c)`
const format = `%cDApp%c @ %c${timestamp}%c -> ${hasDefinedStatus ? `%c${status} ` : ''}${formattedKeyString}${argsFormat ?? ''}`
logger(
format,
'background: #1e63e9; color: white; padding: 2px 4px; border-radius: 3px;', // DApp
'color: #666; font-weight: bold;', // @
'color: #2196F3;', // timestamp
'color: #666;', // ->
...(hasDefinedStatus ? [getStatusStyle(status), 'color: #4CAF50; font-weight: bold;'] : []), // status
...keyStyles, // key
...(restArgs.length ? ['color: #fff;', 'color: #666;', 'color: #fff;'] : []), // args
)
}

export const logQuery = (key: QueryKey, ...args: unknown[]) => log(key, LogStatus.QUERY, ...args)
Expand Down
11 changes: 11 additions & 0 deletions packages/curve-ui-kit/src/shared/icons/CheckIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createSvgIcon } from '@mui/material/utils'

export const CheckIcon = createSvgIcon(
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M12.2314 3.97534C12.5396 4.17683 12.6261 4.58999 12.4246 4.89815L7.89123 11.8315C7.78439 11.9949 7.61131 12.1032 7.41766 12.128C7.22401 12.1527 7.02925 12.0913 6.8848 11.9599L3.95147 9.29328C3.67903 9.04561 3.65895 8.62398 3.90662 8.35154C4.1543 8.0791 4.57593 8.05902 4.84837 8.30669L7.20315 10.4474L11.3086 4.16849C11.5101 3.86032 11.9233 3.77385 12.2314 3.97534Z"
fill="currentColor"
/>
</svg>,
'Check',
)
21 changes: 21 additions & 0 deletions packages/curve-ui-kit/src/shared/icons/ExclamationTriangleIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { createSvgIcon } from '@mui/material/utils'

export const ExclamationTriangleIcon = createSvgIcon(
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M7.28203 4.78525C7.26636 4.3779 7.59235 4.03913 8 4.03913C8.40764 4.03913 8.73363 4.3779 8.71797 4.78525L8.55383 9.05287C8.54238 9.35046 8.29781 9.58581 8 9.58581C7.70218 9.58581 7.45761 9.35046 7.44616 9.05287L7.28203 4.78525Z"
fill="currentColor"
/>
<path
d="M8.79988 11.1745C8.79988 11.6163 8.4417 11.9744 7.99988 11.9744C7.55805 11.9744 7.19988 11.6163 7.19988 11.1745C7.19988 10.7326 7.55805 10.3745 7.99988 10.3745C8.4417 10.3745 8.79988 10.7326 8.79988 11.1745Z"
fill="currentColor"
/>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M9.00789 0.649407C8.55285 -0.114093 7.44714 -0.114093 6.9921 0.649408L0.17192 12.0927C-0.294216 12.8748 0.269334 13.8667 1.17982 13.8667H14.8202C15.7307 13.8667 16.2942 12.8748 15.8281 12.0927L9.00789 0.649407ZM7.90837 1.19551C7.94974 1.1261 8.05025 1.1261 8.09162 1.19551L14.9118 12.6388C14.9542 12.7099 14.903 12.8 14.8202 12.8H1.17982C1.09705 12.8 1.04582 12.7099 1.08819 12.6388L7.90837 1.19551Z"
fill="currentColor"
/>
</svg>,
'ExclamationTriangle',
)
21 changes: 21 additions & 0 deletions packages/curve-ui-kit/src/shared/icons/InfoCircledIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { createSvgIcon } from '@mui/material/utils'

export const InfoCircledIcon = createSvgIcon(
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M8.79988 4.80006C8.79988 5.24189 8.44171 5.60006 7.99988 5.60006C7.55806 5.60006 7.19988 5.24189 7.19988 4.80006C7.19988 4.35823 7.55806 4.00006 7.99988 4.00006C8.44171 4.00006 8.79988 4.35823 8.79988 4.80006Z"
fill="currentColor"
/>
<path
d="M6.40001 6.40006H8.00001C8.29456 6.40006 8.53334 6.63884 8.53334 6.93339V10.6667H9.60001V11.7334H6.40001V10.6667H7.46667V7.46672H6.40001V6.40006Z"
fill="currentColor"
/>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M7.99987 0.935425C4.09834 0.935425 0.935516 4.09825 0.935516 7.99978C0.935516 11.9013 4.09834 15.0641 7.99987 15.0641C11.9014 15.0641 15.0642 11.9013 15.0642 7.99978C15.0642 4.09825 11.9014 0.935425 7.99987 0.935425ZM1.94885 7.99978C1.94885 4.6579 4.65799 1.94876 7.99987 1.94876C11.3417 1.94876 14.0509 4.6579 14.0509 7.99978C14.0509 11.3416 11.3417 14.0508 7.99987 14.0508C4.65799 14.0508 1.94885 11.3416 1.94885 7.99978Z"
fill="currentColor"
/>
</svg>,
'InfoCircled',
)
4 changes: 3 additions & 1 deletion packages/curve-ui-kit/src/shared/ui/Metric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SizesAndSpaces } from '@ui-kit/themes/design/1_sizes_spaces'
import { TypographyVariantKey, TYPOGRAPHY_VARIANTS } from '@ui-kit/themes/typography'
import { abbreviateNumber, scaleSuffix } from '@ui-kit/utils'
import { Duration } from '../../themes/design/0_primitives'
import AlertTitle from '@mui/material/AlertTitle'

const { Spacing } = SizesAndSpaces

Expand Down Expand Up @@ -229,7 +230,8 @@ export const Metric = ({

<Snackbar open={openCopyAlert} onClose={() => setOpenCopyAlert(false)} autoHideDuration={Duration.Snackbar}>
<Alert variant="filled" severity="success">
{copyText}: {value}
<AlertTitle>{copyText}</AlertTitle>
{value}
</Alert>
</Snackbar>
</Box>
Expand Down
27 changes: 17 additions & 10 deletions packages/curve-ui-kit/src/themes/basic-theme/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,24 @@ export const basicMuiTheme = createMuiTheme({
* '@media (min-width: 1200px)': { width: 100, height: '300px' }
* }
*/
export const handleBreakpoints = (values: Record<keyof CSSObject, number | string | Responsive>) =>
export const handleBreakpoints = (values: Record<keyof CSSObject, number | string | Responsive>): CSSObject =>
Object.fromEntries(
basicMuiTheme.breakpoints.keys.map((breakpoint) => [
basicMuiTheme.breakpoints.up(breakpoint),
Object.fromEntries(
Object.entries(values).map(([key, value]) => [
key,
typeof value === 'string' || typeof value === 'number' ? value : value[breakpoint],
]),
),
]),
basicMuiTheme.breakpoints.keys.map((breakpoint) => {
const selector = basicMuiTheme.breakpoints.up(breakpoint)
return [
selector,
{
// in case the selector is already present, merge the values
...((values[selector] as CSSObject) ?? {}),
...Object.fromEntries(
Object.entries(values).map(([key, value]) => [
key,
typeof value === 'string' || typeof value === 'number' || value == null ? value : value[breakpoint],
]),
),
},
]
}),
)

export type Responsive = Record<Breakpoint, string>
6 changes: 4 additions & 2 deletions packages/curve-ui-kit/src/themes/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import { SizesAndSpaces } from './design/1_sizes_spaces'
import { defineMuiSwitch } from './mui-switch'
import { basicMuiTheme } from './basic-theme'
import { alpha } from '@mui/system'
import type { TypographyOptions } from '@mui/material/styles/createTypography'
import { defineMuiMenuItem } from '@ui-kit/themes/mui-menu-item'
import { defineMuiAlert, defineMuiAlertTitle } from '@ui-kit/themes/mui-alert'
import type { TypographyOptions } from '@mui/material/styles/createTypography'
import { TransitionFunction } from '@ui-kit/themes/design/0_primitives'
import { linearProgressClasses } from '@mui/material/LinearProgress'

export const DEFAULT_BAR_SIZE = SizesAndSpaces.ButtonSize.sm
export const MOBILE_SIDEBAR_WIDTH = { width: '100%', minWidth: 320 } as const

export const createComponents = (design: DesignSystem, typography: TypographyOptions): ThemeOptions['components'] => ({
MuiAlert: defineMuiAlert(design, typography),
MuiAlertTitle: defineMuiAlertTitle(design, typography),
MuiButton: defineMuiButton(design),
MuiButtonBase: {
defaultProps: {
Expand Down
Loading

0 comments on commit be82bca

Please sign in to comment.