Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit cc40fee

Browse files
committed
[feature] add background colour controls
1 parent 682b238 commit cc40fee

10 files changed

Lines changed: 94 additions & 5 deletions

File tree

src/css/base.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ html {
88
}
99

1010
body {
11-
background-color: var(--background);
1211
color: rgb(var(--theme-style-text));
1312
font-size: 1rem;
1413
line-height: 1.6;
@@ -21,6 +20,14 @@ body {
2120
transition: background-color var(--layout-timing-extra-fast);
2221
}
2322

23+
.is-background-color-by-theme body {
24+
background-color: var(--background-color-theme);
25+
}
26+
27+
.is-background-color-by-custom body {
28+
background-color: var(--background-color-custom);
29+
}
30+
2431
.is-layout-scrollpastend body {
2532
margin-bottom: 40vh;
2633
}

src/css/form.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ input[type="color"]:focus {
311311
}
312312

313313
input[type="color"][disabled] {
314-
opacity: 0.5;
314+
opacity: 0.25;
315+
cursor: default;
315316
}
316317

317318
input[type="color"][disabled]:hover,

src/css/variables.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
--layout-shadow-medium: 0 2px 4px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.2);
6161
--layout-shadow-large: 0 3px 6px rgba(0, 0, 0, 0.1), 0 6px 12px rgba(0, 0, 0, 0.2);
6262
/* background */
63-
--background: rgb(var(--theme-gray-01));
63+
--background-color-theme: rgb(var(--theme-gray-01));
64+
--background-color-custom: rgb(0, 0, 0);
6465
--background-image: none;
6566
--background-opacity: 1;
6667
--background-scale: 1;

src/index.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,28 @@ <h1 class="menu-item-header-text">Accent</h1>
10261026
</div>
10271027

10281028
<div class="menu-content-area menu-content-area-background is-hidden">
1029+
<div class="menu-item">
1030+
<div class="menu-item-header">
1031+
<h1 class="menu-item-header-text">Colour</h1>
1032+
</div>
1033+
<div class="menu-item-form">
1034+
<div class="input-wrap">
1035+
<input id="control-background-color-by-theme" class="control-background-color-by-theme" type="radio" name="control-background-color-by" value="theme" tabindex="-1">
1036+
<label for="control-background-color-by-theme">Theme background colour</label>
1037+
</div>
1038+
<p class="control-background-color-by-theme-helper form-helper small">Background colour defined by the Dark or Light Theme.</p>
1039+
<div class="input-wrap">
1040+
<input id="control-background-color-by-custom" class="control-background-color-by-custom" type="radio" name="control-background-color-by" value="custom" tabindex="-1">
1041+
<label for="control-background-color-by-custom">Custom background colour</label>
1042+
</div>
1043+
<div class="form-indent">
1044+
<div class="input-wrap">
1045+
<input id="control-background-color-custom-current" class="control-background-color-custom-current mb-0" type="color" tabindex="1">
1046+
</div>
1047+
<p class="control-background-color-theme-helper form-helper small">Take care as some colours may make the Clock, Date and other text unreadable.</p>
1048+
</div>
1049+
</div>
1050+
</div>
10291051
<div class="menu-item">
10301052
<div class="menu-item-header">
10311053
<h1 class="menu-item-header-text">Image</h1>

src/js/background.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ var background = (function() {
6969

7070
var render = {};
7171

72+
render.color = function() {
73+
var html = helper.e("html");
74+
html.style.setProperty("--background-color-custom", "rgb(" + state.get().background.color.custom.r + ", " + state.get().background.color.custom.g + ", " + state.get().background.color.custom.b + ")");
75+
};
76+
7277
render.image = function() {
7378
var html = helper.e("html");
7479
if (state.get().background.image.show) {
@@ -209,6 +214,7 @@ var background = (function() {
209214
};
210215

211216
var init = function() {
217+
render.color();
212218
render.image();
213219
render.blur();
214220
render.grayscale();

src/js/control.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,6 +2097,29 @@ var control = (function() {
20972097
theme.render.accent.color();
20982098
link.items();
20992099
}
2100+
}, {
2101+
element: helper.e(".control-background-color-by-theme"),
2102+
path: "background.color.by",
2103+
type: "radio",
2104+
func: function() {
2105+
render.dependents();
2106+
render.class();
2107+
}
2108+
}, {
2109+
element: helper.e(".control-background-color-by-custom"),
2110+
path: "background.color.by",
2111+
type: "radio",
2112+
func: function() {
2113+
render.dependents();
2114+
render.class();
2115+
}
2116+
}, {
2117+
element: helper.e(".control-background-color-custom-current"),
2118+
path: "background.color.custom",
2119+
type: "color",
2120+
func: function() {
2121+
background.render.color();
2122+
}
21002123
}, {
21012124
element: helper.e(".control-background-image-show"),
21022125
path: "background.image.show",
@@ -2492,6 +2515,9 @@ var control = (function() {
24922515
};
24932516
};
24942517
var _background = function() {
2518+
helper.removeClass(html, "is-background-color-by-theme");
2519+
helper.removeClass(html, "is-background-color-by-custom");
2520+
helper.addClass(html, "is-background-color-by-" + state.get().background.color.by);
24952521
if (state.get().background.image.show) {
24962522
helper.addClass(html, "is-background-image-show");
24972523
} else {
@@ -3018,6 +3044,13 @@ var control = (function() {
30183044
_disable.input(".control-background-image-url", true);
30193045
_disable.element(".control-background-image-url-helper", true);
30203046
};
3047+
if (state.get().background.color.by == "theme") {
3048+
_disable.input(".control-background-color-custom-current", true);
3049+
_disable.element(".control-background-color-theme-helper", true);
3050+
} else if (state.get().background.color.by == "custom") {
3051+
_disable.input(".control-background-color-custom-current", false);
3052+
_disable.element(".control-background-color-theme-helper", false);
3053+
};
30213054
};
30223055
_header();
30233056
_edit();

src/js/state.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ var state = (function() {
196196
radius: 0.2
197197
},
198198
background: {
199+
color: {
200+
by: "theme",
201+
custom: {
202+
r: 0,
203+
g: 0,
204+
b: 0
205+
}
206+
},
199207
image: {
200208
show: false,
201209
from: "file",

src/js/update.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,17 @@ var update = (function() {
592592
"3.51.0": function(data) {
593593
data.state.link.add = false;
594594
return data;
595+
},
596+
"3.66.0": function(data) {
597+
data.state.background.color = {
598+
by: "theme",
599+
custom: {
600+
r: 0,
601+
g: 0,
602+
b: 0
603+
}
604+
};
605+
return data;
595606
}
596607
};
597608

src/js/version.js

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

3-
var current = "3.65.0";
3+
var current = "3.66.0";
44

55
var compare = function(a, b) {
66
var pa = a.split(".");

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": "3.65.0",
5+
"version": "3.66.0",
66
"manifest_version": 2,
77
"chrome_url_overrides": {
88
"newtab": "index.html"

0 commit comments

Comments
 (0)