Skip to content

Commit 9456fd3

Browse files
committed
[design] improve link item name colour
1 parent 7574b14 commit 9456fd3

File tree

2 files changed

+40
-14
lines changed

2 files changed

+40
-14
lines changed

‎src/js/link.js‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,18 +1360,23 @@ var link = (function(){
13601360
};
13611361
if(stagedLink.link.color.by=="custom"){
13621362
varhsl=helper.convertColor.rgb.hsl(stagedLink.link.color.rgb);
1363-
varshades=theme.mod.color.shades(stagedLink.link.color.rgb);
1363+
1364+
varshades=theme.mod.color.shades({
1365+
rgb: stagedLink.link.color.rgb,
1366+
contrastNegative: 8,
1367+
contrastPositive: 8
1368+
});
1369+
13641370
varrgb;
1365-
if(hsl.l<50){
1366-
rgb=shades.positive["10"];
1367-
}else{
1368-
rgb=shades.negative["10"];
1369-
};
1370-
if(hsl.l<50){
1371+
1372+
if(hsl.l<=50){
1373+
rgb=shades.positive["9"];
13711374
linkItemStyle.push("--theme-style-text: var(--theme-white);");
13721375
}else{
1376+
rgb=shades.negative["9"];
13731377
linkItemStyle.push("--theme-style-text: var(--theme-black);");
13741378
};
1379+
13751380
linkItemStyle.push("--link-item-visual-element-color-focus-hover: var(--theme-style-text);");
13761381
linkItemStyle.push("--link-item-color: "+stagedLink.link.color.rgb.r+", "+stagedLink.link.color.rgb.g+", "+stagedLink.link.color.rgb.b+"");
13771382
linkItemStyle.push("--link-item-color-focus-hover: "+stagedLink.link.color.rgb.r+", "+stagedLink.link.color.rgb.g+", "+stagedLink.link.color.rgb.b+"");

‎src/js/theme.js‎

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -741,12 +741,28 @@ var theme = (function(){
741741
}
742742
});
743743
},
744-
shades: function(rgb){
744+
shades: function(override){
745+
varoptions={
746+
rgb: null,
747+
contrastNegative: null,
748+
contrastPositive: null
749+
};
750+
if(override){
751+
options=helper.applyOptions(options,override);
752+
};
753+
745754
varshadeMax=10;
746755
varshadeMin=1;
747-
varcontrastNeg=state.get.current().theme.color.contrast.dark;
748-
varcontrastPos=state.get.current().theme.color.contrast.light;
749-
varhsl=helper.convertColor.rgb.hsl(rgb);
756+
757+
if(options.contrastNegative==null||!options.contrastNegative){
758+
options.contrastNegative=state.get.default().theme.color.contrast.dark;
759+
};
760+
if(options.contrastPositive==null||!options.contrastPositive){
761+
options.contrastPositive=state.get.default().theme.color.contrast.light;
762+
};
763+
764+
varhsl=helper.convertColor.rgb.hsl(options.rgb);
765+
750766
varvalidateRGBNumber=function(rgb){
751767
for(varkeyinrgb){
752768
if(rgb[key]<0){
@@ -764,11 +780,12 @@ var theme = (function(){
764780
positive: {}
765781
};
766782

783+
// set light theme shades
767784
for(vari=shadeMax;i>=shadeMin;i--){
768785
varrgb=helper.convertColor.hsl.rgb({
769786
h: hsl.h,
770787
s: hsl.s,
771-
l: hsl.l-(contrastNeg*i)
788+
l: hsl.l-(options.contrastNegative*i)
772789
});
773790
shadeColors.negative[i]=validateRGBNumber(rgb);
774791
};
@@ -778,15 +795,19 @@ var theme = (function(){
778795
varrgb=helper.convertColor.hsl.rgb({
779796
h: hsl.h,
780797
s: hsl.s,
781-
l: hsl.l+(contrastPos*i)
798+
l: hsl.l+(options.contrastPositive*i)
782799
});
783800
shadeColors.positive[i]=validateRGBNumber(rgb);
784801
};
785802

786803
returnshadeColors;
787804
},
788805
generated: function(){
789-
varshades=mod.color.shades(state.get.current().theme.color.rgb);
806+
varshades=mod.color.shades({
807+
rgb: state.get.current().theme.color.rgb,
808+
contrastNegative: state.get.current().theme.color.contrast.dark,
809+
contrastPositive: state.get.current().theme.color.contrast.light
810+
});
790811
helper.setObject({
791812
object: state.get.current(),
792813
path: "theme.color.generated.negative",

0 commit comments

Comments
(0)