0
Talk guys, everything jewels?
I have tremendous doubt, and I have no idea how to fix it. I recently participated in Omnistack Week 11 and was able to develop an application from scratch, from backend to frontend and mobile, and today (02/04/2020) I decided to add a dark theme in the application, this feature is working 100%, but I’m having trouble changing the icon I’m using to use the "dark theme feature". I wonder how do I put a "sun icon(symbolizing the light theme)" as soon as I click on the "moon(symbolizing the dark theme)"?.
Follow the excerpt of the code that makes the magic happen:
import React from 'react';
import {FiSun, FiMoon} from 'react-icons/fi';
import './style.css';
const ThemeSwitcher = ( {toggleTheme} ) => (
<a onClick={toggleTheme}><FiMoon size={16} color="#343746"/></a>
);
As you can see in the code above, I am importing two icons from the 'React-icons/fi' library. Also note that I am using the "Fimoon" tag 'a'. Basically this code is essential for the dark theme feature to work as it is by clicking on this link/icon that the theme is applied.
The CSS file does not contain anything relevant, just a 'cursor: inter;'.
As you can see in the image below the moon icon is next to the logo, and as soon as it is clicked the dark theme is applied:
As you can see the theme has been applied but the moon icon has disappeared because it is the same color as the background, so I want to put the sun icon to symbolize the light theme:
From now on, thank you.
Has there been any response?
– novic