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
a44d803f
Commit
a44d803f
authored
Jul 18, 2024
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mud mobile views
parent
0891adbd
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
253 additions
and
113 deletions
+253
-113
AddressMudBreadcrumbs.tsx
ui/address/mud/AddressMudBreadcrumbs.tsx
+14
-3
AddressMudRecord.tsx
ui/address/mud/AddressMudRecord.tsx
+36
-38
AddressMudRecordValues.tsx
ui/address/mud/AddressMudRecordValues.tsx
+41
-0
AddressMudRecordsTable.tsx
ui/address/mud/AddressMudRecordsTable.tsx
+21
-16
AddressMudTable.tsx
ui/address/mud/AddressMudTable.tsx
+43
-48
AddressMudTables.tsx
ui/address/mud/AddressMudTables.tsx
+4
-4
AddressMudTablesListItem.tsx
ui/address/mud/AddressMudTablesListItem.tsx
+93
-0
AddressMudTablesTableItem.tsx
ui/address/mud/AddressMudTablesTableItem.tsx
+1
-4
No files found.
ui/address/mud/AddressMudBreadcrumbs.tsx
View file @
a44d803f
import
{
Grid
,
Box
,
useColorModeValue
,
chakra
,
HStack
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
useColorModeValue
,
chakra
,
HStack
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
CopyToClipboard
from
'
ui/shared/CopyToClipboard
'
;
import
CopyToClipboard
from
'
ui/shared/CopyToClipboard
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
LinkInternal
from
'
ui/shared/links/LinkInternal
'
;
import
LinkInternal
from
'
ui/shared/links/LinkInternal
'
;
...
@@ -70,8 +71,18 @@ const BreadcrumbItem = ({ text, href, isLast, scrollRef }: BreadcrumbItemProps)
...
@@ -70,8 +71,18 @@ const BreadcrumbItem = ({ text, href, isLast, scrollRef }: BreadcrumbItemProps)
const
AddressMudBreadcrumbs
=
(
props
:
TableViewProps
|
RecordViewProps
)
=>
{
const
AddressMudBreadcrumbs
=
(
props
:
TableViewProps
|
RecordViewProps
)
=>
{
const
queryParams
=
{
tab
:
'
mud
'
,
hash
:
props
.
hash
};
const
queryParams
=
{
tab
:
'
mud
'
,
hash
:
props
.
hash
};
const
isMobile
=
useIsMobile
();
return
(
return
(
<
Grid
templateColumns=
"20px auto auto auto"
gap=
{
2
}
alignItems=
"center"
className=
{
props
.
className
}
>
<
Box
display=
{
isMobile
?
'
flex
'
:
'
grid
'
}
flexWrap=
"wrap"
gridTemplateColumns=
"20px auto auto auto"
gap=
{
2
}
alignItems=
"center"
className=
{
props
.
className
}
width=
"fit-content"
>
<
IconSvg
name=
"MUD"
boxSize=
{
5
}
color=
"green.500"
/>
<
IconSvg
name=
"MUD"
boxSize=
{
5
}
color=
"green.500"
/>
<
BreadcrumbItem
<
BreadcrumbItem
text=
"MUD World"
text=
"MUD World"
...
@@ -93,7 +104,7 @@ const AddressMudBreadcrumbs = (props: TableViewProps | RecordViewProps) => {
...
@@ -93,7 +104,7 @@ const AddressMudBreadcrumbs = (props: TableViewProps | RecordViewProps) => {
/>
/>
)
}
)
}
</
Grid
>
</
Box
>
);
);
};
};
...
...
ui/address/mud/AddressMudRecord.tsx
View file @
a44d803f
import
{
Box
,
Td
,
Tr
,
Flex
,
useColorModeValue
,
Table
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
Td
,
Tr
,
Flex
,
Text
,
Table
,
Show
,
Hide
,
Divider
,
VStack
}
from
'
@chakra-ui/react
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
...
@@ -9,6 +9,7 @@ import ContentLoader from 'ui/shared/ContentLoader';
...
@@ -9,6 +9,7 @@ import ContentLoader from 'ui/shared/ContentLoader';
import
TruncatedValue
from
'
ui/shared/TruncatedValue
'
;
import
TruncatedValue
from
'
ui/shared/TruncatedValue
'
;
import
AddressMudBreadcrumbs
from
'
./AddressMudBreadcrumbs
'
;
import
AddressMudBreadcrumbs
from
'
./AddressMudBreadcrumbs
'
;
import
AddressMudRecordValues
from
'
./AddressMudRecordValues
'
;
type
Props
=
{
type
Props
=
{
scrollRef
?:
React
.
RefObject
<
HTMLDivElement
>
;
scrollRef
?:
React
.
RefObject
<
HTMLDivElement
>
;
...
@@ -22,8 +23,6 @@ const AddressMudRecord = ({ tableId, recordId, isQueryEnabled = true, scrollRef
...
@@ -22,8 +23,6 @@ const AddressMudRecord = ({ tableId, recordId, isQueryEnabled = true, scrollRef
const
hash
=
getQueryParamString
(
router
.
query
.
hash
);
const
hash
=
getQueryParamString
(
router
.
query
.
hash
);
const
valuesBgColor
=
useColorModeValue
(
'
blackAlpha.50
'
,
'
whiteAlpha.50
'
);
const
{
data
,
isLoading
,
isError
}
=
useApiQuery
(
'
address_mud_record
'
,
{
const
{
data
,
isLoading
,
isError
}
=
useApiQuery
(
'
address_mud_record
'
,
{
pathParams
:
{
hash
,
table_id
:
tableId
,
record_id
:
recordId
},
pathParams
:
{
hash
,
table_id
:
tableId
,
record_id
:
recordId
},
queryOptions
:
{
queryOptions
:
{
...
@@ -52,8 +51,8 @@ const AddressMudRecord = ({ tableId, recordId, isQueryEnabled = true, scrollRef
...
@@ -52,8 +51,8 @@ const AddressMudRecord = ({ tableId, recordId, isQueryEnabled = true, scrollRef
scrollRef=
{
scrollRef
}
scrollRef=
{
scrollRef
}
/>
/>
)
}
)
}
<
Show
above=
"lg"
ssr=
{
false
}
>
<
Table
borderRadius=
"8px"
style=
{
{
tableLayout
:
'
auto
'
}
}
width=
"100%
"
>
<
Table
borderRadius=
"8px"
style=
{
{
tableLayout
:
'
auto
'
}
}
width=
"100%"
overflow=
"hidden
"
>
{
data
?.
schema
.
key_names
.
length
&&
data
?.
schema
.
key_names
.
map
((
keyName
,
index
)
=>
(
{
data
?.
schema
.
key_names
.
length
&&
data
?.
schema
.
key_names
.
map
((
keyName
,
index
)
=>
(
<
Tr
key=
{
keyName
}
borderBottomStyle=
{
index
===
data
.
schema
.
key_names
.
length
-
1
?
'
hidden
'
:
'
solid
'
}
>
<
Tr
key=
{
keyName
}
borderBottomStyle=
{
index
===
data
.
schema
.
key_names
.
length
-
1
?
'
hidden
'
:
'
solid
'
}
>
<
Td
fontWeight=
{
600
}
whiteSpace=
"nowrap"
>
<
Td
fontWeight=
{
600
}
whiteSpace=
"nowrap"
>
...
@@ -67,28 +66,27 @@ const AddressMudRecord = ({ tableId, recordId, isQueryEnabled = true, scrollRef
...
@@ -67,28 +66,27 @@ const AddressMudRecord = ({ tableId, recordId, isQueryEnabled = true, scrollRef
</
Td
>
</
Td
>
</
Tr
>
</
Tr
>
))
}
))
}
{
data
?.
schema
.
value_names
.
length
&&
(
<
AddressMudRecordValues
data=
{
data
}
/>
</
Table
>
</
Show
>
<
Hide
above=
"lg"
ssr=
{
false
}
>
<>
<>
<
Tr
backgroundColor=
{
valuesBgColor
}
borderBottomStyle=
"hidden"
>
{
data
?.
schema
.
key_names
.
length
&&
data
?.
schema
.
key_names
.
map
((
keyName
,
index
)
=>
(
<
Td
fontWeight=
{
600
}
>
Field
</
Td
>
<
VStack
gap=
{
1
}
key=
{
keyName
}
alignItems=
"start"
>
<
Td
fontWeight=
{
600
}
>
Type
</
Td
>
<
Divider
/>
<
Td
fontWeight=
{
600
}
w=
"100%"
wordBreak=
"break-all"
>
Value
</
Td
>
<
Text
fontWeight=
{
600
}
whiteSpace=
"nowrap"
>
</
Tr
>
{
keyName
}
(
{
data
.
schema
.
key_types
[
index
]
}
)
{
data
?.
schema
.
value_names
.
map
((
valName
,
index
)
=>
(
</
Text
>
<
Tr
key=
{
valName
}
backgroundColor=
{
valuesBgColor
}
borderBottomStyle=
"hidden"
>
<
Text
wordBreak=
"break-all"
>
{
data
.
record
.
decoded
[
keyName
]
}
</
Text
>
<
Td
whiteSpace=
"nowrap"
>
{
valName
}
</
Td
>
{
index
===
0
&&
<
Box
color=
"text_secondary"
>
{
dayjs
(
data
.
record
.
timestamp
).
format
(
'
lll
'
)
}
</
Box
>
}
<
Td
>
{
data
.
schema
.
value_types
[
index
]
}
</
Td
>
</
VStack
>
<
Td
w=
"100%"
wordBreak=
"break-all"
>
<
Box
>
{
data
.
record
.
decoded
[
valName
]
}
</
Box
>
</
Td
>
</
Tr
>
))
}
))
}
<
/
>
<
Table
borderRadius=
"8px"
style=
{
{
tableLayout
:
'
auto
'
}
}
width=
"100%"
mt=
{
2
}
overflow=
"hidden"
>
)
}
<
AddressMudRecordValues
data=
{
data
}
/>
</
Table
>
</
Table
>
</>
</>
</
Hide
>
</>
);
);
};
};
...
...
ui/address/mud/AddressMudRecordValues.tsx
0 → 100644
View file @
a44d803f
import
{
Box
,
Td
,
Tr
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
AddressMudRecord
}
from
'
types/api/address
'
;
type
Props
=
{
data
?:
AddressMudRecord
;
}
const
AddressMudRecordValues
=
({
data
}:
Props
)
=>
{
const
valuesBgColor
=
useColorModeValue
(
'
blackAlpha.50
'
,
'
whiteAlpha.50
'
);
if
(
!
data
?.
schema
.
value_names
.
length
)
{
return
null
;
}
return
(
<>
<
Tr
backgroundColor=
{
valuesBgColor
}
borderBottomStyle=
"hidden"
>
<
Td
fontWeight=
{
600
}
>
Field
</
Td
>
<
Td
fontWeight=
{
600
}
>
Type
</
Td
>
<
Td
fontWeight=
{
600
}
w=
"100%"
wordBreak=
"break-all"
>
Value
</
Td
>
</
Tr
>
{
data
?.
schema
.
value_names
.
map
((
valName
,
index
)
=>
(
<
Tr
key=
{
valName
}
backgroundColor=
{
valuesBgColor
}
borderBottomStyle=
"hidden"
>
<
Td
whiteSpace=
"nowrap"
py=
{
0
}
pb=
{
4
}
>
{
valName
}
</
Td
>
<
Td
py=
{
0
}
pb=
{
4
}
>
{
data
.
schema
.
value_types
[
index
]
}
</
Td
>
<
Td
w=
"100%"
wordBreak=
"break-all"
py=
{
0
}
pb=
{
4
}
>
<
Box
>
{
data
.
record
.
decoded
[
valName
]
}
</
Box
>
</
Td
>
</
Tr
>
))
}
</>
);
};
export
default
AddressMudRecordValues
;
ui/address/mud/AddressMudRecordsTable.tsx
View file @
a44d803f
...
@@ -7,6 +7,7 @@ import type { AddressMudRecords, AddressMudRecordsFilter, AddressMudRecordsSorti
...
@@ -7,6 +7,7 @@ import type { AddressMudRecords, AddressMudRecordsFilter, AddressMudRecordsSorti
import
capitalizeFirstLetter
from
'
lib/capitalizeFirstLetter
'
;
import
capitalizeFirstLetter
from
'
lib/capitalizeFirstLetter
'
;
import
dayjs
from
'
lib/date/dayjs
'
;
import
dayjs
from
'
lib/date/dayjs
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
{
default
as
Thead
}
from
'
ui/shared/TheadSticky
'
;
import
{
default
as
Thead
}
from
'
ui/shared/TheadSticky
'
;
...
@@ -14,7 +15,9 @@ import AddressMudRecordsKeyFilter from './AddressMudRecordsKeyFilter';
...
@@ -14,7 +15,9 @@ import AddressMudRecordsKeyFilter from './AddressMudRecordsKeyFilter';
import
{
getNameTypeText
}
from
'
./utils
'
;
import
{
getNameTypeText
}
from
'
./utils
'
;
const
COL_MIN_WIDTH
=
180
;
const
COL_MIN_WIDTH
=
180
;
const
COL_MIN_WIDTH_MOBILE
=
140
;
const
CUT_COL_WIDTH
=
36
;
const
CUT_COL_WIDTH
=
36
;
const
MIN_CUT_COUNT
=
2
;
type
Props
=
{
type
Props
=
{
data
:
AddressMudRecords
;
data
:
AddressMudRecords
;
...
@@ -37,9 +40,11 @@ const AddressMudRecordsTable = ({
...
@@ -37,9 +40,11 @@ const AddressMudRecordsTable = ({
toggleTableHasHorisontalScroll
,
toggleTableHasHorisontalScroll
,
scrollRef
,
scrollRef
,
}:
Props
)
=>
{
}:
Props
)
=>
{
const
[
colsCutCount
,
setColsCutCount
]
=
React
.
useState
<
number
>
(
0
);
const
totalColsCut
=
data
.
schema
.
key_names
.
length
+
data
.
schema
.
value_names
.
length
;
const
isMobile
=
useIsMobile
(
false
);
const
[
colsCutCount
,
setColsCutCount
]
=
React
.
useState
<
number
>
(
isMobile
?
2
:
0
);
const
[
isOpened
,
setIsOpened
]
=
useBoolean
(
false
);
const
[
isOpened
,
setIsOpened
]
=
useBoolean
(
false
);
const
[
hasCut
,
setHasCut
]
=
useBoolean
(
true
);
const
[
hasCut
,
setHasCut
]
=
useBoolean
(
isMobile
?
totalColsCut
>
MIN_CUT_COUNT
:
true
);
const
tableRef
=
React
.
useRef
<
HTMLTableElement
>
(
null
);
const
tableRef
=
React
.
useRef
<
HTMLTableElement
>
(
null
);
...
@@ -56,10 +61,7 @@ const AddressMudRecordsTable = ({
...
@@ -56,10 +61,7 @@ const AddressMudRecordsTable = ({
record_id
:
e
.
currentTarget
.
getAttribute
(
'
data-id
'
)
as
string
,
record_id
:
e
.
currentTarget
.
getAttribute
(
'
data-id
'
)
as
string
,
};
};
router
.
push
({
pathname
:
router
.
pathname
,
query
:
newQuery
},
undefined
,
{
shallow
:
true
});
router
.
push
({
pathname
:
router
.
pathname
,
query
:
newQuery
},
undefined
,
{
shallow
:
true
});
window
.
setTimeout
(()
=>
{
scrollRef
?.
current
?.
scrollIntoView
();
// cannot do scroll instantly, have to wait a little
scrollRef
?.
current
?.
scrollIntoView
({
behavior
:
'
smooth
'
});
},
500
);
},
[
router
,
scrollRef
]);
},
[
router
,
scrollRef
]);
const
handleFilterChange
=
React
.
useCallback
((
field
:
keyof
AddressMudRecordsFilter
)
=>
(
val
:
string
)
=>
{
const
handleFilterChange
=
React
.
useCallback
((
field
:
keyof
AddressMudRecordsFilter
)
=>
(
val
:
string
)
=>
{
...
@@ -80,39 +82,42 @@ const AddressMudRecordsTable = ({
...
@@ -80,39 +82,42 @@ const AddressMudRecordsTable = ({
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
if
(
hasCut
&&
!
colsCutCount
&&
tableRef
.
current
)
{
if
(
hasCut
&&
!
colsCutCount
&&
tableRef
.
current
)
{
const
count
=
Math
.
floor
((
tableRef
.
current
.
getBoundingClientRect
().
width
-
CUT_COL_WIDTH
)
/
COL_MIN_WIDTH
);
const
count
=
Math
.
floor
((
tableRef
.
current
.
getBoundingClientRect
().
width
-
CUT_COL_WIDTH
)
/
COL_MIN_WIDTH
);
const
total
=
data
.
schema
.
key_names
.
length
+
data
.
schema
.
value_names
.
length
;
if
(
totalColsCut
>
2
&&
count
-
1
<
totalColsCut
)
{
if
(
total
>
2
&&
count
-
1
<
total
)
{
setColsCutCount
(
count
-
1
);
setColsCutCount
(
count
-
1
);
}
else
{
}
else
{
setHasCut
.
off
();
setHasCut
.
off
();
}
}
}
}
},
[
colsCutCount
,
data
.
schema
,
hasCut
,
setHasCut
]);
},
[
colsCutCount
,
data
.
schema
,
hasCut
,
setHasCut
,
totalColsCut
]);
const
cutWidth
=
`
${
CUT_COL_WIDTH
}
px `
;
const
cutWidth
=
`
${
CUT_COL_WIDTH
}
px `
;
const
colW
=
isMobile
?
COL_MIN_WIDTH_MOBILE
:
COL_MIN_WIDTH
;
const
tdStyles
:
StyleProps
=
{
const
tdStyles
:
StyleProps
=
{
wordBreak
:
'
break-all
'
,
wordBreak
:
'
break-all
'
,
whiteSpace
:
'
normal
'
,
whiteSpace
:
'
normal
'
,
minW
:
`
${
COL_MIN_WIDTH
}
px`
,
minW
:
`
${
colW
}
px`
,
w
:
`
${
COL_MIN_WIDTH
}
px`
,
w
:
`
${
colW
}
px`
,
};
};
const
thStyles
:
StyleProps
=
{
const
thStyles
:
StyleProps
=
{
wordBreak
:
'
break-word
'
,
wordBreak
:
'
break-word
'
,
whiteSpace
:
'
normal
'
,
whiteSpace
:
'
normal
'
,
minW
:
`
${
COL_MIN_WIDTH
}
px`
,
minW
:
`
${
colW
}
px`
,
w
:
`
${
COL_MIN_WIDTH
}
px`
,
w
:
`
${
colW
}
px`
,
};
};
const
keys
=
(
isOpened
||
!
hasCut
)
?
data
.
schema
.
key_names
:
data
.
schema
.
key_names
.
slice
(
0
,
colsCutCount
);
const
keys
=
(
isOpened
||
!
hasCut
)
?
data
.
schema
.
key_names
:
data
.
schema
.
key_names
.
slice
(
0
,
colsCutCount
);
const
values
=
(
isOpened
||
!
hasCut
)
?
data
.
schema
.
value_names
:
data
.
schema
.
value_names
.
slice
(
0
,
colsCutCount
-
data
.
schema
.
key_names
.
length
);
const
values
=
(
isOpened
||
!
hasCut
)
?
data
.
schema
.
value_names
:
data
.
schema
.
value_names
.
slice
(
0
,
colsCutCount
-
data
.
schema
.
key_names
.
length
);
const
hasHorizontalScroll
=
isMobile
||
isOpened
;
return
(
return
(
// can't implement both horisontal table scroll and sticky header
// can't implement both horisontal table scroll and sticky header
<
Box
maxW=
"100%"
overflowX=
{
isOpened
?
'
scroll
'
:
'
unset
'
}
whiteSpace=
"nowrap"
>
<
Box
maxW=
"100%"
overflowX=
{
hasHorizontalScroll
?
'
scroll
'
:
'
unset
'
}
whiteSpace=
"nowrap"
>
<
Table
variant=
"simple"
size=
"sm"
style=
{
{
tableLayout
:
'
fixed
'
}
}
ref=
{
tableRef
}
>
<
Table
variant=
"simple"
size=
"sm"
style=
{
{
tableLayout
:
'
fixed
'
}
}
ref=
{
tableRef
}
>
<
Thead
top=
{
isOpened
?
0
:
top
}
display=
{
isOpened
?
'
table
'
:
'
table-header-group
'
}
w=
"100%"
>
<
Thead
top=
{
hasHorizontalScroll
?
0
:
top
}
display=
{
hasHorizontalScroll
?
'
table
'
:
'
table-header-group
'
}
w=
"100%"
>
<
Tr
>
<
Tr
>
{
keys
.
map
((
keyName
,
index
)
=>
{
{
keys
.
map
((
keyName
,
index
)
=>
{
const
text
=
getNameTypeText
(
keyName
,
data
.
schema
.
key_types
[
index
]);
const
text
=
getNameTypeText
(
keyName
,
data
.
schema
.
key_types
[
index
]);
...
@@ -147,7 +152,7 @@ const AddressMudRecordsTable = ({
...
@@ -147,7 +152,7 @@ const AddressMudRecordsTable = ({
{
hasCut
&&
isOpened
&&
<
Th
width=
{
cutWidth
}
><
Link
onClick=
{
toggleIsOpen
}
>
...
</
Link
></
Th
>
}
{
hasCut
&&
isOpened
&&
<
Th
width=
{
cutWidth
}
><
Link
onClick=
{
toggleIsOpen
}
>
...
</
Link
></
Th
>
}
</
Tr
>
</
Tr
>
</
Thead
>
</
Thead
>
<
Tbody
display=
{
isOpened
?
'
table
'
:
'
table-row-group
'
}
w=
"100%"
>
<
Tbody
display=
{
hasHorizontalScroll
?
'
table
'
:
'
table-row-group
'
}
w=
"100%"
>
{
data
.
items
.
map
((
item
)
=>
(
{
data
.
items
.
map
((
item
)
=>
(
<
Tr
key=
{
item
.
id
}
>
<
Tr
key=
{
item
.
id
}
>
{
keys
.
map
((
keyName
,
index
)
=>
(
{
keys
.
map
((
keyName
,
index
)
=>
(
...
...
ui/address/mud/AddressMudTable.tsx
View file @
a44d803f
import
{
Box
,
HStack
,
Hide
,
Show
,
Tag
,
TagCloseButton
,
chakra
,
useBoolean
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
HStack
,
Tag
,
TagCloseButton
,
chakra
,
useBoolean
}
from
'
@chakra-ui/react
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
AddressMudRecordsFilter
,
AddressMudRecordsSorting
}
from
'
types/api/address
'
;
import
type
{
AddressMudRecordsFilter
,
AddressMudRecordsSorting
}
from
'
types/api/address
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
{
apos
,
nbsp
}
from
'
lib/html-entities
'
;
import
{
apos
,
nbsp
}
from
'
lib/html-entities
'
;
import
getQueryParamString
from
'
lib/router/getQueryParamString
'
;
import
getQueryParamString
from
'
lib/router/getQueryParamString
'
;
import
ActionBar
,
{
ACTION_BAR_HEIGHT_DESKTOP
}
from
'
ui/shared/ActionBar
'
;
import
ActionBar
,
{
ACTION_BAR_HEIGHT_DESKTOP
}
from
'
ui/shared/ActionBar
'
;
...
@@ -31,7 +32,8 @@ const AddressMudTable = ({ scrollRef, tableId, isQueryEnabled = true }: Props) =
...
@@ -31,7 +32,8 @@ const AddressMudTable = ({ scrollRef, tableId, isQueryEnabled = true }: Props) =
const
[
sorting
,
setSorting
]
=
const
[
sorting
,
setSorting
]
=
React
.
useState
<
AddressMudRecordsSorting
|
undefined
>
(
getSortParamsFromQuery
<
AddressMudRecordsSorting
>
(
router
.
query
,
SORT_SEQUENCE
));
React
.
useState
<
AddressMudRecordsSorting
|
undefined
>
(
getSortParamsFromQuery
<
AddressMudRecordsSorting
>
(
router
.
query
,
SORT_SEQUENCE
));
const
[
filters
,
setFilters
]
=
React
.
useState
<
AddressMudRecordsFilter
>
({});
const
[
filters
,
setFilters
]
=
React
.
useState
<
AddressMudRecordsFilter
>
({});
const
[
tableHasHorisontalScroll
,
setTableHasHorisontalScroll
]
=
useBoolean
(
false
);
const
isMobile
=
useIsMobile
();
const
[
tableHasHorisontalScroll
,
setTableHasHorisontalScroll
]
=
useBoolean
(
isMobile
);
const
hash
=
getQueryParamString
(
router
.
query
.
hash
);
const
hash
=
getQueryParamString
(
router
.
query
.
hash
);
...
@@ -93,10 +95,7 @@ const AddressMudTable = ({ scrollRef, tableId, isQueryEnabled = true }: Props) =
...
@@ -93,10 +95,7 @@ const AddressMudTable = ({ scrollRef, tableId, isQueryEnabled = true }: Props) =
</
HStack
>
</
HStack
>
)
:
null
;
)
:
null
;
const
actionBar
=
(
const
breadcrumbs
=
data
?
(
<
ActionBar
mt=
{
-
6
}
showShadow=
{
tableHasHorisontalScroll
}
justifyContent=
"space-between"
alignItems=
{
hasActiveFilters
?
'
start
'
:
'
center
'
}
>
<
Box
>
{
data
&&
(
<
AddressMudBreadcrumbs
<
AddressMudBreadcrumbs
hash=
{
hash
}
hash=
{
hash
}
tableId=
{
tableId
}
tableId=
{
tableId
}
...
@@ -104,7 +103,12 @@ const AddressMudTable = ({ scrollRef, tableId, isQueryEnabled = true }: Props) =
...
@@ -104,7 +103,12 @@ const AddressMudTable = ({ scrollRef, tableId, isQueryEnabled = true }: Props) =
scrollRef=
{
scrollRef
}
scrollRef=
{
scrollRef
}
mb=
{
hasActiveFilters
?
4
:
0
}
mb=
{
hasActiveFilters
?
4
:
0
}
/>
/>
)
}
)
:
null
;
const
actionBar
=
(
!
isMobile
||
hasActiveFilters
||
pagination
.
isVisible
)
&&
(
<
ActionBar
mt=
{
-
6
}
showShadow=
{
tableHasHorisontalScroll
}
justifyContent=
"space-between"
alignItems=
{
hasActiveFilters
?
'
start
'
:
'
center
'
}
>
<
Box
>
{
!
isMobile
&&
breadcrumbs
}
{
filtersTags
}
{
filtersTags
}
</
Box
>
</
Box
>
<
Pagination
ml=
{
{
base
:
0
,
lg
:
8
}
}
{
...
pagination
}
/>
<
Pagination
ml=
{
{
base
:
0
,
lg
:
8
}
}
{
...
pagination
}
/>
...
@@ -112,8 +116,6 @@ const AddressMudTable = ({ scrollRef, tableId, isQueryEnabled = true }: Props) =
...
@@ -112,8 +116,6 @@ const AddressMudTable = ({ scrollRef, tableId, isQueryEnabled = true }: Props) =
);
);
const
content
=
data
?.
items
?
(
const
content
=
data
?.
items
?
(
<>
<
Hide
below=
"lg"
ssr=
{
false
}
>
<
AddressMudRecordsTable
<
AddressMudRecordsTable
data=
{
data
}
data=
{
data
}
top=
{
actionBatHeight
}
top=
{
actionBatHeight
}
...
@@ -124,21 +126,13 @@ const AddressMudTable = ({ scrollRef, tableId, isQueryEnabled = true }: Props) =
...
@@ -124,21 +126,13 @@ const AddressMudTable = ({ scrollRef, tableId, isQueryEnabled = true }: Props) =
toggleTableHasHorisontalScroll=
{
setTableHasHorisontalScroll
.
toggle
}
toggleTableHasHorisontalScroll=
{
setTableHasHorisontalScroll
.
toggle
}
scrollRef=
{
scrollRef
}
scrollRef=
{
scrollRef
}
/>
/>
</
Hide
>
<
Show
below=
"lg"
ssr=
{
false
}
>
waiting for mobile mockup
{
/* { data.items.map((item, index) => (
<AddressMudListItem
key={ item.table.table_id + (isPlaceholderData ? String(index) : '') }
item={ item }
isLoading={ isPlaceholderData }
/>
)) } */
}
</
Show
>
</>
)
:
null
;
)
:
null
;
return
(
return
(
<>
{
isMobile
&&
(
<
Box
mb=
{
6
}
>
{
breadcrumbs
}
</
Box
>
)
}
<
DataListDisplay
<
DataListDisplay
isError=
{
isError
}
isError=
{
isError
}
items=
{
data
?.
items
}
items=
{
data
?.
items
}
...
@@ -149,8 +143,9 @@ const AddressMudTable = ({ scrollRef, tableId, isQueryEnabled = true }: Props) =
...
@@ -149,8 +143,9 @@ const AddressMudTable = ({ scrollRef, tableId, isQueryEnabled = true }: Props) =
}
}
}
}
content=
{
content
}
content=
{
content
}
actionBar=
{
actionBar
}
actionBar=
{
actionBar
}
showActionBarIfEmpty
showActionBarIfEmpty=
{
!
isMobile
}
/>
/>
</>
);
);
};
};
...
...
ui/address/mud/AddressMudTables.tsx
View file @
a44d803f
...
@@ -13,6 +13,7 @@ import FilterInput from 'ui/shared/filters/FilterInput';
...
@@ -13,6 +13,7 @@ import FilterInput from 'ui/shared/filters/FilterInput';
import
Pagination
from
'
ui/shared/pagination/Pagination
'
;
import
Pagination
from
'
ui/shared/pagination/Pagination
'
;
import
useQueryWithPages
from
'
ui/shared/pagination/useQueryWithPages
'
;
import
useQueryWithPages
from
'
ui/shared/pagination/useQueryWithPages
'
;
import
AddressMudTablesListItem
from
'
./AddressMudTablesListItem
'
;
import
AddressMudTablesTable
from
'
./AddressMudTablesTable
'
;
import
AddressMudTablesTable
from
'
./AddressMudTablesTable
'
;
type
Props
=
{
type
Props
=
{
...
@@ -73,14 +74,13 @@ const AddressMudTables = ({ scrollRef, isQueryEnabled = true }: Props) => {
...
@@ -73,14 +74,13 @@ const AddressMudTables = ({ scrollRef, isQueryEnabled = true }: Props) => {
/>
/>
</
Hide
>
</
Hide
>
<
Show
below=
"lg"
ssr=
{
false
}
>
<
Show
below=
"lg"
ssr=
{
false
}
>
waiting for mobile mockup
{
data
.
items
.
map
((
item
,
index
)
=>
(
{
/* { data.items.map((item, index) => (
<
AddressMudTablesListItem
<AddressMudListItem
key=
{
item
.
table
.
table_id
+
(
isPlaceholderData
?
String
(
index
)
:
''
)
}
key=
{
item
.
table
.
table_id
+
(
isPlaceholderData
?
String
(
index
)
:
''
)
}
item=
{
item
}
item=
{
item
}
isLoading=
{
isPlaceholderData
}
isLoading=
{
isPlaceholderData
}
/>
/>
)) }
*/
}
))
}
</
Show
>
</
Show
>
</>
</>
)
:
null
;
)
:
null
;
...
...
ui/address/mud/AddressMudTablesListItem.tsx
0 → 100644
View file @
a44d803f
import
{
Divider
,
Text
,
Skeleton
,
useBoolean
,
Flex
,
Link
,
VStack
,
chakra
,
Box
,
Grid
,
GridItem
}
from
'
@chakra-ui/react
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
type
{
AddressMudTableItem
}
from
'
types/api/address
'
;
import
Tag
from
'
ui/shared/chakra/Tag
'
;
import
HashStringShorten
from
'
ui/shared/HashStringShorten
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
ListItemMobile
from
'
ui/shared/ListItemMobile/ListItemMobile
'
;
type
Props
=
{
item
:
AddressMudTableItem
;
isLoading
:
boolean
;
scrollRef
?:
React
.
RefObject
<
HTMLDivElement
>
;
};
const
AddressMudTablesListItem
=
({
item
,
isLoading
,
scrollRef
}:
Props
)
=>
{
const
[
isOpened
,
setIsOpened
]
=
useBoolean
(
false
);
const
router
=
useRouter
();
const
onTableClick
=
React
.
useCallback
((
e
:
React
.
MouseEvent
)
=>
{
const
newQuery
=
{
...
router
.
query
,
table_id
:
e
.
currentTarget
.
getAttribute
(
'
data-id
'
)
as
string
,
};
router
.
push
({
pathname
:
router
.
pathname
,
query
:
newQuery
},
undefined
,
{
shallow
:
true
});
scrollRef
?.
current
?.
scrollIntoView
();
},
[
router
,
scrollRef
]);
return
(
<
ListItemMobile
rowGap=
{
3
}
fontSize=
"sm"
py=
{
3
}
>
<
Flex
w=
"100%"
>
<
Skeleton
isLoaded=
{
!
isLoading
}
>
<
Link
display=
"block"
>
<
IconSvg
name=
"arrows/east-mini"
transform=
{
isOpened
?
'
rotate(270deg)
'
:
'
rotate(180deg)
'
}
boxSize=
{
6
}
cursor=
"pointer"
onClick=
{
setIsOpened
.
toggle
}
transitionDuration=
"faster"
/>
</
Link
>
</
Skeleton
>
<
Box
flexGrow=
"1"
>
<
Flex
justifyContent=
"space-between"
height=
{
6
}
alignItems=
"center"
mb=
{
3
}
>
<
Skeleton
isLoaded=
{
!
isLoading
}
>
<
Link
onClick=
{
onTableClick
}
data
-
id=
{
item
.
table
.
table_id
}
fontWeight=
{
500
}
>
{
item
.
table
.
table_full_name
}
</
Link
>
</
Skeleton
>
<
Skeleton
isLoaded=
{
!
isLoading
}
color=
"text_secondary"
>
{
item
.
table
.
table_type
}
</
Skeleton
>
</
Flex
>
<
Skeleton
isLoaded=
{
!
isLoading
}
color=
"text_secondary"
>
<
HashStringShorten
hash=
{
item
.
table
.
table_id
}
type=
"long"
/>
</
Skeleton
>
</
Box
>
</
Flex
>
{
isOpened
&&
(
<
Grid
templateColumns=
"48px 1fr"
gap=
"8px 24px"
fontWeight=
{
500
}
w=
"100%"
>
{
Boolean
(
item
.
schema
.
key_names
.
length
)
&&
(
<>
<
Text
lineHeight=
"24px"
>
Key
</
Text
>
<
VStack
gap=
{
1
}
alignItems=
"start"
>
{
item
.
schema
.
key_names
.
map
((
name
,
index
)
=>
(
<
Tag
key=
{
name
}
>
<
chakra
.
span
fontWeight=
{
700
}
>
{
item
.
schema
.
key_types
[
index
]
}
</
chakra
.
span
>
{
name
}
</
Tag
>
))
}
</
VStack
>
</>
)
}
<
GridItem
colSpan=
{
2
}
><
Divider
/></
GridItem
>
<
Text
lineHeight=
"24px"
>
Value
</
Text
>
<
VStack
gap=
{
1
}
alignItems=
"start"
>
{
item
.
schema
.
value_names
.
map
((
name
,
index
)
=>
(
<
Text
key=
{
name
}
>
<
chakra
.
span
fontWeight=
{
700
}
>
{
item
.
schema
.
value_types
[
index
]
}
</
chakra
.
span
>
{
name
}
</
Text
>
))
}
</
VStack
>
</
Grid
>
)
}
</
ListItemMobile
>
);
};
export
default
React
.
memo
(
AddressMudTablesListItem
);
ui/address/mud/AddressMudTablesTableItem.tsx
View file @
a44d803f
...
@@ -24,10 +24,7 @@ const AddressMudTablesTableItem = ({ item, isLoading, scrollRef }: Props) => {
...
@@ -24,10 +24,7 @@ const AddressMudTablesTableItem = ({ item, isLoading, scrollRef }: Props) => {
table_id
:
e
.
currentTarget
.
getAttribute
(
'
data-id
'
)
as
string
,
table_id
:
e
.
currentTarget
.
getAttribute
(
'
data-id
'
)
as
string
,
};
};
router
.
push
({
pathname
:
router
.
pathname
,
query
:
newQuery
},
undefined
,
{
shallow
:
true
});
router
.
push
({
pathname
:
router
.
pathname
,
query
:
newQuery
},
undefined
,
{
shallow
:
true
});
window
.
setTimeout
(()
=>
{
scrollRef
?.
current
?.
scrollIntoView
();
// cannot do scroll instantly, have to wait a little
scrollRef
?.
current
?.
scrollIntoView
({
behavior
:
'
smooth
'
});
},
500
);
},
[
router
,
scrollRef
]);
},
[
router
,
scrollRef
]);
return
(
return
(
...
...
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