From cefc067969c16bcf492c8ca4d7d26d779a974152 Mon Sep 17 00:00:00 2001 From: johnnadeluy Date: Mon, 29 Jul 2024 14:14:56 +0200 Subject: [PATCH 1/3] Add alt-text for press images for employees MIM-1933 --- src/main/resources/lib/types/partTypes/employee.ts | 1 + src/main/resources/site/parts/employee/employee.ts | 4 +++- src/main/resources/site/parts/employee/employee.tsx | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/resources/lib/types/partTypes/employee.ts b/src/main/resources/lib/types/partTypes/employee.ts index 1329f0c1d..47226846e 100644 --- a/src/main/resources/lib/types/partTypes/employee.ts +++ b/src/main/resources/lib/types/partTypes/employee.ts @@ -24,6 +24,7 @@ export interface EmployeeProps { pressPicturesDescrPhrase: string pressPictureLabelPhrase: string imagePhrase: string + pressImageAltText?: string } export interface Project { diff --git a/src/main/resources/site/parts/employee/employee.ts b/src/main/resources/site/parts/employee/employee.ts index 85eeb701d..f7859cc1a 100644 --- a/src/main/resources/site/parts/employee/employee.ts +++ b/src/main/resources/site/parts/employee/employee.ts @@ -2,7 +2,7 @@ import { type Content, get as getContentByKey } from '/lib/xp/content' import { localize } from '/lib/xp/i18n' import { getContent, pageUrl, attachmentUrl } from '/lib/xp/portal' import { render } from '/lib/enonic/react4xp' -import { imageUrl } from '/lib/ssb/utils/imageUtils' +import { getImageAlt, imageUrl } from '/lib/ssb/utils/imageUtils' import { renderError } from '/lib/ssb/error/error' import * as util from '/lib/util' @@ -31,6 +31,7 @@ function renderPart(req: XP.Request) { const projects: Array = projectIds && projectIds.length > 0 ? parseProject(projectIds) : [] const profileImageIds: Array = page.data.profileImages ? util.data.forceArray(page.data.profileImages) : [] + const pressImageAltText = profileImageIds.length ? getImageAlt(profileImageIds[0]) : '' const profileImages: Array | void[] = profileImageIds ? profileImageIds.map((image: string) => { return imageUrl({ @@ -156,6 +157,7 @@ function renderPart(req: XP.Request) { pressPicturesDescrPhrase, pressPictureLabelPhrase, imagePhrase, + pressImageAltText, } return render('site/parts/employee/employee', props, req) diff --git a/src/main/resources/site/parts/employee/employee.tsx b/src/main/resources/site/parts/employee/employee.tsx index c21a6ec26..a9cc4a8c5 100644 --- a/src/main/resources/site/parts/employee/employee.tsx +++ b/src/main/resources/site/parts/employee/employee.tsx @@ -31,6 +31,7 @@ const Employee = (props: EmployeeProps) => { pressPicturesDescrPhrase, pressPictureLabelPhrase, imagePhrase, + pressImageAltText, } = props const calculateCvSize = (bytes: number) => { @@ -90,7 +91,7 @@ const Employee = (props: EmployeeProps) => {
{profileImages.length != 0 ? (
- +
) : null} {profileImages.length != 0 ? ( From 024df56807e4d2a68367789062eefc43e4b34d8f Mon Sep 17 00:00:00 2001 From: johnnadeluy Date: Mon, 29 Jul 2024 14:23:33 +0200 Subject: [PATCH 2/3] Minor code refactoring --- src/main/resources/site/parts/employee/employee.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/site/parts/employee/employee.tsx b/src/main/resources/site/parts/employee/employee.tsx index a9cc4a8c5..8134bf1dd 100644 --- a/src/main/resources/site/parts/employee/employee.tsx +++ b/src/main/resources/site/parts/employee/employee.tsx @@ -91,7 +91,7 @@ const Employee = (props: EmployeeProps) => {
{profileImages.length != 0 ? (
- +
) : null} {profileImages.length != 0 ? ( From d78f75b933734b8626b9885d8d62b1691cfab48d Mon Sep 17 00:00:00 2001 From: johnnadeluy Date: Mon, 29 Jul 2024 14:26:25 +0200 Subject: [PATCH 3/3] Remove aria-hidden attribute for press picture --- src/main/resources/site/pages/default/default.ts | 1 - src/main/resources/site/parts/employee/employee.tsx | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/resources/site/pages/default/default.ts b/src/main/resources/site/pages/default/default.ts index a44e0166b..3c23a7529 100644 --- a/src/main/resources/site/pages/default/default.ts +++ b/src/main/resources/site/pages/default/default.ts @@ -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' diff --git a/src/main/resources/site/parts/employee/employee.tsx b/src/main/resources/site/parts/employee/employee.tsx index 8134bf1dd..dbf2a9edf 100644 --- a/src/main/resources/site/parts/employee/employee.tsx +++ b/src/main/resources/site/parts/employee/employee.tsx @@ -91,7 +91,7 @@ const Employee = (props: EmployeeProps) => {
{profileImages.length != 0 ? (
- + {pressImageAltText
) : null} {profileImages.length != 0 ? (