Skip to content

Commit 10e29c7

Browse files
committed
update - implementation of dark mode
1 parent 8aee4be commit 10e29c7

9 files changed

Lines changed: 2210 additions & 12 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"eslint": "8.29.0",
1616
"eslint-config-next": "13.0.6",
1717
"next": "13.0.6",
18+
"next-themes": "^0.2.1",
1819
"phosphor-react": "^1.4.1",
1920
"react": "18.2.0",
2021
"react-dom": "18.2.0",

src/components/background.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type PropsChildren = {
66

77
export default function Bg({children}: PropsChildren) {
88
return(
9-
<div className="h-screen bg-gray/[.7] bg-paper-pattern bg-paper-pattern-size bg-paper-pattern-position">
9+
<div className="h-screen bg-gray/[.7] dark:bg-black bg-paper-pattern bg-paper-pattern-size bg-paper-pattern-position dark:bg-paper-pattern-dark">
1010
{children}
1111
</div>
1212
)

src/components/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function Layout({ children }: PropsChildren) {
2222
return (
2323
<div className="h-screen w-full font-pontserrat">
2424
<Head>
25-
<title>{router.pathname.slice(1).toLowerCase()} - Diego Silva</title>
25+
<title>{router.pathname != "/" ? `${router.pathname.slice(1).toLowerCase()} - ` : ""}Diego Silva</title>
2626
<meta name="description" content="Generated by create next app" />
2727
<link rel="icon" href="/favicon.png" />
2828
</Head>

src/components/modal.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import { Link } from "phosphor-react";
2+
import { useTheme } from "next-themes";
23

34
export default function Modal() {
5+
const {theme, setTheme} = useTheme()
6+
47
return (
58
<div className="fixed top-0 left-0 w-screen h-screen bg-white/10 backdrop-blur-sm z-40 transition-opacity ease-in-out">
69
<div>
7-
<h1>Ola mundo</h1>
10+
<button
11+
onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
12+
>
13+
Mudar Tema
14+
</button>
815
</div>
916
</div>
1017
)

src/pages/_app.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import '../../styles/globals.css'
22
import type { AppProps } from 'next/app'
33

44
import Bg from '../components/background'
5+
import { ThemeProvider } from 'next-themes'
56

67
export default function App({ Component, pageProps }: AppProps) {
78
return (
8-
<Bg>
9-
<Component {...pageProps} />
10-
</Bg>
9+
<ThemeProvider attribute="class">
10+
<Component {...pageProps} />
11+
</ThemeProvider>
1112
)
1213
}

src/pages/_document.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import Document, { Html, Head, Main, NextScript } from 'next/document'
1+
import Document, { Html, Main, NextScript } from 'next/document'
22

33
export default class MyDocument extends Document {
44
return () {
5-
<Html lang="pt-BR">
6-
<Head>
7-
</Head>
5+
<Html className="" lang="pt-BR">
86
<body>
97
<Main />
108
<NextScript />

styles/globals.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,14 @@
1212
::-webkit-scrollbar {
1313
width: 0;
1414
}
15+
16+
body {
17+
@apply bg-gray/[.7]
18+
dark:bg-black
19+
bg-paper-pattern
20+
bg-paper-pattern-size
21+
bg-paper-pattern-position
22+
dark:bg-paper-pattern-dark
23+
}
1524
}
1625

tailwind.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/** @type {import('tailwindcss').Config} */
22
module.exports = {
3+
darkMode: 'class',
4+
purge: ["./pages/**/*.{js,ts,jsx,tsx}", "./components/**/*.{js,ts,jsx,tsx}"],
35
content: [
46
"./src/pages/**/*.{js,ts,jsx,tsx}",
57
"./src/components/**/*.{js,ts,jsx,tsx}",
@@ -16,7 +18,8 @@ module.exports = {
1618
gray: '#AEAEAE'
1719
},
1820
backgroundImage: {
19-
'paper-pattern': "radial-gradient(50% 50% at 50% 50%, rgba(174, 174, 174, 0) 0%, rgba(174, 174, 174, 0.94) 100%), linear-gradient(rgba(23, 23, 23, 0.1) 1.6px, transparent 1.6px), linear-gradient(90deg, rgba(23, 23, 23, 0.1) 1.6px, transparent 1.6px), linear-gradient(rgba(23, 23, 23, 0.1) 0.8px, transparent 0.8px), linear-gradient(90deg, rgba(23, 23, 23, 0.1) 0.8px, rgba(173, 173, 173, 0) 0.8px)",
21+
'paper-pattern': "radial-gradient(50% 50% at 50% 50%, rgba(174, 174, 174, 0) 0%, rgba(174, 174, 174, 0.94) 100%), linear-gradient(rgba(22, 22, 22, 0.1) 1.6px, transparent 1.6px), linear-gradient(90deg, rgba(22, 22, 22, 0.1) 1.6px, transparent 1.6px), linear-gradient(rgba(22, 22, 22, 0.1) 0.8px, transparent 0.8px), linear-gradient(90deg, rgba(22, 22, 22, 0.1) 0.8px, rgba(173, 173, 173, 0) 0.8px)",
22+
'paper-pattern-dark': "radial-gradient(50% 50% at 50% 50%, rgba(22, 22, 22, 0) 0%, rgba(22, 22, 22, 0.94) 100%), linear-gradient(rgba(174, 174, 174, 0.1) 1.6px, transparent 1.6px), linear-gradient(90deg, rgba(174, 174, 174, 0.1) 1.6px, transparent 1.6px), linear-gradient(rgba(174, 174, 174, 0.1) 0.8px, transparent 0.8px), linear-gradient(90deg, rgba(174, 174, 174, 0.1) 0.8px, rgba(22, 22, 22, 0) 0.8px)",
2023
'hero-img': "url('/images/hero_1.png')"
2124
},
2225
fontFamily: {
@@ -30,7 +33,7 @@ module.exports = {
3033

3134
backgroundPosition: {
3235
'paper-pattern-position': 'center, -1.6px -1.6px, -1.6px -1.6px, -0.8px -0.8px, -0.8px -0.8px'
33-
}
36+
},
3437
},
3538
plugins: [],
3639
}

0 commit comments

Comments
 (0)