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
20785776
Commit
20785776
authored
May 08, 2023
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
review fixes
parent
0e9a61e4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
33 deletions
+32
-33
useHasAccount.ts
lib/hooks/useHasAccount.ts
+6
-1
LatestTxsItemSkeleton.tsx
ui/home/LatestTxsItemSkeleton.tsx
+1
-0
Home.pw.tsx_dark-color-mode_default-view---default-desktop-xl-dark-mode-1.png
...or-mode_default-view---default-desktop-xl-dark-mode-1.png
+0
-0
RoutedTabs.tsx
ui/shared/Tabs/RoutedTabs.tsx
+11
-18
TabsMenu.tsx
ui/shared/Tabs/TabsMenu.tsx
+5
-5
TabsWithScroll.tsx
ui/shared/Tabs/TabsWithScroll.tsx
+8
-8
SkeletonTabs.tsx
ui/shared/skeletons/SkeletonTabs.tsx
+1
-1
No files found.
lib/hooks/useHasAccount.ts
View file @
20785776
...
@@ -4,7 +4,12 @@ import * as cookies from 'lib/cookies';
...
@@ -4,7 +4,12 @@ import * as cookies from 'lib/cookies';
export
default
function
useHasAccount
()
{
export
default
function
useHasAccount
()
{
const
appProps
=
useAppContext
();
const
appProps
=
useAppContext
();
if
(
!
appConfig
.
isAccountSupported
)
{
return
false
;
}
const
cookiesString
=
appProps
.
cookies
;
const
cookiesString
=
appProps
.
cookies
;
const
hasAuth
=
Boolean
(
cookies
.
get
(
cookies
.
NAMES
.
API_TOKEN
,
cookiesString
));
const
hasAuth
=
Boolean
(
cookies
.
get
(
cookies
.
NAMES
.
API_TOKEN
,
cookiesString
));
return
hasAuth
&&
appConfig
.
isAccountSupported
;
return
hasAuth
;
}
}
ui/home/LatestTxsItemSkeleton.tsx
View file @
20785776
...
@@ -11,6 +11,7 @@ const LatestTxsItemSkeleton = () => {
...
@@ -11,6 +11,7 @@ const LatestTxsItemSkeleton = () => {
return
(
return
(
<
Box
<
Box
width=
"100%"
width=
"100%"
minW=
"700px"
borderTop=
"1px solid"
borderTop=
"1px solid"
borderColor=
"divider"
borderColor=
"divider"
py=
{
4
}
py=
{
4
}
...
...
ui/pages/__screenshots__/Home.pw.tsx_dark-color-mode_default-view---default-desktop-xl-dark-mode-1.png
View replaced file @
0e9a61e4
View file @
20785776
224 KB
|
W:
|
H:
225 KB
|
W:
|
H:
2-up
Swipe
Onion skin
ui/shared/Tabs/RoutedTabs.tsx
View file @
20785776
...
@@ -2,7 +2,7 @@ import type { ChakraProps, ThemingProps } from '@chakra-ui/react';
...
@@ -2,7 +2,7 @@ import type { ChakraProps, ThemingProps } from '@chakra-ui/react';
import
{
chakra
}
from
'
@chakra-ui/react
'
;
import
{
chakra
}
from
'
@chakra-ui/react
'
;
import
_pickBy
from
'
lodash/pickBy
'
;
import
_pickBy
from
'
lodash/pickBy
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
,
{
useEffect
,
useRef
,
useState
}
from
'
react
'
;
import
React
,
{
useEffect
,
useRef
}
from
'
react
'
;
import
type
{
RoutedTab
}
from
'
./types
'
;
import
type
{
RoutedTab
}
from
'
./types
'
;
...
@@ -18,7 +18,15 @@ interface Props extends ThemingProps<'Tabs'> {
...
@@ -18,7 +18,15 @@ interface Props extends ThemingProps<'Tabs'> {
const
RoutedTabs
=
({
tabs
,
tabListProps
,
rightSlot
,
stickyEnabled
,
className
,
...
themeProps
}:
Props
)
=>
{
const
RoutedTabs
=
({
tabs
,
tabListProps
,
rightSlot
,
stickyEnabled
,
className
,
...
themeProps
}:
Props
)
=>
{
const
router
=
useRouter
();
const
router
=
useRouter
();
const
[
activeTabIndex
,
setActiveTabIndex
]
=
useState
<
number
>
(
tabs
.
length
+
1
);
let
tabIndex
=
0
;
const
tabFromRoute
=
router
.
query
.
tab
;
if
(
tabFromRoute
)
{
tabIndex
=
tabs
.
findIndex
(({
id
,
subTabs
})
=>
id
===
tabFromRoute
||
subTabs
?.
some
((
id
)
=>
id
===
tabFromRoute
));
if
(
tabIndex
<
0
)
{
tabIndex
=
0
;
}
}
const
tabsRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
tabsRef
=
useRef
<
HTMLDivElement
>
(
null
);
...
@@ -50,21 +58,6 @@ const RoutedTabs = ({ tabs, tabListProps, rightSlot, stickyEnabled, className, .
...
@@ -50,21 +58,6 @@ const RoutedTabs = ({ tabs, tabListProps, rightSlot, stickyEnabled, className, .
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[]);
},
[]);
useEffect
(()
=>
{
if
(
router
.
isReady
)
{
let
tabIndex
=
0
;
const
tabFromRoute
=
router
.
query
.
tab
;
if
(
tabFromRoute
)
{
tabIndex
=
tabs
.
findIndex
(({
id
,
subTabs
})
=>
id
===
tabFromRoute
||
subTabs
?.
some
((
id
)
=>
id
===
tabFromRoute
));
if
(
tabIndex
<
0
)
{
tabIndex
=
0
;
}
}
setActiveTabIndex
(
tabIndex
);
}
},
[
tabs
,
router
,
activeTabIndex
]);
return
(
return
(
<
TabsWithScroll
<
TabsWithScroll
tabs=
{
tabs
}
tabs=
{
tabs
}
...
@@ -72,7 +65,7 @@ const RoutedTabs = ({ tabs, tabListProps, rightSlot, stickyEnabled, className, .
...
@@ -72,7 +65,7 @@ const RoutedTabs = ({ tabs, tabListProps, rightSlot, stickyEnabled, className, .
rightSlot=
{
rightSlot
}
rightSlot=
{
rightSlot
}
stickyEnabled=
{
stickyEnabled
}
stickyEnabled=
{
stickyEnabled
}
onTabChange=
{
handleTabChange
}
onTabChange=
{
handleTabChange
}
activeTabIndex=
{
activeT
abIndex
}
defaultTabIndex=
{
t
abIndex
}
{
...
themeProps
}
{
...
themeProps
}
/>
/>
);
);
...
...
ui/shared/Tabs/
Routed
TabsMenu.tsx
→
ui/shared/Tabs/TabsMenu.tsx
View file @
20785776
...
@@ -10,13 +10,13 @@ import { Popover,
...
@@ -10,13 +10,13 @@ import { Popover,
import
type
{
StyleProps
}
from
'
@chakra-ui/styled-system
'
;
import
type
{
StyleProps
}
from
'
@chakra-ui/styled-system
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
MenuButton
,
RoutedTab
}
from
'
./types
'
;
import
type
{
MenuButton
,
TabItem
}
from
'
./types
'
;
import
{
menuButton
}
from
'
./utils
'
;
import
{
menuButton
}
from
'
./utils
'
;
interface
Props
{
interface
Props
{
tabs
:
Array
<
RoutedTab
|
MenuButton
>
;
tabs
:
Array
<
TabItem
|
MenuButton
>
;
activeTab
?:
RoutedTab
;
activeTab
?:
TabItem
;
tabsCut
:
number
;
tabsCut
:
number
;
isActive
:
boolean
;
isActive
:
boolean
;
styles
?:
StyleProps
;
styles
?:
StyleProps
;
...
@@ -25,7 +25,7 @@ interface Props {
...
@@ -25,7 +25,7 @@ interface Props {
size
:
ButtonProps
[
'
size
'
];
size
:
ButtonProps
[
'
size
'
];
}
}
const
Routed
TabsMenu
=
({
tabs
,
tabsCut
,
isActive
,
styles
,
onItemClick
,
buttonRef
,
activeTab
,
size
}:
Props
)
=>
{
const
TabsMenu
=
({
tabs
,
tabsCut
,
isActive
,
styles
,
onItemClick
,
buttonRef
,
activeTab
,
size
}:
Props
)
=>
{
const
{
isOpen
,
onClose
,
onOpen
}
=
useDisclosure
();
const
{
isOpen
,
onClose
,
onOpen
}
=
useDisclosure
();
const
handleItemClick
=
React
.
useCallback
((
event
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
=>
{
const
handleItemClick
=
React
.
useCallback
((
event
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
=>
{
...
@@ -69,4 +69,4 @@ const RoutedTabsMenu = ({ tabs, tabsCut, isActive, styles, onItemClick, buttonRe
...
@@ -69,4 +69,4 @@ const RoutedTabsMenu = ({ tabs, tabsCut, isActive, styles, onItemClick, buttonRe
);
);
};
};
export
default
React
.
memo
(
Routed
TabsMenu
);
export
default
React
.
memo
(
TabsMenu
);
ui/shared/Tabs/TabsWithScroll.tsx
View file @
20785776
...
@@ -19,7 +19,7 @@ import { useScrollDirection } from 'lib/contexts/scrollDirection';
...
@@ -19,7 +19,7 @@ import { useScrollDirection } from 'lib/contexts/scrollDirection';
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useIsSticky
from
'
lib/hooks/useIsSticky
'
;
import
useIsSticky
from
'
lib/hooks/useIsSticky
'
;
import
RoutedTabsMenu
from
'
./Routed
TabsMenu
'
;
import
TabsMenu
from
'
./
TabsMenu
'
;
import
useAdaptiveTabs
from
'
./useAdaptiveTabs
'
;
import
useAdaptiveTabs
from
'
./useAdaptiveTabs
'
;
const
hiddenItemStyles
:
StyleProps
=
{
const
hiddenItemStyles
:
StyleProps
=
{
...
@@ -36,7 +36,7 @@ interface Props extends ThemingProps<'Tabs'> {
...
@@ -36,7 +36,7 @@ interface Props extends ThemingProps<'Tabs'> {
rightSlot
?:
React
.
ReactNode
;
rightSlot
?:
React
.
ReactNode
;
stickyEnabled
?:
boolean
;
stickyEnabled
?:
boolean
;
onTabChange
?:
(
index
:
number
)
=>
void
;
onTabChange
?:
(
index
:
number
)
=>
void
;
active
TabIndex
?:
number
;
default
TabIndex
?:
number
;
className
?:
string
;
className
?:
string
;
}
}
...
@@ -47,12 +47,12 @@ const TabsWithScroll = ({
...
@@ -47,12 +47,12 @@ const TabsWithScroll = ({
rightSlot
,
rightSlot
,
stickyEnabled
,
stickyEnabled
,
onTabChange
,
onTabChange
,
activeTabIndex
:
activeTabIndexProps
,
defaultTabIndex
,
className
,
className
,
...
themeProps
...
themeProps
}:
Props
)
=>
{
}:
Props
)
=>
{
const
scrollDirection
=
useScrollDirection
();
const
scrollDirection
=
useScrollDirection
();
const
[
activeTabIndex
,
setActiveTabIndex
]
=
useState
<
number
>
(
activeTabIndexProps
||
0
);
const
[
activeTabIndex
,
setActiveTabIndex
]
=
useState
<
number
>
(
defaultTabIndex
||
0
);
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
const
tabsRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
tabsRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
{
tabsCut
,
tabsList
,
tabsRefs
,
listRef
,
rightSlotRef
}
=
useAdaptiveTabs
(
tabs
,
isMobile
);
const
{
tabsCut
,
tabsList
,
tabsRefs
,
listRef
,
rightSlotRef
}
=
useAdaptiveTabs
(
tabs
,
isMobile
);
...
@@ -64,10 +64,10 @@ const TabsWithScroll = ({
...
@@ -64,10 +64,10 @@ const TabsWithScroll = ({
},
[
onTabChange
]);
},
[
onTabChange
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
activeTabIndexProps
!==
undefined
)
{
if
(
defaultTabIndex
!==
undefined
)
{
setActiveTabIndex
(
activeTabIndexProps
);
setActiveTabIndex
(
defaultTabIndex
);
}
}
},
[
activeTabIndexProps
]);
},
[
defaultTabIndex
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
activeTabIndex
<
tabs
.
length
&&
isMobile
)
{
if
(
activeTabIndex
<
tabs
.
length
&&
isMobile
)
{
...
@@ -138,7 +138,7 @@ const TabsWithScroll = ({
...
@@ -138,7 +138,7 @@ const TabsWithScroll = ({
{
tabsList
.
map
((
tab
,
index
)
=>
{
{
tabsList
.
map
((
tab
,
index
)
=>
{
if
(
!
tab
.
id
)
{
if
(
!
tab
.
id
)
{
return
(
return
(
<
Routed
TabsMenu
<
TabsMenu
key=
"menu"
key=
"menu"
tabs=
{
tabs
}
tabs=
{
tabs
}
activeTab=
{
tabs
[
activeTabIndex
]
}
activeTab=
{
tabs
[
activeTabIndex
]
}
...
...
ui/shared/skeletons/SkeletonTabs.tsx
View file @
20785776
import
{
Flex
,
Skeleton
,
chakra
}
from
'
@chakra-ui/react
'
;
import
{
Flex
,
Skeleton
,
chakra
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
RoutedTab
}
from
'
../
Routed
Tabs/types
'
;
import
type
{
RoutedTab
}
from
'
../Tabs/types
'
;
interface
Props
{
interface
Props
{
className
?:
string
;
className
?:
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