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
8b15c118
Commit
8b15c118
authored
Jan 03, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
subtabs for contract tab
parent
4979acc7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
9 deletions
+72
-9
Tabs.ts
theme/components/Tabs.ts
+23
-0
AddressContract.tsx
ui/address/AddressContract.tsx
+15
-0
AddressLogs.tsx
ui/address/AddressLogs.tsx
+0
-0
Address.tsx
ui/pages/Address.tsx
+17
-1
RoutedTabs.tsx
ui/shared/RoutedTabs/RoutedTabs.tsx
+14
-8
types.ts
ui/shared/RoutedTabs/types.ts
+3
-0
No files found.
theme/components/Tabs.ts
View file @
8b15c118
...
@@ -6,6 +6,8 @@ import { mode } from '@chakra-ui/theme-tools';
...
@@ -6,6 +6,8 @@ import { mode } from '@chakra-ui/theme-tools';
const
{
defineMultiStyleConfig
,
definePartsStyle
}
=
const
{
defineMultiStyleConfig
,
definePartsStyle
}
=
createMultiStyleConfigHelpers
(
parts
.
keys
);
createMultiStyleConfigHelpers
(
parts
.
keys
);
import
Button
from
'
./Button/Button
'
;
const
variantSoftRounded
=
definePartsStyle
((
props
)
=>
{
const
variantSoftRounded
=
definePartsStyle
((
props
)
=>
{
return
{
return
{
tab
:
{
tab
:
{
...
@@ -26,11 +28,32 @@ const variantSoftRounded = definePartsStyle((props) => {
...
@@ -26,11 +28,32 @@ const variantSoftRounded = definePartsStyle((props) => {
};
};
});
});
const
variantOutline
=
definePartsStyle
((
props
)
=>
{
return
{
tab
:
{
...
Button
.
variants
?.
outline
(
props
),
...
Button
.
baseStyle
,
_selected
:
Button
.
variants
?.
outline
(
props
).
_active
,
},
};
});
const
sizes
=
{
sm
:
definePartsStyle
({
tab
:
Button
.
sizes
?.
sm
,
}),
md
:
definePartsStyle
({
tab
:
Button
.
sizes
?.
md
,
}),
};
const
variants
=
{
const
variants
=
{
'
soft-rounded
'
:
variantSoftRounded
,
'
soft-rounded
'
:
variantSoftRounded
,
outline
:
variantOutline
,
};
};
const
Tabs
=
defineMultiStyleConfig
({
const
Tabs
=
defineMultiStyleConfig
({
sizes
,
variants
,
variants
,
});
});
...
...
ui/address/AddressContract.tsx
0 → 100644
View file @
8b15c118
import
React
from
'
react
'
;
import
type
{
RoutedSubTab
}
from
'
ui/shared/RoutedTabs/types
'
;
import
RoutedTabs
from
'
ui/shared/RoutedTabs/RoutedTabs
'
;
interface
Props
{
tabs
:
Array
<
RoutedSubTab
>
;
}
const
AddressContract
=
({
tabs
}:
Props
)
=>
{
return
<
RoutedTabs
tabs=
{
tabs
}
variant=
"outline"
colorScheme=
"gray"
size=
"sm"
tabListProps=
{
{
columnGap
:
3
}
}
/>;
};
export
default
AddressContract
;
ui/address/
logs/
AddressLogs.tsx
→
ui/address/AddressLogs.tsx
View file @
8b15c118
File moved
ui/pages/Address.tsx
View file @
8b15c118
...
@@ -8,17 +8,27 @@ import useApiQuery from 'lib/api/useApiQuery';
...
@@ -8,17 +8,27 @@ import useApiQuery from 'lib/api/useApiQuery';
import
notEmpty
from
'
lib/notEmpty
'
;
import
notEmpty
from
'
lib/notEmpty
'
;
import
AddressBlocksValidated
from
'
ui/address/AddressBlocksValidated
'
;
import
AddressBlocksValidated
from
'
ui/address/AddressBlocksValidated
'
;
import
AddressCoinBalance
from
'
ui/address/AddressCoinBalance
'
;
import
AddressCoinBalance
from
'
ui/address/AddressCoinBalance
'
;
import
AddressContract
from
'
ui/address/AddressContract
'
;
import
AddressDetails
from
'
ui/address/AddressDetails
'
;
import
AddressDetails
from
'
ui/address/AddressDetails
'
;
import
AddressInternalTxs
from
'
ui/address/AddressInternalTxs
'
;
import
AddressInternalTxs
from
'
ui/address/AddressInternalTxs
'
;
import
AddressLogs
from
'
ui/address/AddressLogs
'
;
import
AddressTokenTransfers
from
'
ui/address/AddressTokenTransfers
'
;
import
AddressTokenTransfers
from
'
ui/address/AddressTokenTransfers
'
;
import
AddressTxs
from
'
ui/address/AddressTxs
'
;
import
AddressTxs
from
'
ui/address/AddressTxs
'
;
import
AddressLogs
from
'
ui/address/logs/AddressLogs
'
;
import
TextAd
from
'
ui/shared/ad/TextAd
'
;
import
TextAd
from
'
ui/shared/ad/TextAd
'
;
import
Page
from
'
ui/shared/Page/Page
'
;
import
Page
from
'
ui/shared/Page/Page
'
;
import
PageTitle
from
'
ui/shared/Page/PageTitle
'
;
import
PageTitle
from
'
ui/shared/Page/PageTitle
'
;
import
RoutedTabs
from
'
ui/shared/RoutedTabs/RoutedTabs
'
;
import
RoutedTabs
from
'
ui/shared/RoutedTabs/RoutedTabs
'
;
import
SkeletonTabs
from
'
ui/shared/skeletons/SkeletonTabs
'
;
import
SkeletonTabs
from
'
ui/shared/skeletons/SkeletonTabs
'
;
const
CONTRACT_TABS
=
[
{
id
:
'
contact_code
'
,
title
:
'
Code
'
,
component
:
<
div
>
Code
</
div
>
},
{
id
:
'
contact_decompiled_code
'
,
title
:
'
Decompiled code
'
,
component
:
<
div
>
Decompiled code
</
div
>
},
{
id
:
'
read_contract
'
,
title
:
'
Read contract
'
,
component
:
<
div
>
Read contract
</
div
>
},
{
id
:
'
read_proxy
'
,
title
:
'
Read proxy
'
,
component
:
<
div
>
Read proxy
</
div
>
},
{
id
:
'
write_contract
'
,
title
:
'
Write contract
'
,
component
:
<
div
>
Write contract
</
div
>
},
{
id
:
'
write_proxy
'
,
title
:
'
Write proxy
'
,
component
:
<
div
>
Write proxy
</
div
>
},
];
const
AddressPageContent
=
()
=>
{
const
AddressPageContent
=
()
=>
{
const
router
=
useRouter
();
const
router
=
useRouter
();
...
@@ -46,6 +56,12 @@ const AddressPageContent = () => {
...
@@ -46,6 +56,12 @@ const AddressPageContent = () => {
// later api will return info about available tabs
// later api will return info about available tabs
{
id
:
'
blocks_validated
'
,
title
:
'
Blocks validated
'
,
component
:
<
AddressBlocksValidated
/>
},
{
id
:
'
blocks_validated
'
,
title
:
'
Blocks validated
'
,
component
:
<
AddressBlocksValidated
/>
},
isContract
?
{
id
:
'
logs
'
,
title
:
'
Logs
'
,
component
:
<
AddressLogs
/>
}
:
undefined
,
isContract
?
{
id
:
'
logs
'
,
title
:
'
Logs
'
,
component
:
<
AddressLogs
/>
}
:
undefined
,
isContract
?
{
id
:
'
contract
'
,
title
:
'
Contract
'
,
component
:
<
AddressContract
tabs=
{
CONTRACT_TABS
}
/>,
subTabs
:
CONTRACT_TABS
,
}
:
undefined
,
].
filter
(
notEmpty
);
].
filter
(
notEmpty
);
},
[
isContract
]);
},
[
isContract
]);
...
...
ui/shared/RoutedTabs/RoutedTabs.tsx
View file @
8b15c118
import
type
{
ChakraProps
}
from
'
@chakra-ui/react
'
;
import
type
{
ChakraProps
,
ThemingProps
}
from
'
@chakra-ui/react
'
;
import
{
import
{
Tab
,
Tab
,
Tabs
,
Tabs
,
...
@@ -7,6 +7,7 @@ import {
...
@@ -7,6 +7,7 @@ import {
TabPanels
,
TabPanels
,
Box
,
Box
,
useColorModeValue
,
useColorModeValue
,
chakra
,
}
from
'
@chakra-ui/react
'
;
}
from
'
@chakra-ui/react
'
;
import
type
{
StyleProps
}
from
'
@chakra-ui/styled-system
'
;
import
type
{
StyleProps
}
from
'
@chakra-ui/styled-system
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
...
@@ -28,14 +29,15 @@ const hiddenItemStyles: StyleProps = {
...
@@ -28,14 +29,15 @@ const hiddenItemStyles: StyleProps = {
visibility
:
'
hidden
'
,
visibility
:
'
hidden
'
,
};
};
interface
Props
{
interface
Props
extends
ThemingProps
<
'
Tabs
'
>
{
tabs
:
Array
<
RoutedTab
>
;
tabs
:
Array
<
RoutedTab
>
;
tabListProps
?:
ChakraProps
;
tabListProps
?:
ChakraProps
;
rightSlot
?:
React
.
ReactNode
;
rightSlot
?:
React
.
ReactNode
;
stickyEnabled
?:
boolean
;
stickyEnabled
?:
boolean
;
className
?:
string
;
}
}
const
RoutedTabs
=
({
tabs
,
tabListProps
,
rightSlot
,
stickyEnabled
}:
Props
)
=>
{
const
RoutedTabs
=
({
tabs
,
tabListProps
,
rightSlot
,
stickyEnabled
,
className
,
...
themeProps
}:
Props
)
=>
{
const
router
=
useRouter
();
const
router
=
useRouter
();
const
scrollDirection
=
useScrollDirection
();
const
scrollDirection
=
useScrollDirection
();
const
[
activeTabIndex
,
setActiveTabIndex
]
=
useState
<
number
>
(
tabs
.
length
+
1
);
const
[
activeTabIndex
,
setActiveTabIndex
]
=
useState
<
number
>
(
tabs
.
length
+
1
);
...
@@ -58,8 +60,9 @@ const RoutedTabs = ({ tabs, tabListProps, rightSlot, stickyEnabled }: Props) =>
...
@@ -58,8 +60,9 @@ const RoutedTabs = ({ tabs, tabListProps, rightSlot, stickyEnabled }: Props) =>
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
router
.
isReady
)
{
if
(
router
.
isReady
)
{
let
tabIndex
=
0
;
let
tabIndex
=
0
;
if
(
router
.
query
.
tab
)
{
const
tabFromRoute
=
router
.
query
.
tab
;
tabIndex
=
tabs
.
findIndex
(({
id
})
=>
id
===
router
.
query
.
tab
);
if
(
tabFromRoute
)
{
tabIndex
=
tabs
.
findIndex
(({
id
,
subTabs
})
=>
id
===
tabFromRoute
||
subTabs
?.
some
(({
id
})
=>
id
===
tabFromRoute
));
if
(
tabIndex
<
0
)
{
if
(
tabIndex
<
0
)
{
tabIndex
=
0
;
tabIndex
=
0
;
}
}
...
@@ -89,12 +92,14 @@ const RoutedTabs = ({ tabs, tabListProps, rightSlot, stickyEnabled }: Props) =>
...
@@ -89,12 +92,14 @@ const RoutedTabs = ({ tabs, tabListProps, rightSlot, stickyEnabled }: Props) =>
return
(
return
(
<
Tabs
<
Tabs
variant=
"soft-rounded"
className=
{
className
}
colorScheme=
"blue"
variant=
{
themeProps
.
variant
||
'
soft-rounded
'
}
colorScheme=
{
themeProps
.
colorScheme
||
'
blue
'
}
isLazy
isLazy
onChange=
{
handleTabChange
}
onChange=
{
handleTabChange
}
index=
{
activeTabIndex
}
index=
{
activeTabIndex
}
position=
"relative"
position=
"relative"
size=
{
themeProps
.
size
||
'
md
'
}
>
>
<
TabList
<
TabList
marginBottom=
{
{
base
:
6
,
lg
:
8
}
}
marginBottom=
{
{
base
:
6
,
lg
:
8
}
}
...
@@ -155,6 +160,7 @@ const RoutedTabs = ({ tabs, tabListProps, rightSlot, stickyEnabled }: Props) =>
...
@@ -155,6 +160,7 @@ const RoutedTabs = ({ tabs, tabListProps, rightSlot, stickyEnabled }: Props) =>
ref=
{
tabsRefs
[
index
]
}
ref=
{
tabsRefs
[
index
]
}
{
...
(
index
<
tabsCut
?
{}
:
hiddenItemStyles
)
}
{
...
(
index
<
tabsCut
?
{}
:
hiddenItemStyles
)
}
scrollSnapAlign=
"start"
scrollSnapAlign=
"start"
flexShrink=
{
0
}
>
>
{
tab
.
title
}
{
tab
.
title
}
</
Tab
>
</
Tab
>
...
@@ -169,4 +175,4 @@ const RoutedTabs = ({ tabs, tabListProps, rightSlot, stickyEnabled }: Props) =>
...
@@ -169,4 +175,4 @@ const RoutedTabs = ({ tabs, tabListProps, rightSlot, stickyEnabled }: Props) =>
);
);
};
};
export
default
React
.
memo
(
RoutedTabs
);
export
default
React
.
memo
(
chakra
(
RoutedTabs
)
);
ui/shared/RoutedTabs/types.ts
View file @
8b15c118
...
@@ -2,8 +2,11 @@ export interface RoutedTab {
...
@@ -2,8 +2,11 @@ export interface RoutedTab {
id
:
string
;
id
:
string
;
title
:
string
;
title
:
string
;
component
:
React
.
ReactNode
;
component
:
React
.
ReactNode
;
subTabs
?:
Array
<
RoutedSubTab
>
;
}
}
export
type
RoutedSubTab
=
Omit
<
RoutedTab
,
'
subTabs
'
>
;
export
interface
MenuButton
{
export
interface
MenuButton
{
id
:
null
;
id
:
null
;
title
:
string
;
title
:
string
;
...
...
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