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
b873c929
Commit
b873c929
authored
Jul 16, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tags, table and toggler
parent
6a14a62c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
8 deletions
+29
-8
Table.ts
theme/components/Table.ts
+6
-0
Tag.ts
theme/components/Tag.ts
+4
-0
ColorModeToggler.tsx
ui/header/ColorModeToggler.tsx
+19
-8
No files found.
theme/components/Table.ts
View file @
b873c929
...
...
@@ -2,18 +2,24 @@ import type { tableAnatomy as parts } from '@chakra-ui/anatomy';
import
type
{
ComponentMultiStyleConfig
}
from
'
@chakra-ui/theme
'
;
import
{
mode
}
from
'
@chakra-ui/theme-tools
'
;
import
type
{
PartsStyleFunction
}
from
'
@chakra-ui/theme-tools
'
;
import
getDefaultTransitionProps
from
'
../utils/getDefaultTransitionProps
'
;
const
variantSimple
:
PartsStyleFunction
<
typeof
parts
>
=
(
props
)
=>
{
const
transitionProps
=
getDefaultTransitionProps
();
return
{
th
:
{
border
:
0
,
color
:
mode
(
'
gray.500
'
,
'
gray.50
'
)(
props
),
...
transitionProps
,
},
thead
:
{
backgroundColor
:
mode
(
'
gray.50
'
,
'
whiteAlpha.200
'
)(
props
),
...
transitionProps
,
},
td
:
{
borderColor
:
mode
(
'
gray.200
'
,
'
whiteAlpha.200
'
)(
props
),
...
transitionProps
,
},
}
}
...
...
theme/components/Tag.ts
View file @
b873c929
...
...
@@ -2,12 +2,16 @@ import type { tagAnatomy as parts } from '@chakra-ui/anatomy';
import
type
{
ComponentStyleConfig
}
from
'
@chakra-ui/theme
'
;
import
{
mode
}
from
'
@chakra-ui/theme-tools
'
;
import
type
{
PartsStyleFunction
}
from
'
@chakra-ui/theme-tools
'
;
import
getDefaultTransitionProps
from
'
../utils/getDefaultTransitionProps
'
;
const
variantGray
:
PartsStyleFunction
<
typeof
parts
>
=
(
props
)
=>
{
const
transitionProps
=
getDefaultTransitionProps
();
return
{
container
:
{
bg
:
mode
(
'
gray.200
'
,
'
gray.600
'
)(
props
),
color
:
mode
(
'
gray.600
'
,
'
gray.50
'
)(
props
),
...
transitionProps
,
},
}
}
...
...
ui/header/ColorModeToggler.tsx
View file @
b873c929
...
...
@@ -14,11 +14,10 @@ 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
getDefaultTransitionProps
from
'
../../theme/utils/getDefaultTransitionProps
'
;
import
styles
from
'
./ColorModeToggler.module.css
'
;
const
TRANSITION_DURATION
=
150
;
export
interface
ColorModeTogglerProps
extends
Omit
<
UseCheckboxProps
,
'
isIndeterminate
'
>
,
Omit
<
HTMLChakraProps
<
'
label
'
>
,
keyof
UseCheckboxProps
>
,
...
...
@@ -38,16 +37,18 @@ export const ColorModeToggler = forwardRef<ColorModeTogglerProps, 'input'>((prop
const
trackBg
=
useColorModeValue
(
'
blackAlpha.100
'
,
'
whiteAlpha.200
'
)
const
thumbBg
=
useColorModeValue
(
'
white
'
,
'
black
'
)
const
transitionProps
=
getDefaultTransitionProps
();
const
trackStyles
:
SystemStyleObject
=
React
.
useMemo
(()
=>
({
bg
:
trackBg
,
}),
[
trackBg
])
...
transitionProps
,
}),
[
trackBg
,
transitionProps
])
const
thumbStyles
:
SystemStyleObject
=
React
.
useMemo
(()
=>
({
bg
:
thumbBg
,
transitionProperty
:
'
transform
'
,
transition
Duration
:
`
${
TRANSITION_DURATION
}
ms`
,
}),
[
thumbBg
])
...
transitionProps
,
transition
Property
:
'
background-color, transform
'
,
}),
[
thumbBg
,
transitionProps
])
return
(
<
chakra
.
label
...
...
@@ -60,14 +61,24 @@ export const ColorModeToggler = forwardRef<ColorModeTogglerProps, 'input'>((prop
className=
{
styles
.
track
}
__css=
{
trackStyles
}
>
<
MoonIcon
className=
{
styles
.
nightIcon
}
boxSize=
{
4
}
color=
{
useColorModeValue
(
'
blue.600
'
,
'
white
'
)
}
/>
<
MoonIcon
className=
{
styles
.
nightIcon
}
boxSize=
{
4
}
color=
{
useColorModeValue
(
'
blue.600
'
,
'
white
'
)
}
{
...
transitionProps
}
/>
<
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
'
)
}
/>
<
SunIcon
className=
{
styles
.
dayIcon
}
boxSize=
{
4
}
color=
{
useColorModeValue
(
'
gray.500
'
,
'
blue.600
'
)
}
{
...
transitionProps
}
/>
</
chakra
.
div
>
</
chakra
.
label
>
)
...
...
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