Skip to content

Commit 8fac5b8

Browse files
authored
Merge pull request #1738 from curvefi/feat/analytics-app
feat: add new barebones analytics app
2 parents 0bd9772 + 852da5d commit 8fac5b8

File tree

15 files changed

+110
-16
lines changed

15 files changed

+110
-16
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { Outlet } from '@tanstack/react-router'
2+
3+
export function AnalyticsLayout() {
4+
return <Outlet />
5+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const PageHome = () => <div data-testid="new-app">hello world</div>

apps/main/src/routes/GlobalLayout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const useAppRoutes = (network: NetworkDef) => ({
3232
dao: APP_LINK.dao.routes,
3333
llamalend: APP_LINK.llamalend.routes,
3434
dex: useDexRoutes(network),
35+
analytics: APP_LINK.analytics.routes,
3536
})
3637

3738
const useAppMenu = (app: AppName): AppMenuOption =>
@@ -41,6 +42,7 @@ const useAppMenu = (app: AppName): AppMenuOption =>
4142
lend: 'llamalend' as const,
4243
llamalend: 'llamalend' as const,
4344
dex: 'dex' as const,
45+
analytics: 'analytics' as const,
4446
})[app]
4547

4648
const useAppSupportedNetworks = (allNetworks: NetworkMapping, app: AppName) =>
@@ -50,6 +52,7 @@ const useAppSupportedNetworks = (allNetworks: NetworkMapping, app: AppName) =>
5052
lend: lendNetworks,
5153
llamalend: lendNetworks,
5254
dex: allNetworks,
55+
analytics: allNetworks,
5356
})[app]
5457

5558
// when the mobile drawer is open, we want to ignore the scrollbar and expand the content to full page width
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import '@/global-extensions'
2+
import { AnalyticsLayout } from '@/analytics/AnalyticsLayout'
3+
import { PageHome } from '@/analytics/components/PageHome'
4+
import Skeleton from '@mui/material/Skeleton'
5+
import { createRoute } from '@tanstack/react-router'
6+
import { SizesAndSpaces } from '@ui-kit/themes/design/1_sizes_spaces'
7+
import { rootRoute } from './root.routes'
8+
import { redirectTo } from './util'
9+
10+
const { MinHeight } = SizesAndSpaces
11+
12+
const analyticsLayoutRoute = createRoute({
13+
getParentRoute: () => rootRoute,
14+
path: 'analytics',
15+
component: AnalyticsLayout,
16+
})
17+
18+
const layoutProps = { getParentRoute: () => analyticsLayoutRoute }
19+
20+
export const analyticsRoutes = analyticsLayoutRoute.addChildren([
21+
createRoute({
22+
path: '/',
23+
component: () => <Skeleton width="100%" height={MinHeight.pageContent} />,
24+
head: () => ({
25+
meta: [{ title: 'Analytics - Curve' }],
26+
}),
27+
...layoutProps,
28+
}),
29+
createRoute({
30+
path: '$network',
31+
loader: ({ params: { network } }) => redirectTo(`/analytics/${network}/home`),
32+
...layoutProps,
33+
}),
34+
createRoute({
35+
path: '$network/home',
36+
component: PageHome,
37+
...layoutProps,
38+
}),
39+
])

