-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loader component #37
Merged
Merged
Loader component #37
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import Ember from 'ember'; | ||
import layout from '../templates/components/materialize-loader'; | ||
|
||
export default Ember.Component.extend({ | ||
layout: layout, | ||
mode: 'indeterminate', | ||
percent: 0, | ||
size: 'big', | ||
active: true, | ||
color: null, | ||
classNameBindings: ['isBarType:progress:preloader-wrapper', 'active:active', 'size'], | ||
|
||
isBarType: function () { | ||
return ['determinate', 'indeterminate'].indexOf(this.get('mode')) >= 0; | ||
}.property('mode'), | ||
|
||
isDeterminate: function () { | ||
return ['determinate'].indexOf(this.get('mode')); | ||
}.property('mode'), | ||
|
||
barStyle: function () { | ||
if (this.get('mode') === 'determinate') { | ||
var pct = this.get('percent'); | ||
return `width: ${pct}%`; | ||
} | ||
}.property('mode', 'percent'), | ||
|
||
barClassName: function () { | ||
var mode = this.get('mode'); | ||
if (this.get('isBarType')) { | ||
return mode; | ||
} | ||
else { | ||
return null; | ||
} | ||
}.property('isBarType', 'mode'), | ||
|
||
spinnerClassNames: function () { | ||
if (!this.get('isBarType')) { | ||
var color = this.get('color'); | ||
if (!color) { | ||
return ['blue', 'red', 'green', 'yellow'].map((c) => (`spinner-layer spinner-${c}`)); | ||
} | ||
else { | ||
return [`spinner-layer spinner-${color}-only`]; | ||
} | ||
} | ||
else { | ||
return []; | ||
} | ||
}.property('color', 'isBarType') | ||
}); |
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,14 @@ | ||
{{#if isBarType}} | ||
<div class={{barClassName}} style={{barStyle}}></div> | ||
{{/if}} | ||
{{#each spinnerClassNames as |spinnerClassName|}} | ||
<div class={{spinnerClassName}}> | ||
<div class="circle-clipper left"> | ||
<div class="circle"></div> | ||
</div><div class="gap-patch"> | ||
<div class="circle"></div> | ||
</div><div class="circle-clipper right"> | ||
<div class="circle"></div> | ||
</div> | ||
</div> | ||
{{/each}} |
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,3 @@ | ||
import materializeLoader from 'ember-cli-materialize/components/materialize-loader'; | ||
|
||
export default materializeLoader; |
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,5 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Controller.extend({ | ||
percent: 70 | ||
}); |
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 |
---|---|---|
|
@@ -54,6 +54,7 @@ span.badge { | |
} | ||
&.default-value { | ||
float: none; | ||
position: inherit; | ||
} | ||
} | ||
.intro { | ||
|
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,85 @@ | ||
<div class="section index-banner"> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col s12 m9"> | ||
<h1 class="header">Loader</h1> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class='container'> | ||
<div class="section"> | ||
<div class="intro"> | ||
<h4 class="col s12 header">The component supports one option:</h4> | ||
<ul> | ||
<li>mode, default value <span class="default-value badge">indeterminate</span> - Loader mode (determinate, indeterminate, circular)</li> | ||
<li>percent, default value <span class="default-value badge">0</span> - Percent progress (determinate loader only)</li> | ||
<li>active, default value <span class="default-value badge">true</span> - Whether the animation should be active or not (indeterminate loaders only)</li> | ||
<li>color, default value <span class="default-value badge">null</span> - Circular loader color (null, yellow, blue, green, red). Setting this to null (default) will result in the color rotating</li> | ||
<li>size, default value <span class="default-value badge">big</span> - Circular loader size (small, big)</li> | ||
</ul> | ||
</div> | ||
</div> | ||
|
||
<!-- INDETERMINATE LOADER --> | ||
<div class="section"> | ||
<h4 class="col s12 header">Indeterminate Loader</h4> | ||
<div class="button-example"> | ||
{{materialize-loader}} | ||
|
||
<pre class=" language-markup"> | ||
<code class=" col s8 language-markup"> | ||
<span>{{</span>materialize-loader<span>}}</span> | ||
</code> | ||
</pre> | ||
</div> | ||
</div> | ||
|
||
<!-- DETERMINATE LOADER --> | ||
<div class="section"> | ||
<h4 class="col s12 header">Determinate Loader</h4> | ||
<div class="button-example"> | ||
<div class="row"> | ||
<div class="col s2"> | ||
{{materialize-input label="Percent" type="number" value=percent step=5 min=0 max=100}} | ||
</div> | ||
<div class="col s10"> | ||
{{materialize-loader mode="determinate" percent=percent}} | ||
</div> | ||
</div> | ||
|
||
<pre class=" language-markup"> | ||
<code class=" col s12 language-markup"> | ||
<span>{{</span>materialize-loader mode="determinate"<span>}}</span> | ||
</code> | ||
</pre> | ||
</div> | ||
</div> | ||
|
||
<!-- CIRCULAR DETERMINATE LOADER --> | ||
<div class="section"> | ||
<h4 class="col s12 header">Circular Indeterminate Loader</h4> | ||
<div class="button-example"> | ||
<div class="row"> | ||
<div class="col s2 center">{{materialize-loader mode="circular"}}</div> | ||
<div class="col s2 center">{{materialize-loader mode="circular" size="small"}}</div> | ||
<div class="col s2 center">{{materialize-loader mode="circular" color="blue"}}</div> | ||
<div class="col s2 center">{{materialize-loader mode="circular" color="red"}}</div> | ||
<div class="col s2 center">{{materialize-loader mode="circular" color="green"}}</div> | ||
<div class="col s2 center">{{materialize-loader mode="circular" color="yellow"}}</div> | ||
</div> | ||
|
||
<pre class=" language-markup"> | ||
<code class=" col s12 language-markup"> | ||
<span>{{</span>materialize-loader mode="circular"<span>}}</span> | ||
<span>{{</span>materialize-loader mode="circular" size="small"<span>}}</span> | ||
<span>{{</span>materialize-loader mode="circular" color="blue"<span>}}</span> | ||
<span>{{</span>materialize-loader mode="circular" color="red"<span>}}</span> | ||
<span>{{</span>materialize-loader mode="circular" color="green"<span>}}</span> | ||
<span>{{</span>materialize-loader mode="circular" color="yellow"<span>}}</span> | ||
</code> | ||
</pre> | ||
</div> | ||
</div> | ||
</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,21 @@ | ||
import { | ||
moduleForComponent, | ||
test | ||
} from 'ember-qunit'; | ||
|
||
moduleForComponent('materialize-loader', { | ||
// Specify the other units that are required for this test | ||
// needs: ['component:foo', 'helper:bar'] | ||
}); | ||
|
||
test('it renders', function(assert) { | ||
assert.expect(2); | ||
|
||
// Creates the component instance | ||
var component = this.subject(); | ||
assert.equal(component._state, 'preRender'); | ||
|
||
// Renders the component to the page | ||
this.render(); | ||
assert.equal(component._state, 'inDOM'); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ember-cli crashes at this point. I'm getting the following error message:
SyntaxError: illegal character
return
width: ${pct}%
;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should update your Ember-cli. It now includes babel.js to transpile ES6 syntax like this template string to ES5.