Skip to content

Update bridge preview chevron design #37

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 1 commit 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
gap: 12px;
}

.toggle {
display: flex;
gap: 4px;
background-color: var(--gray-6);
width: fit-content;
padding: 4px 12px;
border-radius: 16px;
font-size: 12px;
font-weight: 600;

&:hover {
background-color: var(--gray-5);
}
}

.route {
background: var(--gray-8);
border: 1px solid var(--gray-5);
Expand Down
17 changes: 13 additions & 4 deletions packages/widget-react/src/pages/bridge/BridgePreviewRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { zipObj } from "ramda"
import { useToggle } from "react-use"
import { Collapsible } from "radix-ui"
import { useAccount } from "wagmi"
import { IconWallet } from "@initia/icons-react"
import { IconList, IconMinus, IconWallet } from "@initia/icons-react"
import { AddressUtils } from "@/public/utils"
import AsyncBoundary from "@/components/AsyncBoundary"
import CheckboxButton from "@/components/CheckboxButton"
import Image from "@/components/Image"
import type { RouterOperationJson } from "./data/simulate"
import { useBridgePreviewState } from "./data/tx"
Expand Down Expand Up @@ -112,7 +111,17 @@ const BridgePreviewRoute = ({ addressList }: Props) => {
<Collapsible.Root className={styles.root} open={showAll} onOpenChange={toggleShowAll}>
{canToggleShowAll && (
<Collapsible.Trigger asChild>
<CheckboxButton checked={showAll} onClick={toggleShowAll} label="Show details" />
<button className={styles.toggle} onClick={toggleShowAll}>
{showAll ? (
<>
<IconMinus size={12} /> Hide detail
</>
) : (
<>
<IconList size={12} /> Show detail
</>
)}
</button>
</Collapsible.Trigger>
Comment on lines +114 to 125
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add accessibility attributes to the toggle button.

The toggle button implementation is functionally correct but could benefit from accessibility improvements for screen readers.

-          <button className={styles.toggle} onClick={toggleShowAll}>
+          <button 
+            className={styles.toggle} 
+            onClick={toggleShowAll}
+            aria-expanded={showAll}
+            aria-label={showAll ? "Hide operation details" : "Show operation details"}
+          >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<button className={styles.toggle} onClick={toggleShowAll}>
{showAll ? (
<>
<IconMinus size={12} /> Hide detail
</>
) : (
<>
<IconList size={12} /> Show detail
</>
)}
</button>
</Collapsible.Trigger>
<button
className={styles.toggle}
onClick={toggleShowAll}
aria-expanded={showAll}
aria-label={showAll ? "Hide operation details" : "Show operation details"}
>
{showAll ? (
<>
<IconMinus size={12} /> Hide detail
</>
) : (
<>
<IconList size={12} /> Show detail
</>
)}
</button>
</Collapsible.Trigger>
🤖 Prompt for AI Agents
In packages/widget-react/src/pages/bridge/BridgePreviewRoute.tsx around lines
114 to 125, the toggle button lacks accessibility attributes. Add appropriate
ARIA attributes such as aria-expanded to indicate the toggle state and
aria-controls to reference the collapsible content it controls. This will
improve screen reader support and make the button's purpose and state clear to
all users.

)}

Expand All @@ -131,7 +140,7 @@ const BridgePreviewRoute = ({ addressList }: Props) => {
))}
</Collapsible.Content>

<OperationItem {...lastOperationProps} />
<OperationItem {...lastOperationProps} onClick={showAll ? undefined : toggleShowAll} />
</div>
</Collapsible.Root>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,22 @@
justify-content: center;
align-items: center;

background-color: var(--border);
background-color: var(--gray-8);
border-radius: 4px;
color: var(--dimmed);
cursor: default;
width: 24px;
height: 24px;
z-index: 1;

transition: color var(--transition) ease;

&:hover {
color: var(--gray-1);
}
}

button.type:hover {
color: var(--gray-1);
button.type {
background-color: var(--border);
}
}

Expand Down
11 changes: 6 additions & 5 deletions packages/widget-react/src/pages/bridge/OperationItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface ComponentProps extends Props {
}

const OperationItemComponent = (props: ComponentProps) => {
const { source, type, amount, denom, chainId, address, walletIcon } = props
const { source, type, onClick, amount, denom, chainId, address, walletIcon } = props
const { symbol = truncate(denom), decimals = 0, logo_uri = placeholder } = props
const { chain_name, pretty_name } = useSkipChain(chainId)

Expand All @@ -27,14 +27,14 @@ const OperationItemComponent = (props: ComponentProps) => {
<div className={styles.divider} />
{type ? (
<WidgetTooltip label={type}>
<button className={styles.type}>
<span className={styles.type}>
<IconChevronDown size={16} />
</button>
</span>
</WidgetTooltip>
) : (
<span className={styles.type}>
<button onClick={onClick} className={styles.type}>
<IconChevronDown size={16} />
</span>
</button>
)}
</div>
)}
Expand Down Expand Up @@ -75,6 +75,7 @@ const OperationItemComponent = (props: ComponentProps) => {
interface Props {
source?: boolean
type?: string
onClick?: () => void
amount: string
denom: string
chainId: string
Expand Down