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
70e9b9b7
Commit
70e9b9b7
authored
Jan 07, 2025
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add color mode switcher
parent
111d09e2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
6 deletions
+65
-6
switch.tsx
chakra/components/switch.tsx
+39
-0
semanticTokens.ts
chakra/theme/foundations/semanticTokens.ts
+12
-0
globalCss.ts
chakra/theme/globalCss.ts
+5
-5
scrollbar.ts
chakra/theme/globals/scrollbar.ts
+0
-0
chakra.tsx
pages/chakra.tsx
+2
-1
Chakra.tsx
ui/pages/Chakra.tsx
+7
-0
No files found.
chakra/components/switch.tsx
0 → 100644
View file @
70e9b9b7
import
{
Switch
as
ChakraSwitch
}
from
'
@chakra-ui/react
'
;
import
*
as
React
from
'
react
'
;
export
interface
SwitchProps
extends
ChakraSwitch
.
RootProps
{
inputProps
?:
React
.
InputHTMLAttributes
<
HTMLInputElement
>
;
rootRef
?:
React
.
Ref
<
HTMLLabelElement
>
;
trackLabel
?:
{
on
:
React
.
ReactNode
;
off
:
React
.
ReactNode
};
thumbLabel
?:
{
on
:
React
.
ReactNode
;
off
:
React
.
ReactNode
};
}
export
const
Switch
=
React
.
forwardRef
<
HTMLInputElement
,
SwitchProps
>
(
function
Switch
(
props
,
ref
)
{
const
{
inputProps
,
children
,
rootRef
,
trackLabel
,
thumbLabel
,
...
rest
}
=
props
;
return
(
<
ChakraSwitch
.
Root
ref=
{
rootRef
}
{
...
rest
}
>
<
ChakraSwitch
.
HiddenInput
ref=
{
ref
}
{
...
inputProps
}
/>
<
ChakraSwitch
.
Control
>
<
ChakraSwitch
.
Thumb
>
{
thumbLabel
&&
(
<
ChakraSwitch
.
ThumbIndicator
fallback=
{
thumbLabel
?.
off
}
>
{
thumbLabel
?.
on
}
</
ChakraSwitch
.
ThumbIndicator
>
)
}
</
ChakraSwitch
.
Thumb
>
{
trackLabel
&&
(
<
ChakraSwitch
.
Indicator
fallback=
{
trackLabel
.
off
}
>
{
trackLabel
.
on
}
</
ChakraSwitch
.
Indicator
>
)
}
</
ChakraSwitch
.
Control
>
{
children
!=
null
&&
(
<
ChakraSwitch
.
Label
>
{
children
}
</
ChakraSwitch
.
Label
>
)
}
</
ChakraSwitch
.
Root
>
);
},
);
chakra/theme/foundations/semanticTokens.ts
View file @
70e9b9b7
...
@@ -27,6 +27,18 @@ const semanticTokens: ThemingConfig['semanticTokens'] = {
...
@@ -27,6 +27,18 @@ const semanticTokens: ThemingConfig['semanticTokens'] = {
},
},
},
},
},
},
globals
:
{
body
:
{
bg
:
{
DEFAULT
:
{
value
:
{
base
:
'
{colors.white}
'
,
_dark
:
'
{colors.black}
'
}
},
},
},
mark
:
{
bg
:
{
DEFAULT
:
{
value
:
{
base
:
'
{colors.green.100}
'
,
_dark
:
'
{colors.green.800}
'
}
},
},
},
},
// OLD TOKENS
// OLD TOKENS
divider
:
{
divider
:
{
...
...
chakra/theme/globalCss.ts
View file @
70e9b9b7
import
type
{
StyleFunctionProps
,
SystemStyleObject
}
from
'
@chakra-ui/theme-tools
'
;
import
type
{
StyleFunctionProps
,
SystemStyleObject
}
from
'
@chakra-ui/theme-tools
'
;
import
{
mode
}
from
'
@chakra-ui/theme-tools
'
;
import
{
mode
}
from
'
@chakra-ui/theme-tools
'
;
import
scrollbar
from
'
./foundations/scrollbar
'
;
// TODO @tom2drum check address highlight feature
import
addressEntity
from
'
./globals/address-entity
'
;
import
addressEntity
from
'
./globals/address-entity
'
;
import
recaptcha
from
'
./globals/recaptcha
'
;
import
recaptcha
from
'
./globals/recaptcha
'
;
// import getDefaultTransitionProps from './utils/getDefaultTransitionProps';
// TODO @tom2drum check custom scrollbar colors
import
scrollbar
from
'
./globals/scrollbar
'
;
const
globalCss
:
Record
<
string
,
SystemStyleObject
>
=
{
const
globalCss
:
Record
<
string
,
SystemStyleObject
>
=
{
body
:
{
body
:
{
// bg: mode('white', 'black')(props),
bg
:
'
globals.body.bg
'
,
// ...getDefaultTransitionProps(),
'
-webkit-tap-highlight-color
'
:
'
transparent
'
,
'
-webkit-tap-highlight-color
'
:
'
transparent
'
,
'
font-variant-ligatures
'
:
'
no-contextual
'
,
'
font-variant-ligatures
'
:
'
no-contextual
'
,
},
},
mark
:
{
mark
:
{
// bgColor: mode('green.100', 'green.800')(props)
,
bg
:
'
globals.mark.bg
'
,
color
:
'
inherit
'
,
color
:
'
inherit
'
,
},
},
'
svg *::selection
'
:
{
'
svg *::selection
'
:
{
...
...
chakra/theme/
foundation
s/scrollbar.ts
→
chakra/theme/
global
s/scrollbar.ts
View file @
70e9b9b7
File moved
pages/chakra.tsx
View file @
70e9b9b7
import
type
{
NextPage
}
from
'
next
'
;
import
type
{
NextPage
}
from
'
next
'
;
import
dynamic
from
'
next/dynamic
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
PageNextJs
from
'
nextjs/PageNextJs
'
;
import
PageNextJs
from
'
nextjs/PageNextJs
'
;
import
Chakra
from
'
ui/pages/Chakra
'
;
const
Chakra
=
dynamic
(()
=>
import
(
'
ui/pages/Chakra
'
),
{
ssr
:
false
})
;
const
Page
:
NextPage
=
()
=>
{
const
Page
:
NextPage
=
()
=>
{
return
(
return
(
...
...
ui/pages/Chakra.tsx
View file @
70e9b9b7
...
@@ -2,12 +2,19 @@ import { Heading, HStack } from '@chakra-ui/react';
...
@@ -2,12 +2,19 @@ import { Heading, HStack } from '@chakra-ui/react';
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
Button
}
from
'
chakra/components/button
'
;
import
{
Button
}
from
'
chakra/components/button
'
;
import
{
useColorMode
}
from
'
chakra/components/color-mode
'
;
import
{
Switch
}
from
'
chakra/components/switch
'
;
import
PageTitle
from
'
ui/shared/Page/PageTitle
'
;
import
PageTitle
from
'
ui/shared/Page/PageTitle
'
;
const
ChakraShowcases
=
()
=>
{
const
ChakraShowcases
=
()
=>
{
const
colorMode
=
useColorMode
();
return
(
return
(
<>
<>
<
PageTitle
title=
"Chakra UI Showcase"
/>
<
PageTitle
title=
"Chakra UI Showcase"
/>
<
Switch
onCheckedChange=
{
colorMode
.
toggleColorMode
}
checked=
{
colorMode
.
colorMode
===
'
dark
'
}
mb=
{
4
}
>
Color mode:
{
colorMode
.
colorMode
}
</
Switch
>
<
Heading
textStyle=
"heading.md"
mb=
{
4
}
>
Buttons
</
Heading
>
<
Heading
textStyle=
"heading.md"
mb=
{
4
}
>
Buttons
</
Heading
>
<
HStack
gap=
{
4
}
>
<
HStack
gap=
{
4
}
>
<
Button
>
Solid
</
Button
>
<
Button
>
Solid
</
Button
>
...
...
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