Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 8eb3fda

Browse files
dark-mode-toggle #38
1 parent d768de7 commit 8eb3fda

File tree

12 files changed

+27065
-1
lines changed

12 files changed

+27065
-1
lines changed

dark-mode-react-web-app-project/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
![under_construction](https://user-images.githubusercontent.com/37651620/93677983-a7942e00-facc-11ea-8b6d-b57e73dc73bf.png)
1+
![light_mode](https://user-images.githubusercontent.com/37651620/94393048-c43dff00-0179-11eb-9181-31e24e54ab8b.png)
2+
![dark_mode](https://user-images.githubusercontent.com/37651620/94393067-cef89400-0179-11eb-8488-fe54d93901b9.png)
3+
4+
## It's Live 🎉 Visit here ==> https://dark-mode-switcher.netlify.app/
5+
6+
---
27

38
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
49

dark-mode-react-web-app-project/package-lock.json

Lines changed: 15996 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "dark-mode-react-web-app-project",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@material-ui/core": "^4.11.0",
7+
"@testing-library/jest-dom": "^4.2.4",
8+
"@testing-library/react": "^9.3.2",
9+
"@testing-library/user-event": "^7.1.2",
10+
"react": "^16.13.1",
11+
"react-dom": "^16.13.1",
12+
"react-scripts": "3.4.3"
13+
},
14+
"scripts": {
15+
"start": "react-scripts start",
16+
"build": "react-scripts build",
17+
"test": "react-scripts test",
18+
"eject": "react-scripts eject"
19+
},
20+
"eslintConfig": {
21+
"extends": "react-app"
22+
},
23+
"browserslist": {
24+
"production": [
25+
">0.2%",
26+
"not dead",
27+
"not op_mini all"
28+
],
29+
"development": [
30+
"last 1 chrome version",
31+
"last 1 firefox version",
32+
"last 1 safari version"
33+
]
34+
}
35+
}
Binary file not shown.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
<meta
9+
name="description"
10+
content="Web site created using create-react-app"
11+
/>
12+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
14+
<title>🌚 Dark Mode ☀️</title>
15+
</head>
16+
<body>
17+
<noscript>You need to enable JavaScript to run this app.</noscript>
18+
<div id="root"></div>
19+
</body>
20+
</html>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
},
10+
{
11+
"src": "logo192.png",
12+
"type": "image/png",
13+
"sizes": "192x192"
14+
},
15+
{
16+
"src": "logo512.png",
17+
"type": "image/png",
18+
"sizes": "512x512"
19+
}
20+
],
21+
"start_url": ".",
22+
"display": "standalone",
23+
"theme_color": "#000000",
24+
"background_color": "#ffffff"
25+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://www.robotstxt.org/robotstxt.html
2+
User-agent: *
3+
Disallow:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.App {
2+
text-align: center;
3+
}
4+
5+
.App-logo {
6+
height: 40vmin;
7+
pointer-events: none;
8+
}
9+
10+
@media (prefers-reduced-motion: no-preference) {
11+
.App-logo {
12+
animation: App-logo-spin infinite 20s linear;
13+
}
14+
}
15+
16+
.App-header {
17+
background-color: #282c34;
18+
min-height: 100vh;
19+
display: flex;
20+
flex-direction: column;
21+
align-items: center;
22+
justify-content: center;
23+
font-size: calc(10px + 2vmin);
24+
color: white;
25+
}
26+
27+
.App-link {
28+
color: #61dafb;
29+
}
30+
31+
@keyframes App-logo-spin {
32+
from {
33+
transform: rotate(0deg);
34+
}
35+
to {
36+
transform: rotate(360deg);
37+
}
38+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React, { useState } from "react";
2+
import { Button, Switch, Grid, Typography, Paper } from "@material-ui/core";
3+
import { ThemeProvider, createMuiTheme } from "@material-ui/core/styles";
4+
import { green } from "@material-ui/core/colors";
5+
import "./App.css";
6+
7+
function App() {
8+
const [darkMode, setDarkMode] = useState(false);
9+
10+
const darkTheme = createMuiTheme({
11+
palette: {
12+
type: "dark",
13+
},
14+
});
15+
const lightTheme = createMuiTheme({
16+
palette: {
17+
type: "light",
18+
primary: green,
19+
},
20+
});
21+
return (
22+
<ThemeProvider theme={darkMode ? darkTheme : lightTheme}>
23+
<Paper style={{ height: "100vh", width: "100%" }}>
24+
<Typography variant="h1">
25+
{/* <Button
26+
variant="contained"
27+
color="primary"
28+
onClick={() => setDarkMode(!darkMode)}
29+
>
30+
<span role="img" aria-label="sun">
31+
☀️
32+
</span>
33+
</Button> */}
34+
Awesome Dark Mode &nbsp;
35+
<Button
36+
variant="contained"
37+
color="primary"
38+
onClick={() => setDarkMode(!darkMode)}
39+
>
40+
<span role="img" aria-label="moon">
41+
🌚
42+
</span>
43+
&nbsp;
44+
</Button>
45+
<Grid component="label" container direction="row" alignItems="center">
46+
<Grid item>
47+
<span role="img" aria-label="sun">
48+
☀️
49+
</span>
50+
</Grid>
51+
<Grid item>
52+
<Switch
53+
checked={darkMode}
54+
onChange={() => setDarkMode(!darkMode)}
55+
/>
56+
</Grid>
57+
<Grid item>
58+
<span role="img" aria-label="moon">
59+
🌚
60+
</span>
61+
</Grid>
62+
</Grid>
63+
</Typography>
64+
</Paper>
65+
</ThemeProvider>
66+
);
67+
}
68+
69+
export default App;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
body {
2+
margin: 0;
3+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5+
sans-serif;
6+
-webkit-font-smoothing: antialiased;
7+
-moz-osx-font-smoothing: grayscale;
8+
}
9+
10+
code {
11+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12+
monospace;
13+
}

0 commit comments

Comments
 (0)