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
2867abd1
Unverified
Commit
2867abd1
authored
Jul 12, 2022
by
N
Committed by
GitHub
Jul 12, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #44 from blockscout/dark-theme-2
dark mode: part 2
parents
dcc3e4f0
0e286a6c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
147 additions
and
15 deletions
+147
-15
Table.ts
theme/components/Table.ts
+1
-1
Tag.ts
theme/components/Tag.ts
+17
-8
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
useColors.ts
ui/navigation/useColors.ts
+2
-2
No files found.
theme/components/Table.ts
View file @
2867abd1
...
@@ -10,7 +10,7 @@ const variantSimple: PartsStyleFunction<typeof parts> = (props) => {
...
@@ -10,7 +10,7 @@ const variantSimple: PartsStyleFunction<typeof parts> = (props) => {
color
:
mode
(
'
gray.500
'
,
'
gray.50
'
)(
props
),
color
:
mode
(
'
gray.500
'
,
'
gray.50
'
)(
props
),
},
},
thead
:
{
thead
:
{
backgroundColor
:
mode
(
'
gray.50
'
,
'
whiteAlpha.
1
00
'
)(
props
),
backgroundColor
:
mode
(
'
gray.50
'
,
'
whiteAlpha.
2
00
'
)(
props
),
},
},
td
:
{
td
:
{
borderColor
:
mode
(
'
gray.200
'
,
'
whiteAlpha.200
'
)(
props
),
borderColor
:
mode
(
'
gray.200
'
,
'
whiteAlpha.200
'
)(
props
),
...
...
theme/components/Tag.ts
View file @
2867abd1
import
type
{
tagAnatomy
as
parts
}
from
'
@chakra-ui/anatomy
'
;
import
type
{
ComponentStyleConfig
}
from
'
@chakra-ui/theme
'
;
import
type
{
ComponentStyleConfig
}
from
'
@chakra-ui/theme
'
;
import
{
mode
}
from
'
@chakra-ui/theme-tools
'
;
import
type
{
PartsStyleFunction
}
from
'
@chakra-ui/theme-tools
'
;
const
variantGray
:
PartsStyleFunction
<
typeof
parts
>
=
(
props
)
=>
{
return
{
container
:
{
bg
:
mode
(
'
gray.200
'
,
'
gray.600
'
)(
props
),
color
:
mode
(
'
gray.600
'
,
'
gray.50
'
)(
props
),
},
}
}
const
variants
=
{
gray
:
variantGray
,
}
const
Tag
:
ComponentStyleConfig
=
{
const
Tag
:
ComponentStyleConfig
=
{
baseStyle
:
{
baseStyle
:
{
...
@@ -9,14 +25,7 @@ const Tag: ComponentStyleConfig = {
...
@@ -9,14 +25,7 @@ const Tag: ComponentStyleConfig = {
borderRadius
:
'
md
'
,
borderRadius
:
'
md
'
,
},
},
},
},
variants
:
{
variants
,
gray
:
{
container
:
{
bg
:
'
gray.200
'
,
color
:
'
gray.600
'
,
},
},
},
}
}
export
default
Tag
;
export
default
Tag
;
ui/header/ColorModeToggler.module.css
0 → 100644
View file @
2867abd1
.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 @
2867abd1
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 @
2867abd1
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
}
/>
...
...
ui/navigation/useColors.ts
View file @
2867abd1
...
@@ -5,11 +5,11 @@ export default function useColors() {
...
@@ -5,11 +5,11 @@ export default function useColors() {
text
:
{
text
:
{
'
default
'
:
useColorModeValue
(
'
gray.600
'
,
'
gray.300
'
),
'
default
'
:
useColorModeValue
(
'
gray.600
'
,
'
gray.300
'
),
active
:
useColorModeValue
(
'
blue.700
'
,
'
gray.300
'
),
active
:
useColorModeValue
(
'
blue.700
'
,
'
gray.300
'
),
hover
:
useColorModeValue
(
'
blue.400
'
,
'
gray.100
'
)
,
hover
:
'
blue.400
'
,
},
},
bg
:
{
bg
:
{
'
default
'
:
'
transparent
'
,
'
default
'
:
'
transparent
'
,
active
:
useColorModeValue
(
'
blue.50
'
,
'
gray.9
00
'
),
active
:
useColorModeValue
(
'
blue.50
'
,
'
whiteAlpha.2
00
'
),
},
},
}
}
}
}
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