-
Notifications
You must be signed in to change notification settings - Fork 41
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
1b3c9ac
commit 632270c
Showing
7 changed files
with
79 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import Ember from 'ember'; | ||
import layout from '../templates/components/nf-component'; | ||
|
||
const { | ||
assert, | ||
isPresent | ||
} = Ember; | ||
|
||
/** | ||
Renders a custom component with the given component name. | ||
## Example | ||
The following example will render a custom svg image component at (0, 50): | ||
{{#graph.component 'my-custom-svg-image' as |image|}} | ||
{{component image src="images/star.svg"}} | ||
{{/graph.component}} | ||
@namespace components | ||
@class nf-component | ||
@extends Ember.Component | ||
*/ | ||
const NfComponent = Ember.Component.extend({ | ||
layout, | ||
tagName: '', | ||
|
||
/** | ||
The name of the component to be rendered. | ||
@property componentName | ||
@type String | ||
@default '' | ||
*/ | ||
componentName: '', | ||
|
||
/** | ||
The parent graph for a component. | ||
@property graph | ||
@type components.nf-graph | ||
@default null | ||
*/ | ||
graph: null, | ||
|
||
/** | ||
The scale source | ||
@property scaleSource | ||
@type d3.nf-graph | ||
@default graph | ||
*/ | ||
scaleSource: null, | ||
|
||
init(){ | ||
this._super(...arguments); | ||
assert('[ember-nf-graph] A component name must be passed into nf-component.', isPresent(this.get('componentName'))); | ||
} | ||
}); | ||
|
||
NfComponent.reopenClass({ | ||
positionalParams: ['componentName'] | ||
}); | ||
|
||
export default NfComponent; |
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 @@ | ||
{{yield (component componentName graph=graph scaleSource=scaleSource)}} |
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 @@ | ||
{{yield}} |
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 @@ | ||
export { default } from 'ember-nf-graph/components/nf-component'; |