Skip to content

Commit 0f537fb

Browse files
committed
Upd: Theme to Material 3
1 parent c8b5568 commit 0f537fb

File tree

82 files changed

+4691
-472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+4691
-472
lines changed

fonts/material_icons.css

+4-24
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,10 @@
33
font-family: 'Material Icons';
44
font-style: normal;
55
font-weight: 400;
6-
src: local('Material Icons'),
7-
local('MaterialIcons-Regular'),
8-
url(./material_icons/material_icons.woff2) format('woff2');
6+
src: url(./material_icons/material_symbols_rounded.woff2) format('woff2');
97
}
108

11-
12-
@font-face
13-
{
14-
font-family: 'Material Icons Extras';
15-
font-style: normal;
16-
font-weight: 400;
17-
src: url(./material_icons/material_icons_extras.woff2) format('woff2');
18-
}
19-
20-
.material-icon, .material-icon-extras
9+
.material-icon
2110
{
2211
font-family: 'Material Icons';
2312
font-weight: normal;
@@ -33,17 +22,8 @@
3322
word-wrap: normal;
3423
white-space: nowrap;
3524
direction: ltr;
36-
color: #808080;
25+
color: var(--md-sys-color-on-surface-variant);
3726
-webkit-font-smoothing: antialiased;
3827
text-rendering: optimizeLegibility;
39-
}
40-
41-
.night-mode .material-icon, .night-mode .material-icon-extras
42-
{
43-
color: #d9d9d9;
44-
}
45-
46-
.material-icon-extras
47-
{
48-
font-family: 'Material Icons Extras';
28+
font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
4929
}
-43.3 KB
Binary file not shown.
-1.27 KB
Binary file not shown.
Binary file not shown.

