···134134 // pageBg should inherit from leafletBg
135135 const bgPage =
136136 !showPageBackground && !hasBackgroundImage ? bgLeaflet : bgPageProp;
137137- // set accent contrast to the accent color that has the highest contrast with the page background
137137+138138 let accentContrast;
139139-140140- //sorting the accents by contrast on background
141139 let sortedAccents = [accent1, accent2].sort((a, b) => {
140140+ // sort accents by contrast against the background
142141 return (
143142 getColorDifference(
144143 colorToString(b, "rgb"),
···150149 )
151150 );
152151 });
153153-154154- // if the contrast-y accent is too similar to the primary text color,
155155- // and the not contrast-y option is different from the backgrond,
156156- // then use the not contrasty option
157157-158152 if (
153153+ // if the contrast-y accent is too similar to text color
159154 getColorDifference(
160155 colorToString(sortedAccents[0], "rgb"),
161156 colorToString(primary, "rgb"),
162157 ) < 0.15 &&
158158+ // and if the other accent is different enough from the background
163159 getColorDifference(
164160 colorToString(sortedAccents[1], "rgb"),
165161 colorToString(showPageBackground ? bgPage : bgLeaflet, "rgb"),
166166- ) > 0.08
162162+ ) > 0.31
167163 ) {
164164+ //then choose the less contrast-y accent
168165 accentContrast = sortedAccents[1];
169169- } else accentContrast = sortedAccents[0];
166166+ } else {
167167+ // otherwise, choose the more contrast-y option
168168+ accentContrast = sortedAccents[0];
169169+ }
170170171171 useEffect(() => {
172172 if (local) return;