4.0.1-p4.0.0.1 • Published 4 years ago

@limetech/mdc-linear-progress v4.0.1-p4.0.0.1

Weekly downloads
494
License
MIT
Repository
github
Last release
4 years ago

Linear Progress

The MDC Linear Progress component is a spec-aligned linear progress indicator component adhering to the Material Design progress & activity requirements.

Design & API Documentation

Installation

npm install @limetech/mdc-linear-progress

Basic Usage

HTML Structure

<div role="progressbar" class="mdc-linear-progress">
  <div class="mdc-linear-progress__buffering-dots"></div>
  <div class="mdc-linear-progress__buffer"></div>
  <div class="mdc-linear-progress__bar mdc-linear-progress__primary-bar">
    <span class="mdc-linear-progress__bar-inner"></span>
  </div>
  <div class="mdc-linear-progress__bar mdc-linear-progress__secondary-bar">
    <span class="mdc-linear-progress__bar-inner"></span>
  </div>
</div>

Styles

@import "@limetech/mdc-linear-progress/mdc-linear-progress";

JavaScript Instantiation

import { MDCLinearProgress } from '@limetech/mdc-linear-progress';

const linearProgress = new MDCLinearProgress(document.querySelector('.mdc-linear-progress'));

See Importing the JS component for more information on how to import JavaScript.

CSS Modifiers

The provided modifiers are:

ClassDescription
mdc-linear-progress--indeterminatePuts the linear progress indicator in an indeterminate state.
mdc-linear-progress--reversedReverses the direction of the linear progress indicator.
mdc-linear-progress--closedHides the linear progress indicator.

Sass Mixins

MixinDescription
mdc-linear-progress-bar-color($color)Sets the color of the progress bar
mdc-linear-progress-buffer-color($color)Sets the color of the buffer bar and dots

Using the Foundation Class

MDC Linear Progress ships with an MDCLinearProgressFoundation class that external frameworks and libraries can use to integrate the component. As with all foundation classes, an adapter object must be provided. The adapter for linear progress must provide the following functions, with correct signatures:

Method SignatureDescription
addClass(className: string) => voidAdds a class to the root element.
removeClass(className: string) => voidRemoves a class from the root element.
hasClass(className: string) => booleanReturns boolean indicating whether the root element has a given class.
forceLayout() => voidForce-trigger a layout on the root element. This is needed to restart animations correctly.
getPrimaryBar() => ElementReturns the primary bar element.
getBuffer() => ElementReturns the buffer element.
setStyle(el: Element, styleProperty: string, value: string) => voidSets the inline style on the given element.

MDCLinearProgressFoundation API

MDC Linear Progress Foundation exposes the following methods:

Method SignatureDescription
setDeterminate(value: boolean) => voidToggles the component between the determinate and indeterminate state.
setProgress(value: number) => voidSets the progress bar to this value. Value should be between 0, 1.
setBuffer(value: number) => voidSets the buffer bar to this value. Value should be between 0, 1.
setReverse(value: boolean) => voidReverses the direction of the linear progress indicator.
open() => voidPuts the component in the open state.
close() => voidPuts the component in the closed state.

MDCLinearProgress API

MDC Linear Progress exposes the following methods:

Method SignatureDescription
set determinate(value: boolean) => voidToggles the component between the determinate and indeterminate state.
set progress(value: number) => voidSets the progress bar to this value. Value should be between 0, 1.
set buffer(value: number) => voidSets the buffer bar to this value. Value should be between 0, 1.
set reverse(value: boolean) => voidReverses the direction of the linear progress indicator.
open() => voidPuts the component in the open state.
close() => voidPuts the component in the closed state.