Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

feat(linear-progress): Implement Linear Progress indicators #672

Merged
merged 9 commits into from
May 23, 2017
8 changes: 8 additions & 0 deletions demos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@
</a>
</li>

<li class="mdc-list-item">
<span class="catalog-list-icon mdc-list-item__start-detail"><img class="catalog-component-icon" src="/images/ic_component_24px.svg" /></span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this image should be:

https://material.io/components/images/component_icons/progress_activity.svg

At least, that's what iOS uses.

<a href="linear-progress.html" class="mdc-list-item__text">
Linear progress
<span class="mdc-list-item__text__secondary">Fills from 0% to 100%, represented by bars</span>
</a>
</li>

<li class="mdc-list-item">
<span class="catalog-list-icon mdc-list-item__start-detail"><img class="catalog-component-icon" src="/images/ic_list_24px.svg" /></span>
<a href="list.html" class="mdc-list-item__text">
Expand Down
186 changes: 186 additions & 0 deletions demos/linear-progress.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<!DOCTYPE html>
Copy link
Contributor

@amsheehan amsheehan May 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This demos look gorgeous. The only thing I might change is giving each example a little more space to breath. For a good minute I was looking at the reverse LPI thinking it was a very wrong implementation of buffer LPI. 😝

<!--
Copyright 2016 Google Inc. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2017

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License
-->
<html>
<head>
<meta charset="utf-8">
<title>Linear Progress - Material Compoonents Catalog</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="assets/material-components-web.css.js" charset="utf-8"></script>
<link href="demos.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<style>
fieldset {
margin: 24px;
margin-top: 0;
margin-bottom: 16px;
}
fieldset .mdc-linear-progress {
margin: 16px 0;
}

fieldset legend {
display: block;
padding: 16px;
padding-top: 64px;
padding-bottom: 24px;
}
</style>
</head>
<body>
<header class="mdc-toolbar mdc-toolbar--fixed">
<div class="mdc-toolbar__row">
<section class="mdc-toolbar__section mdc-toolbar__section--align-start">
<span class="catalog-back">
<a href="/"><i class="material-icons">&#xE5C4;</i></a>
</span>
<span class="mdc-toolbar__title catalog-title">Linear Progress Indicators</span>
</section>
</div>
</header>
<main class="mdc-toolbar-fixed-adjust">

<section class="hero">
<div role="progressbar" class="mdc-linear-progress mdc-linear-progress--indeterminate">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indent level

<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>
</section>

<section>
<fieldset>
<legend class="mdc-typography--title">Linear Progress Indicators</legend>

<figure class="linear-progress-demo">
<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>
<figcaption>Determinate</figcaption>
</figure>

<figure class="linear-progress-demo">
<div role="progressbar" class="mdc-linear-progress mdc-linear-progress--indeterminate">
<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>
<figcaption>Indeterminate</figcaption>
</figure>

<figure class="linear-progress-demo">
<div role="progressbar" class="mdc-linear-progress" data-buffer="true">
<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>
<figcaption>Buffer</figcaption>
</figure>

<figure class="linear-progress-demo">
<div role="progressbar" class="mdc-linear-progress mdc-linear-progress--reversed">
<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>
<figcaption>Reversed</figcaption>
</figure>

<figure class="linear-progress-demo">
<div role="progressbar" class="mdc-linear-progress mdc-linear-progress--indeterminate mdc-linear-progress--reversed">
<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>
<figcaption>Indeterminate Reversed</figcaption>
</figure>

<figure class="linear-progress-demo">
<div role="progressbar" class="mdc-linear-progress mdc-linear-progress--reversed" data-buffer="true">
<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>
<figcaption>Buffer Reversed</figcaption>
</figure>

<figure class="linear-progress-demo">
<div role="progressbar" class="mdc-linear-progress mdc-linear-progress--accent">
<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>
<figcaption>Accent</figcaption>
</figure>

</fieldset>
</section>

