Skip to content
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
5 changes: 2 additions & 3 deletions src/components/common/table-container-with-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ type TableContainerWithHeaderProps = {
actions?: React.ReactNode;
children: React.ReactNode;
className?: string;
noPadding?: boolean;
};

/**
Expand All @@ -30,14 +29,14 @@ type TableContainerWithHeaderProps = {
* <Table>...</Table>
* </TableContainerWithHeader>
*/
export function TableContainerWithHeader({ title, actions, children, className = '', noPadding = false }: TableContainerWithHeaderProps) {
export function TableContainerWithHeader({ title, actions, children, className = '' }: TableContainerWithHeaderProps) {
return (
<div className={`bg-surface rounded-md font-zen shadow-sm ${className}`}>
<div className="flex items-center justify-between border-b border-gray-200 dark:border-gray-800 px-6 py-0.5">
<h3 className="font-monospace text-xs uppercase text-secondary">{title}</h3>
{actions && <div className="flex items-center gap-2">{actions}</div>}
</div>
<div className={`overflow-x-auto ${noPadding ? '' : 'pb-4'}`}>{children}</div>
<div className="overflow-x-auto pb-4">{children}</div>
</div>
);
}
Expand Down
4 changes: 1 addition & 3 deletions src/components/status/empty-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ type EmptyScreenProps = {

export default function EmptyScreen({ message = 'No data', hint, className }: EmptyScreenProps) {
return (
<div
className={`bg-surface my-4 flex min-h-48 w-full flex-col items-center justify-center space-y-4 rounded py-8 shadow-sm ${className}`}
>
<div className={`bg-surface my-4 flex min-h-48 w-full flex-col items-center justify-center space-y-4 rounded py-8 ${className}`}>
<Image
src={emptyImg}
alt="Logo"
Expand Down
2 changes: 1 addition & 1 deletion src/features/markets/components/filters/asset-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export default function AssetFilter({
</ul>
<div className="bg-surface absolute bottom-0 left-0 right-0 border-gray-700 p-2">
<button
className="hover:bg-main flex w-full items-center justify-between rounded-sm p-2 text-left text-xs text-secondary"
className="hover:bg-main flex w-full items-center justify-between rounded-sm p-2 text-left text-xs text-secondary transition-colors duration-200 hover:text-normal"
onClick={clearSelection}
type="button"
>
Expand Down
77 changes: 47 additions & 30 deletions src/features/markets/components/filters/network-filter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';
import { useState, useRef, useEffect, type KeyboardEvent } from 'react';
import { ChevronDownIcon } from '@radix-ui/react-icons';
import { ChevronDownIcon, TrashIcon } from '@radix-ui/react-icons';
import Image from 'next/image';
import { type SupportedNetworks, getNetworkImg, networks } from '@/utils/networks';

Expand Down Expand Up @@ -33,6 +33,11 @@ export default function NetworkFilter({ setSelectedNetwork, selectedNetwork }: F
setIsOpen(false);
};

const clearSelection = () => {
setSelectedNetwork(null);
setIsOpen(false);
};

const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
if (event.key === 'Enter' || event.key === ' ') {
toggleDropdown();
Expand Down Expand Up @@ -84,36 +89,48 @@ export default function NetworkFilter({ setSelectedNetwork, selectedNetwork }: F
isOpen ? 'visible translate-y-0 opacity-100' : 'invisible -translate-y-2 opacity-0'
}`}
>
<ul
className="custom-scrollbar max-h-96 overflow-auto"
role="listbox"
>
{networks.map((network) => (
<li
key={network.network}
className={`m-2 flex cursor-pointer items-center justify-between rounded p-2 text-sm transition-colors duration-200 hover:bg-gray-300 dark:hover:bg-gray-700 ${
selectedNetwork === network.network ? 'bg-gray-300 dark:bg-gray-700' : ''
}`}
onClick={() => selectNetwork(network.network)}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
selectNetwork(network.network);
}
}}
role="option"
aria-selected={selectedNetwork === network.network}
tabIndex={0}
<div className="relative">
<ul
className="custom-scrollbar max-h-96 overflow-auto pb-12"
role="listbox"
>
{networks.map((network) => (
<li
key={network.network}
className={`m-2 flex cursor-pointer items-center justify-between rounded p-2 text-sm transition-colors duration-200 hover:bg-gray-300 dark:hover:bg-gray-700 ${
selectedNetwork === network.network ? 'bg-gray-300 dark:bg-gray-700' : ''
}`}
onClick={() => selectNetwork(network.network)}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
selectNetwork(network.network);
}
}}
role="option"
aria-selected={selectedNetwork === network.network}
tabIndex={0}
>
<span className="text-primary font-zen">{network.name}</span>
<Image
src={network.logo}
alt={network.name}
width={18}
height={18}
/>
</li>
))}
</ul>
<div className="bg-surface absolute bottom-0 left-0 right-0 border-gray-700 p-2">
<button
className="hover:bg-main flex w-full items-center justify-between rounded-sm p-2 text-left text-xs text-secondary transition-colors duration-200 hover:text-normal"
onClick={clearSelection}
type="button"
>
<span className="text-primary font-zen">{network.name}</span>
<Image
src={network.logo}
alt={network.name}
width={18}
height={18}
/>
</li>
))}
</ul>
<span>Clear</span>
<TrashIcon className="h-5 w-5" />
</button>
</div>
</div>
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/features/markets/components/table/markets-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ function MarketsTable({
<TableContainerWithHeader
title=""
actions={headerActions}
noPadding={loading || isEmpty || markets.length === 0}
className="w-full"
>
{loading ? (
Expand All @@ -214,6 +213,7 @@ function MarketsTable({
<EmptyScreen
message="No markets found with the current filters"
hint={getEmptyStateHint()}
className="min-h-[300px] container px-[4%]"
/>
) : (
<Table className={tableClassNames}>
Expand Down