Skip to content

Commit

Permalink
Accessibility tweaks (#15)
Browse files Browse the repository at this point in the history
...and some minor theme related additions (Lumo/Material).
  • Loading branch information
anezthes authored Feb 9, 2021
1 parent d84d1b3 commit 121fa4c
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 22 deletions.
27 changes: 16 additions & 11 deletions src/vaadin-message-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,27 @@ class MessageListElement extends ElementMixin(ThemableMixin(PolymerElement)) {
display: none !important;
}
</style>
<template is="dom-repeat" items="[[items]]">
<vaadin-message
time="[[item.time]]"
user-name="[[item.userName]]"
user-abbr="[[item.userAbbr]]"
user-img="[[item.userImg]]"
user-color-index="[[item.userColorIndex]]"
>[[item.text]]</vaadin-message
>
</template>
<div role="list">
<template is="dom-repeat" items="[[items]]">
<vaadin-message
time="[[item.time]]"
user-name="[[item.userName]]"
user-abbr="[[item.userAbbr]]"
user-img="[[item.userImg]]"
user-color-index="[[item.userColorIndex]]"
role="listitem"
>[[item.text]]</vaadin-message
>
</template>
</div>
`;
}

ready() {
super.ready();
this.setAttribute('role', 'list');
this.setAttribute('aria-relevant', 'additions');
this.setAttribute('role', 'log');
this.setAttribute('tabindex', '0');
}

static get is() {
Expand Down
4 changes: 2 additions & 2 deletions src/vaadin-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ class MessageElement extends ElementMixin(ThemableMixin(PolymerElement)) {
}
vaadin-avatar {
border: none;
flex-shrink: 0;
margin: 0;
}
[part='content'] {
Expand Down Expand Up @@ -151,8 +153,6 @@ class MessageElement extends ElementMixin(ThemableMixin(PolymerElement)) {

ready() {
super.ready();
this.setAttribute('aria-live', 'polite');
this.setAttribute('role', 'listitem');
}

static get is() {
Expand Down
Binary file modified test/visual/screens/vaadin-message/lumo-message-list-ltr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/visual/screens/vaadin-message/lumo-message-list-rtl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/visual/screens/vaadin-message/lumo-message-ltr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/visual/screens/vaadin-message/lumo-message-rtl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/visual/screens/vaadin-message/material-message-list-ltr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/visual/screens/vaadin-message/material-message-list-rtl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/visual/screens/vaadin-message/material-message-ltr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/visual/screens/vaadin-message/material-message-rtl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions theme/lumo/vaadin-message-list-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import './vaadin-message-styles.js';
registerStyles(
'vaadin-message-list',
css`
:host {
padding: var(--lumo-space-s);
:host(:focus) {
box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);
outline: none;
}
`,
{ moduleId: 'lumo-message-list' }
Expand Down
6 changes: 3 additions & 3 deletions theme/lumo/vaadin-message-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ registerStyles(
}
vaadin-avatar {
margin-right: var(--lumo-space-s);
margin-top: calc(var(--lumo-space-xs) * 1.5);
margin-right: var(--lumo-space-m);
margin-top: var(--lumo-space-s);
}
:host([dir='rtl']) vaadin-avatar {
margin-left: var(--lumo-space-s);
margin-left: var(--lumo-space-m);
margin-right: 0;
}
Expand Down
4 changes: 2 additions & 2 deletions theme/material/vaadin-message-list-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import './vaadin-message-styles.js';
registerStyles(
'vaadin-message-list',
css`
:host {
padding: 8px;
div[role='list'] {
padding: 8px 0;
}
`,
{ moduleId: 'material-message-list' }
Expand Down
6 changes: 4 additions & 2 deletions theme/material/vaadin-message-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ registerStyles(
}
vaadin-avatar {
margin-right: 0.5em;
height: 2.5em;
margin-right: 1em;
margin-top: 0.125em;
width: 2.5em;
}
:host([dir='rtl']) vaadin-avatar {
margin-left: 0.5em;
margin-left: 1em;
margin-right: 0;
}
Expand Down

0 comments on commit 121fa4c

Please sign in to comment.