Skip to content

Commit 1d73874

Browse files
committed
add support for wide drawer layout in CCIP components
1 parent 0e7423e commit 1d73874

File tree

6 files changed

+28
-8
lines changed

6 files changed

+28
-8
lines changed

src/components/CCIP/Drawer/Drawer.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@
4848
}
4949

5050
@media (min-width: 768px) {
51-
/* Full width minus ESC button width (--space-12x) and spacing (--space-8x for gaps on both sides) */
5251
.drawer__container {
52+
width: 75%;
53+
}
54+
55+
/* Wide drawer for lane details - full width minus ESC button width and spacing */
56+
.drawer__container--wide {
5357
width: calc(100% - var(--space-12x) - var(--space-8x));
5458
}
5559

src/components/CCIP/Drawer/Drawer.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useStore } from "@nanostores/react"
22
import "./Drawer.css"
3-
import { drawerContentStore } from "./drawerStore.ts"
3+
import { drawerContentStore, drawerWidthStore, DrawerWidth } from "./drawerStore.ts"
44
import { useRef, useEffect, useState } from "react"
55
import { clsx } from "~/lib/clsx/clsx.ts"
66
import type { ReactNode } from "react"
@@ -9,6 +9,7 @@ function Drawer() {
99
const drawerRef = useRef<HTMLDivElement>(null)
1010
const drawerContentRef = useRef<HTMLDivElement>(null)
1111
const $drawerContent = useStore(drawerContentStore) as (() => ReactNode) | ReactNode | null
12+
const $drawerWidth = useStore(drawerWidthStore)
1213
const [isOpened, setIsOpened] = useState(false)
1314

1415
// exit when press esc
@@ -47,6 +48,7 @@ function Drawer() {
4748
// Use transitionend event instead of setTimeout for better performance
4849
const handleTransitionEnd = () => {
4950
drawerContentStore.set(null)
51+
drawerWidthStore.set(DrawerWidth.Default)
5052
drawerRef.current?.removeEventListener("transitionend", handleTransitionEnd)
5153
}
5254

@@ -62,7 +64,12 @@ function Drawer() {
6264
ref={drawerRef}
6365
onClick={handleClickOutside}
6466
>
65-
<div className="drawer__container" ref={drawerContentRef}>
67+
<div
68+
className={clsx("drawer__container", {
69+
"drawer__container--wide": $drawerWidth === DrawerWidth.Wide,
70+
})}
71+
ref={drawerContentRef}
72+
>
6673
<div className="drawer__close">
6774
<button id="drawer-exit" onClick={handleClose} aria-label="Close drawer">
6875
<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">

src/components/CCIP/Drawer/TokenDrawer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "../Tables/Table.css"
2-
import { drawerContentStore } from "../Drawer/drawerStore.ts"
2+
import { drawerContentStore, drawerWidthStore, DrawerWidth } from "../Drawer/drawerStore.ts"
33
import TokenDetailsHero from "../ChainHero/TokenDetailsHero.tsx"
44
import {
55
Environment,
@@ -231,6 +231,7 @@ function TokenDrawer({
231231
type="button"
232232
className={`ccip-table__network-name ${tokenPaused ? "ccip-table__network-name--paused" : ""}`}
233233
onClick={() => {
234+
drawerWidthStore.set(DrawerWidth.Wide)
234235
drawerContentStore.set(() => (
235236
<LaneDrawer
236237
environment={environment}

src/components/CCIP/Drawer/drawerStore.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22
import { atom } from "nanostores"
33
import type { JSX } from "preact"
44

5+
export enum DrawerWidth {
6+
Default = "default",
7+
Wide = "wide",
8+
}
9+
510
export const drawerContentStore = atom<(() => JSX.Element) | null>(null)
11+
export const drawerWidthStore = atom<DrawerWidth>(DrawerWidth.Default)

src/components/CCIP/Search/Search.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { clsx } from "~/lib/clsx/clsx.ts"
44
import { useClickOutside } from "~/hooks/useClickOutside.tsx"
55
import { Environment, LaneConfig, LaneFilter } from "~/config/data/ccip/types.ts"
66
import { directoryToSupportedChain, getExplorer, fallbackTokenIconUrl } from "~/features/utils/index.ts"
7-
import { drawerContentStore } from "../Drawer/drawerStore.ts"
7+
import { drawerContentStore, drawerWidthStore, DrawerWidth } from "../Drawer/drawerStore.ts"
88
import LaneDrawer from "../Drawer/LaneDrawer.tsx"
99
import { ChainType, ExplorerInfo } from "~/config/types.ts"
1010
import type { WorkerMessage, WorkerResponse } from "~/workers/data-worker.ts"
@@ -236,7 +236,8 @@ function Search({ chains, tokens, small, environment, lanes }: SearchProps) {
236236
<li key={lane.sourceNetwork.name + lane.destinationNetwork.key}>
237237
<button
238238
type="button"
239-
onClick={() =>
239+
onClick={() => {
240+
drawerWidthStore.set(DrawerWidth.Wide)
240241
drawerContentStore.set(() => (
241242
<LaneDrawer
242243
environment={environment}
@@ -249,7 +250,7 @@ function Search({ chains, tokens, small, environment, lanes }: SearchProps) {
249250
explorer={generateExplorerUrl(lane)}
250251
/>
251252
))
252-
}
253+
}}
253254
aria-label={`View lane from ${lane.sourceNetwork.name} to ${lane.destinationNetwork.name}`}
254255
>
255256
<div className="ccip-hero__search-results__lane-images">

src/components/CCIP/Tables/ChainTable.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Tabs from "./Tabs.tsx"
44
import TableSearchInput from "./TableSearchInput.tsx"
55
import { useEffect, useState } from "react"
66
import { getExplorerAddressUrl } from "~/features/utils/index.ts"
7-
import { drawerContentStore } from "../Drawer/drawerStore.ts"
7+
import { drawerContentStore, drawerWidthStore, DrawerWidth } from "../Drawer/drawerStore.ts"
88
import LaneDrawer from "../Drawer/LaneDrawer.tsx"
99
import { Environment, Version, LaneFilter } from "~/config/data/ccip/types.ts"
1010
import { getLane } from "~/config/data/ccip/data.ts"
@@ -130,6 +130,7 @@ function ChainTable({ lanes, explorer, sourceNetwork, environment }: TableProps)
130130
version: Version.V1_2_0,
131131
})
132132

133+
drawerWidthStore.set(DrawerWidth.Wide)
133134
drawerContentStore.set(() => (
134135
<LaneDrawer
135136
environment={environment}

0 commit comments

Comments
 (0)