Skip to content

Commit a1ba15a

Browse files
committed
[feature] add link background colour controls
1 parent 340fad2 commit a1ba15a

File tree

12 files changed

+143
-19
lines changed

12 files changed

+143
-19
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": "4.4.1",
3+
"version": "4.5.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/link.css‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115

116116
/* link panel front */
117117
.link-panel-front{
118-
background-color:rgb(var(--theme-color-02));
119118
position: absolute;
120119
left:0;
121120
width:100%;
@@ -128,6 +127,14 @@
128127
transition: background-color var(--layout-timing-extra-fast), height var(--layout-timing-extra-fast), box-shadow var(--layout-timing-extra-fast), border-radius var(--layout-timing-extra-fast);
129128
}
130129

130+
.is-link-item-color-by-theme .link-panel-front{
131+
background-color:rgb(var(--link-item-color-theme));
132+
}
133+
134+
.is-link-item-color-by-custom .link-panel-front{
135+
background-color:rgb(var(--link-item-color-custom));
136+
}
137+
131138
.is-link-style-block .link-panel-front{
132139
padding:1em;
133140
}
@@ -163,11 +170,18 @@
163170
.link-item:focus-within .link-panel-front,
164171
.link-item:focus .link-panel-front,
165172
.link-item:hover .link-panel-front{
166-
background-color:rgb(var(--theme-color-03));
167173
outline: none;
168174
text-decoration: none;
169175
}
170176

