two examples of implementing react components
This commit is contained in:
parent
67e466ee11
commit
36b1ee2be9
3 changed files with 26 additions and 19 deletions
|
@ -3,19 +3,18 @@
|
|||
*/
|
||||
var testComponent = React.createClass({
|
||||
propTypes: {
|
||||
prop1: React.PropTypes.string.isRequired,
|
||||
prop2: React.PropTypes.string.isRequired
|
||||
firstProp: React.PropTypes.string.isRequired,
|
||||
secondProp: React.PropTypes.string.isRequired
|
||||
},
|
||||
render: function() {
|
||||
return React.DOM.span(null,
|
||||
'This is a react component: ' + this.props.prop1 + ' ' + this.props.prop2
|
||||
'This is a react component: ' + this.props.firstProp + ' ' + this.props.secondProp
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
angular.module('quayPages')
|
||||
.value('TestComponent', testComponent)
|
||||
.directive('testComponent', function(reactDirective) {
|
||||
return reactDirective(testComponent);
|
||||
});
|
||||
angular.module('quayPages').value('test-component', testComponent);
|
||||
angular.module('quayPages').directive('testComponent', function(reactDirective) {
|
||||
return reactDirective('testComponent');
|
||||
});
|
||||
|
||||
|
|
|
@ -2,19 +2,18 @@
|
|||
/**
|
||||
* Repository view page.
|
||||
*/
|
||||
angular.module('quayPages')
|
||||
.config(['pages', function(pages) {
|
||||
pages.create('repo-view', 'repo-view.html', RepoViewCtrl, {
|
||||
'newLayout': true,
|
||||
'title': '{{ namespace }}/{{ name }}',
|
||||
'description': 'Repository {{ namespace }}/{{ name }}'
|
||||
});
|
||||
}])
|
||||
angular.module('quayPages').config(['pages', function(pages) {
|
||||
pages.create('repo-view', 'repo-view.html', RepoViewCtrl, {
|
||||
'newLayout': true,
|
||||
'title': '{{ namespace }}/{{ name }}',
|
||||
'description': 'Repository {{ namespace }}/{{ name }}'
|
||||
});
|
||||
}]);
|
||||
|
||||
function RepoViewCtrl($scope, $routeParams, $location, $timeout, ApiService, UserService, AngularPollChannel, ImageLoaderService, CookieService) {
|
||||
$scope.reactProps = {
|
||||
prop1: 'Prop 1',
|
||||
prop2: 'Prop 2'
|
||||
firstProp: 'Prop 1',
|
||||
secondProp: 'Prop 2'
|
||||
};
|
||||
|
||||
$scope.namespace = $routeParams.namespace;
|
||||
|
|
|
@ -5,7 +5,16 @@
|
|||
<!-- New Public Repo Page experiment -->
|
||||
<div ng-if="newRepoExperiment">
|
||||
<!-- Test React Component -->
|
||||
<div><react-component name="TestComponent" props="reactProps"/></div>
|
||||
<div>
|
||||
<div>
|
||||
<div>This is using the generic react-component directive</div>
|
||||
<react-component name="test-component" props="reactProps"/>
|
||||
</div>
|
||||
<div>
|
||||
<div>This is creating a specific directive corresponding to a react component</div>
|
||||
<test-component first-prop="reactProps.firstProp" second-prop="reactProps.secondProp"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Old Repo Page -->
|
||||
<div ng-if="!newRepoExperiment">
|
||||
|
|
Reference in a new issue