Skip to content

Commit 4d7e738

Browse files
authored
[feature] change link url and control colour based on accent
1 parent a5cc2f1 commit 4d7e738

File tree

10 files changed

+68
-52
lines changed

10 files changed

+68
-52
lines changed

‎src/css/link.css‎

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,9 @@
201201
.is-link-url-show:not(.is-link-item-line) .link-item:focus .link-panel-back,
202202
.is-link-url-show:not(.is-link-item-line) .link-item:focus-within .link-panel-back,
203203
.is-link-url-show:not(.is-link-item-line) .link-item:hover .link-panel-back{
204-
top:0;
205204
height:100%;
205+
top:0;
206+
clip-path:polygon(0var(--layout-line-width),100%var(--layout-line-width),100%100%,0100%);
206207
}
207208

208209
.link-control{
@@ -228,6 +229,14 @@
228229
flex-basis:50%;
229230
}
230231

232+
.link-url-text-dark .link-control-item{
233+
color:rgb(var(--theme-black));
234+
}
235+
236+
.link-url-text-light .link-control-item{
237+
color:rgb(var(--theme-white));
238+
}
239+
231240
.link-control-item:first-child{
232241
border-radius:000var(--theme-radius);
233242
}
@@ -236,16 +245,26 @@
236245
border-radius:00var(--theme-radius) 0
237246
}
238247

