Skip to content

Commit 2eec669

Browse files
committed
Conditionally render banner and logo on theme
1 parent 1b4f054 commit 2eec669

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

src/components/AppBanner.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import ThemeSwitcher from '../hooks/ThemeSwitcher';
12
import { FiArrowDownCircle } from 'react-icons/fi';
23
import developerLight from '../images/developer.svg';
34
import developerDark from '../images/developer-dark.svg';
45

56
const AppBanner = () => {
7+
const [activeTheme, seTheme] = ThemeSwitcher();
8+
69
return (
710
<section className="flex flex-col sm:justify-between items-center sm:flex-row mt-12 sm:mt-2">
811
<div className="w-full sm:w-1/3 text-left">
@@ -25,7 +28,12 @@ const AppBanner = () => {
2528
</div>
2629
</div>
2730
<div className="w-full sm:w-2/3 text-right float-right mt-8 sm:mt-0">
28-
<img src={developerLight} alt="Developer" />
31+
<img
32+
src={
33+
activeTheme === 'light' ? developerLight : developerDark
34+
}
35+
alt="Developer"
36+
/>
2937
</div>
3038
</section>
3139
);

src/components/AppHeader.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FiMoon, FiSun } from 'react-icons/fi';
22
import { Link } from 'react-router-dom';
33
import ThemeSwitcher from '../hooks/ThemeSwitcher';
44

5-
// import logoLight from '../images/logo-light.svg';
5+
import logoLight from '../images/logo-light.svg';
66
import logoDark from '../images/logo-dark.svg';
77

88
const AppHeader = () => {
@@ -17,11 +17,19 @@ const AppHeader = () => {
1717
<div className="flex justify-between items-center px-4 sm:px-0">
1818
<div>
1919
<Link to="/">
20-
<img
21-
src={logoDark}
22-
className="w-36"
23-
alt="Dark Logo"
24-
/>
20+
{activeTheme === 'dark' ? (
21+
<img
22+
src={logoDark}
23+
className="w-36"
24+
alt="Dark Logo"
25+
/>
26+
) : (
27+
<img
28+
src={logoLight}
29+
className="w-36"
30+
alt="Dark Logo"
31+
/>
32+
)}
2533
</Link>
2634
</div>
2735

@@ -108,12 +116,12 @@ const AppHeader = () => {
108116
<div
109117
onClick={() => setTheme(activeTheme)}
110118
aria-label="Theme Switcher"
111-
className="ml-8 bg-primary-light dark:bg-ternary-dark px-3 py-2 shadow-sm rounded-xl cursor-pointer"
119+
className="ml-8 bg-primary-light dark:bg-ternary-dark p-3 shadow-sm rounded-xl cursor-pointer"
112120
>
113121
{activeTheme === 'dark' ? (
114-
<FiMoon class="text-liText-ternary-dark hover:text-gray-400 dark:text-liText-ternary-light dark:hover:text-liBorder-primary-light w-5" />
122+
<FiMoon class="text-liText-ternary-dark hover:text-gray-400 dark:text-liText-ternary-light dark:hover:text-liBorder-primary-light text-xl" />
115123
) : (
116-
<FiSun class="text-gray-200 hover:text-gray-50 w-5" />
124+
<FiSun class="text-gray-200 hover:text-gray-50 text-xl" />
117125
)}
118126
</div>
119127
</div>

0 commit comments

Comments
 (0)