apps/main/src/routes/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createRoute, createRouter } from '@tanstack/react-router'
55
import { t } from '@ui-kit/lib/i18n'
66
import { ErrorPage } from '@ui-kit/pages/ErrorPage'
77
import { SizesAndSpaces } from '@ui-kit/themes/design/1_sizes_spaces'
8+
import { analyticsRoutes } from './analytics.routes'
89
import { crvusdRoutes } from './crvusd.routes'
910
import { daoRoutes } from './dao.routes'
1011
import { dexRoutes } from './dex.routes'
@@ -33,6 +34,7 @@ export const router = createRouter({
3334
scrollRestoration: true,
3435
routeTree: rootRoute.addChildren([
3536
indexRoute,
37+
analyticsRoutes,
3638
crvusdRoutes,
3739
daoRoutes,
3840
dexRoutes,

packages/curve-ui-kit/src/features/connect-wallet/lib/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ export const AppLibs = {
4545
dex: 'curveApi',
4646
lend: 'llamaApi',
4747
llamalend: 'llamaApi',
48-
} satisfies Record<AppName, LibKey>
48+
// Technically this app doesn't need a lib, but making this optional opens a can of worms. Refactor later.
49+
analytics: 'curveApi',
50+
} satisfies Record<AppName, LibKey | undefined>
4951
type AppLibMap = typeof AppLibs
5052

5153
export type AppLib<A extends AppName> = Libs[AppLibMap[A]]

packages/curve-ui-kit/src/hooks/useFeatureFlags.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ export const useNewBandsChart = useBetaChannel
3838

3939
/** New card for managing soft liquidations */
4040
export const useManageSoftLiquidation = useAlphaChannel
41+
42+
/** Entire new app containing in-depth analyses for knowledgeable users */
43+
export const useAnalyticsApp = useAlphaChannel

packages/curve-ui-kit/src/shared/route-redirects.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import { type ParsedLocation } from '@tanstack/router-core'
22
import { type AppName, AppNames, CRVUSD_ROUTES, DAO_ROUTES, DEX_ROUTES, LEND_ROUTES, LLAMALEND_ROUTES } from './routes'
33

4-
const defaultPages = { dex: 'swap', lend: 'markets', crvusd: 'markets', dao: 'proposals', llamalend: 'markets' }
4+
const defaultPages = {
5+
dex: 'swap',
6+
lend: 'markets',
7+
crvusd: 'markets',
8+
dao: 'proposals',
9+
llamalend: 'markets',
10+
analytics: 'home',
11+
}
512
const oldOrigins = ['lend', 'crvusd', 'dao'] as const
613

714
// old redirects that were hardcoded in the react-router routes. The network name gets added in the redirect.
@@ -30,6 +37,7 @@ const OldRoutes: Record<AppName, string[]> = {
3037
],
3138
lend: [LEND_ROUTES.PAGE_MARKETS, LEND_ROUTES.PAGE_INTEGRATIONS],
3239
llamalend: [LLAMALEND_ROUTES.PAGE_MARKETS, LLAMALEND_ROUTES.PAGE_INTEGRATIONS],
40+
analytics: [],
3341
}
3442

3543
/**

packages/curve-ui-kit/src/shared/routes.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ export const DAO_ROUTES = {
4747
PAGE_INTEGRATIONS,
4848
} as const
4949

50-
export const AppNames = ['dex', 'lend', 'crvusd', 'dao', 'llamalend'] as const
50+
export const ANALYTICS_ROUTES = {
51+
PAGE_HOME: '/home',
52+
}
53+
54+
export const AppNames = ['dex', 'lend', 'crvusd', 'dao', 'llamalend', 'analytics'] as const
5155
export type AppName = (typeof AppNames)[number]
5256

53-
export const AppMenuOptions = ['dex', 'llamalend', 'dao'] as const
57+
export const AppMenuOptions = ['dex', 'llamalend', 'dao', 'analytics'] as const
5458
export type AppMenuOption = (typeof AppMenuOptions)[number]
5559

5660
export const APP_LINK: Record<AppMenuOption, AppRoutes> = {
@@ -81,6 +85,10 @@ export const APP_LINK: Record<AppMenuOption, AppRoutes> = {
8185
{ app: 'dao', route: DAO_ROUTES.DISCUSSION, label: () => t`Discussion`, target: '_blank' },
8286
],
8387
},
88+
analytics: {
89+
label: 'Analytics',
90+
routes: [{ app: 'analytics', route: ANALYTICS_ROUTES.PAGE_HOME, label: () => t`Home` }],
91+
},
8492
}
8593

8694
/** Returns the full pathname for a given app and network */

packages/curve-ui-kit/src/widgets/Header/AppButtonLinks.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import Box from '@mui/material/Box'
22
import Button from '@mui/material/Button'
3-
import { APP_LINK, type AppMenuOption, getInternalUrl } from '@ui-kit/shared/routes'
3+
import { type AppMenuOption, getInternalUrl } from '@ui-kit/shared/routes'
44
import { RouterLink } from '@ui-kit/shared/ui/RouterLink'
5+
import { useVisibleAppLinks } from './useVisibleAppLinks'
56

67
type AppNavAppsProps = { currentMenu: AppMenuOption; onChange: (appName: AppMenuOption) => void; networkId: string }
78

89
export const AppButtonLinks = ({ currentMenu, onChange, networkId }: AppNavAppsProps) => (
910
<Box display="flex" alignItems="center" marginX={[2, 3, 4]} gap={2}>
10-
{Object.entries(APP_LINK).map(([menu, { label, routes }]) => (
11+
{useVisibleAppLinks().map(([menu, { label, routes }]) => (
1112
<Button
1213
key={menu}
1314
color="navigation"

0 commit comments

Comments
 (0)