Skip to content

Commit 7968534

Browse files
committed
[feature] add support for system prefered colour scheme
1 parent 88a3c05 commit 7968534

File tree

9 files changed

+90
-5
lines changed

9 files changed

+90
-5
lines changed

‎package-lock.json‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nightTab",
3-
"version": "5.14.0",
3+
"version": "5.15.0",
44
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
55
"main": "index.js",
66
"scripts":{

‎src/css/variables.css‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,60 @@
330330
--theme-style-text:var(--theme-black);
331331
}
332332

333+
@media (prefers-color-scheme: light){
334+
.is-theme-style-system{
335+
--theme-color:var(--theme-shade);
336+
--theme-color-01:var(--theme-shade-positive-10);
337+
--theme-color-02:var(--theme-shade-positive-09);
338+
--theme-color-03:var(--theme-shade-positive-08);
339+
--theme-color-04:var(--theme-shade-positive-07);
340+
--theme-color-05:var(--theme-shade-positive-06);
341+
--theme-color-06:var(--theme-shade-positive-05);
342+
--theme-color-07:var(--theme-shade-positive-04);
343+
--theme-color-08:var(--theme-shade-positive-03);
344+
--theme-color-09:var(--theme-shade-positive-02);
345+
--theme-color-10:var(--theme-shade-positive-01);
346+
--theme-color-11:var(--theme-shade-negative-01);
347+
--theme-color-12:var(--theme-shade-negative-02);
348+
--theme-color-13:var(--theme-shade-negative-03);
349+
--theme-color-14:var(--theme-shade-negative-04);
350+
--theme-color-15:var(--theme-shade-negative-05);
351+
--theme-color-16:var(--theme-shade-negative-06);
352+
--theme-color-17:var(--theme-shade-negative-07);
353+
--theme-color-18:var(--theme-shade-negative-08);
354+
--theme-color-19:var(--theme-shade-negative-09);
355+
--theme-color-20:var(--theme-shade-negative-10);
356+
--theme-style-text:var(--theme-black);
357+
}
358+
}
359+
360+
@media (prefers-color-scheme: dark){
361+
.is-theme-style-system{
362+
--theme-color:var(--theme-shade);
363+
--theme-color-01:var(--theme-shade-negative-10);
364+
--theme-color-02:var(--theme-shade-negative-09);
365+
--theme-color-03:var(--theme-shade-negative-08);
366+
--theme-color-04:var(--theme-shade-negative-07);
367+
--theme-color-05:var(--theme-shade-negative-06);
368+
--theme-color-06:var(--theme-shade-negative-05);
369+
--theme-color-07:var(--theme-shade-negative-04);
370+
--theme-color-08:var(--theme-shade-negative-03);
371+
--theme-color-09:var(--theme-shade-negative-02);
372+
--theme-color-10:var(--theme-shade-negative-01);
373+
--theme-color-11:var(--theme-shade-positive-01);
374+
--theme-color-12:var(--theme-shade-positive-02);
375+
--theme-color-13:var(--theme-shade-positive-03);
376+
--theme-color-14:var(--theme-shade-positive-04);
377+
--theme-color-15:var(--theme-shade-positive-05);
378+
--theme-color-16:var(--theme-shade-positive-06);
379+
--theme-color-17:var(--theme-shade-positive-07);
380+
--theme-color-18:var(--theme-shade-positive-08);
381+
--theme-color-19:var(--theme-shade-positive-09);
382+
--theme-color-20:var(--theme-shade-positive-10);
383+
--theme-style-text:var(--theme-white);
384+
}
385+
}
386+
333387
.is-link-style-block{
334388
/* link */
335389
--link-item-width:11em;

‎src/html/menu/content/theme/style.html‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ <h1 class="menu-item-header-text">Style</h1>
1111
<inputid="control-theme-style-light" class="control-theme-style-light" type="radio" name="control-theme-style" value="light" tabindex="-1">
1212
<labelfor="control-theme-style-light"><spanclass="label-icon"></span> Light</label>
1313
</div>
14+
<divclass="form-wrap">
15+
<inputid="control-theme-style-system" class="control-theme-style-system" type="radio" name="control-theme-style" value="system" tabindex="-1">
16+
<labelfor="control-theme-style-system"><spanclass="label-icon"></span> Follow system light or dark</label>
17+
</div>
1418
<divclass="form-helper">
1519
<pclass="control-theme-style-helper form-helper-item">Flip the colour shades defined by the primary Colour.</p>
1620
</div>

‎src/js/control.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4649,6 +4649,13 @@ var control = (function(){
46494649
func: function(){
46504650
theme.style.light();
46514651
}
4652+
},{
4653+
element: ".control-theme-style-system",
4654+
path: "theme.style",
4655+
type: "radio",
4656+
func: function(){
4657+
theme.style.system();
4658+
}
46524659
}],
46534660
color: [{
46544661
element: ".control-theme-color-rgb-color",

‎src/js/keyboard.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ var keyboard = (function(){
124124
// ctrl+alt+d
125125
if(event.ctrlKey&&event.altKey&&event.keyCode==68){
126126
theme.style.toggle();
127-
control.render.update.control.header();
128127
control.render.update.control.menu();
129128
data.save();
130129
};

‎src/js/theme.js‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ var theme = (function(){
137137
path: "theme.style",
138138
newValue: "dark"
139139
});
140+
},
141+
system: function(){
142+
helper.setObject({
143+
object: state.get.current(),
144+
path: "theme.style",
145+
newValue: "system"
146+
});
140147
}
141148
};
142149

@@ -1700,11 +1707,19 @@ var theme = (function(){
17001707
varhtml=helper.e("html");
17011708
helper.addClass(html,"is-theme-style-dark");
17021709
helper.removeClass(html,"is-theme-style-light");
1710+
helper.removeClass(html,"is-theme-style-system");
17031711
},
17041712
light: function(){
17051713
varhtml=helper.e("html");
17061714
helper.removeClass(html,"is-theme-style-dark");
17071715
helper.addClass(html,"is-theme-style-light");
1716+
helper.removeClass(html,"is-theme-style-system");
1717+
},
1718+
system: function(){
1719+
varhtml=helper.e("html");
1720+
helper.removeClass(html,"is-theme-style-dark");
1721+
helper.removeClass(html,"is-theme-style-light");
1722+
helper.addClass(html,"is-theme-style-system");
17081723
}
17091724
};
17101725

@@ -2290,11 +2305,17 @@ var theme = (function(){
22902305
mod.style.light();
22912306
render.style.light();
22922307
},
2308+
system: function(){
2309+
mod.style.system();
2310+
render.style.system();
2311+
},
22932312
check: function(){
22942313
if(state.get.current().theme.style=="dark"){
22952314
style.dark();
22962315
}elseif(state.get.current().theme.style=="light"){
22972316
style.light();
2317+
}elseif(state.get.current().theme.style=="system"){
2318+
style.system();
22982319
};
22992320
},
23002321
toggle: function(){

‎src/js/version.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
varversion=(function(){
22

3-
varcurrent="5.14.0";
3+
varcurrent="5.15.0";
44

55
varname="Zonked Tarsier";
66

‎src/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nightTab",
33
"short_name": "nightTab",
44
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
5-
"version": "5.14.0",
5+
"version": "5.15.0",
66
"manifest_version": 2,
77
"chrome_url_overrides":{
88
"newtab": "index.html"

0 commit comments

Comments
(0)