Skip to content

Commit

Permalink
fix(spinner): progressbar role on host
Browse files Browse the repository at this point in the history
  • Loading branch information
bennypowers committed Apr 11, 2024
1 parent 74179fd commit fbf1439
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
5 changes: 2 additions & 3 deletions elements/pf-spinner/BaseSpinner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// will remove file in 2627
/* eslint-disable lit-a11y/accessible-name */

import { LitElement, html } from 'lit';
import { property } from 'lit/decorators/property.js';

Expand All @@ -14,7 +14,6 @@ export type SpinnerSize = (

/**
* Base spinner class
*
* @cssprop {<length>} --pf-c-spinner--diameter {@default `3.375rem`}
* @cssprop {<length>} --pf-c-spinner--Width {@default `3.375rem`}
* @cssprop {<length>} --pf-c-spinner--Height {@default `3.375rem`}
Expand Down Expand Up @@ -42,7 +41,7 @@ export abstract class BaseSpinner extends LitElement {

override render() {
return html`
<svg role="progressbar" viewBox="0 0 100 100">
<svg viewBox="0 0 100 100">
<circle cx="50" cy="50" r="45" fill="none" />
</svg>
`;
Expand Down
8 changes: 7 additions & 1 deletion elements/pf-spinner/pf-spinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { html } from 'lit';
import { customElement } from 'lit/decorators/custom-element.js';
import { styleMap } from 'lit/directives/style-map.js';

import { InternalsController } from '@patternfly/pfe-core/controllers/internals-controller.js';

import { BaseSpinner } from './BaseSpinner.js';

import styles from './pf-spinner.css';

/**
* A **spinner** is used to indicate to users that an action is in progress. For actions
* that may take a long time, use a progress bar instead.
*
* @cssprop {<length>} --pf-c-spinner--diameter {@default `3.375rem`}
* @cssprop {<length>} --pf-c-spinner--Width {@default `3.375rem`}
* @cssprop {<length>} --pf-c-spinner--Height {@default `3.375rem`}
Expand All @@ -28,6 +30,10 @@ import styles from './pf-spinner.css';
@customElement('pf-spinner')
export class PfSpinner extends BaseSpinner {
static readonly styles = [...BaseSpinner.styles, styles];

// eslint-disable-next-line no-unused-private-class-members
#internals = InternalsController.of(this, { role: 'progressbar' });

render() {
return html`<div style=${styleMap({ '--pf-c-spinner--diameter': this.diameter })}>${super.render()}</div>`;
}
Expand Down
11 changes: 10 additions & 1 deletion elements/pf-spinner/test/pf-spinner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,19 @@ describe('<pf-spinner>', function() {
const element = await createFixture<PfSpinner>(html`
<pf-spinner>Loading...</pf-spinner>
`);

expect(element.getAttribute('size')).to.equal('xl');
});

describe('basic usage', function() {
let element: PfSpinner;
beforeEach(async function() {
element = await createFixture<PfSpinner>(html`<pf-spinner>Loading...</pf-spinner>`);
});
it('is accessible', async function() {
await expect(element).to.be.accessible();
});
});

describe('size attribute', function() {
let element: PfSpinner;

Expand Down

0 comments on commit fbf1439

Please sign in to comment.