-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Show spinner while loading ZIM content in viewer iframe #1183
Conversation
Hi @kelson42, I've added a spinner to improve the user experience while ZIM content is loading in the viewer iframe. The iframe is initially hidden and becomes visible once loading completes. I also added styles in kiwix.css and used CSS animations for a smooth effect. Could you review the changes and let me know if any improvements are needed? Thanks! |
@Optimus-NP thank you, I'm not a maintainer on this repo, but I see one potential flaw, can you check how your spinner render on smaller screens (e.g. phones in portrait mode). I'm concerned about the fact that text might be split on two rows which is probably a bit ugly. |
f57da12
to
fc2a6f6
Compare
Thanks @benoit74 for the feedback. I have addressed the comment. kiwix_issue_mob_731.mp4 |
@kelson42 who should review this? |
Hi @kelson42 Requesting you to review this PR. |
Please review this PR. |
fc2a6f6
to
fc89461
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failures of the unit-tests must be fixed by updating the cacheid
s of the modified static resources (the new values can be seen in the test failure reports).
static/skin/viewer.js
Outdated
@@ -425,6 +425,10 @@ let viewerSetupComplete = false; | |||
|
|||
function on_content_load() { | |||
if ( viewerSetupComplete ) { | |||
const loader = document.getElementById("kiwix__loader"); | |||
const iframe = document.getElementById("content_iframe"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the readily available global variable contentIframe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @veloman-yunkan
I appreciate your well-thought-out recommendations. They will certainly help improve the outcome.
static/skin/viewer.js
Outdated
const loader = document.getElementById("kiwix__loader"); | ||
const iframe = document.getElementById("content_iframe"); | ||
iframe.style.visibility = "visible"; | ||
loader.style.display = "none"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should be moved out of the if
statement (it doesn't depend on the viewer setup, which is mostly about loading translations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have now integrated for the i18n for the loading content message so I need to wait for the translations to happen.
static/viewer.html
Outdated
@@ -30,9 +30,12 @@ | |||
location.href = root + '/'; | |||
} | |||
</script> | |||
</head> | |||
|
|||
</head> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that.
static/viewer.html
Outdated
<body style="margin:0" onload="setupViewer()"> | ||
<div class="loader" id="kiwix__loader"> | ||
<div class="spinner"></div> | ||
Loading content... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This text is not internationalized/translated. You will have to update the function updateUIText()
in viewer.js
. Please do that in a separate commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sincerely appreciate your guidance on i18n. I wasn’t familiar with how to use and implement it, but thanks to your help, I now understand its importance and how to integrate it effectively. Your insights were incredibly valuable—thank you!
static/skin/kiwix.css
Outdated
.content-iframe { | ||
visibility: hidden; /* Hide initially */ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better rename this class to hidden
or invisible
and then dynamically remove it from from the classList
of the content iframe element in order to make it visible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s a solid idea, appreciate you sharing it.
f598cb2
to
4a0428a
Compare
Thanks this fixes the test failure issues. |
Thanks for the review. I have addressed the comment. |
Requesting you to review this PR. |
static/skin/i18n/ar.json
Outdated
@@ -34,5 +34,6 @@ | |||
"magnet-link-text": "رابط جذب {رابط جاذب}", | |||
"magnet-alt-text": "التحميل {التنزيل} عن طريق/بواسطة رابط الجذب\n{الرابط الجاذب}", | |||
"torrent-download-link-text": "بت تورنت", | |||
"torrent-download-alt-text": "التحميل {التنزيل} عن طريق/بواسطة بت تورنت" | |||
"torrent-download-alt-text": "التحميل {التنزيل} عن طريق/بواسطة بت تورنت", | |||
"text-loading-content": "جاري تحميل المحتوى" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder where the translations of the new i18n string came from. Did you add them yourself? If so, then please undo those changes. Be advised that translation is outsourced to https://translatewiki.net and its results are integrated into our code via automated pull requests like, for example, #1179. The only files that should be manually modified under static/skin/i18n
directory are en.json
(the source text for translation), qqq.json
(provides context for translation), and test.json
(used in unit tests).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing that out. I’ve reverted the changes to the translation files and ensured that only en.json, qqq.json, and test.json are manually modified as per the guidelines. I'll make sure to follow the correct workflow via TranslateWiki for future updates.
static/viewer.html
Outdated
@@ -25,14 +25,16 @@ | |||
|
|||
const root = getRootLocation(); | |||
const blankPageUrl = root + "/skin/blank.html?KIWIXCACHEID"; | |||
|
|||
if ( location.hash == '' ) { | |||
if (location.hash == '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undo this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reverted this change.
static/viewer.html
Outdated
<body style="margin:0" onload="setupViewer()"> | ||
<div class="loader" id="kiwix__loader"> | ||
<div class="spinner"></div> | ||
<span id="kiwix__loading_text">Loading content...</span> <!-- Added ID for translation --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment has no value. Please remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the comment as requested.
static/viewer.html
Outdated
@@ -78,7 +80,7 @@ | |||
</div> | |||
</div> | |||
|
|||
<iframe id="content_iframe" | |||
<iframe id="content_iframe" class="content-iframe" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no CSS class content-iframe
anymore - it has been renamed to hidden
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. I’ve updated the references accordingly to use hidden instead of content-iframe.
static/skin/viewer.js
Outdated
//viewerSetupComplete is marked as true once the translations are loaded | ||
//Now we can load the spinner. | ||
const loader = document.getElementById("kiwix__loader"); | ||
|
||
contentIframe.classList.remove("hidden"); | ||
loader.style.display = "none"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hiding the spinner and showing the content doesn't in any way depend on the translations being loaded and therefore must be performed outside the if
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification. I’ve updated the logic to ensure that hiding the spinner and showing the content happens independently of the translations being loaded.
08ec098
to
da87a5f
Compare
Thanks for the review. I have addressed the comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but before we merge please remove the reference to the issue number from the commit title (since it points to the wrong issue as the issue addressed is in a different repository).
Thank you for catching that. Addressed. |
Please help in merging this. |
Not really. Please remove the reference to the issue number from the commit title. The PR title could be fixed after we merge. The commit title - once merged - will stay there forever. |
- Implemented a spinner to improve user experience while ZIM content is loading in the viewer iframe. - Added .loader and .spinner styles in kiwix.css. - The iframe content is initially hidden (visibility: hidden) and will be displayed once loading completes. - Used CSS animations (@Keyframes spin) for a smooth rotating effect.
da87a5f
to
c7e86c9
Compare
done @veloman-yunkan |
Please help in merging this. |
Please help in merging this. |
Fixes #731
Demo
kiwix_issue_731.mp4
Command