diff --git a/docs/components/avatar.md b/docs/components/avatar.md index 5191aa71..a48907b5 100644 --- a/docs/components/avatar.md +++ b/docs/components/avatar.md @@ -4,15 +4,17 @@ Avatars are used to represent a person or object. +Like [images](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img), you should always provide `alt` text for avatars as alternate text for assistive devices. + ```html preview - + ``` ```jsx react import { SlAvatar } from '@shoelace-style/shoelace/dist/react'; const App = () => ( - Button + ); ``` @@ -25,7 +27,7 @@ To use an image for the avatar, set the `image` and `alt` attributes. This will ```html preview ``` @@ -35,7 +37,7 @@ import { SlAvatar } from '@shoelace-style/shoelace/dist/react'; const App = () => ( ); ``` @@ -45,14 +47,14 @@ const App = () => ( When you don't have an image to use, you can set the `initials` attribute to show something more personalized than an icon. ```html preview - + ``` ```jsx react import { SlAvatar } from '@shoelace-style/shoelace/dist/react'; const App = () => ( - + ); ``` @@ -61,15 +63,15 @@ const App = () => ( When no image or initials are set, an icon will be shown. The default avatar shows a generic "user" icon, but you can customize this with the `icon` slot. ```html preview - + - + - + ``` @@ -79,15 +81,15 @@ import { SlAvatar, SlIcon } from '@shoelace-style/shoelace/dist/react'; const App = () => ( <> - + - + - + @@ -99,9 +101,9 @@ const App = () => ( Avatars can be shaped using the `shape` attribute. ```html preview - - - + + + ``` ```jsx react @@ -109,9 +111,9 @@ import { SlAvatar, SlIcon } from '@shoelace-style/shoelace/dist/react'; const App = () => ( <> - - - + + + ); ``` @@ -122,10 +124,25 @@ You can group avatars with a few lines of CSS. ```html preview
- - - - + + + + + + +
diff --git a/docs/index.html b/docs/index.html index 3a3f9180..31767c86 100644 --- a/docs/index.html +++ b/docs/index.html @@ -8,10 +8,7 @@ name="description" content="Shoelace provides a collection of professionally designed, every day UI components built on a framework-agnostic technology." /> - + ` by representing it as an image with an `alt` [#579](https://github.com/shoelace-style/shoelace/issues/579) +- Improved a11y of the scroll buttons in `` +- Improved a11y of the close button in `` +- Improved a11y of `` by removing an invalid `aria-selected` attribute [#579](https://github.com/shoelace-style/shoelace/issues/579) - Moved `role` from the shadow root to the host element in `` - Removed redundant `role="menu"` in `` - Slightly faster animations for showing and hiding `` diff --git a/src/components/avatar/avatar.test.ts b/src/components/avatar/avatar.test.ts index e27aae69..165b8d74 100644 --- a/src/components/avatar/avatar.test.ts +++ b/src/components/avatar/avatar.test.ts @@ -8,7 +8,7 @@ describe('', () => { describe('when provided no parameters', async () => { before(async () => { - el = await fixture(html` `); + el = await fixture(html` `); }); it('passes accessibility test', async () => { @@ -71,7 +71,7 @@ describe('', () => { describe('when provided initials parameter', async () => { const initials = 'SL'; before(async () => { - el = await fixture(html``); + el = await fixture(html``); }); it('passes accessibility test', async () => { @@ -88,7 +88,7 @@ describe('', () => { ['square', 'rounded', 'circle'].forEach(shape => { describe(`when passed a shape attribute ${shape}`, () => { before(async () => { - el = await fixture(html``); + el = await fixture(html``); }); it('passes accessibility test', async () => { @@ -106,7 +106,7 @@ describe('', () => { describe('when passed a , on slot "icon"', async () => { before(async () => { - el = await fixture(html`random content`); + el = await fixture(html`random content`); }); it('passes accessibility test', async () => { diff --git a/src/components/avatar/avatar.ts b/src/components/avatar/avatar.ts index 14bad898..df8c2046 100644 --- a/src/components/avatar/avatar.ts +++ b/src/components/avatar/avatar.ts @@ -48,12 +48,13 @@ export default class SlAvatar extends LitElement { 'avatar--rounded': this.shape === 'rounded', 'avatar--square': this.shape === 'square' })} + role="img" aria-label=${this.alt} > ${this.initials ? html`
${this.initials}
` : html` -
+