fix: make the OCR progress bar accessible (#1445)

* fix: make the OCR progress bar accessible

* fixup
This commit is contained in:
Nolan Lawson 2019-08-28 08:13:24 -07:00 committed by GitHub
parent c8738f17b0
commit 7d4cb1914a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,17 +23,12 @@
<button class="extract-text-button" type="button" <button class="extract-text-button" type="button"
on:click="onClick()" on:click="onClick()"
disabled={extracting} disabled={extracting}
aria-label={extractButtonLabel}
> >
<SvgIcon href="{extracting ? '#fa-spinner' : '#fa-magic'}" <SvgIcon href="{extracting ? '#fa-spinner' : '#fa-magic'}"
className="extract-text-svg {extracting ? 'spin' : ''}" className="extract-text-svg {extracting ? 'spin' : ''}"
/> />
<span> <span>{extractButtonText}</span>
{#if extracting}
Extracting text…
{:else}
Extract text from image
{/if}
</span>
</button> </button>
<LengthGauge <LengthGauge
length={extractionProgress} length={extractionProgress}
@ -135,7 +130,14 @@
computed: { computed: {
length: ({ rawText }) => length(rawText || ''), length: ({ rawText }) => length(rawText || ''),
overLimit: ({ mediaAltCharLimit, length }) => length > mediaAltCharLimit, overLimit: ({ mediaAltCharLimit, length }) => length > mediaAltCharLimit,
url: ({ media, index }) => get(media, [index, 'data', 'url']) url: ({ media, index }) => get(media, [index, 'data', 'url']),
extractButtonText: ({ extracting }) => extracting ? 'Extracting text…' : 'Extract text from image',
extractButtonLabel: ({ extractButtonText, extractionProgress, extracting }) => {
if (extracting) {
return `Extracting text (${Math.round(extractionProgress)}% complete)…`
}
return extractButtonText
}
}, },
methods: { methods: {
observe, observe,