Skip to content

Commit e166e3c

Browse files
committed
feat: replaced dark/light button with theme editor
1 parent 8f3990b commit e166e3c

File tree

4 files changed

+68
-12
lines changed

4 files changed

+68
-12
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
"name": "horizon-ui-chakra",
44
"version": "1.0.1",
55
"private": true,
6-
"dependencies": {
6+
"dependencies": {
77
"@chakra-ui/icons": "^1.1.5",
88
"@chakra-ui/react": "1.8.8",
99
"@chakra-ui/system": "^1.12.1",
1010
"@chakra-ui/theme-tools": "^1.3.6",
1111
"@emotion/cache": "^11.7.1",
1212
"@emotion/react": "^11.4.1",
1313
"@emotion/styled": "^11.3.0",
14+
"@hypertheme-editor/chakra-ui": "^0.1.5",
1415
"@testing-library/jest-dom": "^5.14.1",
1516
"@testing-library/react": "^11.2.7",
1617
"@testing-library/user-event": "^12.8.3",

src/components/navbar/NavbarLinksAdmin.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ import PropTypes from "prop-types";
2222
import React from "react";
2323
// Assets
2424
import navImage from "assets/img/layout/Navbar.png";
25-
import { MdNotificationsNone, MdInfoOutline } from "react-icons/md";
25+
import { MdNotificationsNone, MdInfoOutline, MdPalette } from "react-icons/md";
2626
import { IoMdMoon, IoMdSunny } from "react-icons/io";
2727
import { FaEthereum } from "react-icons/fa";
2828
import routes from "routes.js";
29+
import { ThemeEditor } from "./ThemeEditor";
2930
export default function HeaderLinks(props) {
3031
const { secondary } = props;
3132
const { colorMode, toggleColorMode } = useColorMode();
@@ -205,7 +206,7 @@ export default function HeaderLinks(props) {
205206
</MenuList>
206207
</Menu>
207208

208-
<Button
209+
{/* <Button
209210
variant='no-hover'
210211
bg='transparent'
211212
p='0px'
@@ -221,7 +222,10 @@ export default function HeaderLinks(props) {
221222
color={navbarIcon}
222223
as={colorMode === "light" ? IoMdMoon : IoMdSunny}
223224
/>
224-
</Button>
225+
</Button> */}
226+
227+
<ThemeEditor navbarIcon={navbarIcon} />
228+
225229
<Menu>
226230
<MenuButton p='0px'>
227231
<Avatar

src/components/navbar/ThemeEditor.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from 'react'
2+
import {
3+
ThemeEditor as ThemeEditorContainer,
4+
ThemeEditorDrawer,
5+
ThemeEditorColors,
6+
ThemeEditorFontSizes
7+
} from '@hypertheme-editor/chakra-ui'
8+
import { Button, Icon } from '@chakra-ui/react'
9+
import { CgColorPicker } from 'react-icons/cg'
10+
import { ImFontSize } from 'react-icons/im'
11+
import { MdPalette } from 'react-icons/md'
12+
13+
export function ThemeEditor(props) {
14+
return (
15+
<ThemeEditorContainer>
16+
<ThemeEditorButton {...props} />
17+
<ThemeEditorDrawer hideUpgradeToPro>
18+
<ThemeEditorColors icon={CgColorPicker} title="Colors" />
19+
<ThemeEditorFontSizes icon={ImFontSize} title="Font Sizes" />
20+
</ThemeEditorDrawer>
21+
</ThemeEditorContainer>
22+
)
23+
}
24+
25+
function ThemeEditorButton({ onOpen, navbarIcon, ...rest }) {
26+
return (
27+
<Button
28+
variant='no-hover'
29+
bg='transparent'
30+
p='0px'
31+
minW='unset'
32+
minH='unset'
33+
h='18px'
34+
w='max-content'
35+
_focus={{ boxShadow: 'none' }}
36+
onClick={onOpen}
37+
{...rest}
38+
>
39+
<Icon
40+
me='10px'
41+
h='18px'
42+
w='18px'
43+
color={navbarIcon}
44+
as={MdPalette}
45+
/>
46+
</Button>
47+
)
48+
}

src/index.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@ import AdminLayout from "layouts/admin";
77
import RTLLayout from "layouts/rtl";
88
import { ChakraProvider } from "@chakra-ui/react";
99
import theme from "theme/theme";
10+
import { ThemeEditorProvider } from "@hypertheme-editor/chakra-ui";
1011

1112
ReactDOM.render(
1213
<ChakraProvider theme={theme}>
1314
<React.StrictMode>
14-
<HashRouter>
15-
<Switch>
16-
<Route path={`/auth`} component={AuthLayout} />
17-
<Route path={`/admin`} component={AdminLayout} />
18-
<Route path={`/rtl`} component={RTLLayout} />
19-
<Redirect from='/' to='/admin' />
20-
</Switch>
21-
</HashRouter>
15+
<ThemeEditorProvider>
16+
<HashRouter>
17+
<Switch>
18+
<Route path={`/auth`} component={AuthLayout} />
19+
<Route path={`/admin`} component={AdminLayout} />
20+
<Route path={`/rtl`} component={RTLLayout} />
21+
<Redirect from='/' to='/admin' />
22+
</Switch>
23+
</HashRouter>
24+
</ThemeEditorProvider>
2225
</React.StrictMode>
2326
</ChakraProvider>,
2427
document.getElementById("root")

0 commit comments

Comments
 (0)