···134 // pageBg should inherit from leafletBg
135 const bgPage =
136 !showPageBackground && !hasBackgroundImage ? bgLeaflet : bgPageProp;
137- // set accent contrast to the accent color that has the highest contrast with the page background
138 let accentContrast;
139-140- //sorting the accents by contrast on background
141 let sortedAccents = [accent1, accent2].sort((a, b) => {
0142 return (
143 getColorDifference(
144 colorToString(b, "rgb"),
···150 )
151 );
152 });
153-154- // if the contrast-y accent is too similar to the primary text color,
155- // and the not contrast-y option is different from the backgrond,
156- // then use the not contrasty option
157-158 if (
0159 getColorDifference(
160 colorToString(sortedAccents[0], "rgb"),
161 colorToString(primary, "rgb"),
162 ) < 0.15 &&
0163 getColorDifference(
164 colorToString(sortedAccents[1], "rgb"),
165 colorToString(showPageBackground ? bgPage : bgLeaflet, "rgb"),
166- ) > 0.08
167 ) {
0168 accentContrast = sortedAccents[1];
169- } else accentContrast = sortedAccents[0];
000170171 useEffect(() => {
172 if (local) return;
···134 // pageBg should inherit from leafletBg
135 const bgPage =
136 !showPageBackground && !hasBackgroundImage ? bgLeaflet : bgPageProp;
137+138 let accentContrast;
00139 let sortedAccents = [accent1, accent2].sort((a, b) => {
140+ // sort accents by contrast against the background
141 return (
142 getColorDifference(
143 colorToString(b, "rgb"),
···149 )
150 );
151 });
00000152 if (
153+ // if the contrast-y accent is too similar to text color
154 getColorDifference(
155 colorToString(sortedAccents[0], "rgb"),
156 colorToString(primary, "rgb"),
157 ) < 0.15 &&
158+ // and if the other accent is different enough from the background
159 getColorDifference(
160 colorToString(sortedAccents[1], "rgb"),
161 colorToString(showPageBackground ? bgPage : bgLeaflet, "rgb"),
162+ ) > 0.31
163 ) {
164+ //then choose the less contrast-y accent
165 accentContrast = sortedAccents[1];
166+ } else {
167+ // otherwise, choose the more contrast-y option
168+ accentContrast = sortedAccents[0];
169+ }
170171 useEffect(() => {
172 if (local) return;