Skip to content

Commit

Permalink
Merge pull request #17287 from Snuffleupagus/CSS-loading-icon
Browse files Browse the repository at this point in the history
Re-factor the loading-icons used in the viewer toolbars
  • Loading branch information
Snuffleupagus authored Nov 21, 2023
2 parents 02ccdbb + 625d4f7 commit 83f0029
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 64 deletions.
24 changes: 0 additions & 24 deletions web/images/loading-dark.svg

This file was deleted.

4 changes: 1 addition & 3 deletions web/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import {
toggleCheckedBtn,
} from "./ui_utils.js";

const PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";

/**
* @typedef {Object} ToolbarOptions
* @property {HTMLDivElement} container - Container for the secondary toolbar.
Expand Down Expand Up @@ -300,7 +298,7 @@ class Toolbar {
updateLoadingIndicatorState(loading = false) {
const { pageNumber } = this.items;

pageNumber.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
pageNumber.classList.toggle("loading", loading);
}
}

Expand Down
84 changes: 49 additions & 35 deletions web/viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@
--doorhanger-separator-color: rgb(92 92 97);
--dialog-button-bg-color: rgb(92 92 97);
--dialog-button-hover-bg-color: rgb(115 115 115);

/* This image is used in <input> elements, which unfortunately means that
* the `mask-image` approach used with all of the other images doesn't work
* here; hence why we still have two versions of this particular image. */
--loading-icon: url(images/loading-dark.svg);
}
}

Expand Down Expand Up @@ -494,22 +489,21 @@ body {

#findInput {
width: 200px;
}
/*#if !MOZCENTRAL*/
#findInput::-webkit-input-placeholder {
color: rgb(191 191 191);
}
/*#endif*/
#findInput::placeholder {
font-style: normal;
}
#findInput[data-status="pending"] {
background-image: var(--loading-icon);
background-repeat: no-repeat;
background-position: calc(50% + 48% * var(--dir-factor));
}
#findInput[data-status="notFound"] {
background-color: rgb(255 102 102);

/*#if !MOZCENTRAL*/
&::-webkit-input-placeholder {
color: rgb(191 191 191);
}
/*#endif*/
&::placeholder {
font-style: normal;
}
.loadingInput:has(> &[data-status="pending"])::after {
visibility: visible;
}
&[data-status="notFound"] {
background-color: rgb(255 102 102);
}
}

.secondaryToolbar,
Expand Down Expand Up @@ -1100,22 +1094,42 @@ a:is(.toolbarButton, .secondaryToolbarButton)[href="#"] {
width: 40px;
background-size: 0 0;
transition-property: none;

/*#if !MOZCENTRAL*/
&::-webkit-inner-spin-button {
-webkit-appearance: none;
}
/*#endif*/

.loadingInput:has(> &.loading)::after {
visibility: visible;

transition-property: visibility;
transition-delay: var(--loading-icon-delay);
}
}
#pageNumber.visiblePageIsLoading {
background-image: var(--loading-icon);
background-repeat: no-repeat;
background-position: calc(50% - 42% * var(--dir-factor));
background-size: 16px 16px;
/* Using a delay with background-image doesn't work,
consequently we use background-size. */
transition-property: background-size;
transition-delay: var(--loading-icon-delay);
}
/*#if !MOZCENTRAL*/
#pageNumber::-webkit-inner-spin-button {
-webkit-appearance: none;

.loadingInput {
&::after {
position: absolute;
visibility: hidden;
top: calc(50% - 8px);
width: 16px;
height: 16px;

content: "";
background-color: var(--toolbar-icon-bg-color);
mask-size: cover;
mask-image: var(--loading-icon);
}

&.start::after {
inset-inline-start: 4px;
}
&.end::after {
inset-inline-end: 4px;
}
}
/*#endif*/

.toolbarField:focus {
border-color: #0a84ff;
Expand Down
8 changes: 6 additions & 2 deletions web/viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@
<div id="mainContainer">
<div class="findbar hidden doorHanger" id="findbar">
<div id="findbarInputContainer">
<input id="findInput" class="toolbarField" title="Find" placeholder="Find in document…" tabindex="91" data-l10n-id="pdfjs-find-input" aria-invalid="false">
<span class="loadingInput end">
<input id="findInput" class="toolbarField" title="Find" placeholder="Find in document…" tabindex="91" data-l10n-id="pdfjs-find-input" aria-invalid="false">
</span>
<div class="splitToolbarButton">
<button id="findPrevious" class="toolbarButton" title="Find the previous occurrence of the phrase" tabindex="92" data-l10n-id="pdfjs-find-previous-button">
<span data-l10n-id="pdfjs-find-previous-button-label">Previous</span>
Expand Down Expand Up @@ -325,7 +327,9 @@
<span data-l10n-id="pdfjs-next-button-label">Next</span>
</button>
</div>
<input type="number" id="pageNumber" class="toolbarField" title="Page" value="1" min="1" tabindex="15" data-l10n-id="pdfjs-page-input" autocomplete="off">
<span class="loadingInput start">
<input type="number" id="pageNumber" class="toolbarField" title="Page" value="1" min="1" tabindex="15" data-l10n-id="pdfjs-page-input" autocomplete="off">
</span>
<span id="numPages" class="toolbarLabel"></span>
</div>
<div id="toolbarViewerRight">
Expand Down

0 comments on commit 83f0029

Please sign in to comment.