-
Notifications
You must be signed in to change notification settings - Fork 18
feat: reduce CLS with skeleton loaders and remove useWindowSize #598
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,15 @@ | ||
| import { Skeleton } from "@livepeer/design-system"; | ||
|
|
||
| const ConnectButtonSkeleton = () => ( | ||
| <Skeleton | ||
| css={{ | ||
| height: "40px", | ||
| minWidth: "145px", | ||
| width: "145px", | ||
| borderRadius: "8px", | ||
| display: "inline-block", | ||
| }} | ||
| /> | ||
| ); | ||
|
|
||
| export default ConnectButtonSkeleton; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { Box, Flex, Skeleton } from "@livepeer/design-system"; | ||
|
|
||
| const OrchestratorListSkeleton = () => { | ||
| return ( | ||
| <Box | ||
| css={{ | ||
| border: "1px solid $colors$neutral4", | ||
| backgroundColor: "$panel", | ||
| borderRadius: "$4", | ||
| }} | ||
| > | ||
| {/* Input section skeleton */} | ||
| <Box | ||
| css={{ | ||
| marginTop: "$4", | ||
| marginLeft: "$5", | ||
| marginBottom: "$4", | ||
| }} | ||
| > | ||
| <Flex css={{ alignItems: "center", marginBottom: "$2" }}> | ||
| <Skeleton css={{ width: 20, height: 20, borderRadius: "$2" }} /> | ||
| <Skeleton css={{ width: 200, height: 16, marginLeft: "$2" }} /> | ||
| </Flex> | ||
| <Flex css={{ gap: "$2", marginBottom: "$2" }}> | ||
| <Skeleton css={{ width: 120, height: 32, borderRadius: "$2" }} /> | ||
| <Skeleton css={{ width: 120, height: 32, borderRadius: "$2" }} /> | ||
| <Skeleton css={{ width: 120, height: 32, borderRadius: "$2" }} /> | ||
| </Flex> | ||
| </Box> | ||
|
|
||
| {/* Table header skeleton */} | ||
| <Box | ||
| css={{ padding: "$3 $5", borderBottom: "1px solid $colors$neutral4" }} | ||
| > | ||
| <Flex css={{ gap: "$4" }}> | ||
| <Skeleton css={{ width: 150, height: 16 }} /> | ||
|
Comment on lines
+31
to
+36
|
||
| <Skeleton css={{ width: 120, height: 16 }} /> | ||
| <Skeleton css={{ width: 120, height: 16 }} /> | ||
| <Skeleton css={{ width: 100, height: 16 }} /> | ||
| <Skeleton css={{ width: 100, height: 16 }} /> | ||
| </Flex> | ||
| </Box> | ||
|
|
||
| {/* Table rows skeleton (10 rows) */} | ||
| {Array.from({ length: 10 }).map((_, i) => ( | ||
| <Box | ||
| key={i} | ||
| css={{ | ||
| padding: "$3 $5", | ||
| borderBottom: i < 9 ? "1px solid $colors$neutral4" : "none", | ||
| }} | ||
| > | ||
| <Flex css={{ gap: "$4", alignItems: "center" }}> | ||
| <Skeleton css={{ width: 150, height: 40, borderRadius: "$2" }} /> | ||
| <Skeleton css={{ width: 120, height: 20 }} /> | ||
| <Skeleton css={{ width: 120, height: 20 }} /> | ||
| <Skeleton css={{ width: 100, height: 20 }} /> | ||
| <Skeleton css={{ width: 100, height: 20 }} /> | ||
| </Flex> | ||
| </Box> | ||
| ))} | ||
|
|
||
| {/* Pagination skeleton */} | ||
| <Flex | ||
| css={{ | ||
| paddingTop: "$4", | ||
| paddingBottom: "$4", | ||
| alignItems: "center", | ||
| justifyContent: "center", | ||
| gap: "$3", | ||
| }} | ||
| > | ||
| <Skeleton css={{ width: 20, height: 20, borderRadius: "$2" }} /> | ||
| <Skeleton css={{ width: 100, height: 16 }} /> | ||
| <Skeleton css={{ width: 20, height: 20, borderRadius: "$2" }} /> | ||
| </Flex> | ||
| </Box> | ||
| ); | ||
| }; | ||
|
|
||
| export default OrchestratorListSkeleton; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import AppBar from "@components/AppBar"; | ||
| import Drawer from "@components/Drawer"; | ||
| import Hamburger from "@components/Hamburger"; | ||
| import InactiveWarning from "@components/InactiveWarning"; | ||
|
|
@@ -57,7 +57,7 @@ | |
| } from "react"; | ||
| import { isMobile } from "react-device-detect"; | ||
| import ReactGA from "react-ga"; | ||
| import { useWindowSize } from "react-use"; | ||
|
|
||
| import { Chain } from "viem"; | ||
|
|
||
| import { | ||
|
|
@@ -108,8 +108,11 @@ | |
| children?: React.ReactNode; | ||
| }>; | ||
|
|
||
| import ConnectButtonSkeleton from "../components/ConnectButton/Skeleton"; | ||
|
|
||
| const ConnectButton = dynamic(() => import("../components/ConnectButton"), { | ||
| ssr: false, | ||
| loading: () => <ConnectButtonSkeleton />, | ||
|
Comment on lines
+111
to
+115
|
||
| }); | ||
|
|
||
| const Claim = dynamic(() => import("../components/Claim"), { ssr: false }); | ||
|
|
@@ -134,7 +137,6 @@ | |
| const activeChain = useActiveChain(); | ||
| const [drawerOpen, setDrawerOpen] = useState(false); | ||
| const [bannerActive, setBannerActive] = useState<boolean>(false); | ||
| const { width } = useWindowSize(); | ||
|
Contributor
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. |
||
| const ref = useRef(null); | ||
| const currentRound = useCurrentRoundData(); | ||
| const pendingFeesAndStake = usePendingFeesAndStakeData(accountAddress); | ||
|
|
@@ -208,16 +210,6 @@ | |
| return () => window.removeEventListener("storage", onStorage); | ||
| }, [isReady, isBannerDisabledByQuery]); | ||
|
|
||
| useEffect(() => { | ||
| if (width >= 1200) { | ||
| document.body.removeAttribute("style"); | ||
| } | ||
|
|
||
| if (width < 1200 && drawerOpen) { | ||
| document.body.style.overflow = "hidden"; | ||
| } | ||
| }, [drawerOpen, width]); | ||
|
|
||
| useEffect(() => { | ||
| ReactGA.set({ | ||
| customBrowserType: !isMobile | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,11 @@ | ||||||||||
| import "react-circular-progressbar/dist/styles.css"; | ||||||||||
|
|
||||||||||
| import ErrorComponent from "@components/Error"; | ||||||||||
| import type { Group } from "@components/ExplorerChart"; | ||||||||||
| import ExplorerChart from "@components/ExplorerChart"; | ||||||||||
| import OrchestratorList from "@components/OrchestratorList"; | ||||||||||
| import RoundStatus from "@components/RoundStatus"; | ||||||||||
| import OrchestratorListSkeleton from "@components/OrchestratorList/Skeleton"; | ||||||||||
|
Comment on lines
7
to
+8
|
||||||||||
| import RoundStatus from "@components/RoundStatus"; | |
| import OrchestratorListSkeleton from "@components/OrchestratorList/Skeleton"; | |
| import OrchestratorListSkeleton from "@components/OrchestratorList/Skeleton"; | |
| import RoundStatus from "@components/RoundStatus"; |
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.
The input-section spacing here doesn’t match the real
Tableinput wrapper:components/Table/index.tsxappliesmarginTop: "$4"andmarginLeft: "$5"but no wrappermarginBottom. The extramarginBottom: "$4"in the skeleton makes it taller than the real OrchestratorList header area, which can cause a vertical layout shift when swapping from skeleton to the actual table.