-
-
Notifications
You must be signed in to change notification settings - Fork 333
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
Feature/new new chips #344
Closed
mansona
wants to merge
22
commits into
adopted-ember-addons:master
from
stonecircle:feature/new-new-chips
Closed
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
6ef05b5
implementing basic chips
mansona e1deb79
adding the ability to include custom templates
mansona 08786d1
updating the demo
mansona bafde72
fixing deprecation warning
mansona d9ad2ea
fixing chips implementation based on new master
mansona 8604e32
escaping {{item}}
mansona b8f7946
fixing scrolling issue
mansona 7622172
adding basic contact chips
mansona 76e1193
fixing an issue with length checking
mansona ea278d1
importing chips from angular-material
mansona a87bbdb
convering template to hasBlock
mansona ddf6085
cleaning up code to jscs style
mansona 630fad7
fixing jscs
mansona 0b582db
fixing the location of templates
mansona 15f93bf
putting back overflow hidden that was removed in previous commit
mansona 3285a3a
fixing massive error that pops up in Atom
mansona a5ecf35
reverting another previous change
mansona f675ec1
action related feedback
mansona d1fe811
more action realated feedback
mansona 94d9db9
reverting suave version to try fix the build
mansona 494177b
Ttrigger add/remove contact actions properly in Chips demo
pauln cc0d193
Merge pull request #1 from pauln/feature/new-new-chips
mansona 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
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 @@ | ||
import Ember from 'ember'; | ||
|
||
const { get, Component } = Ember; | ||
|
||
export default Component.extend({ | ||
tagName: 'md-chips', | ||
classNames: ['md-default-theme'], | ||
|
||
actions: { | ||
addItem(newItem) { | ||
if (get(newItem, 'length')) { | ||
this.sendAction('addItem', newItem); | ||
this.set('newChipValue', ''); | ||
} | ||
}, | ||
|
||
inputFocus() { | ||
this.set('isFocused', true); | ||
}, | ||
|
||
inputBlur() { | ||
this.set('isFocused', 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,18 @@ | ||
import Ember from 'ember'; | ||
|
||
let { Component } = Ember; | ||
|
||
export default Component.extend({ | ||
tagName: 'md-contact-chips', | ||
classNames: ['md-default-theme'], | ||
|
||
actions: { | ||
inputFocus() { | ||
this.set('isFocused', true); | ||
}, | ||
|
||
inputBlur() { | ||
this.set('isFocused', 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,3 @@ | ||
import PaperChips from 'ember-paper/components/paper-chips'; | ||
|
||
export default PaperChips; |
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 PaperContactChips from 'ember-paper/components/paper-contact-chips'; | ||
|
||
export default PaperContactChips; |
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,29 @@ | ||
<md-chips-wrap class="md-chips {{if isFocused 'md-focused'}}"> | ||
{{#each content as |item|}} | ||
<md-chip class="md-chip md-default-theme"> | ||
<div class="md-chip-content" tabindex="-1" aria-hidden="true"> | ||
{{#if hasBlock}} | ||
{{yield item}} | ||
{{else}} | ||
<span>{{item}}</span> | ||
{{/if}} | ||
</div> | ||
<div class="md-chip-remove-container"> | ||
{{#unless readOnly}} | ||
<button class="md-chip-remove" {{action (action removeItem item)}} type="button" aria-hidden="true" tabindex="-1"> | ||
{{paper-icon icon="clear"}} | ||
<span class="md-visually-hidden"> Remove </span> | ||
</button> | ||
{{/unless}} | ||
</div> | ||
{{#unless readOnly}} | ||
<span class="md-visually-hidden"> Press delete to remove this chip. </span> | ||
{{/unless}} | ||
</md-chip> | ||
{{/each}} | ||
{{#unless readOnly}} | ||
<div class="md-chip-input-container"> | ||
{{input tabindex="0" placeholder=placeholder aria-label="Add Tag" value=newChipValue focus-in="inputFocus" focus-out="inputBlur" enter=(action 'addItem' newChipValue)}} | ||
</div> | ||
{{/unless}} | ||
</md-chips-wrap> |
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,37 @@ | ||
<md-chips-wrap class="md-chips md-contact-chips {{if isFocused 'md-focused'}}"> | ||
{{#each content as |item|}} | ||
<md-chip class="md-chip md-default-theme"> | ||
<div class="md-chip-content" tabindex="-1" aria-hidden="true"> | ||
<div class="md-contact-avatar"> | ||
<img src={{item.image}}> | ||
</div> | ||
<span class="md-contact-name">{{item.name}}</span> | ||
</div> | ||
<div class="md-chip-remove-container"> | ||
{{#unless readOnly}} | ||
<button class="md-chip-remove" {{action (action removeItem item)}} type="button" aria-hidden="true" tabindex="-1"> | ||
{{paper-icon icon="clear"}} | ||
<span class="md-visually-hidden"> Remove </span> | ||
</button> | ||
{{/unless}} | ||
</div> | ||
{{#unless readOnly}} | ||
<span class="md-visually-hidden"> Press delete to remove this chip. </span> | ||
{{/unless}} | ||
</md-chip> | ||
{{/each}} | ||
{{#unless readOnly}} | ||
{{#if source.length}} | ||
<div class="md-chip-input-container"> | ||
{{#paper-autocomplete minLength=0 placeholder="Add A Contact" source=source lookupKey="email" pickModel=(action addItem) as |searchText item index|}} | ||
<div class="md-contact-suggestion"> | ||
<img src={{item.image}} alt={{item.name}} class="md-contact-avatar"> | ||
|
||
<span class="md-contact-name">{{item.name}}</span> | ||
<span class="md-contact-email">{{item.email}}</span> | ||
</div> | ||
{{/paper-autocomplete}} | ||
</div> | ||
{{/if}} | ||
{{/unless}} | ||
</md-chips-wrap> |
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,57 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Controller.extend({ | ||
fruitNames: Ember.A(['Apple', 'Banana', 'Orange']), | ||
|
||
customFruitNames: Ember.A(['Apple', 'Banana', 'Orange']), | ||
|
||
contacts: Ember.A([{ | ||
name: 'James', | ||
email: 'james@ember.com', | ||
image: 'tomster.png' | ||
}]), | ||
|
||
allContacts: Ember.A([{ | ||
name: 'James', | ||
email: 'james@ember.com', | ||
image: 'tomster.png' | ||
}, { | ||
name: 'Chris', | ||
email: 'chris@ember.com', | ||
image: 'tomster.png' | ||
}]), | ||
|
||
remainingContacts: Ember.computed('allContacts.@each.email', 'contacts.@each.email', function() { | ||
return this.get('allContacts').filter((source) => { | ||
return !this.get('contacts').any(function(myContact) { | ||
return source.email === myContact.email; | ||
}); | ||
}); | ||
}), | ||
|
||
actions: { | ||
removeItem(item) { | ||
this.get('fruitNames').removeObject(item); | ||
}, | ||
|
||
addItem(item) { | ||
this.get('fruitNames').pushObject(item); | ||
}, | ||
|
||
removeCustomItem(item) { | ||
this.get('customFruitNames').removeObject(item); | ||
}, | ||
|
||
addCustomItem(item) { | ||
this.get('customFruitNames').pushObject(item); | ||
}, | ||
|
||
addContact(item) { | ||
this.get('contacts').pushObject(item); | ||
}, | ||
|
||
removeContact(item) { | ||
this.get('contacts').removeObject(item); | ||
} | ||
} | ||
}); |
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,24 @@ | ||
{{page-toolbar pageTitle="Chips" isDemo=true}} | ||
|
||
{{#doc-content}} | ||
|
||
{{! BEGIN-SNIPPET chips.example }} | ||
<h2>Default Template</h2> | ||
{{paper-chips content=fruitNames readOnly=readOnly removeItem=(action 'removeItem') addItem=(action 'addItem') placeholder="Add a tag"}} | ||
|
||
<h2>Custom Template</h2> | ||
{{#paper-chips readOnly=readOnly removeItem=(action 'removeCustomItem') addItem=(action 'addCustomItem') placeholder="Add a tag" content=customFruitNames as |item|}} | ||
<strong>{{item}}</strong> | ||
<em>(fruit)</em> | ||
{{/paper-chips}} | ||
|
||
<h2>Contact Chips</h2> | ||
{{paper-contact-chips class="md-contact-chips" readOnly=readOnly removeItem=(action 'removeContact') addItem=(action 'addContact') placeholder="Add a tag" content=contacts source=remainingContacts}} | ||
|
||
{{#paper-checkbox value=readOnly onChange=(action (mut readOnly))}}Read Only{{/paper-checkbox}} | ||
{{! END-SNIPPET }} | ||
|
||
<h3>Template</h3> | ||
{{code-snippet name="chips.example.hbs"}} | ||
|
||
{{/doc-content}} |
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.
This diverges from the angular implementation, which uses its own svg icon called
md-close
. Clear looks similar, but is too big and the positioning is off (perhaps because it is too bid). I'm not sure what the right thing to do here is. If we have to bit off angular'siconService.js
for other components, such as tags, maybe that's the thing to do? Oh @miguelcobain?