Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 7 additions & 38 deletions src/components/email-viewer/email-viewer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
flex-direction: column;
width: 100%;
height: 100%;
padding-bottom: 0.5rem;
box-shadow: var(--shadow-depth-8);
}

Expand Down Expand Up @@ -93,7 +92,7 @@
.attachments {
flex-shrink: 0;
padding: 0.5rem;
border-bottom: 1px dashed rga(var(--contrast-700));
border-bottom: 1px dashed rgba(var(--contrast-700));

span {
padding-left: 0.25rem;
Expand All @@ -106,47 +105,17 @@
}
}

ul {
all: unset;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
.attachment-list {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;

padding: 0.5rem 0;
}

li {
all: unset;
position: relative;
display: flex;
flex-direction: column;
gap: 0.25rem;

font-size: 0.6875rem;
line-height: normal;

padding: 0.5rem 0.5rem 1rem 0.5rem;
border-radius: 0.5rem;
border: 1px solid rgba(var(--contrast-600));
background-color: rgba(var(--contrast-400));
}

.attachment-filename {
font-weight: 500;
}

.attachment-mime-type {
opacity: 0.7;
}

limel-badge {
--badge-max-width: auto;
--badge-background-color: rgb(var(--contrast-1000), 0.7);
--badge-text-color: rgb(var(--color-white));
position: absolute;
bottom: 0.125rem;
right: 0.125rem;
box-shadow: var(--shadow-brighten-edges-outside);
limel-chip {
--chip-max-width: 18rem;
--badge-max-width: 3rem;
}
}

Expand Down
41 changes: 26 additions & 15 deletions src/components/email-viewer/email-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import { applyRemoteImagesPolicy, containsRemoteImages } from './remote-images';
import { splitEmailAddressList } from './split-email-address-list';
import { formatBytes } from '../../util/format-bytes';
import { getIconForFile } from '../file/icons';
import { getIconFillColorForFile } from '../file/icon-fill-colors';
import { getIconBackgroundColorForFile } from '../file/icon-background-colors';

/**
* This is a private component, used to render `.eml` files inside
Expand Down Expand Up @@ -214,11 +217,11 @@
return (
<div class="attachments">
<span>{label}</span>
<ul>
<div class="attachment-list" role="list">

Check warning on line 220 in src/components/email-viewer/email-viewer.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use <menu>, <ol>, or <ul> instead of the "list" role to ensure accessibility across all devices.

See more on https://sonarcloud.io/project/issues?id=Lundalogik_lime-elements&issues=AZ4BlbzcWZBg9RBodCbt&open=AZ4BlbzcWZBg9RBodCbt&pullRequest=4064
{attachments.map((attachment, index) =>
this.renderAttachment(attachment, index)
)}
</ul>
</div>
</div>
);
Comment on lines 219 to 226
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Accessibility: associate the "Attachments" label with the role="list" container.

Without aria-labelledby, screen readers announce the container as just "list" and drop the "Attachments" context entirely. Linking the span to the list fixes this with minimal code.

♿ Proposed fix
-            <div class="attachments">
-                <span>{label}</span>
-                <div class="attachment-list" role="list">
+            <div class="attachments">
+                <span id="attachments-label">{label}</span>
+                <div class="attachment-list" role="list" aria-labelledby="attachments-label">
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/email-viewer/email-viewer.tsx` around lines 219 - 226, The
attachments container (the div with class "attachment-list" and role="list")
isn't associated with the visible "Attachments" span, so screen readers announce
it only as "list"; add an accessible relationship by giving the span a unique id
(e.g., attachmentsLabel) and reference that id from the list container via
aria-labelledby (or alternatively set an aria-label) so the list reads as
"Attachments"—update the JSX around the span and the div where attachments.map
and renderAttachment are used to include this id/aria-labelledby pairing.

}
Expand All @@ -228,21 +231,29 @@
attachment.filename?.trim() ||
this.getTranslation('file-viewer.email.attachment.unnamed');
const mimeType = attachment.mimeType?.trim() || '';
return (
<li key={`attachment-${index}`}>
<span class="attachment-filename">{filename}</span>
<span class="attachment-mime-type"> {mimeType}</span>
{this.renderSizeBadge(attachment.size)}
</li>
);
};
const dotIndex = filename.lastIndexOf('.');
const extension = dotIndex > 0 ? filename.slice(dotIndex + 1) : '';
const tooltip = mimeType ? `${filename}\n${mimeType}` : filename;
const fileSize =
typeof attachment.size === 'number'
? formatBytes(attachment.size)
: undefined;

private renderSizeBadge = (size?: number) => {
if (typeof size !== 'number') {
return;
}
return (
<limel-badge class="attachment-size" label={formatBytes(size)} />
<limel-chip
key={`attachment-${index}`}
role="listitem"
title={tooltip}
text={filename}
icon={{
name: getIconForFile(extension),
color: getIconFillColorForFile(extension),
backgroundColor: getIconBackgroundColorForFile(extension),
}}
badge={fileSize}
readonly={true}
language={this.language}
/>
);
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/file-viewer/examples/file-viewer-basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export class FileViewerExample {
private files = [
{
title: 'Image',
url: 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a8/TEIDE.JPG/2880px-TEIDE.JPG',
alt: 'A synthetic-aperture radar image acquired by the SIR-C/X-SAR radar on board the Space Shuttle Endeavour shows the Teide volcano.',
url: 'https://picsum.photos/id/1018/2880/1920.jpg',
alt: 'A scenic mountain landscape from Picsum Photos.',
},
{
title: 'Vector graphic',
Expand Down
Loading