-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a white shadow in dark mode #277
Comments
Fix anki-geo#277. I suggest #ccc (202,202,202) rather than pure white, since pure white looked slightly too glowy with Ankidroid's "dark" theme.
I had tested with no offset or spread-radius (as well as a couple of other parameter sets with fractional However, I'm obviously very much in favour of finding a better value for the shadow, if the current one is disliked. Some alternative ideas:
|
I think this is a main reason it looked strange to me at first. Dark shadows should be offset, but light glows ought to be symmetrical. Maybe it would work on your phone with zero offset but a larger
I agree this could work if we can't find pure CSS that's satisfactory.
How about removing the alpha channel and setting shadow color to dark grey? This should effectively be invisible on grey unless looking very closely. Alpha is useful for putting a shadow over a changing background (e.g. gradient or photo), but to me doesn't seem useful for plain backgrounds. For example:
|
If anything, reducing the offset increases (worst-case) visibility, so if the asymmetry is what bothered you, then the You're probably right, though, that for a light glow, asymmetry doesn't make sense!
That's pretty clever! After all, if the shadow colour is the same as the background colour, then the shadow won't be visible. (I'm not convinced a priori that the alpha should be 1, though in practice it just about could be — see below.) The disadvantage of that approach is that if the background is lighter than the glow colour, then the glow will become a (symmetric) shadow again, which isn't really desirable. For reference, AnkiDroid's dark gray background is #303030, while Anki's is #2F2F31. If we set the glow to slightly lighter than #313131, then (assuming iOS's dark gray mode isn't too different) we should be safe (for now...). Let's say #353535 to have a slight margin for changes in Anki or AnkiDroid. With an alpha of 0.2, glow/shadow colour of #CCC and background colour of #000, the current "effective" colour of the glow is #282828 ( To achieve the same "effective" colour, if the colour of the glow/shadow itself is #353535, we need an alpha of ~ Overall, perhaps (removing the asymmetry, as discussed):
Testing it provides the same visibility as the current parameters. (Just using #333 (ignoring alpha) would also be OK, if possibly making the glow slightly too strong.) |
I'm ambivalent to whether alpha stays or goes away, as long as it looks good in practice I'm fine. I think the alpha=0.8 in your last example looks good on grey with the glow essentially invisible. However, I'm noticing another potential problem that also applies to the currently-released styling when on a black background. This occurs when my phone brightness is completely turned down (and I'm in a darkish room, not direct sunlight). In light mode, I can still clearly see the shadow-on-white (shadow contrasting against white flag borders). But in night mode with my phone brightness turned down completely, I can no longer discern glow-on-black (the glow contrasting against black flag borders on black background). I was especially surprised because I can discern the glow against grey, just not against black. I investigated the contrast of various combinations using the tool at leaverou/contrast-ratio. Click to expand contrast investigation(Background Key: Anki Desktop Grey = pc-g, AnkiDroid Grey = droid-g, AnkiDroid Black = droid-b)
I also tested various parameters which achieve contrast with black background of at least 1.6 (CwB≥1.6).
The background change from You can see in the tables above that with the released v3.3 glow with alpha near With alpha near But apparently I still seem to be missing something because when testing on my phone at minimum brightness, the glow is still invisible in the same condition where shadow-on-white is crystal-clear. Even though mathematically, these two should have the same contrast of 1.6. Increasing TLDR: Rather than matching a theme color, how about matching the contrast of the shadow-on-white? I'm not fully satisfied the results of this as it doesn't fix my issue on minimum brightness, but it does significantly increase contrast at the low brightnesses I more typically use. And it seems to be a better basis to me than the somewhat choice of matching theme color #CCC and α=0.2. This suggestion still keeps some alpha, is still symmetrical, is still being mostly invisible against a grey background, and seems to me to still have a low amount of "glowy", Note, I chose α=0.9 rather than α=0.8 because it further reduces visibility against grey. I also wouldn't be opposed to increasing Lastly, it could be nice to apply this css only to flags and not also maps. It could be done easily enough by targeting |
Wow! That's incredibly comprehensive and also really fascinating! (I had indeed also thought that the contrast was greater against the grey background than the black one, but I had been convinced that I was imagining it. The argument about non-linearity in luminance (but not alpha), as well as the calculated contrasts, have persuaded me, though!)
Testing this, it looks great (and works) under both backgrounds and most screen brightnesses! (Under the very lowest screen brightness on AnkiDroid, the glow-on-black still isn't visible, for me (like for you), though obviously that was also the case with the current configuration, and with this the "bad" range has shrunk from the lowest ~10% of brightness to the lowest ~5%.) (Weirdly, unlike you, I do get ~ exactly the same appearance for
With I'm not sure if there's a set of parameters which will allow the glow to be visible on a black edge, at all screen brightnesses, while not being strongly visible on a blue edge. Hence, I think that we either need to compromise between the "glow-on-black" not being visible at the lowest brightnesses and the glow being annoying against a dark-but-not-black flag, or constrain the glow to only be present for the flags that need it (have black elements that can "merge" with the background) and for them, dial it up.
Definitely! (It probably doesn't help much, as most of the maps have light edges against which the glow wouldn't be seen anyway, but the CSS is entirely clear/self-explanatory, so it doesn't hurt readability and possibly even improves it.) TLDR; My vote would go to your suggestions: .nightMode .value > img[src*="-flag"]:not([src*="-nobox"]) {
box-shadow: 0 0 4px 1px rgba(54, 54, 54, 0.9);
} or perhaps a targeted " |
Thank you, I enjoyed the rabbit hole of discovery as well!
Do you mean they look the same to you on a grey background? They have the same appearance on black (both have ~1.6 contrasts), but should have slightly different appearances on grey (1.08 versus 1.17 contrasts). It's not a lot, but on Anki Desktop if I set What surprises me is how different all our systems apparently are. I guess I shouldn't be surprised considering the variation I already see between my computer and phone, but I still am lol.
The |
Yeah, I wouldn't recommend the I actually think keeping a box shadow on all flags (and maps?) is a good idea for visual consistency... unless it's particularly unappealing? Removing the shadow with |
I've made a pull request with what I think is closest to the current consensus: .nightMode .value > img:not([src*="-nobox"]),
.night_mode .value > img:not([src*="-nobox"]) {
box-shadow: 0 0 4px 1px rgba(54, 54, 54, 0.9);
} but please feel free to tear this apart. :) Clearing up my misreading and random musings on luminance
Sorry, I'm a total idiot — I was in a bit of a hurry but still wanted to respond, and misread that section (I completely missed the part about shadow-on-white and illogically assumed you were referring to the variation in alpha from the previous paragraph). (In my reply I had meant that they look the same with a black background, which they obviously have to. FWIW with the grey background they look the same to me at Replying to what you had previously actually written (rather than what I imagined) regarding the difference in visibility of glow-on-black vs. shadow-on-white, at low brightness, despite the contrast being technically the same — I also see shadow-on-white well, at the lowest brightness, while not seeing glow-on-black. I guess it depends exactly on how screen brightness maps onto actual luminance, and how well actual luminance maps onto "W3 luminance". Assuming that screen brightness maps linearly onto the actual luminance of any given pixel and that the actual luminance maps linearly onto "W3 luminance" (with a white pixel, at maximum screen brightness, having a "W3 luminance" of 1), then I think that the discrepancy in glow-on-black vs. shadow-on-white that we observe is due to the 0.05 term in the contrast ratio. In the case of shadow-on-white, at full screen brightness, These are obviously just my rather random thoughts... |
I think your PR is good. Maybe someone else will find an even better solution in the future, but it's better than the existing styling imo and the best we've come up with, so I'm content. For reference, I count 39 flags with black edges that would need
|
I find the current glow particularly unappealing on the map of Melilla. On the other maps I didn't notice it as much, and with the new proposed glow I pretty much don't notice it at all. I also think the visual consistency goals of light and dark mode don't necessarily need to be the same. In light mode the shadow looks good on all rectangular images, and happens to be necessary to add contrast to some flags with white borders. In night mode, glow would ideally be completely unnecessary, but it's necessary for some flags with black borders. |
This might help distinguish the edges of flags which have black elements. (See #274 (comment).)
For example, Afghanistan, Belgium, Ceuta, Egypt or Uganda.
To remind myself: I'll need to test this on both types of Ankidroid's night theme (dark and black).
The text was updated successfully, but these errors were encountered: