Last active
April 8, 2020 14:50
-
-
Save nightire/fef86bc426193e399166f82d62589e93 to your computer and use it in GitHub Desktop.
limited-items
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
import Component from '@glimmer/component'; | |
export default class extends Component { | |
get shouldLimit() { | |
return this.args.items.length > this.args.showMax; | |
} | |
get items() { | |
if (this.shouldLimit) { | |
const [...items] = this.args.items; | |
return items.splice(0, items.length - (this.args.showMax - 1)); | |
} else { | |
return this.args.items; | |
} | |
} | |
get remaining() { | |
return this.args.items.length - this.args.showMax; | |
} | |
} |
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
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
options = [ | |
{ name: 'A' }, | |
{ name: 'B' }, | |
{ name: 'C' }, | |
{ name: 'D' }, | |
{ name: 'E' }, | |
] | |
} |
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
{ | |
"version": "0.17.0", | |
"EmberENV": { | |
"FEATURES": {}, | |
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false, | |
"_APPLICATION_TEMPLATE_WRAPPER": true, | |
"_JQUERY_INTEGRATION": true | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.17.0", | |
"ember-template-compiler": "3.17.0", | |
"ember-testing": "3.17.0" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment