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
6a14a62c
Commit
6a14a62c
authored
Jul 16, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
smooth transition for Header and NavBar
parent
70921643
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
46 additions
and
17 deletions
+46
-17
Input.ts
theme/components/Input.ts
+5
-1
Link.ts
theme/components/Link.ts
+7
-1
config.ts
theme/config.ts
+1
-0
global.ts
theme/global.ts
+2
-0
getDefaultTransitionProps.ts
theme/utils/getDefaultTransitionProps.ts
+7
-0
ColorModeToggler.tsx
ui/header/ColorModeToggler.tsx
+3
-11
NavFooter.tsx
ui/navigation/NavFooter.tsx
+3
-1
Navigation.tsx
ui/navigation/Navigation.tsx
+18
-3
No files found.
theme/components/Input.ts
View file @
6a14a62c
...
@@ -3,6 +3,7 @@ import type { ComponentStyleConfig } from '@chakra-ui/theme';
...
@@ -3,6 +3,7 @@ import type { ComponentStyleConfig } from '@chakra-ui/theme';
import
type
{
PartsStyleFunction
,
SystemStyleObject
}
from
'
@chakra-ui/theme-tools
'
;
import
type
{
PartsStyleFunction
,
SystemStyleObject
}
from
'
@chakra-ui/theme-tools
'
;
import
{
getColor
,
mode
}
from
'
@chakra-ui/theme-tools
'
;
import
{
getColor
,
mode
}
from
'
@chakra-ui/theme-tools
'
;
import
getDefaultFormColors
from
'
../utils/getDefaultFormColors
'
;
import
getDefaultFormColors
from
'
../utils/getDefaultFormColors
'
;
import
getDefaultTransitionProps
from
'
../utils/getDefaultTransitionProps
'
;
const
sizes
:
Record
<
string
,
SystemStyleObject
>
=
{
const
sizes
:
Record
<
string
,
SystemStyleObject
>
=
{
md
:
{
md
:
{
...
@@ -17,13 +18,15 @@ const sizes: Record<string, SystemStyleObject> = {
...
@@ -17,13 +18,15 @@ const sizes: Record<string, SystemStyleObject> = {
const
variantOutline
:
PartsStyleFunction
<
typeof
parts
>
=
(
props
)
=>
{
const
variantOutline
:
PartsStyleFunction
<
typeof
parts
>
=
(
props
)
=>
{
const
{
theme
}
=
props
const
{
theme
}
=
props
const
{
focusColor
:
fc
,
errorColor
:
ec
}
=
getDefaultFormColors
(
props
)
const
{
focusColor
:
fc
,
errorColor
:
ec
}
=
getDefaultFormColors
(
props
);
const
transitionProps
=
getDefaultTransitionProps
();
return
{
return
{
field
:
{
field
:
{
border
:
'
2px solid
'
,
border
:
'
2px solid
'
,
bg
:
'
inherit
'
,
bg
:
'
inherit
'
,
borderColor
:
mode
(
'
gray.100
'
,
'
whiteAlpha.200
'
)(
props
),
borderColor
:
mode
(
'
gray.100
'
,
'
whiteAlpha.200
'
)(
props
),
...
transitionProps
,
_hover
:
{
_hover
:
{
borderColor
:
mode
(
'
gray.300
'
,
'
whiteAlpha.400
'
)(
props
),
borderColor
:
mode
(
'
gray.300
'
,
'
whiteAlpha.400
'
)(
props
),
},
},
...
@@ -51,6 +54,7 @@ const variantOutline: PartsStyleFunction<typeof parts> = (props) => {
...
@@ -51,6 +54,7 @@ const variantOutline: PartsStyleFunction<typeof parts> = (props) => {
border
:
'
2px solid
'
,
border
:
'
2px solid
'
,
borderColor
:
mode
(
'
gray.100
'
,
'
whiteAlpha.200
'
)(
props
),
borderColor
:
mode
(
'
gray.100
'
,
'
whiteAlpha.200
'
)(
props
),
bg
:
mode
(
'
gray.100
'
,
'
whiteAlpha.200
'
)(
props
),
bg
:
mode
(
'
gray.100
'
,
'
whiteAlpha.200
'
)(
props
),
...
transitionProps
,
},
},
}
}
}
}
...
...
theme/components/Link.ts
View file @
6a14a62c
import
type
{
ComponentStyleConfig
}
from
'
@chakra-ui/theme
'
;
import
type
{
ComponentStyleConfig
}
from
'
@chakra-ui/theme
'
;
import
{
mode
}
from
'
@chakra-ui/theme-tools
'
;
import
{
mode
}
from
'
@chakra-ui/theme-tools
'
;
import
type
{
SystemStyleFunction
}
from
'
@chakra-ui/theme-tools
'
;
import
type
{
SystemStyleFunction
,
SystemStyleInterpolation
}
from
'
@chakra-ui/theme-tools
'
;
import
getDefaultTransitionProps
from
'
../utils/getDefaultTransitionProps
'
;
const
baseStyle
:
SystemStyleInterpolation
=
{
...
getDefaultTransitionProps
(),
}
const
variantPrimary
:
SystemStyleFunction
=
(
props
)
=>
{
const
variantPrimary
:
SystemStyleFunction
=
(
props
)
=>
{
return
{
return
{
...
@@ -32,6 +37,7 @@ const defaultProps = {
...
@@ -32,6 +37,7 @@ const defaultProps = {
const
Link
:
ComponentStyleConfig
=
{
const
Link
:
ComponentStyleConfig
=
{
variants
,
variants
,
defaultProps
,
defaultProps
,
baseStyle
,
}
}
export
default
Link
;
export
default
Link
;
theme/config.ts
View file @
6a14a62c
...
@@ -3,6 +3,7 @@ import { type ThemeConfig } from '@chakra-ui/react';
...
@@ -3,6 +3,7 @@ import { type ThemeConfig } from '@chakra-ui/react';
const
config
:
ThemeConfig
=
{
const
config
:
ThemeConfig
=
{
initialColorMode
:
'
system
'
,
initialColorMode
:
'
system
'
,
useSystemColorMode
:
false
,
useSystemColorMode
:
false
,
disableTransitionOnChange
:
false
,
}
}
export
default
config
;
export
default
config
;
theme/global.ts
View file @
6a14a62c
import
type
{
StyleFunctionProps
}
from
'
@chakra-ui/theme-tools
'
;
import
type
{
StyleFunctionProps
}
from
'
@chakra-ui/theme-tools
'
;
import
{
mode
}
from
'
@chakra-ui/theme-tools
'
;
import
{
mode
}
from
'
@chakra-ui/theme-tools
'
;
import
getDefaultTransitionProps
from
'
./utils/getDefaultTransitionProps
'
;
const
global
=
(
props
:
StyleFunctionProps
)
=>
({
const
global
=
(
props
:
StyleFunctionProps
)
=>
({
body
:
{
body
:
{
bg
:
mode
(
'
white
'
,
'
black
'
)(
props
),
bg
:
mode
(
'
white
'
,
'
black
'
)(
props
),
...
getDefaultTransitionProps
(),
},
},
})
})
...
...
theme/utils/getDefaultTransitionProps.ts
0 → 100644
View file @
6a14a62c
export
default
function
getDefaultTransitionProps
()
{
return
{
transitionProperty
:
'
background-color, color, border-color
'
,
transitionDuration
:
'
normal
'
,
transitionTimingFunction
:
'
ease
'
,
}
}
ui/header/ColorModeToggler.tsx
View file @
6a14a62c
...
@@ -27,8 +27,7 @@ export interface ColorModeTogglerProps
...
@@ -27,8 +27,7 @@ export interface ColorModeTogglerProps
export
const
ColorModeToggler
=
forwardRef
<
ColorModeTogglerProps
,
'
input
'
>
((
props
,
ref
)
=>
{
export
const
ColorModeToggler
=
forwardRef
<
ColorModeTogglerProps
,
'
input
'
>
((
props
,
ref
)
=>
{
const
ownProps
=
omitThemingProps
(
props
);
const
ownProps
=
omitThemingProps
(
props
);
const
{
toggleColorMode
,
colorMode
}
=
useColorMode
();
const
{
toggleColorMode
}
=
useColorMode
();
const
[
isOn
,
setMode
]
=
React
.
useState
(
colorMode
===
'
light
'
);
const
{
const
{
state
,
state
,
...
@@ -50,16 +49,9 @@ export const ColorModeToggler = forwardRef<ColorModeTogglerProps, 'input'>((prop
...
@@ -50,16 +49,9 @@ export const ColorModeToggler = forwardRef<ColorModeTogglerProps, 'input'>((prop
transitionDuration
:
`
${
TRANSITION_DURATION
}
ms`
,
transitionDuration
:
`
${
TRANSITION_DURATION
}
ms`
,
}),
[
thumbBg
])
}),
[
thumbBg
])
const
handleInputChange
=
React
.
useCallback
(()
=>
{
// was not able to make transition while consuming flag value from chakra's useColorMode hook
// that's why there is a local state for toggler and this fancy window.setTimeout
setMode
((
isOn
)
=>
!
isOn
);
window
.
setTimeout
(
toggleColorMode
,
TRANSITION_DURATION
);
},
[
toggleColorMode
]);
return
(
return
(
<
chakra
.
label
<
chakra
.
label
{
...
getRootProps
({
onChange
:
handleInputChang
e
})
}
{
...
getRootProps
({
onChange
:
toggleColorMod
e
})
}
className=
{
styles
.
root
}
className=
{
styles
.
root
}
>
>
<
input
className=
{
styles
.
input
}
{
...
getInputProps
({},
ref
)
}
/>
<
input
className=
{
styles
.
input
}
{
...
getInputProps
({},
ref
)
}
/>
...
@@ -71,7 +63,7 @@ export const ColorModeToggler = forwardRef<ColorModeTogglerProps, 'input'>((prop
...
@@ -71,7 +63,7 @@ export const ColorModeToggler = forwardRef<ColorModeTogglerProps, 'input'>((prop
<
MoonIcon
className=
{
styles
.
nightIcon
}
boxSize=
{
4
}
color=
{
useColorModeValue
(
'
blue.600
'
,
'
white
'
)
}
/>
<
MoonIcon
className=
{
styles
.
nightIcon
}
boxSize=
{
4
}
color=
{
useColorModeValue
(
'
blue.600
'
,
'
white
'
)
}
/>
<
chakra
.
div
<
chakra
.
div
className=
{
styles
.
thumb
}
className=
{
styles
.
thumb
}
data
-
checked=
{
dataAttr
(
isOn
)
}
data
-
checked=
{
dataAttr
(
state
.
isChecked
)
}
data
-
hover=
{
dataAttr
(
state
.
isHovered
)
}
data
-
hover=
{
dataAttr
(
state
.
isHovered
)
}
__css=
{
thumbStyles
}
__css=
{
thumbStyles
}
/>
/>
...
...
ui/navigation/NavFooter.tsx
View file @
6a14a62c
...
@@ -6,6 +6,7 @@ import ghIcon from '../../icons/social/git.svg';
...
@@ -6,6 +6,7 @@ import ghIcon from '../../icons/social/git.svg';
import
twIcon
from
'
../../icons/social/tweet.svg
'
;
import
twIcon
from
'
../../icons/social/tweet.svg
'
;
import
tgIcon
from
'
../../icons/social/telega.svg
'
;
import
tgIcon
from
'
../../icons/social/telega.svg
'
;
import
statsIcon
from
'
../../icons/social/stats.svg
'
;
import
statsIcon
from
'
../../icons/social/stats.svg
'
;
import
getDefaultTransitionProps
from
'
../../theme/utils/getDefaultTransitionProps
'
;
const
SOCIAL_LINKS
=
[
const
SOCIAL_LINKS
=
[
{
link
:
'
#gh
'
,
icon
:
ghIcon
},
{
link
:
'
#gh
'
,
icon
:
ghIcon
},
...
@@ -20,12 +21,13 @@ const NavFooter = () => {
...
@@ -20,12 +21,13 @@ const NavFooter = () => {
as=
"footer"
as=
"footer"
spacing=
{
8
}
spacing=
{
8
}
borderTop=
"1px solid"
borderTop=
"1px solid"
borderColor=
{
useColorModeValue
(
'
gray
.200
'
,
'
whiteAlpha.200
'
)
}
borderColor=
{
useColorModeValue
(
'
blackAlpha
.200
'
,
'
whiteAlpha.200
'
)
}
paddingTop=
{
8
}
paddingTop=
{
8
}
w=
"100%"
w=
"100%"
alignItems=
"baseline"
alignItems=
"baseline"
color=
"gray.500"
color=
"gray.500"
fontSize=
"xs"
fontSize=
"xs"
{
...
getDefaultTransitionProps
()
}
>
>
<
HStack
>
<
HStack
>
{
SOCIAL_LINKS
.
map
(
sl
=>
{
{
SOCIAL_LINKS
.
map
(
sl
=>
{
...
...
ui/navigation/Navigation.tsx
View file @
6a14a62c
...
@@ -8,20 +8,35 @@ import NavFooter from './NavFooter'
...
@@ -8,20 +8,35 @@ import NavFooter from './NavFooter'
import
logoIcon
from
'
../../icons/logo.svg
'
;
import
logoIcon
from
'
../../icons/logo.svg
'
;
import
networksIcon
from
'
../../icons/networks.svg
'
;
import
networksIcon
from
'
../../icons/networks.svg
'
;
import
getDefaultTransitionProps
from
'
../../theme/utils/getDefaultTransitionProps
'
;
const
Navigation
=
()
=>
{
const
Navigation
=
()
=>
{
return
(
return
(
<
VStack
<
VStack
alignItems=
"flex-start"
alignItems=
"flex-start"
spacing=
{
12
}
spacing=
{
12
}
borderRight=
"1px solid"
borderRight=
"1px solid"
borderColor=
{
useColorModeValue
(
'
gray
.200
'
,
'
whiteAlpha.200
'
)
}
borderColor=
{
useColorModeValue
(
'
blackAlpha
.200
'
,
'
whiteAlpha.200
'
)
}
px=
{
10
}
px=
{
10
}
py=
{
12
}
py=
{
12
}
width=
"300px"
width=
"300px"
{
...
getDefaultTransitionProps
()
}
>
>
<
HStack
as=
"header"
justifyContent=
"space-between"
w=
"100%"
px=
{
4
}
mb=
{
2
}
h=
{
10
}
alignItems=
"center"
>
<
HStack
as=
"header"
justifyContent=
"space-between"
w=
"100%"
px=
{
4
}
mb=
{
2
}
h=
{
10
}
alignItems=
"center"
>
<
Icon
as=
{
logoIcon
}
width=
"142px"
height=
"26px"
color=
{
useColorModeValue
(
'
blue.600
'
,
'
white
'
)
}
/>
<
Icon
<
Icon
as=
{
networksIcon
}
width=
"20px"
height=
"20px"
color=
{
useColorModeValue
(
'
gray.500
'
,
'
white
'
)
}
/>
as=
{
logoIcon
}
width=
"142px"
height=
"26px"
color=
{
useColorModeValue
(
'
blue.600
'
,
'
white
'
)
}
{
...
getDefaultTransitionProps
()
}
/>
<
Icon
as=
{
networksIcon
}
width=
"20px"
height=
"20px"
color=
{
useColorModeValue
(
'
gray.500
'
,
'
white
'
)
}
{
...
getDefaultTransitionProps
()
}
/>
</
HStack
>
</
HStack
>
<
MainNavigation
/>
<
MainNavigation
/>
<
AccountNavigation
/>
<
AccountNavigation
/>
...
...
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