lion/packages/progress-indicator
2021-02-15 18:20:21 +01:00
..
demo feat: add loading indicator (#857) 2020-08-06 13:35:26 +02:00
src fix: types base constructor same return type 2021-01-13 17:05:07 +01:00
test feat: add loading indicator (#857) 2020-08-06 13:35:26 +02:00
translations feat: add loading indicator (#857) 2020-08-06 13:35:26 +02:00
CHANGELOG.md Version Packages 2021-01-18 13:38:33 +00:00
custom-elements.json chore: add custom-elements-manifest to dev deps, add script 2021-02-15 18:20:21 +01:00
index.js feat: add loading indicator (#857) 2020-08-06 13:35:26 +02:00
lion-progress-indicator.js feat: add loading indicator (#857) 2020-08-06 13:35:26 +02:00
package.json chore: add custom-elements-manifest to dev deps, add script 2021-02-15 18:20:21 +01:00
README.md fix: normalize dependencies 2021-01-06 10:53:38 +01:00

Progress Indicator

lion-progress-indicator implements accessibility requirements for progress indicators.

import { html } from '@lion/core';
import './demo/custom-progress-indicator.js';

export default {
  title: 'Others/Progress Indicator',
};

Features

  • Accessibility compliant
  • Localized "Loading" label
  • Implementation independent of visuals

How to use

Installation

npm i --save @lion/progress-indicator
import { LionProgressIndicator } from '@lion/progress-indicator';
// or
import '@lion/progress-indicator/lion-progress-indicator.js';

Example

<lion-progress-indicator></lion-progress-indicator>

Extended indicator with a custom visual

LionProgressIndicator is designed to be extended to add visuals. Implement the _graphicTemplate method to set the rendered content, and apply styles normally.

Example extension

class CustomProgressIndicator extends LionProgressIndicator {
  static get styles() {
    return [
      css`
        svg {
          animation: spinner-rotate 2s linear infinite;
          display: inline-block;
          height: 48px;
          width: 48px;
        }

        circle {
          fill: none;
          stroke-width: 3.6;
          stroke: firebrick;
          stroke-dasharray: 100, 28;
        }

        @keyframes spinner-rotate {
          to {
            transform: rotate(360deg);
          }
        }
      `,
    ];
  }

  _graphicTemplate() {
    return html`<svg viewBox="22 22 44 44">
      <circle cx="44" cy="44" r="20.2" />
    </svg>`;
  }
}

Result

export const customProgressDemo = () => html`
  <custom-progress-indicator></custom-progress-indicator>
`;