Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
9d3f151f
Unverified
Commit
9d3f151f
authored
Oct 31, 2022
by
Igor Stuev
Committed by
GitHub
Oct 31, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #288 from blockscout/sorting-menu
Sorting menu
parents
70506bec
64501fd8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
12 deletions
+81
-12
SortButton.tsx
ui/shared/SortButton.tsx
+5
-5
TxsContent.tsx
ui/txs/TxsContent.tsx
+7
-7
TxsSorting.tsx
ui/txs/TxsSorting.tsx
+69
-0
No files found.
ui/shared/SortButton.tsx
View file @
9d3f151f
...
...
@@ -4,12 +4,12 @@ import React from 'react';
import
upDownArrow
from
'
icons/arrows/up-down.svg
'
;
type
Props
=
{
handleSort
:
()
=>
void
;
is
Sort
Active
:
boolean
;
onClick
:
()
=>
void
;
isActive
:
boolean
;
className
?:
string
;
}
const
SortButton
=
({
handleSort
,
isSort
Active
,
className
}:
Props
)
=>
{
const
SortButton
=
({
onClick
,
is
Active
,
className
}:
Props
)
=>
{
return
(
<
IconButton
icon=
{
<
Icon
as=
{
upDownArrow
}
boxSize=
{
5
}
/>
}
...
...
@@ -18,8 +18,8 @@ const SortButton = ({ handleSort, isSortActive, className }: Props) => {
variant=
"outline"
colorScheme=
"gray-dark"
minWidth=
"36px"
onClick=
{
handleSort
}
isActive=
{
is
Sort
Active
}
onClick=
{
onClick
}
isActive=
{
isActive
}
className=
{
className
}
/>
);
...
...
ui/txs/TxsContent.tsx
View file @
9d3f151f
...
...
@@ -10,11 +10,11 @@ import useIsMobile from 'lib/hooks/useIsMobile';
import
DataFetchAlert
from
'
ui/shared/DataFetchAlert
'
;
// import FilterInput from 'ui/shared/FilterInput';
import
Pagination
from
'
ui/shared/Pagination
'
;
import
SortButton
from
'
ui/shared/SortButton
'
;
// import TxsFilters from './TxsFilters';
import
TxsSkeletonDesktop
from
'
./TxsSkeletonDesktop
'
;
import
TxsSkeletonMobile
from
'
./TxsSkeletonMobile
'
;
import
TxsSorting
from
'
./TxsSorting
'
;
import
TxsWithSort
from
'
./TxsWithSort
'
;
import
useQueryWithPages
from
'
./useQueryWithPages
'
;
...
...
@@ -55,10 +55,10 @@ const TxsContent = ({
newVal
=
'
fee-desc
'
;
}
}
cookies
.
set
(
cookies
.
NAMES
.
TXS_SORT
,
newVal
||
''
);
cookies
.
set
(
cookies
.
NAMES
.
TXS_SORT
,
newVal
);
return
newVal
;
});
},
[
setSorting
]);
},
[
]);
const
{
data
,
...
...
@@ -106,11 +106,11 @@ const TxsContent = ({
appliedFiltersNum={ 0 }
/> */
}
{
isMobile
&&
(
<
SortButton
<
TxsSorting
// eslint-disable-next-line react/jsx-no-bind
handleSort=
{
()
=>
{}
}
isSortActive=
{
Boolean
(
sorting
)
}
display=
{
{
base
:
'
block
'
,
lg
:
'
none
'
}
}
isActive=
{
Boolean
(
sorting
)
}
setSorting=
{
setSorting
}
sorting=
{
sorting
}
/>
)
}
{
/* api is not implemented */
}
...
...
ui/txs/TxsSorting.tsx
0 → 100644
View file @
9d3f151f
import
{
chakra
,
Menu
,
MenuButton
,
MenuList
,
MenuOptionGroup
,
MenuItemOption
,
useDisclosure
,
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
Sort
}
from
'
types/client/txs-sort
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
SortButton
from
'
ui/shared/SortButton
'
;
interface
Props
{
isActive
:
boolean
;
sorting
:
Sort
;
setSorting
:
(
val
:
Sort
|
((
val
:
Sort
)
=>
Sort
))
=>
void
;
}
const
SORT_OPTIONS
=
[
{
title
:
'
Default
'
,
id
:
''
},
{
title
:
'
Value ascending
'
,
id
:
'
val-asc
'
},
{
title
:
'
Value descending
'
,
id
:
'
val-desc
'
},
{
title
:
'
Fee ascending
'
,
id
:
'
fee-asc
'
},
{
title
:
'
Fee descending
'
,
id
:
'
fee-desc
'
},
];
const
TxsSorting
=
({
isActive
,
sorting
,
setSorting
}:
Props
)
=>
{
const
{
isOpen
,
onToggle
}
=
useDisclosure
();
const
setSortingFromMenu
=
React
.
useCallback
((
val
:
string
|
Array
<
string
>
)
=>
{
setSorting
((
prevVal
:
Sort
)
=>
{
let
newVal
:
Sort
=
''
;
if
(
val
!==
prevVal
)
{
newVal
=
val
as
Sort
;
}
cookies
.
set
(
cookies
.
NAMES
.
TXS_SORT
,
newVal
);
return
newVal
;
});
},
[
setSorting
]);
return
(
<
Menu
>
<
MenuButton
>
<
SortButton
isActive=
{
isOpen
||
isActive
}
onClick=
{
onToggle
}
/>
</
MenuButton
>
<
MenuList
minWidth=
"240px"
>
<
MenuOptionGroup
value=
{
sorting
}
title=
"Sort by"
type=
"radio"
onChange=
{
setSortingFromMenu
}
>
{
SORT_OPTIONS
.
map
((
option
)
=>
(
<
MenuItemOption
key=
{
option
.
id
}
value=
{
option
.
id
}
>
{
option
.
title
}
</
MenuItemOption
>
))
}
</
MenuOptionGroup
>
</
MenuList
>
</
Menu
>
);
};
export
default
chakra
(
TxsSorting
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment