-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from elwayman02/collapsible
Collapsible Posts
- Loading branch information
Showing
15 changed files
with
201 additions
and
12 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 |
---|---|---|
@@ -1,5 +1,21 @@ | ||
{{#each posts as |post|}} | ||
{{tumblr-post | ||
{{#if collapsible}} | ||
{{#if collapseByDefault}} | ||
{{tumblr-post | ||
post=post | ||
postsRoute=postsRoute | ||
collapsible=true | ||
collapsed=true}} | ||
{{else}} | ||
{{tumblr-post | ||
post=post | ||
postsRoute=postsRoute | ||
collapsible=true | ||
collapsed=false}} | ||
{{/if}} | ||
{{else}} | ||
{{tumblr-post | ||
post=post | ||
postsRoute=postsRoute}} | ||
{{/if}} | ||
{{/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
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,3 +1,5 @@ | ||
{{tumblr-post-text | ||
post=post | ||
postsRoute=postsRoute}} | ||
postsRoute=postsRoute | ||
collapsible=collapsible | ||
collapsed=collapsed}} |
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,7 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
model() { | ||
return this.store.find('tumblr-post-text'); | ||
} | ||
}); |
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,7 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
model() { | ||
return this.store.find('tumblr-post-text'); | ||
} | ||
}); |
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,10 @@ | ||
.index button { | ||
display: block; | ||
padding: 10px; | ||
margin-bottom: 5px; | ||
} | ||
|
||
.tumblr-post.tumblr-post-collapsed .tumblr-body { | ||
max-height: 300px; | ||
overflow: hidden; | ||
} |
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,6 @@ | ||
<h1>Welcome to my blog!</h1> | ||
|
||
{{tumblr-blog | ||
posts=model.content | ||
postsRoute='post' | ||
collapsible=true}} |
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,5 +1,8 @@ | ||
<h1>Ember-Tumblr Demo App</h1> | ||
|
||
<div><button>{{#link-to 'blog'}}Click to View Blog{{/link-to}}</button></div> | ||
<div><button>{{#link-to 'linked-blog'}}Click to View Blog With Links{{/link-to}}</button></div> | ||
|
||
<div class="index"> | ||
{{#link-to 'blog'}}<button>View Blog</button>{{/link-to}} | ||
{{#link-to 'linked-blog'}}<button>View Blog With Links</button>{{/link-to}} | ||
{{#link-to 'collapsed-blog'}}<button>View Blog With Collapsible Posts (Already Collapsed)</button>{{/link-to}} | ||
{{#link-to 'uncollapsed-blog'}}<button>View Blog With Collapsible Posts (Uncollapsed by Default)</button>{{/link-to}} | ||
</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,7 @@ | ||
<h1>Welcome to my blog!</h1> | ||
|
||
{{tumblr-blog | ||
posts=model.content | ||
postsRoute='post' | ||
collapsible=true | ||
collapseByDefault=false}} |
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,27 @@ | ||
import Ember from 'ember'; | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
|
||
moduleForComponent('tumblr-blog', 'Unit | Component | tumblr blog', { | ||
needs: ['component:tumblr-post'], | ||
unit: true | ||
}); | ||
|
||
test('it renders', function (assert) { | ||
assert.expect(2); | ||
|
||
// Creates the component instance | ||
const component = this.subject(); | ||
assert.equal(component._state, 'preRender'); | ||
|
||
// Renders the component to the page | ||
this.render(); | ||
assert.equal(component._state, 'inDOM'); | ||
}); | ||
|
||
test('defaults', function (assert) { | ||
const component = this.subject(); | ||
|
||
assert.ok(!Ember.isPresent(component.get('postsRoute')), 'postsRoute is not defined by default'); | ||
assert.ok(!component.get('collapsible'), 'blog is not collapsible by default'); | ||
assert.ok(component.get('collapseByDefault'), 'blog is set to collapse by default if collapsible'); | ||
}); |
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,20 +1,52 @@ | ||
import Ember from 'ember'; | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
|
||
moduleForComponent('tumblr-post', 'Unit | Component | tumblr post', { | ||
// Specify the other units that are required for this test | ||
// needs: ['component:foo', 'helper:bar'], | ||
needs: ['component:tumblr-post-text'], | ||
unit: true | ||
}); | ||
|
||
test('it renders', function(assert) { | ||
test('it renders', function (assert) { | ||
assert.expect(2); | ||
|
||
// Creates the component instance | ||
var component = this.subject(); | ||
const component = this.subject(); | ||
assert.equal(component._state, 'preRender'); | ||
|
||
// Renders the component to the page | ||
this.render(); | ||
assert.equal(component._state, 'inDOM'); | ||
}); | ||
|
||
test('defaults', function (assert) { | ||
const component = this.subject(); | ||
|
||
assert.ok(!Ember.isPresent(component.get('postsRoute')), 'postsRoute is not defined by default'); | ||
assert.ok(!component.get('collapsible'), 'post is not collapsible by default'); | ||
assert.ok(component.get('collapsed'), 'post is set to collapse by default if collapsible'); | ||
assert.ok(!component.get('isCollapsed'), 'post will not collapse by default, because it is not collapsible'); | ||
}); | ||
|
||
test('isCollapsed', function (assert) { | ||
const component = this.subject(); | ||
|
||
component.set('collapsible', true); | ||
assert.ok(component.get('isCollapsed'), 'post is collapsed by default when collapsible'); | ||
|
||
component.set('collapsed', false); | ||
assert.ok(!component.get('isCollapsed'), 'post is not collapsed'); | ||
}); | ||
|
||
test('expandButtonText', function (assert) { | ||
const collapsedText = 'foo'; | ||
const expandedText = 'bar'; | ||
const component = this.subject({ | ||
collapsedText, | ||
expandedText | ||
}); | ||
|
||
assert.equal(component.get('expandButtonText'), expandedText, 'expandedText is displayed by default'); | ||
|
||
component.set('collapsible', true); | ||
assert.equal(component.get('expandButtonText'), collapsedText, 'collapsedText is displayed when collapsed'); | ||
}); |