-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added: Light Theme Mode #63
Added: Light Theme Mode #63
Conversation
@all-contributors please add @GaganpreetKaurKalsi for code and design |
I've put up a pull request to add @GaganpreetKaurKalsi! 🎉 |
5571d36
to
3ebfd4d
Compare
I am not a big fan of how CSS modules way of switching themes. I am tempted to switch to styled-components for all things CSS, but that would be a big restructure. What do you think? |
Definitely it would be a big restructure. The problem is that many classes are not defined by the project builder. They are inbuilt classes from modules. |
<svg | ||
aria-hidden="true" | ||
focusable="false" | ||
data-prefix="fas" | ||
data-icon="expand" | ||
className="svg-inline--fa fa-expand fa-w-14 MuiSvgIcon-root" | ||
role="img" | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 448 512" | ||
> | ||
<path | ||
fill="currentColor" | ||
d="M0 180V56c0-13.3 10.7-24 24-24h124c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H64v84c0 6.6-5.4 12-12 12H12c-6.6 0-12-5.4-12-12zM288 44v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12V56c0-13.3-10.7-24-24-24H300c-6.6 0-12 5.4-12 12zm148 276h-40c-6.6 0-12 5.4-12 12v84h-84c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24V332c0-6.6-5.4-12-12-12zM160 468v-40c0-6.6-5.4-12-12-12H64v-84c0-6.6-5.4-12-12-12H12c-6.6 0-12 5.4-12 12v124c0 13.3 10.7 24 24 24h124c6.6 0 12-5.4 12-12z" | ||
></path> | ||
</svg> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this as svg file in assets and export the SVG here
ex: import GoogleSVG from "assets/google.svg";
More Context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not using the SVG in image tag as I am unable to update the color upon theme change. I have made an icon file in the assets folder which contains svg returned from function.
|
||
const EditorToolbar: FC<Props> = ({ screenSize, setScreenSize }) => { | ||
const { language, handleLanguageChange } = useContext(SettingContext) as SettingsContextType; | ||
const { id } = useParams<Record<string, string>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use roomID()
hook to get id
src/pages/Room/Room.tsx
Outdated
const [screenSize, setScreenSize] = useState("normal"); | ||
const [theme, setTheme] = useState("dark"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to store this information in the global context in service/SettingContext.tsx
we already have a variable called theme
for setting editor-theme; let's rename that to editorTheme
and define theme
variable for global light or dark mode
Let me do some research about the pros and cons of |
I have worked with styled-components. |
I have made all the requested changes. You can have a look now! |
@GaganpreetKaurKalsi After doing some research about how to implement different themes, I think CSS modules would work well too, we just need to do some workaround.
<StyledEngineProvider injectFirst>
{/* Your component tree. Now you can override MUI's styles. */}
</StyledEngineProvider> If we do this we can also remove all the CSS-in-JS we have used at different places, like we do here
const lightTheme = {
"--primary": "#31e981",
"--seconday": "#000000",
};
//This is our dark mode
const darkTheme = {
"--primary": "#286843",
"--seconday": "#ffffff",
};
export { lightTheme, darkTheme }; const ApplyTheme = ({ theme, children }) => {
//Update the CSS Variables
const updateCSSVariables = theme => {
const arrayOfVariableKeys = Object.keys(theme);
const arrayOfVariableValues = Object.values(theme);
//Loop through each array key and set the CSS Variables
arrayOfVariableKeys.forEach((cssVariableKey, index) => {
//Based on our snippet from MDN
document.documentElement.style.setProperty(
cssVariableKey,
arrayOfVariableValues[index]
);
});
}; Here is an article which explains theming in details |
Okay! I got it. But this workaround is quite huge. I would suggest you merge this pull request first and open up another issue and assign that to me. I will work on it then. Also it would be great if you could merge the others as well, as I am participating in Hacktoberfest for the first time and it means a lot to me. |
#44 : Successfully added Light Mode to caucus
I have added classes such as tone1, tone2, tone3 to the components. In future, if you would like to add other themes to the components, you just need to specify it in the Theme.style.css file. Below are some screenshots for your reference.
Kindly review and let me know if I need to do something on my part.
Thanks!