Skip to content

Commit f57de77

Browse files
feat(theme): Add automatic dark mode support
1 parent f9e3da1 commit f57de77

File tree

6 files changed

+74
-40
lines changed

6 files changed

+74
-40
lines changed

styles/Converter.module.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
.container {
2-
background: #ffffff;
3-
border: 4px solid #1a1a1a;
2+
background: var(--background-container);
3+
border: 4px solid var(--border-primary);
44
padding: 30px;
55
max-width: 800px;
66
width: 100%;
7-
box-shadow: 8px 8px 0px #1a1a1a;
7+
box-shadow: 8px 8px 0px var(--shadow-primary);
88
}
99

1010
.title {

styles/Examples.module.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.examples {
2-
background: #f0f0f0;
3-
border: 3px solid #1a1a1a;
2+
background: var(--background-secondary);
3+
border: 3px solid var(--border-primary);
44
padding: 25px;
55
margin-top: 25px;
66
}
@@ -18,8 +18,8 @@
1818
font-size: 0.9rem;
1919
font-weight: bold;
2020
padding: 8px;
21-
background: #ffffff;
22-
border-left: 4px solid #1a1a1a;
21+
background: var(--background-container);
22+
border-left: 4px solid var(--border-primary);
2323
line-height: 1.4;
2424
}
2525

@@ -36,4 +36,4 @@
3636
.exampleItem {
3737
font-size: 0.8rem;
3838
}
39-
}
39+
}

styles/Form.module.css

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@
3030
.inputField input, .baseField select, .baseField input {
3131
width: 100%;
3232
padding: 12px;
33-
border: 3px solid #1a1a1a;
33+
border: 3px solid var(--border-primary);
3434
font-size: 16px;
35-
background: #ffffff;
36-
color: #1a1a1a;
35+
background: var(--background-container);
36+
color: var(--text-primary);
3737
font-family: 'Ubuntu Sans Mono', monospace;
3838
}
3939

4040
.inputField input:focus, .baseField input:focus, .baseField select:focus {
4141
outline: none;
42-
background: #f0f0f0;
43-
border-color: #000;
42+
background: var(--background-input-focus);
43+
border-color: var(--border-primary);
4444
}
4545

4646
.convertBtn {
47-
background: #1a1a1a;
48-
color: #ffffff;
47+
background: var(--background-primary-accent);
48+
color: var(--text-inverted);
4949
border: none;
5050
padding: 16px 30px;
5151
font-size: 16px;
@@ -62,9 +62,9 @@
6262
}
6363

6464
.convertBtn:hover {
65-
background: #333;
65+
background: var(--background-primary-accent-hover);
6666
transform: translate(-2px, -2px);
67-
box-shadow: 4px 4px 0px #1a1a1a;
67+
box-shadow: 4px 4px 0px var(--shadow-primary);
6868
}
6969

7070
.convertBtn:active {
@@ -102,6 +102,6 @@
102102
.baseField input:-webkit-autofill:hover,
103103
.baseField input:-webkit-autofill:focus,
104104
.baseField input:-webkit-autofill:active {
105-
-webkit-box-shadow: 0 0 0 30px #e9e9e9 inset !important;
106-
-webkit-text-fill-color: #1a1a1a !important;
107-
}
105+
-webkit-box-shadow: 0 0 0 30px var(--background-autofill) inset !important;
106+
-webkit-text-fill-color: var(--text-primary) !important;
107+
}

styles/Result.module.css

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.resultSection {
2-
background: #f8f8f8;
3-
border: 3px solid #1a1a1a;
2+
background: var(--background-tertiary);
3+
border: 3px solid var(--border-primary);
44
padding: 25px;
55
margin-top: 20px;
66
text-align: center;
@@ -11,17 +11,17 @@
1111
font-weight: bold;
1212
margin: 15px 0;
1313
word-break: break-all;
14-
background: #1a1a1a;
15-
color: #ffffff;
14+
background: var(--background-primary-accent);
15+
color: var(--text-inverted);
1616
padding: 12px;
17-
border: 2px solid #1a1a1a;
17+
border: 2px solid var(--border-primary);
1818
overflow-wrap: break-word;
1919
}
2020

