-
Notifications
You must be signed in to change notification settings - Fork 962
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
Feature: Generalised Dark Mode into General Theme #4348
base: master
Are you sure you want to change the base?
Feature: Generalised Dark Mode into General Theme #4348
Conversation
…heme selection, Updated README.md for theme customisation
@walterbender here is the new PR without linting about General Theme Selection |
css/themes.css
Outdated
} | ||
|
||
|
||
/* Your Custom Theme can go down if you dont want to modify the existing dark mode */ |
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.
maybe ^can go down^can go here^ ?
js/themebox.js
Outdated
@@ -0,0 +1,75 @@ | |||
// Copyright (c) 2018-21 Walter Bender |
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.
Should be your name here and 2025
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.
Yeah, I saw that. I actually used the existing languagebox.js to make the new themebox.js to maintain consistency, so I didn't understand how copyright works in open source projects. But I will make the changes asked.
js/themebox.js
Outdated
// * @returns {void} | ||
// */ | ||
// custom_onclick() { | ||
// this._theme = "pastel"; |
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.
maybe replace pastel with "custom" or "your custom theme"?
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.
Hmm, my bad, missed it here and in other places, will make the changes
js/toolbar.js
Outdated
["ur", _("اردو"), "innerHTML"], | ||
["light", _("Light Mode"), "innerHTML"], | ||
["dark", _("Dark Mode"), "innerHTML"] | ||
// ["custom", _("Theme Name"), "innerHTML"], |
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.
We should be consistent with the string (even if it is commented out). How about "Custom Theme" everywhere?
js/utils/README.md
Outdated
|
||
1. **Refresh Required for Theme Application** | ||
1. When the page loads for the first time, the default theme of light mode is used. (because no themePreference has been set yet) |
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.
maybe drop "(because... yet)"
js/utils/README.md
Outdated
|
||
The site must be refreshed to apply a new theme in Music Blocks. | ||
2. When you choose a theme, an Object stores inside the localStorage called themePreference. |
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.
an object is stored...
js/utils/README.md
Outdated
|
||
2. **Canvas and Palette Button Styles** | ||
3. As of now, all the styling of Music Blocks happens at the time of loading. So we will simply load the page. |
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.
- All styling... time of loading. When we change themes, we reload the page.
js/utils/README.md
Outdated
|
||
Styles for the canvas and palette buttons are initialized at the time of loading MB. | ||
- These cannot be directly modified using CSS. | ||
4. The stylings on the main page happen due to two things: |
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.
- Most of the Music Blocks theme styles are defined in two places:
js/utils/README.md
Outdated
MB uses a combination of internal and external CSS: | ||
- **Internal CSS**: Block colors, pie menu, background, and other essential styles are defined in `js/utils/platformstyle.js`. | ||
- **External CSS**: Elements like the navbar and dropdown menu are styled using external CSS files. | ||
5. the styling on the planet page happens due to one file |
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.
- The Plant theme styles are defined in:
js/utils/README.md
Outdated
<a id="dark"></a> | ||
</li> | ||
<li> | ||
<a id="pastel"></a> |
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.
this is no longer there.
js/utils/README.md
Outdated
string = [[...], | ||
["light", _("Light Mode"), "innerHTML"], | ||
["dark", _("Dark Mode"), "innerHTML"], | ||
["pastel", _("Pastel Theme"), "innerHTML"], |
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.
same
js/utils/README.md
Outdated
string = [_(...), | ||
_("Light Mode"), | ||
_("Dark Mode"), | ||
_("Pastel Theme"), |
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.
same
js/utils/README.md
Outdated
class Activity { | ||
constructor( | ||
... | ||
this.themes = ["light", "pastel", "dark", "your_theme"]; |
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.
no pastel
js/utils/README.md
Outdated
|
||
5. **Applying the Theme After Reload** | ||
If no theme is selected, i.e., there is no themePreference in localStorage. The styles will default to light mode, as it is the base styling without a class in themes.css. But when there is a themePreference in localStorage, the class respective to the chosen theme will be added to the elements which will apply because of higher specificity. |
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.
If no theme has been selected (i.e., themePreference has not been defined in localStorage), the styles will default to "light". Otherwise, the theme defined in themePreference will be applied.
js/utils/README.md
Outdated
}); | ||
``` | ||
|
||
Add your theme here as well. This for loop above checks (after the DOM is loaded) for all themes in themes array to add the class in planetThemes.css (which you will add in later steps) which match themePreference in localStorage to the elements on planet/index.html. That is why the changes happen after the reload. |
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.
The "for" loop shown above...
js/utils/README.md
Outdated
``` | ||
|
||
Add your theme here as well. This for loop above checks (after the DOM is loaded) for all themes in themes array to add the class in planetThemes.css (which you will add in later steps) which match themePreference in localStorage to the elements on planet/index.html. That is why the changes happen after the reload. | ||
If no theme is selected (i.e., there is no themePreference in localStorage), the styles will default to light mode because it is the base styling with no class in planetThemes.css . But when there is a themePreference in localStorage, the class respective to the chosen theme will be added to the elements which will apply because of higher specificity. |
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 the same text as in the comment above.
js/utils/README.md
Outdated
* @returns {void} | ||
*/ | ||
pastel_onclick() { | ||
this._theme = "pastel"; |
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.
again...
@walterbender Made the revisions, please review it. |
@arjunjayan999 i dont think we need to have a dropdown menu of theme list as we currently only have 2 modes and switching means chnaging to another theme |
@walterbender Also i m confused what sort of changes do this creates as we can can simply use css variable for the selection of different themes in my mind this needs more dicussion i guess |
A drop-down simplifies the approach in which a user can customise an existing theme, or maybe they want some (or many) changes but don't want to loose their previous themes. |
@arjunjayan999 but I ll feel the drop-down option weird must get review from Walterv |
This PR address issue #4340 and focuses on refactoring the theme management system, replacing the old dark mode implementation with a more flexible theme selection mechanism. The changes introduce a new
ThemeBox
class to handle theme preferences and update various files to support this new approach.Key changes include:
Theme Management Refactor:
css/darkmode.css
andcss/activities.css
. [1] [2]css/themes.css
.index.html
to referencecss/themes.css
instead ofcss/darkmode.css
and added a theme selection dropdown. [1] [2] [3]README.md
in js/utils to explain thoroughly how to customise theme, or add one.JavaScript Updates:
ThemeBox
class injs/themebox.js
to manage theme preferences.js/activity.js
to integrateThemeBox
and remove old dark mode toggle logic. [1] [2] [3] [4] [5] [6] [7] [8]js/toolbar.js
to render the new theme selection icon and handle theme changes. [1] [2] [3] [4] [5] [6] [7]