Skip to content

Commit

Permalink
[MIM-1932] Mim 1932 sr arrow keyfigure (#2838)
Browse files Browse the repository at this point in the history
* Add screen reader change screen reader only text for keyFigures

MIM-1932

* Minor code refactoring; types and duplicate imports
  • Loading branch information
johnnadeluy authored Jul 30, 2024
1 parent 4d26ed9 commit e4cbb7b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/main/resources/lib/ssb/parts/keyFigure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,22 @@ function getDataTbProcessor(
changeText += ` ${denomination}`
}
}
const changePeriod = row2.th.toString()
// set arrow direction based on change
let changeDirection: KeyFigureChanges['changeDirection'] = 'same'
let srChangeText
if (+change > 0) {
changeDirection = 'up'
const changeDirectionText = localize({
key: 'keyFigure.increase',
})
srChangeText = `${changeDirectionText} ${changeText} ${changePeriod}`
} else if (+change < 0) {
changeDirection = 'down'
const changeDirectionText = localize({
key: 'keyFigure.decrease',
})
srChangeText = `${changeDirectionText} ${changeText} ${changePeriod}`
} else {
changeText = localize({
key: 'keyFigure.noChange',
Expand All @@ -180,7 +190,8 @@ function getDataTbProcessor(
keyFigureViewData.changes = {
changeDirection,
changeText,
changePeriod: row2.th.toString(),
changePeriod,
srChangeText,
}
}

Expand Down Expand Up @@ -221,7 +232,7 @@ function getDataWithFilterStatbankApi(
if (municipalData && municipalData.value !== null) {
// add data to key figure view
keyFigureViewData.number = parseValueZeroSafe(municipalData.value)
keyFigureViewData.time = localizeTimePeriod(municipalData.label)
keyFigureViewData.time = localizeTimePeriod(municipalData.label as string)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lib/types/partTypes/keyFigure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ export interface KeyFigureChanges {
changeDirection: 'up' | 'down' | 'same'
changeText?: string
changePeriod: string
srChangeText?: string
}
2 changes: 2 additions & 0 deletions src/main/resources/site/i18n/phrases.properties
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ period.week = Tall for uke {0} {1}

value.notFound = Tall ikke tilgjengelig
keyFigure.noChange = Ingen endring
keyFigure.increase = Oppgang
keyFigure.decrease = Nedgang

factsAbout = Fakta om
source = Kilde
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/site/i18n/phrases_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ period.week = Figures for week {0} {1}

value.notFound = Numbers not available
keyFigure.noChange = No change
keyFigure.increase = Increase
keyFigure.decrease = Decrease

factsAbout = Facts about
source = Source
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/site/i18n/phrases_nn.properties
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ interval.U = Veke

value.notFound = Tal ikkje tilgjengelege
keyFigure.noChange = Inga endring
keyFigure.increase = Oppgang
keyFigure.decrease = Nedgang

factsAbout = Fakta om
source = Kjelde
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/site/pages/default/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import { isEnabled } from '/lib/featureToggle'
import { ensureArray } from '/lib/ssb/utils/arrayUtils'
import { type SubjectItem } from '/lib/types/subject'
import { type MunicipalityWithCounty, type RequestWithCode } from '/lib/types/municipalities'
import { isEnabled } from '/lib/featureToggle'
import { type Default as DefaultPageConfig } from '/site/pages/default'
import { type Page, type Statistics } from '/site/content-types'

Expand Down

0 comments on commit e4cbb7b

Please sign in to comment.