2121
.error {
22-
background: #ffffff;
23-
border: 3px solid #d32f2f;
24-
color: #d32f2f;
22+
background: var(--background-container);
23+
border: 3px solid var(--color-error);
24+
color: var(--color-error);
2525
padding: 15px;
2626
margin: 15px 0;
2727
text-align: center;
@@ -52,4 +52,4 @@
5252
font-size: 1.5rem;
5353
margin: 10px 0;
5454
}
55-
}
55+
}

styles/Steps.module.css

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.stepsSection {
2-
background: #f8f8f8;
3-
border: 3px solid #1a1a1a;
2+
background: var(--background-tertiary);
3+
border: 3px solid var(--border-primary);
44
padding: 20px;
55
margin-top: 20px;
66
}
@@ -17,8 +17,8 @@
1717
.step {
1818
margin: 15px 0;
1919
padding: 15px;
20-
background: #ffffff;
21-
border: 2px solid #1a1a1a;
20+
background: var(--background-container);
21+
border: 2px solid var(--border-primary);
2222
font-size: 0.95rem;
2323
line-height: 1.5;
2424
transition: opacity 0.3s ease-in-out;
@@ -31,7 +31,7 @@
3131
.stepTitle {
3232
font-weight: bold;
3333
margin-bottom: 8px;
34-
color: #1a1a1a;
34+
color: var(--text-primary);
3535
text-transform: uppercase;
3636
font-size: 0.9rem;
3737
letter-spacing: 0.5px;
@@ -45,7 +45,7 @@
4545
.toggleSteps {
4646
background: none;
4747
border: none;
48-
color: #1a1a1a;
48+
color: var(--text-primary);
4949
text-decoration: underline;
5050
cursor: pointer;
5151
font-size: 0.9rem;
@@ -55,12 +55,12 @@
5555
}
5656

5757
.toggleSteps:hover {
58-
color: #333;
58+
color: var(--background-primary-accent-hover);
5959
}
6060

6161
@media (max-width: 768px) {
6262
.step {
6363
padding: 10px;
6464
font-size: 0.85rem;
6565
}
66-
}
66+
}

styles/globals.css

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,43 @@
55
font-family: 'Ubuntu Sans Mono', monospace;
66
}
77

8+
:root {
9+
--background-body: #f5f5f5;
10+
--text-primary: #1a1a1a;
11+
--text-inverted: #ffffff;
12+
--background-container: #ffffff;
13+
--background-secondary: #f0f0f0;
14+
--background-tertiary: #f8f8f8;
15+
--border-primary: #1a1a1a;
16+
--background-primary-accent: #1a1a1a;
17+
--background-primary-accent-hover: #333333;
18+
--background-input-focus: #f0f0f0;
19+
--background-autofill: #e9e9e9;
20+
--color-error: #d32f2f;
21+
--shadow-primary: #1a1a1a;
22+
}
23+
24+
@media (prefers-color-scheme: dark) {
25+
:root {
26+
--background-body: #1c1c1c;
27+
--text-primary: #f0f0f0;
28+
--text-inverted: #1a1a1a;
29+
--background-container: #2a2a2a;
30+
--background-secondary: #3a3a3a;
31+
--background-tertiary: #252525;
32+
--border-primary: #f0f0f0;
33+
--background-primary-accent: #f0f0f0;
34+
--background-primary-accent-hover: #cccccc;
35+
--background-input-focus: #3a3a3a;
36+
--background-autofill: #4a4a4a;
37+
--color-error: #ff6b6b;
38+
--shadow-primary: #f0f0f0;
39+
}
40+
}
41+
842
body {
9-
background-color: #f5f5f5;
10-
color: #1a1a1a;
43+
background-color: var(--background-body);
44+
color: var(--text-primary);
1145
min-height: 100vh;
1246
display: flex;
1347
align-items: center;
@@ -19,4 +53,4 @@ body {
1953
body {
2054
padding: 10px;
2155
}
22-
}
56+
}

0 commit comments

Comments
 (0)