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
0e286a6c
Commit
0e286a6c
authored
Jul 11, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basic toggler
parent
992ed6f2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
127 additions
and
4 deletions
+127
-4
ColorModeToggler.module.css
ui/header/ColorModeToggler.module.css
+53
-0
ColorModeToggler.tsx
ui/header/ColorModeToggler.tsx
+71
-0
Header.tsx
ui/header/Header.tsx
+3
-4
No files found.
ui/header/ColorModeToggler.module.css
0 → 100644
View file @
0e286a6c
.root
{
display
:
inline-block
;
position
:
relative
;
vertical-align
:
middle
;
line-height
:
0
;
}
.track
{
width
:
72px
;
height
:
32px
;
background-color
:
rgba
(
16
,
17
,
18
,
0.06
);
border-radius
:
16px
;
display
:
inline-flex
;
flex-shrink
:
0
;
justify-content
:
space-between
;
box-sizing
:
content-box
;
cursor
:
pointer
;
}
.input
{
border
:
0px
;
clip
:
rect
(
0px
,
0px
,
0px
,
0px
);
height
:
1px
;
width
:
1px
;
margin
:
-1px
;
padding
:
0px
;
overflow
:
hidden
;
white-space
:
nowrap
;
position
:
absolute
;
}
.thumb
{
box-shadow
:
0px
4px
8px
rgba
(
0
,
0
,
0
,
0.1
);
width
:
24px
;
height
:
24px
;
border-radius
:
12px
;
position
:
absolute
;
transform
:
translate
(
44px
,
4px
);
}
.thumb
[
data-checked
]
{
transform
:
translate
(
4px
,
4px
);
}
.nightIcon
{
margin
:
8px
;
z-index
:
5
;
}
.dayIcon
{
margin
:
8px
;
z-index
:
5
;
}
\ No newline at end of file
ui/header/ColorModeToggler.tsx
0 → 100644
View file @
0e286a6c
import
type
{
UseCheckboxProps
}
from
'
@chakra-ui/checkbox
'
;
import
{
useCheckbox
}
from
'
@chakra-ui/checkbox
'
import
type
{
SystemStyleObject
,
ThemingProps
,
HTMLChakraProps
,
}
from
'
@chakra-ui/system
'
;
import
{
chakra
,
forwardRef
,
omitThemingProps
,
}
from
'
@chakra-ui/system
'
import
{
dataAttr
,
__DEV__
}
from
'
@chakra-ui/utils
'
import
*
as
React
from
'
react
'
import
{
SunIcon
,
MoonIcon
}
from
'
@chakra-ui/icons
'
import
{
useColorMode
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
styles
from
'
./ColorModeToggler.module.css
'
;
export
interface
ColorModeTogglerProps
extends
Omit
<
UseCheckboxProps
,
'
isIndeterminate
'
>
,
Omit
<
HTMLChakraProps
<
'
label
'
>
,
keyof
UseCheckboxProps
>
,
ThemingProps
<
'
Switch
'
>
{
}
export
const
ColorModeToggler
=
forwardRef
<
ColorModeTogglerProps
,
'
input
'
>
((
props
,
ref
)
=>
{
const
ownProps
=
omitThemingProps
(
props
);
const
{
toggleColorMode
}
=
useColorMode
();
const
{
state
,
getInputProps
,
getCheckboxProps
,
getRootProps
,
}
=
useCheckbox
(
ownProps
);
const
trackStyles
:
SystemStyleObject
=
{
bg
:
useColorModeValue
(
'
blackAlpha.100
'
,
'
whiteAlpha.200
'
),
}
const
thumbStyles
:
SystemStyleObject
=
{
bg
:
useColorModeValue
(
'
white
'
,
'
black
'
),
}
return
(
<
chakra
.
label
{
...
getRootProps
({
onChange
:
toggleColorMode
})
}
className=
{
styles
.
root
}
>
<
input
className=
{
styles
.
input
}
{
...
getInputProps
({},
ref
)
}
/>
<
chakra
.
div
{
...
getCheckboxProps
()
}
className=
{
styles
.
track
}
__css=
{
trackStyles
}
>
<
MoonIcon
className=
{
styles
.
nightIcon
}
boxSize=
{
4
}
color=
{
useColorModeValue
(
'
blue.600
'
,
'
white
'
)
}
/>
<
chakra
.
div
className=
{
styles
.
thumb
}
data
-
checked=
{
dataAttr
(
state
.
isChecked
)
}
data
-
hover=
{
dataAttr
(
state
.
isHovered
)
}
__css=
{
thumbStyles
}
/>
<
SunIcon
className=
{
styles
.
dayIcon
}
boxSize=
{
4
}
color=
{
useColorModeValue
(
'
gray.500
'
,
'
blue.600
'
)
}
/>
</
chakra
.
div
>
</
chakra
.
label
>
)
})
if
(
__DEV__
)
{
ColorModeToggler
.
displayName
=
'
ColorModeToggler
'
}
ui/header/Header.tsx
View file @
0e286a6c
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
HStack
,
InputGroup
,
Input
,
InputLeftAddon
,
InputLeftElement
,
Center
,
Switch
,
useColorMode
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
HStack
,
InputGroup
,
Input
,
InputLeftAddon
,
InputLeftElement
,
Center
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
SearchIcon
}
from
'
@chakra-ui/icons
'
import
{
SearchIcon
}
from
'
@chakra-ui/icons
'
import
Identicon
from
'
react-identicons
'
;
import
Identicon
from
'
react-identicons
'
;
import
{
ColorModeToggler
}
from
'
./ColorModeToggler
'
;
import
styles
from
'
./Header.module.css
'
;
import
styles
from
'
./Header.module.css
'
;
const
Header
=
()
=>
{
const
Header
=
()
=>
{
const
{
toggleColorMode
}
=
useColorMode
();
return
(
return
(
<
HStack
<
HStack
as=
"header"
as=
"header"
...
@@ -25,7 +24,7 @@ const Header = () => {
...
@@ -25,7 +24,7 @@ const Header = () => {
</
InputLeftElement
>
</
InputLeftElement
>
<
Input
paddingInlineStart=
"50px"
placeholder=
"Search by addresses / transactions /block/ token ... "
/>
<
Input
paddingInlineStart=
"50px"
placeholder=
"Search by addresses / transactions /block/ token ... "
/>
</
InputGroup
>
</
InputGroup
>
<
Switch
size=
"lg"
onChange=
{
toggleColorMode
}
/>
<
ColorModeToggler
/>
<
Center
minWidth=
"50px"
width=
"50px"
height=
"50px"
bg=
{
useColorModeValue
(
'
blackAlpha.100
'
,
'
white
'
)
}
borderRadius=
"50%"
overflow=
"hidden"
>
<
Center
minWidth=
"50px"
width=
"50px"
height=
"50px"
bg=
{
useColorModeValue
(
'
blackAlpha.100
'
,
'
white
'
)
}
borderRadius=
"50%"
overflow=
"hidden"
>
{
/* the displayed size is 40px, but we need to generate x2 for retina displays */
}
{
/* the displayed size is 40px, but we need to generate x2 for retina displays */
}
<
Identicon
className=
{
styles
.
identicon
}
string=
"randomness"
size=
{
80
}
/>
<
Identicon
className=
{
styles
.
identicon
}
string=
"randomness"
size=
{
80
}
/>
...
...
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