Problem/Motivation
The animated GIFs loading.gif and loading-small.gif icons look poor on HiDPI displays.
Note: some instances of .ajax-progress-throbber currently reference loading-small.gif, while others reference throbber-active.gif. throbber-active.gif is being worked on in a separate issue #1974928.
Proposed resolution
-
Replace the animated GIF file
loading.gifwith an animated scalable vector graphic (SVG)loading.svgthat matches the look and feel. -
Replace the animated GIF file
loading-small.gifwith an animated scalable vector graphic (SVG)loading-small.svgthat matches the look and feel. -
Update all references in Drupal core where loading-small.gif was previously used in the CSS
background-image, including some instances of.ajax-progress-throbberand all instances of.ajax-progress-fullscreen. Since loading.gif is not referenced anywhere in Drupal core except in a single test, no CSS or IMG tag changes are required for this image. -
Add an .htaccess RedirectRule to forward requests to the deleted GIF images to their respective SVG image equivalents.
Before / After comparison:
-
loading.gif => loading.svg
https://codepen.io/jameswilson/pen/OJYXqZE -
loading-small.gif => loading-small.svg
https://codepen.io/jameswilson/pen/oNRLVxx
Remaining tasks
Use the visual style / look of the existing loading GIF.Create an SVG based on ^ and animate it.- Create an MR.
- Review and commit.
User interface changes
Users on devices with high resolution screens will see a modern, crisp image with no diffusion artifacts or blur inherent from legacy image formats.
Users on devices with low resolution may or may not notice any visual difference.
API changes
In as much as images can be considered an "API", the old GIF files will be removed. In case any themes still reference the old images, the routes to these static assets can be redirected at the server level to the new SVG assets. Such redirects have been added to the .htaccess file shipped with Drupal core.
Data model changes
None.
Release notes snippet
Not necessary.
| Comment | File | Size | Author |
|---|
Issue fork drupal-2575253
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 11.x
compare
- 2575253-update-loading-icon
changes, plain diff MR !8143
Comments
Comment #2
Jmdrawneek@googlemail.com commentedI'll create a few styles and see what you guys think.
Comment #3
Jmdrawneek@googlemail.com commentedDoes anyone have any thoughts on these?
http://codepen.io/jmdrawneek/pen/ZbBpoK
Comment #4
jwilson3Comment #5
jwilson3I'm not sure about the change from white on black to blue on white.
I think it would be good to get a quick screenshot of how some of these are used on the page in context.
Comment #6
jwilson3Of the demos you created, the best one is the first one. The radial effect is probably a winner, however there are too few "slices" of the different levels of transparency that make the radial gradient look blotchy. So, I made a first attempt at an improved codepen that uses a more "fluid" radial effect to avoid the jagged edges.
http://codepen.io/jameswilson/full/xwRXZy/
But while working on it, it became clear that this is not a realistic way to build the spinner because it depends on a second SVG with a radial gradient overlay that is then spun around, so when you change the background color behind the gradient to anything other than white, the effect looks extremely poor.
On white
On gray
For the more complex objects (like the druplicon or the star) we'll need to rewrite these using SVG masks. For the least complex radial one, I was able to refactor it to just a single rotating SVG, which resolves the issue of different background colors:
http://codepen.io/jameswilson/pen/BoQJVB
Comment #7
Jmdrawneek@googlemail.com commentedYea I think the radial/gradient idea could work well. (Those were just sketches really hence lacking being polished)
What about wrapping the SVG in HTML with a background colour? That would make it more consistent and give it some adaptability to change the background/border at will.
I'll create some mockups of where it would be used this weekend.
Comment #8
mgiffordThose look great. I like the idea of using the drupal logo rather than just a circle.
Comment #9
snehi commentedI am ok with using the drupal logo rather then just a circle.
but the standard is this:
Comment #10
xaiwant commentedHow about this.
Comment #11
mgiffordI'd go for #9, but that's just because it is a bit different. Both look good. How do we decide? Can it be done by 8.0.0?
Comment #12
Bojhan commentedIsn't there already an issue about this leveraging the style guide design (which we should follow, not invent our own here). ?
Comment #13
mgiffordI didn't find it https://groups.drupal.org/node/283223
Could it be somewhere else? Spinners are mentioned but not defined.
Comment #14
Jmdrawneek@googlemail.com commentedHow about something like these?
These use a single svg that rotates, so gets around the issue above.
(Sorry about disappearing – relocating is time-consuming)
Comment #16
emma.mariaThere is an older issue with an identical title, aim and agreed design in place over here... #1974928: Update Drupal's default throbber icons.
Comment #17
jwilson3They are different icons, used in different places as far as I can tell. one is "throbber" the other one is "loading" and they are used for different purposes, which (i presume) is why they have different designs already in core. Agreed that the design is all over the place here. Why group two unrelated animated icons into one issue?
Comment #18
jwilson3Could we scope this issue to leave the design of loading.gif alone and *just* convert the icon "as-is" to a CSS-animated SVG?
Comment #19
jwilson3Here is a prototype using pure CSS animations:
http://codepen.io/jameswilson/pen/WwqyjK
Comment #20
emma.mariaComment #22
mradcliffeAdding dublin2016 tag for general code sprints.
Comment #23
tameeshb commented@jwilson3 May I work on this task or is it for a websprint ?
Comment #25
jwilson3@tameeshb, i think this is free to be worked on but be advised that other people are looking at this through the seven theme's design direction, so you might want to coordinate efforts with others that are involved there first before spinning wheels on design work as has been done in some of the previous comments on this thread.
Please see: #2775725: Update the throbber icon
Comment #26
tameeshb commentedOkay @jwilson3 I'll head over to #2775725
Comment #28
andypostComment #29
rachanakamlesh commentedComment #30
rachanakamlesh commentedAs suggested in issue title that has to use SVG, So here I am attaching patch file containing loader images in SVG format.
Comment #31
dillix commentedFor me #30 looks good.
Comment #32
snehi commentedlooks good to me RTBC too.
Comment #35
mohit1604 commentedpatch #30 applies cleanly on version 8.6.x , adding test for 8.6.x in #30 :)
Comment #36
cleverington commentedPatch #30 is passing tests, but see .png screenshot of the actually 'look' and 'feel' of the loader.
If the final deliverable was to make an as-is transition from loading.gif to loading.svg, it does not appear to pass.
Comment #37
dillix commentedRTBC for #30
Comment #38
cleverington commentedSee #18 & #36. The _digital_ testing passes, but visual regression testing does not.
The current SVG does not appear to match _any_ of the styles used across different parts and systems of D8.
Porting 'as-is' and updating the look/feel should be separate issues and the SVG within the patch does not match the origin.
Either the final deliverable needs to be re-scoped or the task does not meet RTBC needs.
Comment #43
BalajiDS commentedpatch #30 works fine in Drupal -8.8.6, thanks @rachanakamlesh
Comment #52
gauravvvv commentedComment #54
jwilson3I setup a codepen to review the before (GIF) and after (SVG) from the MR.
https://codepen.io/jameswilson/pen/wvbWNbr
Things are really close and this is exciting!
I found a few minor but important things to consider:
loading-small.gifto ezgif.com (here). One second appears slower and more lethargic, which is not what you want to portray when displaying a loader. There needs to be a slight sense of urgency that 0.8 seconds provides, versus 1 second.Comment #55
jwilson3I've pushed fixes for the two items, and created a new codepen for comparison:
0.8s at 24px
https://codepen.io/jameswilson/pen/oNRLVxx
Compare against previous pen with 1s at 25px
https://codepen.io/jameswilson/pen/wvbWNbr
Solves #54.2 and #54.3
Comment #56
jwilson3Restore issue summary lost by comment #43.
Comment #57
jwilson3Clean up issue summary.
Solves #54.4
Comment #58
jwilson3Hide file attachments from previous approaches in the issue summary.
Solves #54.5
Comment #59
jwilson3Remaining tasks:
Comment #60
jwilson3I found an instance of loading-small.gif in the starterkit_theme that can be removed:
./core/themes/starterkit_theme/images/icons/loading-small.gif
Additionally, the starterkit_theme refers to its own copy of loading-small.svg, which doesnt exist, and therefore needs to be copied from core/misc/ folder into the theme's images/icons/ folder.
Comment #61
jwilson3I've fixed all relevant code points made in #54, #59, and #60. NR.
Comment #62
jwilson3Since we're deleting the GIFs, we may want to consider adding an
.htaccessrule to redirect the requests for the deleted GIF images to their respective SVG image counterparts. Thoughts?Comment #63
jwilson3Comment #64
jwilson3Comment #65
jwilson3I've created a comparison codepen for loading.gif => loading.svg
https://codepen.io/jameswilson/pen/OJYXqZE?
Comment #66
smustgrave commentedMay need a rebase. Reran the unit tests multiple time but fails each.
Comment #67
jwilson3Rebased.
Comment #68
jwilson3Comment #69
jwilson3There are all kinds of seemingly unrelated test failures after the rebase. It seems the 11.x branch may be a bit unstable at the moment.Nevermind. I found one real failure worth fixing related to the htaccess file changes not being present in the scaffold file. Fix on the way.
Comment #70
jwilson3Comment #71
jwilson3Yay. tests pass now
Comment #72
smustgrave commentedSo brought this in #frontend and consensus seems to be these images could be used by third party modules so we can't delete. And there is no mechanism for deprecating images so can only remove in a major (D12)
So will need to add those images back and a CR in this ticket about the images being removed in 12
Opened #3452493: [12.x] Remove images that have been replaced in core for D12 to remove those images later.
Comment #73
jwilson3Forgive my ignorance, but isn't D11 the next major? There isn't even a 12.x branch yet.
Comment #74
smustgrave commentedThere's already a beta out for 11 so believe we have missed the boat. Why most deprecations are now going to D12.
Don't need to delete now just need to add the deleted images back, still using the new svgs, and add a CR. Gives contrib modules time to update if they are using.
Then when 12 opens we have that one ticket as a reminder to go and delete the images.
Comment #75
jwilson3I've restored core/misc/loading.gif and core/misc/loading-small.gif.
I did not restore the loading GIF in the starterkit theme, because by its very nature, it is not intended to be referenced, but instead forked/copied and manipulated. There's no need to ship starterkit with a file that will never be used.
I get what you mean, and understand that the files can only be removed in a major upgrade, but I should clarify that the MR does include a mechanism for deprecating the old images which I think will work in the current D11 beta. Specifically:
Comment #76
smustgrave commentedI can't speak on the .htaccess approach but thanks for adding those back!
I did create a super simple CR to announce that these images will be removed in 12.
Comment #77
nod_Thanks for the workaound but let's drop the htaccess changes, since we're keeping the old images for now it won't be an issue. Removing in the next major is enough.
Comment #78
gauravvvv commentedComment #79
smustgrave commentedThe other one landed so imagine this solution works just fine as that.
Comment #82
nod_Committed 14669ce and pushed to 11.x. Thanks!
Comment #84
jwilson3For anyone following along here, I've opened another issue related to PNG to SVG conversion in core file icons: #3521857: Update Drupal's default file type icons to use SVG