Skip to content

Commit cb2d416

Browse files
committed
update error message UI and text
1 parent 7545257 commit cb2d416

1 file changed

Lines changed: 42 additions & 41 deletions

File tree

pt/web/firebird/src/js/components/DownloadPanel/index.svelte

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,18 @@
5151
let clearSelectionLabel = $state('Clear selection');
5252
5353
let emptySelection = $derived(range == 'selected-pages' && selection.pages.length == 0);
54+
let emptySelectionTIFF = $derived(emptySelection && format == 'image-tiff');
5455
let tooManyTiffs = $derived(range == 'selected-pages' && format == 'image-tiff' && selection.pages.length > 10);
55-
let largeTiffVolume = $derived(range == 'volume' && format == 'image-tiff' && totalSeq > 10);
56-
57-
let buttonDisabled = $derived(emptySelection || tooManyTiffs || largeTiffVolume);
56+
let buttonDisabled = $derived(emptySelection || emptySelectionTIFF || tooManyTiffs );
5857
let errorMessage = $derived(
59-
emptySelection ? `You haven't selected any pages to download.
60-
To select pages, use the selection checkbox in the page toolbar.` :
61-
tooManyTiffs ? `You have selected ${
62-
selection.pages.length
63-
} page scans. Please update range to 10 page scans or fewer to proceed with a TIFF download.` :
64-
largeTiffVolume ? `This volume has more than 10 pages. Please choose 10 page scans or fewer to proceed with a TIFF download.` :
58+
emptySelectionTIFF ? `<p>No pages selected.
59+
Use the toolbar to select up to <span class="fw-bold">10 pages</span> to continue your TIFF download.</p>` :
60+
emptySelection ? `<p>No pages selected.
61+
Use the toolbar to select pages.</p>` :
62+
tooManyTiffs ? `<p>Your selection exceeds the TIFF download limit. Select 10 pages or fewer to continue.</p>` :
6563
null
6664
);
67-
65+
let errorCount = 0;
6866
6967
const _mtm = (window._mtm = window._mtm || []);
7068
@@ -264,7 +262,7 @@
264262
scriptEl.onerror = () => {
265263
document.body.removeChild(scriptEl);
266264
errorMessage = 'Failed to start download. Please try again.';
267-
HT.live.announce(errorMessage);
265+
HT.live.announce(errorMessage.replace(/<\/?[^>]+(>|$)/g, ""));
268266
downloadInProgress = false;
269267
_mtm.push({'event': 'pt-large-download-error', 'downloadUrl': `${requestUrl.toString()}`});
270268
};
@@ -425,7 +423,11 @@
425423
426424
$effect(() => {
427425
if (errorMessage) {
428-
HT.live.announce(errorMessage);
426+
errorCount++;
427+
// this is a hacky workaround for aria-live announcements
428+
// chrome does not re-announce the last message it announced, even if it left the DOM and re-entered the DOM
429+
// this adds a space to the end of the message before sending it to our announcement library
430+
HT.live.announce(`${errorMessage.replace(/<\/?[^>]+(>|$)/g, "")}${' '.repeat(errorCount)}`);
429431
}
430432
});
431433
@@ -568,14 +570,6 @@
568570
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
569571
<fieldset class="mb-3" id="download-range">
570572
<legend class="fs-5">Range</legend>
571-
<div aria-live="polite" aria-atomic="true">
572-
{#if format == 'image-tiff' && (range == 'selected-pages' || range == 'volume')}
573-
<p class="fs-7 mb-3 mt-2 text-cyan-700" tabindex="0" id="tiff-note">
574-
Note: TIFF downloads are limited to <span class="fw-bold">10 page scans</span> at a time, as it is resource-intensive.
575-
</p>
576-
{/if}
577-
</div>
578-
579573
{#if $currentView == '1up'}
580574
<div class="form-check">
581575
<input
@@ -687,9 +681,11 @@
687681
</button>
688682
</p>
689683
{#if errorMessage}
690-
<div class="alert alert-warning fs-7 d-flex justify-content-between gap-2 pe-2">
691-
<i class="alert-icon fa-solid fa-triangle-exclamation"></i>
692-
<p class="py-3">{errorMessage}</p>
684+
<div class="alert inline-alert alert-warning fs-7 d-flex gap-2">
685+
<div class="icon-wrapper d-flex">
686+
<i class="alert-icon fa-solid fa-triangle-exclamation" aria-hidden="true"></i>
687+
</div>
688+
{@html errorMessage}
693689
</div>
694690
{/if}
695691
<p class="fs-7 mb-1">
@@ -798,31 +794,36 @@
798794

799795
<style lang="scss">
800796
.alert-warning {
801-
--bs-alert-color: var(--color-neutral-800);
802-
--bs-alert-border-color: #997404;
797+
--alert-warning-color: #664D03;
798+
--alert-warning-base: #FFF3CD;
799+
--alert-warning-border-color: #FFECB5;
800+
--bs-alert-color: var(--alert-warning-color);
801+
--bs-alert-bg: var(--alert-warning-base);
802+
--bs-alert-border-color: var(--alert-warning-border-color);
803803
}
804-
.alert {
805-
border: none;
806-
border-inline-start: 0.25rem solid var(--bs-alert-border-color);
807-
padding: 0;
808-
border-radius: 0.25rem;
804+
.alert.inline-alert {
805+
border: 1px solid var(--bs-alert-border-color);
806+
padding-block: 0.75rem;
807+
padding-inline: 0.5rem 0.75rem;
808+
border-radius: 0.375rem;
809809
box-shadow: 0px 4px 8px 0px rgba(25, 11, 1, 0.04);
810+
line-height: 1.3125rem;
811+
letter-spacing: -0.00875rem;
812+
color: var(--bs-alert-color);
813+
.icon-wrapper {
814+
width: 1.5rem;
815+
height: 1.5rem;
816+
justify-content: center;
817+
align-items: center;
818+
gap: 0.625rem;
819+
}
810820
i.alert-icon {
811-
color: var(--bs-alert-border-color);
821+
font-size: 1rem;
812822
display: flex;
813823
width: 1.5rem;
814-
padding-block-start: 1rem;
815824
flex-direction: column;
816825
align-items: center;
817-
gap: 0.5rem;
818-
align-self: stretch;
819-
margin-inline-start: 0.5rem;
820-
line-height: 1.3125rem;
821-
}
822-
p {
823-
line-height: 1.3125rem;
824-
letter-spacing: -0.01rem;
825-
margin-block-end: 0;
826+
opacity: 0.8;
826827
}
827828
}
828829
</style>

0 commit comments

Comments
 (0)