Skip to content
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

Merge pull request #1438 #1439

Merged
merged 2 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/app/ecosystem/Protocols/ProtocolList/ProtocolCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Image from "next/image"
import { useRef, useState } from "react"
import Img from "react-cool-img"
import { makeStyles } from "tss-react/mui"

import { Box, Button, Stack, SvgIcon, Typography } from "@mui/material"
Expand All @@ -15,6 +15,18 @@ import useCheckViewport from "@/hooks/useCheckViewport"

import NetworkLabel from "./NetworkLabel"

export interface Protocol {
name: string
desc: string
ext: string
// networkLabel: "Mainnet" | "Testnet"
networkLabel: string
rank: object
tags: string[]
twitterHandle: string
website: string
}

const useStyles = makeStyles()(theme => ({
grid: {
backgroundColor: theme.vars.palette.themeBackground.normal,
Expand Down Expand Up @@ -123,7 +135,7 @@ const useStyles = makeStyles()(theme => ({
}))

const ProtocolCard = props => {
const { name, hash, ext, tags, desc, website, twitterHandle, networkLabel, onResize, className, ...restProps } = props
const { name, ext, tags, desc, website, twitterHandle, networkLabel, onResize, className, ...restProps } = props
const { classes, cx } = useStyles()
const { isMobile, isDesktop } = useCheckViewport()

Expand All @@ -146,7 +158,13 @@ const ProtocolCard = props => {
gridArea: "logo",
}}
>
<Img alt={name} src={fetchEcosystemProtocolLogo(name, ext)} placeholder={hash} width={isMobile ? 48 : 88} height={isMobile ? 48 : 88}></Img>{" "}
<Image
alt={name}
src={fetchEcosystemProtocolLogo(name, ext)}
placeholder="empty"
width={isMobile ? 48 : 88}
height={isMobile ? 48 : 88}
></Image>
</Stack>
<Stack direction="row" alignItems="center" gap="0.8rem" className={classes.name}>
<Typography
Expand Down
6 changes: 4 additions & 2 deletions src/app/ecosystem/Protocols/ProtocolList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { isAboveScreen } from "@/utils/dom"

import Error from "./Error"
import NoData from "./NoData"
import ProtocolCard from "./ProtocolCard"
import ProtocolCard, { type Protocol } from "./ProtocolCard"

const useStyles = makeStyles()(theme => ({
listRoot: {
Expand All @@ -36,7 +36,7 @@ const ProtocolList = props => {
const { classes } = useStyles()
const [loading, setLoading] = useState(false)
const prePage = usePrevious(page)
const [ecosystemList, setEcosystemList] = useState([])
const [ecosystemList, setEcosystemList] = useState<Protocol[]>([])
const [isError, setIsError] = useState(false)
const [hasMore, setHasMore] = useState(false)

Expand All @@ -46,7 +46,9 @@ const ProtocolList = props => {
estimateSize: () => 136,
overscan: 5,
gap: 20,

scrollMargin: listRef.current?.offsetTop ?? 0,
getItemKey: index => ecosystemList[index].name,
})
const rows = virtualizer.getVirtualItems()

Expand Down
4 changes: 2 additions & 2 deletions src/components/LinesEllipsis/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function prevSibling(node, count) {
}

const LinesEllipsis = props => {
const { component: Component = "div", ellipsis, trimRight = true, basedOn, maxLine = 1, text, className, onReflow, ...rest } = props
const { component: Component = "div", ellipsis, trimRight = true, basedOn, maxLine = 1, text, className, ...rest } = props

const [displayedText, setDisplayedText] = useState(text)
const [clamped, setClamped] = useState(false)
Expand Down Expand Up @@ -92,7 +92,7 @@ const LinesEllipsis = props => {
const nextDisplayedText = nextClamped ? units.current.slice(0, ellipsisIndex).join("") : props.text
setClamped(nextClamped)
setDisplayedText(nextDisplayedText)
onReflow({ clamped: nextClamped, text: nextDisplayedText })
// onReflow({ clamped: nextClamped, text: nextDisplayedText })
}

// return the index of the first letter/word of each line
Expand Down