177+
.is-link-item-color-by-theme .link-panel-front:hover,
178+
.is-link-item-color-by-theme .link-panel-front:focus,
179+
.is-link-item-color-by-theme .link-item:focus-within .link-panel-front,
180+
.is-link-item-color-by-theme .link-item:focus .link-panel-front,
181+
.is-link-item-color-by-theme .link-item:hover .link-panel-front{
182+
background-color:rgb(var(--theme-color-03));
183+
}
184+
171185
.is-link-item-shadow-show .link-item:focus .link-panel-front,
172186
.is-link-item-shadow-show .link-item:focus-within .link-panel-front,
173187
.is-link-item-shadow-show .link-item:hover .link-panel-front{

‎src/css/variables.css‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
--group-border:0;
4545
/* link */
4646
--link-area-width:100%;
47+
--link-item-color-theme:var(--theme-color-02);
48+
--link-item-color-custom:rgb(0,0,0);
4749
--link-item-size:1em;
4850
--link-item-display-space:0.25em;
4951
--link-item-display-gutter:2;

‎src/index.html‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,32 @@ <h1 class="menu-item-header-text">Bookmarks</h1>
11901190
</div>
11911191
</div>
11921192
</div>
1193+
<divclass="menu-item">
1194+
<divclass="menu-item-header">
1195+
<h1class="menu-item-header-text">Background colour</h1>
1196+
</div>
1197+
<divclass="menu-item-form">
1198+
<divclass="input-wrap">
1199+
<inputid="control-link-item-color-by-theme" class="control-link-item-color-by-theme" type="radio" name="control-link-item-color-by" value="theme" tabindex="-1">
1200+
<labelfor="control-link-item-color-by-theme"><spanclass="label-icon"></span> Theme background colour</label>
1201+
</div>
1202+
<pclass="control-link-item-color-by-theme-helper form-helper small">Use the Background colour defined by the Theme.</p>
1203+
<divclass="input-wrap">
1204+
<inputid="control-link-item-color-by-custom" class="control-link-item-color-by-custom" type="radio" name="control-link-item-color-by" value="custom" tabindex="-1">
1205+
<labelfor="control-link-item-color-by-custom"><spanclass="label-icon"></span> Custom background colour</label>
1206+
</div>
1207+
<pclass="control-link-item-color-by-custom-helper form-helper small">Use a custom Background colour.</p>
1208+
<pclass="control-link-item-color-by-custom-helper form-helper small">Take care as some colours may make the Letter/Icon and Name unreadable.</p>
1209+
<divclass="form-indent">
1210+
<divclass="input-wrap">
1211+
<divclass="form-group form-group-block mb-0">
1212+
<inputid="control-link-item-color-by-picker" class="form-group-item-half control-link-item-color-by-picker mb-0" type="color" value="#000000" tabindex="1">
1213+
<inputid="control-link-item-color-by-hex" class="form-group-item-half control-link-item-color-by-hex mb-0" type="text" placeholder="Hex code" value="#000000" tabindex="1" maxlength="7" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
1214+
</div>
1215+
</div>
1216+
</div>
1217+
</div>
1218+
</div>
11931219
<divclass="menu-item">
11941220
<divclass="menu-item-header">
11951221
<h1class="menu-item-header-text">Border</h1>
@@ -1486,7 +1512,7 @@ <h1 class="menu-item-header-text">Colour</h1>
14861512
<inputid="control-background-color-by-theme" class="control-background-color-by-theme" type="radio" name="control-background-color-by" value="theme" tabindex="-1">
14871513
<labelfor="control-background-color-by-theme"><spanclass="label-icon"></span> Theme background colour</label>
14881514
</div>
1489-
<pclass="control-background-color-by-theme-helper form-helper small">Use the Background colour defined by the Dark or Light Theme.</p>
1515+
<pclass="control-background-color-by-theme-helper form-helper small">Use the Background colour defined by the Theme.</p>
14901516
<divclass="input-wrap">
14911517
<inputid="control-background-color-by-custom" class="control-background-color-by-custom" type="radio" name="control-background-color-by" value="custom" tabindex="-1">
14921518
<labelfor="control-background-color-by-custom"><spanclass="label-icon"></span> Custom background colour</label>
@@ -1496,8 +1522,8 @@ <h1 class="menu-item-header-text">Colour</h1>
14961522
<divclass="form-indent">
14971523
<divclass="input-wrap">
14981524
<divclass="form-group form-group-block mb-0">
1499-
<inputid="control-background-color-custom-current-picker" class="form-group-item-half control-background-color-custom-current-picker mb-0" type="color" value="#000000" tabindex="1">
1500-
<inputid="control-background-color-custom-current-hex" class="form-group-item-half control-background-color-custom-current-hex mb-0" type="text" placeholder="Hex code" value="#000000" tabindex="1" maxlength="7" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
1525+
<inputid="control-background-color-by-picker" class="form-group-item-half control-background-color-by-picker mb-0" type="color" value="#000000" tabindex="1">
1526+
<inputid="control-background-color-by-hex" class="form-group-item-half control-background-color-by-hex mb-0" type="text" placeholder="Hex code" value="#000000" tabindex="1" maxlength="7" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
15011527
</div>
15021528
</div>
15031529
</div>

‎src/js/background.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ var background = (function(){
127127
helper.e(".control-background-image-file").value="";
128128
},
129129
picker: function(){
130-
helper.e(".control-background-color-custom-current-picker").value=helper.rgbToHex(state.get.current().background.color.custom);
130+
helper.e(".control-background-color-by-picker").value=helper.rgbToHex(state.get.current().background.color.custom);
131131
},
132132
hex: function(){
133-
helper.e(".control-background-color-custom-current-hex").value=helper.rgbToHex(state.get.current().background.color.custom);
133+
helper.e(".control-background-color-by-hex").value=helper.rgbToHex(state.get.current().background.color.custom);
134134
}
135135
};
136136

‎src/js/control.js‎

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,6 +2417,39 @@ var control = (function(){
24172417
func: function(){
24182418
link.groupAndItems();
24192419
}
2420+
},{
2421+
element: helper.e(".control-link-item-color-by-theme"),
2422+
path: "link.item.color.by",
2423+
type: "radio",
2424+
func: function(){
2425+
render.dependents();
2426+
render.class();
2427+
}
2428+
},{
2429+
element: helper.e(".control-link-item-color-by-custom"),
2430+
path: "link.item.color.by",
2431+
type: "radio",
2432+
func: function(){
2433+
render.dependents();
2434+
render.class();
2435+
}
2436+
},{
2437+
element: helper.e(".control-link-item-color-by-picker"),
2438+
path: "link.item.color.custom",
2439+
type: "color",
2440+
func: function(){
2441+
link.render.item.color.custom();
2442+
link.render.input.hex();
2443+
}
2444+
},{
2445+
element: helper.e(".control-link-item-color-by-hex"),
2446+
path: "link.item.color.custom",
2447+
type: "text",
2448+
valueMod: ["hexTextString"],
2449+
func: function(){
2450+
link.render.item.color.custom();
2451+
link.render.input.picker();
2452+
}
24202453
},{
24212454
element: helper.e(".control-link-item-border"),
24222455
path: "link.item.border",
@@ -2730,15 +2763,15 @@ var control = (function(){
27302763
render.class();
27312764
}
27322765
},{
2733-
element: helper.e(".control-background-color-custom-current-picker"),
2766+
element: helper.e(".control-background-color-by-picker"),
27342767
path: "background.color.custom",
27352768
type: "color",
27362769
func: function(){
27372770
background.render.color.custom();
27382771
background.render.input.hex();
27392772
}
27402773
},{
2741-
element: helper.e(".control-background-color-custom-current-hex"),
2774+
element: helper.e(".control-background-color-by-hex"),
27422775
path: "background.color.custom",
27432776
type: "text",
27442777
valueMod: ["hexTextString"],
@@ -3150,6 +3183,8 @@ var control = (function(){
31503183
helper.removeClass(html,"is-link-display-alignment-bottomleft");
31513184
helper.removeClass(html,"is-link-display-alignment-bottomcenter");
31523185
helper.removeClass(html,"is-link-display-alignment-bottomright");
3186+
helper.removeClass(html,"is-link-item-color-by-theme");
3187+
helper.removeClass(html,"is-link-item-color-by-custom");
31533188
helper.removeClass(html,"is-link-item-display-direction-horizontal");
31543189
helper.removeClass(html,"is-link-item-display-direction-vertical");
31553190
helper.removeClass(html,"is-link-item-display-order-letconname");
@@ -3168,6 +3203,7 @@ var control = (function(){
31683203
if(state.get.current().link.show){
31693204
helper.addClass(html,"is-link-show");
31703205
helper.addClass(html,"is-link-area-alignment-"+state.get.current().link.area.alignment);
3206+
helper.addClass(html,"is-link-item-color-by-"+state.get.current().link.item.color.by);
31713207
helper.addClass(html,"is-link-item-display-direction-"+state.get.current().link.item.display.direction);
31723208
helper.addClass(html,"is-link-item-display-order-"+state.get.current().link.item.display.order);
31733209
helper.addClass(html,"is-link-display-alignment-"+state.get.current().link.item.display.alignment);
@@ -3672,6 +3708,12 @@ var control = (function(){
36723708
_disable.input(".control-link-item-display-alignment-bottomcenter",true);
36733709
_disable.input(".control-link-item-display-alignment-bottomright",true);
36743710
_disable.input(".control-link-newtab",true);
3711+
_disable.input(".control-link-item-color-by-theme",true);
3712+
_disable.element(".control-link-item-color-by-theme-helper",true);
3713+
_disable.input(".control-link-item-color-by-custom",true);
3714+
_disable.element(".control-link-item-color-by-custom-helper",true);
3715+
_disable.input(".control-link-item-color-by-picker",true);
3716+
_disable.input(".control-link-item-color-by-hex",true);
36753717
_disable.element("[for=control-link-item-border]",true);
36763718
_disable.input(".control-link-item-border",true);
36773719
_disable.element(".control-link-item-border-count",true);
@@ -3714,6 +3756,10 @@ var control = (function(){
37143756
_disable.input(".control-link-item-shadow-show",false);
37153757
_disable.input(".control-link-item-hoverscale",false);
37163758
_disable.input(".control-link-newtab",false);
3759+
_disable.input(".control-link-item-color-by-theme",false);
3760+
_disable.element(".control-link-item-color-by-theme-helper",false);
3761+
_disable.input(".control-link-item-color-by-custom",false);
3762+
_disable.element(".control-link-item-color-by-custom-helper",false);
37173763
_disable.element("[for=control-link-item-border]",false);
37183764
_disable.input(".control-link-item-border",false);
37193765
_disable.element(".control-link-item-border-count",false);
@@ -3783,6 +3829,10 @@ var control = (function(){
37833829
_disable.element(".control-link-item-display-gutter-count",false);
37843830
_disable.input(".control-link-item-display-gutter-default",false);
37853831
};
3832+
if(state.get.current().link.item.color.by=="custom"){
3833+
_disable.input(".control-link-item-color-by-picker",false);
3834+
_disable.input(".control-link-item-color-by-hex",false);
3835+
};
37863836
};
37873837
};
37883838
var_theme=function(){
@@ -3859,13 +3909,11 @@ var control = (function(){
38593909
_disable.element(".control-background-image-url-helper",true);
38603910
};
38613911
if(state.get.current().background.color.by=="theme"){
3862-
_disable.input(".control-background-color-custom-current-picker",true);
3863-
_disable.input(".control-background-color-custom-current-hex",true);
3864-
_disable.element(".control-background-color-theme-helper",true);
3912+
_disable.input(".control-background-color-by-picker",true);
3913+
_disable.input(".control-background-color-by-hex",true);
38653914
}elseif(state.get.current().background.color.by=="custom"){
3866-
_disable.input(".control-background-color-custom-current-picker",false);
3867-
_disable.input(".control-background-color-custom-current-hex",false);
3868-
_disable.element(".control-background-color-theme-helper",false);
3915+
_disable.input(".control-background-color-by-picker",false);
3916+
_disable.input(".control-background-color-by-hex",false);
38693917
};
38703918
};
38713919
_header();

‎src/js/link.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,11 @@ var link = (function(){
523523
};
524524

525525
render.item={
526+
color: {
527+
custom: function(){
528+
helper.e("html").style.setProperty("--link-item-color-custom",state.get.current().link.item.color.custom.r+", "+state.get.current().link.item.color.custom.g+", "+state.get.current().link.item.color.custom.b);
529+
}
530+
},
526531
link: function(){
527532
varlinkItemOptions={
528533
tag: "div",
@@ -1661,6 +1666,15 @@ var link = (function(){
16611666
}
16621667
};
16631668

1669+
render.input={
1670+
picker: function(){
1671+
helper.e(".control-link-item-color-by-picker").value=helper.rgbToHex(state.get.current().link.item.color.custom);
1672+
},
1673+
hex: function(){
1674+
helper.e(".control-link-item-color-by-hex").value=helper.rgbToHex(state.get.current().link.item.color.custom);
1675+
}
1676+
};
1677+
16641678
varadd={
16651679
item: {
16661680
open: function(){
@@ -1756,6 +1770,7 @@ var link = (function(){
17561770
groupAndItems();
17571771
render.group.size();
17581772
render.group.border();
1773+
render.item.color.custom();
17591774
render.item.size();
17601775
render.item.display.letter();
17611776
render.item.display.icon();

‎src/js/state.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ var state = (function(){
139139
alignment: "center"
140140
},
141141
item: {
142+
color: {
143+
by: "theme",
144+
custom: {
145+
r: 0,
146+
g: 0,
147+
b: 0
148+
}
149+
},
142150
display: {
143151
letcon: {
144152
show: true,

‎src/js/update.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,17 @@ var update = (function(){
711711
data.state.header.button.colorAccent=data.state.header.button.accent;
712712
deletedata.state.header.button.accent;
713713
returndata;
714+
},
715+
"4.5.0": function(data){
716+
data.state.link.item.color={
717+
by: "theme",
718+
custom: {
719+
r: 0,
720+
g: 0,
721+
b: 0
722+
}
723+
};
724+
returndata;
714725
}
715726
};
716727

0 commit comments

Comments
(0)