</main>
<script src="assets/material-components-web.js" charset="utf-8"></script>
<script>
var determinates = document.querySelectorAll('.mdc-linear-progress');
for (var i = 0, determinate; determinate = determinates[i]; i++) {
const linearProgress = mdc.linearProgress.MDCLinearProgress.attachTo(determinate);
linearProgress.progress = 0.5;
if (determinate.dataset.buffer) {
linearProgress.buffer = 0.75;
}
}
</script>
</body>
</html>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"grid-list",
"icon-toggle",
"layout-grid",
"linear-progress",
"list",
"menu",
"radio",
Expand Down
7 changes: 5 additions & 2 deletions packages/material-components-web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import * as dialog from '@material/dialog';
import * as drawer from '@material/drawer';
import * as textfield from '@material/textfield';
import * as snackbar from '@material/snackbar';
import * as linearProgress from '@material/linear-progress';
import * as menu from '@material/menu';
import * as select from '@material/select';
import * as tabs from '@material/tabs';
Expand All @@ -39,6 +40,7 @@ autoInit.register('MDCTemporaryDrawer', drawer.MDCTemporaryDrawer);
autoInit.register('MDCRipple', ripple.MDCRipple);
autoInit.register('MDCGridList', gridList.MDCGridList);
autoInit.register('MDCIconToggle', iconToggle.MDCIconToggle);
autoInit.register('MDCLinearProgress', linearProgress.MDCLinearProgress);
autoInit.register('MDCRadio', radio.MDCRadio);
autoInit.register('MDCSnackbar', snackbar.MDCSnackbar);
autoInit.register('MDCTab', tabs.MDCTab);
Expand All @@ -52,14 +54,15 @@ autoInit.register('MDCToolbar', toolbar.MDCToolbar);
export {
base,
checkbox,
dialog,
drawer,
formField,
gridList,
iconToggle,
linearProgress,
radio,
ripple,
snackbar,
dialog,
drawer,
tabs,
textfield,
menu,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
@import "@material/grid-list/mdc-grid-list";
@import "@material/icon-toggle/mdc-icon-toggle";
@import "@material/layout-grid/mdc-layout-grid";
@import "@material/linear-progress/mdc-linear-progress";
@import "@material/list/mdc-list";
@import "@material/menu/mdc-menu";
@import "@material/radio/mdc-radio";
Expand Down
1 change: 1 addition & 0 deletions packages/material-components-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@material/grid-list": "^0.2.2",
"@material/icon-toggle": "^0.1.11",
"@material/layout-grid": "^0.1.2",
"@material/linear-progress": "^0.1.0",
"@material/list": "^0.2.8",
"@material/menu": "^0.2.6",
"@material/radio": "^0.2.4",
Expand Down
78 changes: 78 additions & 0 deletions packages/mdc-linear-progress/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!--docs:
title: "Linear Progress"
layout: detail
section: components
excerpt: "Material Design-styled linear progress indicators."
iconId: linear-progress
path: /catalog/linear-progress/
-->

# Linear Progress

<!--<div class="article__asset">
<a class="article__asset-link"
href="https://material-components-web.appspot.com/linear-progress.html">
</a>
</div>-->

The MDC Linear Progress component is a spec-aligned linear progress indicator component adhering to the
[Material Design progress & activity requirements](https://material.io/guidelines/components/progress-activity.html).

## Design & API Documentation

<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>

## Installation

```
npm install --save @material/linear-progress
```

## Usage

### CSS Modifiers

The provided modifiers are:

| Class | Description |
| --------------------- | ------------------------------------------------------- |
| `mdc-linear-progress--indeterminate` | Puts the linear progress indicator in an indeterminate state. |
| `mdc-linear-progress--reversed` | Reverses the direction of the linear progress indicator. |
| `mdc-linear-progress--accent` | Colors the button with the accent color. |

### 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 temporary drawers must provide the following functions, with correct signatures:

| Method Signature | Description |
| --- | --- |
| `addClass(className: string) => void` | Adds a class to the root element. |
| `removeClass(className: string) => void` | Removes a class from the root element. |
| `hasClass(className: string) => boolean` | Returns boolean indicating whether the root element has a given class. |
| `getPrimaryBar() => Element` | Returns the primary bar element. |
| `getBuffer() => Element` | Returns the buffer element. |
| `setTransform(el: Element, value: string) => void` | Sets the css transform property on the given element. |

### MDCLinearProgress API

MDC Linear Progress exposes the following methods:

| Method Signature | Description |
| --- | --- |
| `set determinate(value: boolean) => void` | Toggles the components between the determinate and indeterminate state. |
| `set progress(value: number) => void` | Sets the progress bar to this value. Value should be between [0, 1]. |
| `set buffer(value: number) => void` | Sets the buffer bar to this value. Value should be between [0, 1]. |
| `set reverse(value: boolean) => void` | Reverses the direction of the linear progress indicator. |
| `open() => void` | Puts the component in the open state. |
| `close() => void` | Puts the component in the closed state. |
Loading