Skip to content
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

Not displaying the complete icon for images smaller than 50x50. #9194

Merged
merged 7 commits into from
Mar 15, 2021

Conversation

magda-chrzescian
Copy link
Contributor

Suggested merge commit message (convention)

Fix (image): The image upload success indicator should not be displayed for images smaller than 50x50px. Closes #9165.


Additional information

For example – encountered issues, assumptions you had to make, other affected tickets, etc.

@AnnaTomanek AnnaTomanek linked an issue Mar 10, 2021 that may be closed by this pull request
Copy link
Member

@oleq oleq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using JS, check out

diff --git a/packages/ckeditor5-theme-lark/theme/ckeditor5-image/imageuploadicon.css b/packages/ckeditor5-theme-lark/theme/ckeditor5-image/imageuploadicon.css
index 5b8eff4006..28e2696e35 100644
--- a/packages/ckeditor5-theme-lark/theme/ckeditor5-image/imageuploadicon.css
+++ b/packages/ckeditor5-theme-lark/theme/ckeditor5-image/imageuploadicon.css
@@ -7,13 +7,12 @@
          --ck-color-image-upload-icon: hsl(0, 0%, 100%);
          --ck-color-image-upload-icon-background: hsl(120, 100%, 27%);

-         --ck-image-upload-icon-size: 20px;
+         --ck-image-upload-icon-size: 20;
          --ck-image-upload-icon-width: 2px;
+         --ck-image-upload-icon-is-visible: clamp(0px, 100% - 50px, 1px);
 }

 .ck-image-upload-complete-icon {
-         width: var(--ck-image-upload-icon-size);
-         height: var(--ck-image-upload-icon-size);
          opacity: 0;
          background: var(--ck-color-image-upload-icon-background);
          animation-name: ck-upload-complete-icon-show, ck-upload-complete-icon-hide;
@@ -21,11 +20,19 @@
          animation-duration: 500ms, 500ms;

          /* To make animation scalable. */
-         font-size: var(--ck-image-upload-icon-size);
+         font-size: calc( 1px * var(--ck-image-upload-icon-size));

          /* Hide completed upload icon after 3 seconds. */
          animation-delay: 0ms, 3000ms;

+         /*
+          * Use CSS math to similate container queries.
+          * https://css-tricks.com/the-raven-technique-one-step-closer-to-container-queries/#what-about-showing-and-hiding-things
+          */
+         overflow: hidden;
+         width: calc(var(--ck-image-upload-icon-is-visible) * var(--ck-image-upload-icon-size));
+         height: calc(var(--ck-image-upload-icon-is-visible) * var(--ck-image-upload-icon-size));
+
          /* This is check icon element made from border-width mixed with animations. */
          &::after {
                   /* Because of border transformation we need to "hard code" left position. */

@magda-chrzescian
Copy link
Contributor Author

magda-chrzescian commented Mar 12, 2021

@oleq Wow, this is a piece of magic!
I'll check if I can go this way also for the #9166.

@magda-chrzescian magda-chrzescian requested a review from oleq March 15, 2021 10:28
@oleq oleq merged commit 60e1fd2 into i/2052-inline-images Mar 15, 2021
@oleq oleq deleted the i/9165-upload-indicator-for-small-images branch March 15, 2021 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The image upload success indicator does not fit small images
2 participants