Skip to content

Commit bb5b9b0

Browse files
author
Microsoft Learn Student
committed
installed chakra ui themes
1 parent dfbe985 commit bb5b9b0

File tree

5 files changed

+1243
-25
lines changed

5 files changed

+1243
-25
lines changed

README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,112 @@
1+
Implementing Dark Theme Toggle
12

3+
A. Styles File to hold an obejct of the colors and associated DOM elements to toggle with the switcher
4+
5+
B. An action to dispatch the toggle, in other words tell the store that we should switch the color mode
6+
7+
C. A reducer to toggle the color object from the styles file
8+
9+
I chose to install chakra ui with the following command
10+
11+
```zsh
12+
npm i @chakra-ui/react @emotion/react@^11 @emotion/styled@^11 framer-motion@^4
13+
```
14+
15+
The output gave me 3 warnings to address
16+
17+
1.
18+
```zsh
19+
npm WARN @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.13.12 requires a peer of @babel/core@^7.13.0 but none is installed. You must install peer dependencies yourself.
20+
```
21+
2.
22+
```zsh
23+
npm WARN @babel/plugin-proposal-class-static-block@7.14.3 requires a peer of @babel/core@^7.12.0 but none is installed. You must install peer dependencies yourself.
24+
```
25+
3.
26+
```zsh
27+
npm WARN tsutils@3.21.0 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
28+
```
29+
Although the package was installed...
30+
31+
```zsh
32+
+ @emotion/styled@11.3.0
33+
+ @emotion/react@11.4.0
34+
+ framer-motion@4.1.17
35+
+ @chakra-ui/react@1.6.3
36+
added 112 packages from 77 contributors and audited 1754 packages in 12.856s
37+
```
38+
39+
... to avoid future complications, I installed the peer dependencies referenced by the warnings.
40+
41+
- @babel/core@^7.12.0
42+
- @babel/core@^7.13.0
43+
[@babel/core@7.14.3](https://www.npmjs.com/package/@babel/core?activeTab=versions)
44+
45+
- typescript@>=2.8.0 and up
46+
[typescript@>=4.3.2](https://www.npmjs.com/package/typescript)
47+
48+
49+
```zsh
50+
npm i @babel/core
51+
```
52+
53+
```zsh
54+
npm i typescript
55+
```
56+
57+
With no more warnings, I could move on to the next step in the documentation.
58+
59+
Setting up the <code>ChakraProvider</code> in the application's root, index.js for create-react-app installations.
60+
61+
1. add import statement
62+
```JSX
63+
import { ChakraProvider, extendTheme } from '@chakra-ui/react';
64+
```
65+
66+
2. define theme
67+
```JSX
68+
const theme = extendTheme({
69+
styles: {
70+
global: {
71+
'html, body': { 'rgb(26,32,44)',
72+
},
73+
},
74+
},
75+
);
76+
```
77+
3. Wrap <code><TodoApp/></code> Component with <code><ChakraProvider></code> wrapper
78+
79+
```JSX
80+
const rootElement = document.getElementById('root')
81+
82+
ReactDOM.render(
83+
<React.StrictMode>
84+
<Provider store={store}>
85+
<ChakraProvider theme = {theme}>
86+
<TodoApp/>
87+
</ChakraProvider>
88+
</Provider>
89+
</React.StrictMode>,
90+
rootElement
91+
);
92+
```
93+
94+
To install Chakra UI icons enter the following command in the terminal at the project's root directory.
95+
96+
```ZSH
97+
npm i @chakra-ui/icons
98+
```
99+
100+
101+
[Chakra-UI > Getting Started](https://chakra-ui.com/docs/getting-started)
102+
103+
[Chakra-UI > Color Mode](https://chakra-ui.com/docs/features/color-mode)
104+
105+
[Dark Mode with React.js & Redux](https://medium.com/@herrerac11/dark-mode-with-react-js-redux-d30680e98de)
106+
107+
[Up & Running with React, Redux Toolkit, Typescript and React Router](https://ogzhanolguncu.com/blog/react-redux-toolkit-with-typescript)
108+
109+
Do I store Image assets in public or src in reactJS?
2110
3111
**WARNING MESSAGE**
4112
"SharedArrayBuffers (SABs) can be used to construct high-resolution timers. High-resolution timers simplify Spectre attacks on cross-origin resources.

0 commit comments

Comments
 (0)