languages/ca.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"back": "Enrere",
2626
"add": "Afegir",
2727
"language": "Idioma",
28-
"settings": "Configuracions",
28+
"settings": "Configuració",
2929
"theme": "Tema",
3030
"valueCannotBeEmpty": "El valor no pot estar buit",
3131
"nightMode": "Mode nit"

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
"url": "git+https://github.com/ollm/OpenComic.git"
2323
},
2424
"scripts": {
25-
"start": "npm run prebuild && electron scripts/main.js",
25+
"start": "npm run prebuild && electron --trace-warnings scripts/main.js",
2626
"rebuild": "electron-rebuild -f -w sharp",
2727
"rebuild2": "electron-builder node-gyp-rebuild",
28-
"prebuild": "node scripts/build.js",
28+
"prebuild": "node scripts/build.js; node themes/material-design/colors/generate-colors.js",
2929
"watch": "nodemon --ignore 'dist/' --ignore scripts/builded --watch * --exec npm run start",
3030
"build": "npm run prebuild && electron-builder build",
3131
"build-dist": "npm run prebuild && electron-builder --x64 --linux deb rpm AppImage 7z && electron-builder --arm64 --linux deb rpm AppImage 7z && electron-builder --mac 7z",

scripts/dom.js

+60-20
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,8 @@ var currentPath = false, currentPathScrollTop = [];
577577

578578
async function loadIndexPage(animation = true, path = false, content = false, keepScroll = false, mainPath = false, fromGoBack = false)
579579
{
580+
selectMenuItem('library');
581+
580582
onReading = false;
581583

582584
reading.hideContent();
@@ -677,7 +679,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
677679

678680
if(!content)
679681
{
680-
template.loadContentLeft('index.content.left.html', animation);
682+
if(template.contentLeft('.menu-list').length === 0) template.loadContentLeft('index.content.left.html', animation);
681683
template.loadGlobalElement('index.elements.menus.html', 'menus');
682684
floatingActionButton(true, 'dom.addComicButtons();');
683685
}
@@ -989,6 +991,7 @@ function indexPathControl(path = false, mainPath = false, isComic = false, fromN
989991
function loadLanguagesPage(animation = true)
990992
{
991993
indexPathControl(false);
994+
selectMenuItem('language');
992995

993996
onReading = false;
994997

@@ -1024,6 +1027,8 @@ function loadLanguagesPage(animation = true)
10241027
template.loadHeader('languages.header.html', animation);
10251028
floatingActionButton(false);
10261029

1030+
events.events();
1031+
10271032
if(readingActive)
10281033
readingActive = false;
10291034
}
@@ -1045,6 +1050,7 @@ function changeLanguage(lan)
10451050
function loadSettingsPage(animation = true)
10461051
{
10471052
indexPathControl(false);
1053+
selectMenuItem('settings');
10481054

10491055
onReading = false;
10501056

@@ -1062,6 +1068,41 @@ function loadSettingsPage(animation = true)
10621068
readingActive = false;
10631069
}
10641070

1071+
/* Page - Theme */
1072+
1073+
function loadThemePage(animation = true)
1074+
{
1075+
indexPathControl(false);
1076+
selectMenuItem('theme');
1077+
1078+
onReading = false;
1079+
1080+
reading.hideContent();
1081+
1082+
generateAppMenu();
1083+
1084+
//template.loadContentRight('theme.content.right.html', animation);
1085+
template.loadHeader('theme.header.html', animation);
1086+
floatingActionButton(false);
1087+
1088+
theme.start();
1089+
1090+
if(readingActive)
1091+
readingActive = false;
1092+
}
1093+
1094+
function selectMenuItem(page)
1095+
{
1096+
let contentLeft = template.contentLeft().get(0);
1097+
//let contentLeft = dom.this(contentLeft);
1098+
1099+
let active = contentLeft.querySelector('.menu-item.active');
1100+
if(active) active.classList.remove('active');
1101+
1102+
page = contentLeft.querySelector('.menu-item-'+page);
1103+
if(page) page.classList.add('active');
1104+
}
1105+
10651106
var addComicButtonsST = false, addComicButtonsActive = false;
10661107

10671108
function addComicButtons(show = true, first = true)
@@ -1239,28 +1280,26 @@ function justifyViewModule()
12391280
{
12401281
if(config.viewIndex == 'module')
12411282
{
1242-
var contentWidth = template.contentRight().children().width();
1283+
let contentRight = template.contentRight().get(0);
1284+
let rect = contentRight.firstElementChild.getBoundingClientRect();
12431285

1244-
var contentPerLine = Math.floor((contentWidth - 16) / (150 + 16));
1286+
let contentPerLine = Math.floor((rect.width - 16) / (150 + 16));
1287+
contentPerLine = contentPerLine > 0 ? contentPerLine : 1;
12451288

1246-
var marginLeft = ((contentWidth - 16) - (contentPerLine * (150 + 16))) / (contentPerLine - 1);
1289+
let marginLeft = ((rect.width - 16) - (contentPerLine * (150 + 16))) / (contentPerLine - 1);
12471290

1248-
if(contentPerLine > 0)
1249-
{
1250-
template.contentRight('.content-view-module > div').each(function(index){
1251-
1252-
if(contentPerLine == 1)
1253-
$(this).css('margin-left', ((contentWidth / 2) - (150 / 2))+'px');
1254-
else if(index % contentPerLine == 0)
1255-
$(this).css('margin-left', '16px');
1256-
else
1257-
$(this).css('margin-left', (marginLeft + 16)+'px');
1291+
let viewModule = contentRight.querySelectorAll('.content-view-module > div');
12581292

1259-
});
1260-
}
1261-
else
1293+
for(let i = 0, len = viewModule.length; i < len; i++)
12621294
{
1263-
template.contentRight('.content-view-module > div').css('margin-left', '16px');
1295+
let _this = viewModule[i];
1296+
1297+
if(contentPerLine == 1)
1298+
_this.style.marginLeft = ((rect.width / 2) - (150 / 2))+'px';
1299+
else if(i % contentPerLine == 0)
1300+
_this.style.marginLeft = '16px';
1301+
else
1302+
_this.style.marginLeft = (marginLeft + 16)+'px';
12641303
}
12651304
}
12661305
}
@@ -1272,14 +1311,14 @@ function nightMode()
12721311
if($('.app').hasClass('night-mode'))
12731312
{
12741313
$('.app').removeClass('night-mode');
1275-
$('.button-night-mode').html('sun');
1314+
$('.button-night-mode').html('light_mode');
12761315
handlebarsContext.nightMode = false;
12771316
storage.updateVar('config', 'nightMode', false);
12781317
}
12791318
else
12801319
{
12811320
$('.app').addClass('night-mode');
1282-
$('.button-night-mode').html('moon');
1321+
$('.button-night-mode').html('dark_mode');
12831322
handlebarsContext.nightMode = true;
12841323
storage.updateVar('config', 'nightMode', true);
12851324
}
@@ -1467,6 +1506,7 @@ module.exports = {
14671506
loadIndexPage: loadIndexPage,
14681507
loadLanguagesPage: loadLanguagesPage,
14691508
loadSettingsPage: loadSettingsPage,
1509+
loadThemePage: loadThemePage,
14701510
changeLanguage: changeLanguage,
14711511
floatingActionButton: floatingActionButton,
14721512
changeView: changeView,

scripts/events.js

+79-16
Original file line numberDiff line numberDiff line change
@@ -125,56 +125,119 @@ function eventHover()
125125

126126
}
127127

128-
function eventSwitch()
128+
switchRemoveAnimeST = false;
129+
130+
function switchRemoveAnime()
129131
{
132+
clearTimeout(switchRemoveAnimeST);
133+
134+
switchRemoveAnimeST = setTimeout(function(){
135+
136+
let switchs = document.querySelectorAll('.switch.animeOn, .switch.animeOff');
137+
138+
for(let i = 0, len = switchs.length; i < len; i++)
139+
{
140+
switchs[i].classList.remove('animeOn', 'animeOff');
141+
}
142+
143+
}, 1000);
144+
}
130145

146+
function eventSwitch()
147+
{
131148
$('.switch').on('click.events', function(){
132149

133-
if($(this).hasClass('a'))
150+
let _this = $(this);
151+
152+
if(_this.hasClass('a'))
134153
{
135-
$(this).removeClass('a');
136-
callbackString($(this).attr('off'));
154+
_this.addClass('animeOff').removeClass('a animeOn');
155+
callbackString(_this.attr('off'));
137156
}
138157
else
139158
{
140-
$(this).addClass('a');
141-
callbackString($(this).attr('on'));
159+
_this.addClass('a animeOn').removeClass('animeOff');
160+
callbackString(_this.attr('on'));
142161
}
143162

163+
switchRemoveAnime();
164+
144165
});
145166
}
146167

168+
function rangePosition(input, range)
169+
{
170+
let value = +input.value;
171+
let min = +input.getAttribute('min') || 0;
172+
let max = +input.getAttribute('max');
173+
let step = input.getAttribute('step');
174+
175+
let percent = (value - min) / (max - min) * 100;
176+
177+
range.querySelector('.range-line').style.width = percent+'%';
178+
range.querySelector('.range-point').style.left = percent+'%';
179+
180+
if(step && (max - min) / step < 60) // Only show steps if has less 60
181+
{
182+
let total = Math.round((max - min) / step);
183+
let steps = '';
184+
185+
for(let i = 0; i <= total; i++)
186+
{
187+
let stepValue = i * step;
188+
steps += '<div'+(stepValue > (value - min) ? '' : ' class="active"')+' style="left: '+(i / total * 100)+'%"></div>';
189+
}
190+
191+
range.querySelector('.range-steps').innerHTML = steps;
192+
}
193+
}
194+
147195

148196
function eventRange()
149197
{
150-
$('.range').on('change.events input.events', function(event) {
198+
$('.range input').on('change.events input.events', function(event) {
151199

152-
var onrange = $(this).attr('onrange');
200+
let range = $(this).closest('.range');
153201

154-
var value;
155-
var value_txt = value = $(this).val();
202+
let onrange = this.getAttribute('onrange');
156203

157-
var step = $(this).attr('step');
204+
let value;
205+
let value_txt = value = this.value;
158206

159-
if(typeof step != 'undefined')
207+
let step = this.getAttribute('step');
208+
209+
rangePosition(this, range.get(0));
210+
211+
if(step)
160212
{
161-
var num_v = value_txt.replace(/.*?(\.|$)/, '').length;
213+
let num_v = value_txt.replace(/.*?(\.|$)/, '').length;
162214

163-
var num_s = step.replace(/.*?(\.|$)/, '').length;
215+
let num_s = step.replace(/.*?(\.|$)/, '').length;
164216

165217
if(num_s != 0)
166218
value_txt = value_txt+(value_txt.match(/\./) ? '' : '.')+('0'.repeat(num_s - num_v));
167219
}
168220

169-
var callback = hb.compile(onrange)({
221+
let callback = hb.compile(onrange)({
170222
value: value,
171223
toEnd: (event.type == 'input' ? 'false' : 'true'),
172224
});
173225

174226
callbackString(callback);
175227

176-
$(this).siblings('.simple-slider-text').find('span').html(value_txt);
228+
range.siblings('.simple-slider-text').find('span').html(value_txt);
177229
});
230+
231+
let ranges = document.querySelectorAll('.range');
232+
233+
for(let i = 0, len = ranges.length; i < len; i++)
234+
{
235+
let range = ranges[i];
236+
let input = range.querySelector('input');
237+
238+
rangePosition(input, range);
239+
}
240+
178241
}
179242

180243
function events()

scripts/main.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ require('@electron/remote/main').initialize();
1010
// be closed automatically when the JavaScript object is garbage collected.
1111
var win, appClosing;
1212

13+
process.traceProcessWarnings = true;
14+
1315
function createWindow() {
1416
// Create the browser window.
1517

@@ -57,7 +59,7 @@ function createWindow() {
5759
var menu = Menu.buildFromTemplate(menuTemplate);
5860
win.setMenu(menu);
5961

60-
// win.webContents.openDevTools();
62+
win.webContents.openDevTools();
6163

6264
win.removeMenu();
6365

0 commit comments

Comments
 (0)