-
Notifications
You must be signed in to change notification settings - Fork 16
Lite - Improve layout stability, bundle size, and UX on dashboard #112
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| User-agent: * | ||
| Allow: / | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { AccrualPosition } from "@morpho-org/blue-sdk"; | |
| import { restructure } from "@morpho-org/blue-sdk-viem"; | ||
| import { metaMorphoFactoryAbi } from "@morpho-org/uikit/assets/abis/meta-morpho-factory"; | ||
| import { morphoAbi } from "@morpho-org/uikit/assets/abis/morpho"; | ||
| import { Tabs, TabsList, TabsTrigger, TabsContent } from "@morpho-org/uikit/components/shadcn/tabs"; | ||
| import useContractEvents from "@morpho-org/uikit/hooks/use-contract-events/use-contract-events"; | ||
| import { | ||
| marketHasDeadDeposit, | ||
|
|
@@ -16,6 +17,7 @@ import { type Address, erc20Abi, type Chain, zeroAddress, type Hex } from "viem" | |
| import { useAccount, useReadContract, useReadContracts } from "wagmi"; | ||
|
|
||
| import { BorrowPositionTable, BorrowTable } from "@/components/borrow-table"; | ||
| import { BoxTopRoundedCorners } from "@/components/box-top-rounded-corners"; | ||
| import { CtaCard } from "@/components/cta-card"; | ||
| import { useMarkets } from "@/hooks/use-markets"; | ||
| import * as Merkl from "@/hooks/use-merkl-campaigns"; | ||
|
|
@@ -240,41 +242,42 @@ export function BorrowSubPage() { | |
|
|
||
| return ( | ||
| <div className="flex min-h-screen flex-col px-2.5 pt-16"> | ||
| {status === "disconnected" ? ( | ||
| <div className="bg-linear-to-b flex w-full flex-col from-transparent to-white/[0.03] px-8 pb-20 pt-8"> | ||
| <CtaCard | ||
| className="md:w-7xl flex flex-col gap-4 md:mx-auto md:max-w-full md:flex-row md:items-center md:justify-between" | ||
| bigText="Provide collateral to borrow any asset" | ||
| littleText="Connect wallet to get started" | ||
| videoSrc={{ | ||
| mov: "https://cdn.morpho.org/v2/assets/videos/borrow-animation.mov", | ||
| webm: "https://cdn.morpho.org/v2/assets/videos/borrow-animation.webm", | ||
| }} | ||
| /> | ||
| </div> | ||
| ) : ( | ||
| userMarkets.length > 0 && ( | ||
| <div className="bg-linear-to-b lg:pt-22 flex h-fit w-full flex-col items-center from-transparent to-white/[0.03] pb-20"> | ||
| <div className="text-primary-foreground w-full max-w-7xl px-2 lg:px-8"> | ||
| <BorrowPositionTable | ||
| chain={chain} | ||
| markets={userMarkets} | ||
| tokens={tokens} | ||
| positions={positions} | ||
| borrowingRewards={borrowingRewards} | ||
| refetchPositions={refetchPositionsRaw} | ||
| /> | ||
| </div> | ||
| </div> | ||
| ) | ||
| )} | ||
| {/* | ||
| Outer div ensures background color matches the end of the gradient from the div above, | ||
| allowing rounded corners to show correctly. Inner div defines rounded corners and table background. | ||
| */} | ||
| <div className="flex grow flex-col bg-white/[0.03]"> | ||
| <div className="bg-linear-to-b from-background to-primary flex h-full grow justify-center rounded-t-xl pb-16 pt-8"> | ||
| <div className="text-primary-foreground w-full max-w-7xl px-2 lg:px-8"> | ||
| <div className="bg-linear-to-b to-white/3 flex w-full flex-col from-transparent px-8 pb-20 pt-8"> | ||
| <CtaCard | ||
| bigText="Provide collateral to borrow any asset" | ||
| littleText="Connect wallet to get started" | ||
| videoSrc={{ | ||
| mov: "https://cdn.morpho.org/v2/assets/videos/borrow-animation.mov", | ||
| webm: "https://cdn.morpho.org/v2/assets/videos/borrow-animation.webm", | ||
| }} | ||
| /> | ||
| </div> | ||
| <BoxTopRoundedCorners> | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BoxTopRoundedCorners to standardize the layout structure and avoid repetition |
||
| <Tabs | ||
| defaultValue={userMarkets.length > 0 ? "user-positions" : "markets"} | ||
| className="w-full max-w-7xl px-2 lg:px-8" | ||
| > | ||
| <TabsList className="grid grid-cols-2 p-0"> | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we are matching the strategy used on the main Morpho app. By placing the static Call-to-Action (CTA) cards at the top, we ensure immediate visual feedback for the user without blocking the render. The data-heavy, asynchronous content (tables for user positions and markets) is moved to the bottom within Tabs. This separation allows the core interface to load instantly while heavier data fetches happen in the background, significantly improving perceived performance and eliminating the layout shift that would occur if dynamic content pushed the static elements down after loading. |
||
| <TabsTrigger | ||
| className="disabled:cursor-not-allowed!" | ||
| value="user-positions" | ||
| disabled={userMarkets.length === 0} | ||
| > | ||
| Your positions | ||
| </TabsTrigger> | ||
| <TabsTrigger value="markets">Markets</TabsTrigger> | ||
| </TabsList> | ||
| <TabsContent value="user-positions" className="mt-4"> | ||
| <BorrowPositionTable | ||
| chain={chain} | ||
| markets={userMarkets} | ||
| tokens={tokens} | ||
| positions={positions} | ||
| borrowingRewards={borrowingRewards} | ||
| refetchPositions={refetchPositionsRaw} | ||
| /> | ||
| </TabsContent> | ||
| <TabsContent value="markets" className="mt-4"> | ||
| <BorrowTable | ||
| chain={chain} | ||
| markets={marketsArr} | ||
|
|
@@ -283,9 +286,9 @@ export function BorrowSubPage() { | |
| borrowingRewards={borrowingRewards} | ||
| refetchPositions={refetchPositionsRaw} | ||
| /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </TabsContent> | ||
| </Tabs> | ||
| </BoxTopRoundedCorners> | ||
| </div> | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following Radix UI best practices, wrapping the entire application in a single is efficient because it allows all tooltip components to share a common configuration (like delay duration). This avoids redundant provider instances, keeps the component tree cleaner and with less code to compile.
https://www.radix-ui.com/primitives/docs/components/tooltip#provider
If a specific tooltip ever needs unique timing or behavior, we can still nest a separate provider locally for that case, but the global one handles the default case for the whole app.