-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03111c4
commit f16d70d
Showing
14 changed files
with
352 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# MdProgressFab | ||
`MdProgressFab` is a normal FAB button surrounded with a `progress-circle`. | ||
|
||
### Screenshots | ||
![Preview](https://cloud.githubusercontent.com/assets/4987015/14406410/eaf20a54-fea6-11e5-8a24-4f751df7e80a.png) | ||
|
||
## `[md-progress-fab]` | ||
### Bound Properties | ||
|
||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| `color` | `"primary" | "accent" | "warn"` | The color palette for the FAB button | | ||
| `value` | `number` | Value for the `progress-circle`.<br/> Necessary when using the `determinate` mode. | | ||
| `mode` | `"determinate" | "indeterminate"` | Mode for the `progress-circle`.<br/> | | ||
| `progressColor` | `"primary" | "accent" | "warn"` | Color for the `progress-circle`.<br/> | | ||
|
||
|
||
### Examples | ||
A basic progress-fab will have the markup: | ||
```html | ||
<button md-progress-fab color="accent"> | ||
<i class="material-icons md-24">favorite</i> | ||
</button> | ||
``` | ||
It will use by default a `indeterminate` progress circle. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<span class="md-button-wrapper"> | ||
<ng-content></ng-content> | ||
|
||
<div class="md-progress-wrap"> | ||
<md-progress-circle | ||
[mode]="progressMode" | ||
[value]="progressValue" | ||
[attr.color]="progressColor"> | ||
</md-progress-circle> | ||
</div> | ||
</span> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@import "../button/button-base"; | ||
|
||
$md-fab-progress-stroke: 6px; | ||
|
||
// Subtract 1px to avoid the ugly space between FAB button and progress circle. | ||
$md-fab-progress-rectangle: ($md-fab-size + $md-fab-padding + $md-fab-progress-stroke / 2) - 1px; | ||
|
||
:host { | ||
@include md-fab($md-fab-size, $md-fab-padding); | ||
|
||
margin: $md-fab-progress-stroke; | ||
|
||
.md-progress-wrap { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
|
||
transform: translate3d(-50%, -50%, 0); | ||
|
||
md-progress-circle { | ||
width: $md-fab-progress-rectangle; | ||
height: $md-fab-progress-rectangle; | ||
|
||
svg { | ||
overflow: visible; | ||
|
||
circle { | ||
stroke-width: $md-fab-progress-stroke; | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import { | ||
it, | ||
describe, | ||
expect, | ||
beforeEach, | ||
inject, | ||
TestComponentBuilder | ||
} from 'angular2/testing'; | ||
import {Component} from 'angular2/core'; | ||
import {By} from 'angular2/platform/browser'; | ||
import {MdProgressFab} from './progress-fab'; | ||
import {MdProgressCircle} from '../progress-circle/progress-circle'; | ||
|
||
export function main() { | ||
describe('MdProgressFab', () => { | ||
let builder: TestComponentBuilder; | ||
|
||
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { | ||
builder = tcb; | ||
})); | ||
|
||
it('should correctly apply the color attribute on the progress circle', (done: () => void) => { | ||
return builder | ||
.createAsync(TestApp) | ||
.then((fixture) => { | ||
let testComponent = fixture.debugElement.componentInstance; | ||
let progressDebugElement = fixture.debugElement.query(By.css('md-progress-circle')); | ||
|
||
testComponent.progressColor = 'primary'; | ||
fixture.detectChanges(); | ||
|
||
expect(progressDebugElement.nativeElement.getAttribute('color')).toBe('primary'); | ||
|
||
testComponent.progressColor = 'accent'; | ||
fixture.detectChanges(); | ||
|
||
expect(progressDebugElement.nativeElement.getAttribute('color')).toBe('accent'); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
it('should correctly apply the mode on the progress circle', (done: () => void) => { | ||
return builder | ||
.createAsync(TestApp) | ||
.then((fixture) => { | ||
let testComponent = fixture.debugElement.componentInstance; | ||
let progressComponent: MdProgressCircle = fixture.debugElement | ||
.query(By.css('md-progress-circle')).componentInstance; | ||
|
||
testComponent.progressMode = 'determinate'; | ||
fixture.detectChanges(); | ||
|
||
expect(progressComponent.mode).toBe('determinate'); | ||
|
||
testComponent.progressColor = 'indeterminate'; | ||
fixture.detectChanges(); | ||
|
||
expect(progressComponent.mode).toBe('determinate'); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
it('should correctly apply the value on the progress circle', (done: () => void) => { | ||
return builder | ||
.createAsync(TestApp) | ||
.then((fixture) => { | ||
let testComponent = fixture.debugElement.componentInstance; | ||
let progressComponent: MdProgressCircle = fixture.debugElement | ||
.query(By.css('md-progress-circle')).componentInstance; | ||
|
||
testComponent.progressValue = 50; | ||
fixture.detectChanges(); | ||
|
||
expect(progressComponent._value).toBe(50); | ||
|
||
testComponent.progressValue = 70; | ||
fixture.detectChanges(); | ||
|
||
expect(progressComponent._value).toBe(70); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
it('should correctly apply the color on the button', (done: () => void) => { | ||
return builder | ||
.createAsync(TestApp) | ||
.then((fixture) => { | ||
let testComponent = fixture.debugElement.componentInstance; | ||
let buttonDebugElement = fixture.debugElement.query(By.css('button')); | ||
|
||
testComponent.buttonColor = 'primary'; | ||
fixture.detectChanges(); | ||
|
||
expect(buttonDebugElement.nativeElement.classList.contains('md-primary')).toBe(true); | ||
|
||
testComponent.buttonColor = 'accent'; | ||
fixture.detectChanges(); | ||
expect(buttonDebugElement.nativeElement.classList.contains('md-accent')).toBe(true); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
}); | ||
} | ||
|
||
@Component({ | ||
selector: 'test-app', | ||
template: ` | ||
<button md-progress-fab [color]="buttonColor" [progressColor]="progressColor" | ||
[mode]="progressMode" [value]="progressValue"> | ||
</button>`, | ||
directives: [MdProgressFab] | ||
}) | ||
class TestApp { | ||
buttonColor: string = 'primary'; | ||
progressColor: string = 'accent'; | ||
progressMode: string = 'indeterminate'; | ||
progressValue: number = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { | ||
Component, | ||
ChangeDetectionStrategy, | ||
Renderer, | ||
ElementRef, | ||
Input | ||
} from 'angular2/core'; | ||
import {MdProgressCircle} from '../progress-circle/progress-circle'; | ||
import {MdButton} from '../button/button'; | ||
|
||
@Component({ | ||
selector: '[md-progress-fab]:not(a)', | ||
templateUrl: './components/progress-fab/progress-fab.html', | ||
styleUrls: ['./components/progress-fab/progress-fab.css'], | ||
directives: [MdProgressCircle], | ||
inputs: ['color'], | ||
host: { | ||
'[class.md-button-focus]': 'isKeyboardFocused', | ||
'(mousedown)': 'setMousedown()', | ||
'(focus)': 'setKeyboardFocus()', | ||
'(blur)': 'removeKeyboardFocus()' | ||
}, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class MdProgressFab extends MdButton { | ||
|
||
@Input('mode') progressMode: string = 'indeterminate'; | ||
@Input('value') progressValue: number; | ||
@Input('progressColor') progressColor: string; | ||
|
||
constructor(elementRef: ElementRef, renderer: Renderer) { | ||
super(elementRef, renderer); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
import {Component} from 'angular2/core'; | ||
import {MdButton, MdAnchor} from '../../components/button/button'; | ||
import {MdProgressFab} from '../../components/progress-fab/progress-fab'; | ||
|
||
@Component({ | ||
selector: 'button-demo', | ||
templateUrl: 'demo-app/button/button-demo.html', | ||
styleUrls: ['demo-app/button/button-demo.css'], | ||
directives: [MdButton, MdAnchor] | ||
directives: [MdButton, MdAnchor, MdProgressFab] | ||
}) | ||
export class ButtonDemo { | ||
isDisabled: boolean = false; | ||
clickCounter: number = 0; | ||
fabProgressValue: number = 0; | ||
|
||
constructor() { | ||
|
||
setInterval(() => this.increaseFabProgress(), 200); | ||
} | ||
|
||
increaseFabProgress() { | ||
this.fabProgressValue += 7; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<div class="demo-progress-fab"> | ||
|
||
<md-card class="demo-progress-card"> | ||
<md-toolbar color="primary">Basic</md-toolbar> | ||
<md-card-content> | ||
<div class="demo-content"> | ||
<button md-progress-fab color="accent"> | ||
<i class="material-icons md-24">favorite</i> | ||
</button> | ||
|
||
<button md-progress-fab | ||
color="primary" | ||
progressColor="warn" | ||
mode="determinate" | ||
[value]="fabProgressValue"> | ||
|
||
<i class="material-icons md-24">feedback</i> | ||
</button> | ||
</div> | ||
</md-card-content> | ||
</md-card> | ||
|
||
<md-card class="demo-progress-card"> | ||
<md-toolbar color="primary">Determinate</md-toolbar> | ||
<md-card-content> | ||
<div class="demo-content"> | ||
|
||
<button md-progress-fab | ||
class="demo-determinate-progress" | ||
[color]="determinateColor" | ||
progressColor="warn" | ||
mode="determinate" | ||
[value]="fabProgressValue" | ||
[class.hide-progress]="determinateHidden"> | ||
|
||
<i class="material-icons md-24">feedback</i> | ||
</button> | ||
</div> | ||
</md-card-content> | ||
</md-card> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.demo-progress-fab { | ||
|
||
.demo-progress-card { | ||
padding: 0; | ||
margin: 16px; | ||
|
||
.demo-content { | ||
padding: 7px; | ||
|
||
.demo-determinate-progress.hide-progress { | ||
.md-progress-wrap { | ||
md-progress-circle { | ||
transition-duration: 0.7s; | ||
transition-property: transform, opacity; | ||
transition-timing-function: ease-out; | ||
|
||
transform: scale(0.8); | ||
opacity: 0; | ||
} | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
} |
Oops, something went wrong.