Skip to content

Commit f98ec73

Browse files
Feature: Changed the styling of theme dropdown list to icons (#4373)
* Changed the styling of theme dropdown to icons * Adjusted the dropdown postioning to center * Added translations of theme tooltips for hindi
1 parent a0d4ece commit f98ec73

File tree

6 files changed

+61
-53
lines changed

6 files changed

+61
-53
lines changed

css/themes.css

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/* Theme DropDown Styling */
2+
3+
#themedropdown{
4+
background-color: transparent;
5+
box-shadow: none;
6+
display: flex;
7+
transform: translateX(-25%) !important;
8+
}
9+
10+
#themedropdown a{
11+
color: #2196F3;
12+
transition: all 0.3s ease;
13+
}
14+
#themedropdown a:hover{
15+
color: #1E88E5;
16+
background-color: transparent;
17+
transition: all 0.3s ease;
18+
}
19+
20+
121
/* Dark Mode */
222

323
.dark .blue {
@@ -39,19 +59,6 @@
3959
color: white !important;
4060
}
4161

42-
.dark .dropdown-content li > a {
43-
background-color: #1c1c1c;
44-
color: #3fe0d1;
45-
}
46-
47-
.dark .dropdown-content li > a:hover {
48-
color: #252525;
49-
}
50-
51-
.dark .dropdown-content {
52-
background-color: #1c1c1c;
53-
}
54-
5562
.dark .language-link {
5663
color: #fff;
5764
}

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@
781781
class="tooltipped dropdown-trigger"
782782
data-position="left"
783783
data-activates="themedropdown"
784-
><i class="material-icons md-48">brightness_4</i></a
784+
><i class="material-icons md-48">brightness_7</i></a
785785
>
786786
</li>
787787
<li>
@@ -921,9 +921,9 @@
921921
<li><a id="ur"></a></li>
922922
</ul>
923923

924-
<ul id="themedropdown" class="dropdown-content">
925-
<li><a id="light"></a></li>
926-
<li><a id="dark"></a></li>
924+
<ul style="display: none;" id="themedropdown" class="dropdown-content">
925+
<a id="light" class="tooltipped" data-tooltip="Light Mode"><i class='material-icons'>brightness_7</i></a>
926+
<a id="dark" class="tooltipped" data-tooltip="Dark Mode"><i class='material-icons'>brightness_4</i></a>
927927
</ul>
928928

929929
<div id="modal-container" style="display: none;z-index: 999;">