239-
.link-control-item:focus,
240-
.link-control-item:hover{
241-
color:rgb(var(--theme-style-text));
248+
.link-url-text-dark .link-control-item:focus,
249+
.link-url-text-dark .link-control-item:hover{
250+
color:rgb(var(--theme-black));
242251
background-color:rgba(0,0,0,0.2);
243252
}
244253

245-
.link-control-item:active{
246-
color:rgb(var(--theme-style-text));
247-
background-color:rgba(0,0,0,0.3);
248-
transition: none;
254+
.link-url-text-light .link-control-item:focus,
255+
.link-url-text-light .link-control-item:hover{
256+
color:rgb(var(--theme-white));
257+
background-color:rgba(255,255,255,0.2);
258+
}
259+
260+
.link-url-text-dark .link-control-item:active{
261+
color:rgb(var(--theme-black));
262+
background-color:rgba(0,0,0,0.1);
263+
}
264+
265+
.link-url-text-light .link-control-item:active{
266+
color:rgb(var(--theme-white));
267+
background-color:rgba(255,255,255,0.1);
249268
}
250269

251270
.link-url{
@@ -289,11 +308,11 @@
289308
text-overflow: ellipsis;
290309
}
291310

292-
.is-link-url-style-dark .link-url-text{
311+
.link-url-text-dark .link-url-text{
293312
color:rgb(var(--theme-black));
294313
}
295314

296-
.is-link-url-style-light .link-url-text{
315+
.link-url-text-light .link-url-text{
297316
color:rgb(var(--theme-white));
298317
}
299318

‎src/index.html‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -793,16 +793,6 @@ <h1 class="menu-item-header-text">Bookmarks</h1>
793793
<inputid="control-link-item-url-show" class="control-link-item-url-show" type="checkbox" tabindex="1">
794794
<labelfor="control-link-item-url-show">URL on hover</label>
795795
</div>
796-
<divclass="form-indent">
797-
<divclass="input-wrap">
798-
<inputid="control-link-item-url-style-dark" class="control-link-item-url-style-dark" type="radio" name="control-link-item-url-style" value="dark" tabindex="1">
799-
<labelfor="control-link-item-url-style-dark">Dark text</label>
800-
</div>
801-
<divclass="input-wrap">
802-
<inputid="control-link-item-url-style-light" class="control-link-item-url-style-light" type="radio" name="control-link-item-url-style" value="light" tabindex="1">
803-
<labelfor="control-link-item-url-style-light">Light text</label>
804-
</div>
805-
</div>
806796
<hr>
807797
<divclass="input-wrap">
808798
<inputid="control-link-item-line" class="control-link-item-line" type="checkbox" tabindex="1">
@@ -1046,6 +1036,7 @@ <h1 class="menu-item-header-text">Clear</h1>
10461036

10471037
<!-- vendor -->
10481038
<scriptsrc="js/vendor/html5sortable.min.js"></script>
1039+
<scriptsrc="js/vendor/invert.min.js"></script>
10491040
<!-- nightTab -->
10501041
<scriptsrc="js/helper.js"></script>
10511042
<scriptsrc="js/data.js"></script>

‎src/js/control.js‎

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ var control = (function(){
2626
type: "color",
2727
func: function(){
2828
accent.render();
29+
link.clear();
30+
link.render.item.all();
31+
sortable(".link-area");
2932
}
3033
},{
3134
element: helper.e(".control-layout-width"),
@@ -1820,26 +1823,12 @@ var control = (function(){
18201823
}
18211824
},{
18221825
element: helper.e(".control-link-item-url-show"),
1823-
path: "link.item.url.show",
1826+
path: "link.item.url",
18241827
type: "checkbox",
18251828
func: function(){
18261829
render();
18271830
dependents();
18281831
}
1829-
},{
1830-
element: helper.e(".control-link-item-url-style-dark"),
1831-
path: "link.item.url.style",
1832-
type: "radio",
1833-
func: function(){
1834-
render();
1835-
}
1836-
},{
1837-
element: helper.e(".control-link-item-url-style-light"),
1838-
path: "link.item.url.style",
1839-
type: "radio",
1840-
func: function(){
1841-
render();
1842-
}
18431832
},{
18441833
element: helper.e(".control-link-item-line"),
18451834
path: "link.item.line",
@@ -2027,6 +2016,9 @@ var control = (function(){
20272016
func: function(){
20282017
accent.random();
20292018
accent.render();
2019+
link.clear();
2020+
link.render.item.all();
2021+
sortable(".link-area");
20302022
}
20312023
},{
20322024
element: helper.e(".control-background-image-show"),
@@ -2339,8 +2331,6 @@ var control = (function(){
23392331
helper.removeClass(html,"is-link-display-alignment-vertical-center");
23402332
helper.removeClass(html,"is-link-display-alignment-vertical-bottom");
23412333
helper.removeClass(html,"is-link-url-show");
2342-
helper.removeClass(html,"is-link-url-style-light");
2343-
helper.removeClass(html,"is-link-url-style-dark");
23442334
helper.removeClass(html,"is-link-item-line");
23452335
helper.removeClass(html,"is-link-item-hover-scale");
23462336
helper.removeClass(html,"is-link-item-alignment-horizontal-left");
@@ -2356,14 +2346,13 @@ var control = (function(){
23562346
helper.addClass(html,"is-link-display-alignment-horizontal-"+state.get().link.item.display.alignment.horizontal);
23572347
helper.addClass(html,"is-link-display-alignment-vertical-"+state.get().link.item.display.alignment.vertical);
23582348
helper.addClass(html,"is-link-style-"+state.get().link.style);
2359-
helper.addClass(html,"is-link-url-style-"+state.get().link.item.url.style);
23602349
if(state.get().link.item.name.show){
23612350
helper.addClass(html,"is-link-name-show");
23622351
};
23632352
if(state.get().link.item.display.show){
23642353
helper.addClass(html,"is-link-display-show");
23652354
};
2366-
if(state.get().link.item.url.show){
2355+
if(state.get().link.item.url){
23672356
helper.addClass(html,"is-link-url-show");
23682357
};
23692358
if(state.get().link.item.line){
@@ -2719,8 +2708,6 @@ var control = (function(){
27192708
helper.e(".control-link-item-name-size").disabled=true;
27202709
helper.e(".control-link-item-name-size-default").disabled=true;
27212710
helper.e(".control-link-item-url-show").disabled=true;
2722-
helper.e(".control-link-item-url-style-dark").disabled=true;
2723-
helper.e(".control-link-item-url-style-light").disabled=true;
27242711
helper.e(".control-link-item-line").disabled=true;
27252712
helper.e(".control-link-item-hover-scale").disabled=true;
27262713
helper.e(".control-link-item-display-alignment-horizontal-label").setAttribute("disabled","");
@@ -2772,7 +2759,7 @@ var control = (function(){
27722759
helper.e(".control-link-item-name-size").disabled=false;
27732760
helper.e(".control-link-item-name-size-default").disabled=false;
27742761
};
2775-
if(state.get().link.item.display.show||state.get().link.item.name.show||state.get().link.item.url.show){
2762+
if(state.get().link.item.display.show||state.get().link.item.name.show||state.get().link.item.url){
27762763
helper.e(".control-link-item-display-alignment-horizontal-label").removeAttribute("disabled");
27772764
helper.e(".control-link-item-display-alignment-horizontal-left").disabled=false;
27782765
helper.e(".control-link-item-display-alignment-horizontal-center").disabled=false;
@@ -2782,10 +2769,6 @@ var control = (function(){
27822769
helper.e(".control-link-item-display-alignment-vertical-center").disabled=false;
27832770
helper.e(".control-link-item-display-alignment-vertical-bottom").disabled=false;
27842771
};
2785-
if(state.get().link.item.url.show){
2786-
helper.e(".control-link-item-url-style-dark").disabled=false;
2787-
helper.e(".control-link-item-url-style-light").disabled=false;
2788-
};
27892772
};
27902773
};
27912774
var_theme=function(){

‎src/js/keyboard.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ var keyboard = (function(){
7070
if(event.ctrlKey&&event.altKey&&event.keyCode==82){
7171
accent.random();
7272
accent.render();
73+
link.clear();
74+
link.render.item.all();
75+
sortable(".link-area");
7376
data.save();
7477
};
7578
},false);

‎src/js/link.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,17 @@ var link = (function(){
328328
key: "style",
329329
value: "--theme-accent: "+data.accent.color.r+", "+data.accent.color.g+", "+data.accent.color.b
330330
});
331+
if(invert(data.accent.color,true)=="#000000"){
332+
linkItemOptions.attr[0].value=linkItemOptions.attr[0].value+" link-url-text-dark";
333+
}elseif(invert(data.accent.color,true)=="#ffffff"){
334+
linkItemOptions.attr[0].value=linkItemOptions.attr[0].value+" link-url-text-light";
335+
};
336+
}else{
337+
if(invert(state.get().theme.accent.current,true)=="#000000"){
338+
linkItemOptions.attr[0].value=linkItemOptions.attr[0].value+" link-url-text-dark";
339+
}elseif(invert(state.get().theme.accent.current,true)=="#ffffff"){
340+
linkItemOptions.attr[0].value=linkItemOptions.attr[0].value+" link-url-text-light";
341+
};
331342
};
332343
varlinkItem=helper.makeNode(linkItemOptions);
333344
varlinkPanelFrontOptions={

‎src/js/state.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,7 @@ var state = (function(){
156156
show: true,
157157
size: 0.9,
158158
},
159-
url: {
160-
show: true,
161-
style: "dark"
162-
},
159+
url: true,
163160
size: 1,
164161
line: true,
165162
hoverScale: true

‎src/js/update.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,12 @@ var update = (function(){
560560
returndata;
561561
};
562562

563+
var_update_3200=function(data){
564+
data.version="3.20.0";
565+
data.state.link.item.url=data.state.link.item.url.show;
566+
returndata;
567+
};
568+
563569
// var _update_300 = function(data){
564570
// data.version = 3.00;
565571
// return data;
@@ -698,6 +704,10 @@ var update = (function(){
698704
console.log("\t= running update 3.18.0");
699705
data=_update_3180(data);
700706
};
707+
if(version.compare(data.version,"3.20.0")==-1){
708+
console.log("\t= running update 3.20.0");
709+
data=_update_3200(data);
710+
};
701711
};
702712
// if no update is needed
703713
// version bump

‎src/js/vendor/invert.min.js‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎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="3.19.0";
3+
varcurrent="3.20.0";
44

55
varcompare=function(a,b){
66
varpa=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.19.0",
5+
"version": "3.20.0",
66
"manifest_version": 2,
77
"chrome_url_overrides":{
88
"newtab": "index.html"

0 commit comments

Comments
(0)