Skip to content

Add a flag to url when see more is clicked #2437

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion src/components/CCIP/Landing/NetworkGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react"
import { useEffect, useState } from "react"
import NetworkCard from "../Cards/NetworkCard"
import SeeMore from "../SeeMore/SeeMore"
import "./NetworkGrid.css"
Expand All @@ -18,6 +18,16 @@ const BEFORE_SEE_MORE = 2 * 7 // Number of networks to show before the "See more

function NetworkGrid({ networks, environment }: NetworkGridProps) {
const [seeMore, setSeeMore] = useState(networks.length <= BEFORE_SEE_MORE)

// Enables displaying all content when `showAll=true` is present in the URL query parameters.
// This is added to help expose additional content for the Algolia crawler.
useEffect(() => {
const urlParams = new URLSearchParams(window.location.search)
if (urlParams.get("showAll") === "true") {
setSeeMore(true)
}
}, [])

return (
<>
<div className="networks__grid">
Expand Down
12 changes: 11 additions & 1 deletion src/components/CCIP/Tables/ChainTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface TableProps {
lanes: {
name: string
logo: string
noOfSupportedTokens: number
onRamp?: {
address: string
version: string
Expand Down Expand Up @@ -48,6 +49,15 @@ function ChainTable({ lanes, explorerUrl, sourceNetwork, environment }: TablePro
}
}, [search])

// Enables displaying all content when `showAll=true` is present in the URL query parameters.
// This is added to help expose additional content for the Algolia crawler.
useEffect(() => {
const urlParams = new URLSearchParams(window.location.search)
if (urlParams.get("showAll") === "true") {
setSeeMore(true)
}
}, [])

useEffect(() => {
const fetchOperationalState = async (network) => {
if (network) {
Expand Down Expand Up @@ -92,7 +102,7 @@ function ChainTable({ lanes, explorerUrl, sourceNetwork, environment }: TablePro
.slice(0, seeMore ? lanes.length : BEFORE_SEE_MORE)
.map((network, index) => (
<tr key={index}>
<td>
<td data-supported-tokens={network.noOfSupportedTokens}>
<div
className="ccip-table__network-name"
role="button"
Expand Down
12 changes: 11 additions & 1 deletion src/components/CCIP/TokenGrid/TokenGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react"
import { useEffect, useState } from "react"
import SeeMore from "../SeeMore/SeeMore"
import "./TokenGrid.css"
import TokenCard from "../Cards/TokenCard"
Expand All @@ -15,6 +15,16 @@ const BEFORE_SEE_MORE = 6 * 4 // Number of networks to show before the "See more

function NetworkGrid({ tokens, environment }: TokenGridProps) {
const [seeMore, setSeeMore] = useState(tokens.length <= BEFORE_SEE_MORE)

// Enables displaying all content when `showAll=true` is present in the URL query parameters.
// This is added to help expose additional content for the Algolia crawler.
useEffect(() => {
const urlParams = new URLSearchParams(window.location.search)
if (urlParams.get("showAll") === "true") {
setSeeMore(true)
}
}, [])

return (
<>
<div className="tokens__grid">
Expand Down
3 changes: 3 additions & 0 deletions src/config/data/ccip/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ export const getAllNetworkLanes = async ({
logo: string
key: string
directory: SupportedChain
noOfSupportedTokens: number
onRamp: {
address: string
version: string
Expand All @@ -541,6 +542,7 @@ export const getAllNetworkLanes = async ({
}
}[] = Object.keys(allLanes).map((lane) => {
const laneData = allLanes[lane]
const noOfSupportedTokens = laneData?.supportedTokens ? Object.keys(laneData.supportedTokens).length : 0

const directory = directoryToSupportedChain(lane || "")
const title = getTitle(directory)
Expand All @@ -552,6 +554,7 @@ export const getAllNetworkLanes = async ({
onRamp: laneData.onRamp,
offRamp: laneData.offRamp,
key: lane,
noOfSupportedTokens,
directory,
}
})
Expand Down