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
20051052
Commit
20051052
authored
Feb 17, 2023
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix2
parent
3dd7c48c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
64 deletions
+63
-64
useNavItems.tsx
lib/hooks/useNavItems.tsx
+1
-5
NavLink.tsx
ui/snippets/navigation/NavLink.tsx
+7
-19
NavLinkGroupDesktop.tsx
ui/snippets/navigation/NavLinkGroupDesktop.tsx
+15
-22
NavLinkGroupMobile.tsx
ui/snippets/navigation/NavLinkGroupMobile.tsx
+4
-17
NavigationDesktop.pw.tsx
ui/snippets/navigation/NavigationDesktop.pw.tsx
+1
-1
useNavLinkStyleProps.tsx
ui/snippets/navigation/useNavLinkStyleProps.tsx
+35
-0
No files found.
lib/hooks/useNavItems.tsx
View file @
20051052
...
@@ -28,11 +28,7 @@ export interface NavItem {
...
@@ -28,11 +28,7 @@ export interface NavItem {
isNewUi
?:
boolean
;
isNewUi
?:
boolean
;
}
}
export
interface
NavGroupItem
{
export
interface
NavGroupItem
extends
Omit
<
NavItem
,
'
nextRoute
'
>
{
text
:
string
;
icon
:
React
.
FunctionComponent
<
React
.
SVGAttributes
<
SVGElement
>>
;
isActive
?:
boolean
;
isNewUi
?:
boolean
;
subItems
:
Array
<
NavItem
>
;
subItems
:
Array
<
NavItem
>
;
}
}
...
...
ui/snippets/navigation/NavLink.tsx
View file @
20051052
...
@@ -4,9 +4,9 @@ import { route } from 'nextjs-routes';
...
@@ -4,9 +4,9 @@ import { route } from 'nextjs-routes';
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
NavItem
}
from
'
lib/hooks/useNavItems
'
;
import
type
{
NavItem
}
from
'
lib/hooks/useNavItems
'
;
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
useColors
from
'
./useColors
'
;
import
useColors
from
'
./useColors
'
;
import
useNavLinkStyleProps
from
'
./useNavLinkStyleProps
'
;
type
Props
=
NavItem
&
{
type
Props
=
NavItem
&
{
isCollapsed
?:
boolean
;
isCollapsed
?:
boolean
;
...
@@ -15,23 +15,19 @@ type Props = NavItem & {
...
@@ -15,23 +15,19 @@ type Props = NavItem & {
const
NavLink
=
({
text
,
nextRoute
,
icon
,
isCollapsed
,
isActive
,
px
,
isNewUi
}:
Props
)
=>
{
const
NavLink
=
({
text
,
nextRoute
,
icon
,
isCollapsed
,
isActive
,
px
,
isNewUi
}:
Props
)
=>
{
const
colors
=
useColors
();
const
colors
=
useColors
();
const
isExpanded
=
isCollapsed
===
false
;
const
isExpanded
=
isCollapsed
===
false
;
const
styleProps
=
useNavLinkStyleProps
({
isCollapsed
,
isExpanded
,
isActive
});
const
content
=
(
const
content
=
(
<
Link
<
Link
{
...
(
isNewUi
?
{}
:
{
href
:
route
(
nextRoute
)
})
}
{
...
(
isNewUi
?
{}
:
{
href
:
route
(
nextRoute
)
})
}
{
...
styleProps
.
itemProps
}
w=
{
{
base
:
'
100%
'
,
lg
:
isExpanded
?
'
100%
'
:
'
60px
'
,
xl
:
isCollapsed
?
'
60px
'
:
'
100%
'
}
}
w=
{
{
base
:
'
100%
'
,
lg
:
isExpanded
?
'
100%
'
:
'
60px
'
,
xl
:
isCollapsed
?
'
60px
'
:
'
100%
'
}
}
px=
{
px
||
{
base
:
3
,
lg
:
isExpanded
?
3
:
'
15px
'
,
xl
:
isCollapsed
?
'
15px
'
:
3
}
}
py=
{
2.5
}
display=
"flex"
display=
"flex"
color=
{
isActive
?
colors
.
text
.
active
:
colors
.
text
.
default
}
px=
{
px
||
{
base
:
3
,
lg
:
isExpanded
?
3
:
'
15px
'
,
xl
:
isCollapsed
?
'
15px
'
:
3
}
}
bgColor=
{
isActive
?
colors
.
bg
.
active
:
colors
.
bg
.
default
}
_hover=
{
{
color
:
isActive
?
colors
.
text
.
active
:
colors
.
text
.
hover
}
}
borderRadius=
"base"
whiteSpace=
"nowrap"
aria
-
label=
{
`${ text } link`
}
aria
-
label=
{
`${ text } link`
}
{
...
getDefaultTransitionProps
({
transitionProperty
:
'
width
,
padding
'
})
}
whiteSpace=
"nowrap"
>
>
<
Tooltip
<
Tooltip
label=
{
text
}
label=
{
text
}
...
@@ -44,15 +40,7 @@ const NavLink = ({ text, nextRoute, icon, isCollapsed, isActive, px, isNewUi }:
...
@@ -44,15 +40,7 @@ const NavLink = ({ text, nextRoute, icon, isCollapsed, isActive, px, isNewUi }:
>
>
<
HStack
spacing=
{
3
}
overflow=
"hidden"
>
<
HStack
spacing=
{
3
}
overflow=
"hidden"
>
<
Icon
as=
{
icon
}
boxSize=
"30px"
/>
<
Icon
as=
{
icon
}
boxSize=
"30px"
/>
<
Text
<
Text
{
...
styleProps
.
textProps
}
>
variant=
"inherit"
fontSize=
"sm"
lineHeight=
"20px"
opacity=
{
{
base
:
'
1
'
,
lg
:
isExpanded
?
'
1
'
:
'
0
'
,
xl
:
isCollapsed
?
'
0
'
:
'
1
'
}
}
transitionProperty=
"opacity"
transitionDuration=
"normal"
transitionTimingFunction=
"ease"
>
{
text
}
{
text
}
</
Text
>
</
Text
>
</
HStack
>
</
HStack
>
...
...
ui/snippets/navigation/NavLinkGroupDesktop.tsx
View file @
20051052
...
@@ -4,6 +4,7 @@ import {
...
@@ -4,6 +4,7 @@ import {
HStack
,
HStack
,
Flex
,
Flex
,
Box
,
Box
,
Link
,
Popover
,
Popover
,
PopoverTrigger
,
PopoverTrigger
,
PopoverContent
,
PopoverContent
,
...
@@ -14,20 +15,19 @@ import React from 'react';
...
@@ -14,20 +15,19 @@ import React from 'react';
import
chevronIcon
from
'
icons/arrows/east-mini.svg
'
;
import
chevronIcon
from
'
icons/arrows/east-mini.svg
'
;
import
type
{
NavGroupItem
}
from
'
lib/hooks/useNavItems
'
;
import
type
{
NavGroupItem
}
from
'
lib/hooks/useNavItems
'
;
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
NavLink
from
'
./NavLink
'
;
import
NavLink
from
'
./NavLink
'
;
import
use
Colors
from
'
./useColor
s
'
;
import
use
NavLinkStyleProps
from
'
./useNavLinkStyleProp
s
'
;
type
Props
=
NavGroupItem
&
{
type
Props
=
NavGroupItem
&
{
isCollapsed
?:
boolean
;
isCollapsed
?:
boolean
;
}
}
const
NavLinkGroupDesktop
=
({
text
,
subItems
,
icon
,
isCollapsed
,
isActive
}:
Props
)
=>
{
const
NavLinkGroupDesktop
=
({
text
,
subItems
,
icon
,
isCollapsed
,
isActive
}:
Props
)
=>
{
const
colors
=
useColors
();
const
isExpanded
=
isCollapsed
===
false
;
const
isExpanded
=
isCollapsed
===
false
;
const
styleProps
=
useNavLinkStyleProps
({
isCollapsed
,
isExpanded
,
isActive
});
return
(
return
(
<
Box
as=
"li"
listStyleType=
"none"
w=
"100%"
>
<
Box
as=
"li"
listStyleType=
"none"
w=
"100%"
>
<
Popover
<
Popover
...
@@ -36,31 +36,21 @@ const NavLinkGroupDesktop = ({ text, subItems, icon, isCollapsed, isActive }: Pr
...
@@ -36,31 +36,21 @@ const NavLinkGroupDesktop = ({ text, subItems, icon, isCollapsed, isActive }: Pr
isLazy
isLazy
>
>
<
PopoverTrigger
>
<
PopoverTrigger
>
<
Box
<
Link
{
...
styleProps
.
itemProps
}
w=
{
{
lg
:
isExpanded
?
'
180px
'
:
'
60px
'
,
xl
:
isCollapsed
?
'
60px
'
:
'
180px
'
}
}
w=
{
{
lg
:
isExpanded
?
'
180px
'
:
'
60px
'
,
xl
:
isCollapsed
?
'
60px
'
:
'
180px
'
}
}
pl=
{
{
lg
:
isExpanded
?
3
:
'
15px
'
,
xl
:
isCollapsed
?
'
15px
'
:
3
}
}
pl=
{
{
lg
:
isExpanded
?
3
:
'
15px
'
,
xl
:
isCollapsed
?
'
15px
'
:
3
}
}
pr=
{
{
lg
:
isExpanded
?
0
:
'
15px
'
,
xl
:
isCollapsed
?
'
15px
'
:
0
}
}
pr=
{
{
lg
:
isExpanded
?
0
:
'
15px
'
,
xl
:
isCollapsed
?
'
15px
'
:
0
}
}
py=
{
2.5
}
display=
"flex"
color=
{
isActive
?
colors
.
text
.
active
:
colors
.
text
.
default
}
bgColor=
{
isActive
?
colors
.
bg
.
active
:
colors
.
bg
.
default
}
_hover=
{
{
color
:
isActive
?
colors
.
text
.
active
:
colors
.
text
.
hover
}
}
borderRadius=
"base"
whiteSpace=
"nowrap"
aria
-
label=
{
`${ text } link group`
}
aria
-
label=
{
`${ text } link group`
}
{
...
getDefaultTransitionProps
({
transitionProperty
:
'
width
,
padding
'
})
}
display=
"grid"
gridColumnGap=
{
3
}
gridTemplateColumns=
"auto, 30px"
>
>
<
Flex
justifyContent=
"space-between"
width=
"100%"
alignItems=
"center"
pr=
{
1
}
>
<
Flex
justifyContent=
"space-between"
width=
"100%"
alignItems=
"center"
pr=
{
1
}
>
<
HStack
spacing=
{
3
}
overflow=
"hidden"
>
<
HStack
spacing=
{
3
}
overflow=
"hidden"
>
<
Icon
as=
{
icon
}
boxSize=
"30px"
/>
<
Icon
as=
{
icon
}
boxSize=
"30px"
/>
<
Text
<
Text
variant=
"inherit"
{
...
styleProps
.
textProps
}
fontSize=
"sm"
lineHeight=
"20px"
opacity=
{
{
lg
:
isExpanded
?
'
1
'
:
'
0
'
,
xl
:
isCollapsed
?
'
0
'
:
'
1
'
}
}
transitionProperty=
"opacity"
transitionDuration=
"normal"
transitionTimingFunction=
"ease"
>
>
{
text
}
{
text
}
</
Text
>
</
Text
>
...
@@ -69,10 +59,13 @@ const NavLinkGroupDesktop = ({ text, subItems, icon, isCollapsed, isActive }: Pr
...
@@ -69,10 +59,13 @@ const NavLinkGroupDesktop = ({ text, subItems, icon, isCollapsed, isActive }: Pr
as=
{
chevronIcon
}
as=
{
chevronIcon
}
transform=
"rotate(180deg)"
transform=
"rotate(180deg)"
boxSize=
{
6
}
boxSize=
{
6
}
display=
{
{
lg
:
isExpanded
?
'
block
'
:
'
none
'
,
xl
:
isCollapsed
?
'
none
'
:
'
block
'
}
}
opacity=
{
{
lg
:
isExpanded
?
'
1
'
:
'
0
'
,
xl
:
isCollapsed
?
'
0
'
:
'
1
'
}
}
transitionProperty=
"opacity"
transitionDuration=
"normal"
transitionTimingFunction=
"ease"
/>
/>
</
Flex
>
</
Flex
>
</
Box
>
</
Link
>
</
PopoverTrigger
>
</
PopoverTrigger
>
<
PopoverContent
width=
"auto"
top=
{
{
lg
:
isExpanded
?
'
-16px
'
:
0
,
xl
:
isCollapsed
?
0
:
'
-16px
'
}
}
>
<
PopoverContent
width=
"auto"
top=
{
{
lg
:
isExpanded
?
'
-16px
'
:
0
,
xl
:
isCollapsed
?
0
:
'
-16px
'
}
}
>
<
PopoverBody
p=
{
4
}
>
<
PopoverBody
p=
{
4
}
>
...
...
ui/snippets/navigation/NavLinkGroupMobile.tsx
View file @
20051052
...
@@ -9,9 +9,8 @@ import React from 'react';
...
@@ -9,9 +9,8 @@ import React from 'react';
import
chevronIcon
from
'
icons/arrows/east-mini.svg
'
;
import
chevronIcon
from
'
icons/arrows/east-mini.svg
'
;
import
type
{
NavGroupItem
}
from
'
lib/hooks/useNavItems
'
;
import
type
{
NavGroupItem
}
from
'
lib/hooks/useNavItems
'
;
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
use
Colors
from
'
./useColor
s
'
;
import
use
NavLinkStyleProps
from
'
./useNavLinkStyleProp
s
'
;
type
Props
=
NavGroupItem
&
{
type
Props
=
NavGroupItem
&
{
isCollapsed
?:
boolean
;
isCollapsed
?:
boolean
;
...
@@ -19,33 +18,21 @@ type Props = NavGroupItem & {
...
@@ -19,33 +18,21 @@ type Props = NavGroupItem & {
}
}
const
NavLinkGroup
=
({
text
,
icon
,
isActive
,
onClick
}:
Props
)
=>
{
const
NavLinkGroup
=
({
text
,
icon
,
isActive
,
onClick
}:
Props
)
=>
{
const
colors
=
useColors
(
);
const
styleProps
=
useNavLinkStyleProps
({
isActive
}
);
return
(
return
(
<
Box
as=
"li"
listStyleType=
"none"
w=
"100%"
onClick=
{
onClick
}
>
<
Box
as=
"li"
listStyleType=
"none"
w=
"100%"
onClick=
{
onClick
}
>
<
Box
<
Box
{
...
styleProps
.
itemProps
}
w=
"100%"
w=
"100%"
px=
{
3
}
px=
{
3
}
py=
{
2.5
}
display=
"flex"
color=
{
isActive
?
colors
.
text
.
active
:
colors
.
text
.
default
}
bgColor=
{
isActive
?
colors
.
bg
.
active
:
colors
.
bg
.
default
}
_hover=
{
{
color
:
isActive
?
colors
.
text
.
active
:
colors
.
text
.
hover
}
}
borderRadius=
"base"
whiteSpace=
"nowrap"
aria
-
label=
{
`${ text } link group`
}
aria
-
label=
{
`${ text } link group`
}
{
...
getDefaultTransitionProps
({
transitionProperty
:
'
width
,
padding
'
})
}
>
>
<
Flex
justifyContent=
"space-between"
width=
"100%"
alignItems=
"center"
pr=
{
1
}
>
<
Flex
justifyContent=
"space-between"
width=
"100%"
alignItems=
"center"
pr=
{
1
}
>
<
HStack
spacing=
{
3
}
overflow=
"hidden"
>
<
HStack
spacing=
{
3
}
overflow=
"hidden"
>
<
Icon
as=
{
icon
}
boxSize=
"30px"
/>
<
Icon
as=
{
icon
}
boxSize=
"30px"
/>
<
Text
<
Text
variant=
"inherit"
{
...
styleProps
.
textProps
}
fontSize=
"sm"
lineHeight=
"20px"
transitionProperty=
"opacity"
transitionDuration=
"normal"
transitionTimingFunction=
"ease"
>
>
{
text
}
{
text
}
</
Text
>
</
Text
>
...
...
ui/snippets/navigation/NavigationDesktop.pw.tsx
View file @
20051052
...
@@ -80,7 +80,7 @@ test('with submenu +@desktop-xl +@dark-mode', async({ mount, page }) => {
...
@@ -80,7 +80,7 @@ test('with submenu +@desktop-xl +@dark-mode', async({ mount, page }) => {
</
TestApp
>,
</
TestApp
>,
{
hooksConfig
},
{
hooksConfig
},
);
);
await
page
.
locator
(
'
div
[aria-label="Blockchain link group"]
'
).
hover
();
await
page
.
locator
(
'
a
[aria-label="Blockchain link group"]
'
).
hover
();
await
expect
(
component
).
toHaveScreenshot
();
await
expect
(
component
).
toHaveScreenshot
();
});
});
...
...
ui/snippets/navigation/useNavLinkStyleProps.tsx
0 → 100644
View file @
20051052
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
useColors
from
'
./useColors
'
;
type
Props
=
{
isExpanded
?:
boolean
;
isCollapsed
?:
boolean
;
isActive
?:
boolean
;
px
?:
string
|
number
;
}
export
default
function
useNavLinkProps
({
isExpanded
,
isCollapsed
,
isActive
}:
Props
)
{
const
colors
=
useColors
();
return
{
itemProps
:
{
py
:
2.5
,
display
:
'
flex
'
,
color
:
isActive
?
colors
.
text
.
active
:
colors
.
text
.
default
,
bgColor
:
isActive
?
colors
.
bg
.
active
:
colors
.
bg
.
default
,
_hover
:
{
color
:
isActive
?
colors
.
text
.
active
:
colors
.
text
.
hover
},
borderRadius
:
'
base
'
,
...
getDefaultTransitionProps
({
transitionProperty
:
'
width, padding
'
}),
},
textProps
:
{
variant
:
'
inherit
'
,
fontSize
:
'
sm
'
,
lineHeight
:
'
20px
'
,
opacity
:
{
base
:
'
1
'
,
lg
:
isExpanded
?
'
1
'
:
'
0
'
,
xl
:
isCollapsed
?
'
0
'
:
'
1
'
},
transitionProperty
:
'
opacity
'
,
transitionDuration
:
'
normal
'
,
transitionTimingFunction
:
'
ease
'
,
},
};
}
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