js/toolbar.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class Toolbar {
6868
["enableHorizScrollIcon", _("Enable horizontal scrolling")],
6969
["disableHorizScrollIcon", _("Disable horizontal scrolling")],
7070
["themeSelectIcon", _("Change theme")],
71+
["light", _("Light Mode")],
72+
["dark", _("Dark Mode")],
7173
["mergeWithCurrentIcon", _("Merge with current project")],
7274
["chooseKeyIcon", _("Set Pitch Preview")],
7375
["toggleJavaScriptIcon", _("JavaScript Editor")],
@@ -104,10 +106,7 @@ class Toolbar {
104106
["ar", _("عربى"), "innerHTML"],
105107
["te", _("తెలుగు"), "innerHTML"],
106108
["he", _("עִברִית"), "innerHTML"],
107-
["ur", _("اردو"), "innerHTML"],
108-
["light", _("Light Mode"), "innerHTML"],
109-
["dark", _("Dark Mode"), "innerHTML"],
110-
// ["custom", _("Custom Theme"), "innerHTML"],
109+
["ur", _("اردو"), "innerHTML"]
111110
];
112111

113112
// Workaround for FF
@@ -134,7 +133,9 @@ class Toolbar {
134133
_("Delete plugin"),
135134
_("Enable horizontal scrolling"),
136135
_("Disable horizontal scrolling"),
137-
_("Change theme"),
136+
_("Change theme"),
137+
_("Light Mode"),
138+
_("Dark Mode"),
138139
_("Merge with current project"),
139140
_("Set Pitch Preview"),
140141
_("JavaScript Editor"),
@@ -177,10 +178,7 @@ class Toolbar {
177178
_("igbo"),
178179
_("عربى"),
179180
_("עִברִית"),
180-
_("اردو"),
181-
_("Light Mode"),
182-
_("Dark Mode")
183-
// _("Custom Theme"),
181+
_("اردو")
184182
];
185183
} else {
186184
strings = [
@@ -207,6 +205,8 @@ class Toolbar {
207205
["enableHorizScrollIcon", _("Enable horizontal scrolling")],
208206
["disableHorizScrollIcon", _("Disable horizontal scrolling")],
209207
["themeSelectIcon", _("Change theme")],
208+
["light", _("Light Mode")],
209+
["dark", _("Dark Mode")],
210210
["mergeWithCurrentIcon", _("Merge with current project")],
211211
["toggleJavaScriptIcon", _("JavaScript Editor")],
212212
["restoreIcon", _("Restore")],
@@ -238,10 +238,7 @@ class Toolbar {
238238
["ar", _("عربى"), "innerHTML"],
239239
["te", _("తెలుగు"), "innerHTML"],
240240
["he", _("עִברִית"), "innerHTML"],
241-
["ur", _("اردو"), "innerHTML"],
242-
["light", _("Light Mode"), "innerHTML"],
243-
["dark", _("Dark Mode"), "innerHTML"]
244-
// ["custom", _("Custom Theme"), "innerHTML"],
241+
["ur", _("اردو"), "innerHTML"]
245242
];
246243

247244
// Workaround for FF
@@ -268,7 +265,9 @@ class Toolbar {
268265
_("Delete plugin"),
269266
_("Enable horizontal scrolling"),
270267
_("Disable horizontal scrolling"),
271-
_("Change theme"),
268+
_("Change theme"),
269+
_("Light Mode"),
270+
_("Dark Mode"),
272271
_("Merge with current project"),
273272
_("JavaScript Editor"),
274273
_("Restore"),
@@ -300,10 +299,7 @@ class Toolbar {
300299
_("igbo"),
301300
_("عربى"),
302301
_("עִברִית"),
303-
_("اردو"),
304-
_("Light Mode"),
305-
_("Dark Mode")
306-
// _("Custom Theme"),
302+
_("اردو")
307303
];
308304
}
309305

@@ -472,6 +468,12 @@ class Toolbar {
472468
}
473469

474470
renderThemeSelectIcon(themeBox, themes) {
471+
const icon = document.getElementById("themeSelectIcon")
472+
themes.forEach((theme) =>{
473+
if(localStorage.themePreference === theme){
474+
icon.innerHTML = document.getElementById(theme).innerHTML;
475+
}
476+
})
475477
const themeSelectIcon = docById("themeSelectIcon");
476478
let themeList = themes;
477479
themeSelectIcon.onclick = () => {

js/utils/README.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,30 @@ This guide explains how you can add your own custom theme or customize an existi
2929

3030
Note: If you want to customise an existing theme, just put your changes in the dark mode and choose dark mode from the theme dropdown. You can skip to step no. 6 if that is your goal.
3131

32-
1. **Adding your theme's name to the list in index.html**
32+
1. **Adding your theme's icon to the list in index.html**
3333

34-
Go to index.html from root, and add your theme to the list (please follow the conventions used by other themes for proper implementation)
34+
Go to index.html from root, and add your theme's icon to the list (please follow the conventions used by other themes for proper implementation)
35+
Add your theme's icon to the bottom of the list, you can find icons in [Material Icons](https://materializecss.com/icons.html).
3536

3637
```javascript
37-
<ul id="themedropdown" class="dropdown-content">
38-
<li>
39-
<a id="light"></a>
40-
</li>
41-
<li>
42-
<a id="dark"></a>
43-
</li>
44-
<li>
45-
<a id="custom"></a>
46-
</li>
38+
<ul style="display: none;" id="themedropdown" class="dropdown-content">
39+
<a id="light" class="tooltipped" data-tooltip="Light Mode"><i class='material-icons'>brightness_7</i></a>
40+
<a id="dark" class="tooltipped" data-tooltip="Dark Mode"><i class='material-icons'>brightness_4</i></a>
41+
<a id="custom" class="tooltipped" data-tooltip="Custom Theme"><i class='material-icons'>choose_your_material_icon</i></a>
4742
</ul>
4843
```
4944

5045
2. **Now go to js/toolbar.js, find init(activity){...}**
5146

5247
There will be 4 arrays named string (two in an if statement, rest two in the else statement).
53-
Add your theme's name to the bottom of the array
48+
Add your theme's name to the bottom of the pre-existing themes.
49+
5450
5551
```javascript
5652
string = [[...],
57-
["light", _("Light Mode"), "innerHTML"],
58-
["dark", _("Dark Mode"), "innerHTML"],
59-
["custom", _("Custom Theme"), "innerHTML"]];
53+
["light", _("Light Mode")],
54+
["dark", _("Dark Mode")],
55+
["custom", _("Custom Theme")]];
6056
```
6157
6258
```javascript
@@ -177,7 +173,7 @@ Note: If you want to customise an existing theme, just put your changes in the d
177173
178174
6. **Now to add styling for your theme**
179175
180-
(If you skipped to here, these are the files responsible for styling, the CSS is easy to understand and modify, but to change the color of elements in javascript files, look at the entire code base and search for "platformColor". You will find all the places where JS is used to style. You don't have to add your own theme, you can just change styling in dark mode CSS and JS, and then choose dark mode n the toolbar.)
176+
(If you skipped to here, these are the files responsible for styling, the CSS is easy to understand and modify, but to change the color of elements in javascript files, look at the entire code base and search for "platformColor". You will find all the places where JS is used to style. You don't have to add your own theme, you can just change styling in dark mode CSS and JS, and then choose dark mode in the toolbar.)
181177

182178
You have to add styling to three places,
183179

js/widgets/jseditor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class JSEditor {
210210
menuRight.appendChild(styleBtn);
211211
menubar.appendChild(menuRight);
212212
this._editor.appendChild(menubar);
213-
generateTooltip(styleBtn, "Change Theme", "left");
213+
generateTooltip(styleBtn, "Change theme", "left");
214214

215215
const editorContainer = document.createElement("div");
216216
editorContainer.id = "editor_container";

localization.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6233,6 +6233,9 @@ Load-plugin = प्लगइन लोड करें
62336233
Delete-plugin = प्लगइन हटाएं
62346234
Enable-horizontal-scrolling = क्षैतिज स्क्रोलिंग सक्षम करें
62356235
Disable-horizontal-scrolling = क्षैतिज स्क्रोलिंग अक्षम करें
6236+
Change-theme = थीम बदलें
6237+
Light-Mode = प्रकाश मोड
6238+
Dark-Mode = अंधेरा मोड
62366239
Merge-with-current-project = वर्तमान परियोजना के साथ मर्ज करें
62376240
Set-Pitch-Preview = पिच पूर्वावलोकन सेट करें
62386241
Restore = पुनर्स्थापित करें

0 commit comments

Comments
 (0)