Commit 9246e478 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner

convert component to React

parent 05f003d3
'use strict'; 'use strict';
module.exports = { const classnames = require('classnames');
controllerAs: 'vm', const propTypes = require('prop-types');
bindings: { const { createElement } = require('preact');
icon: '<',
isDisabled: '<', function AnnotationActionButton({ icon, isDisabled, label, onClick }) {
label: '<', return (
onClick: '&', <button
}, className="btn btn-clean annotation-action-btn"
template: require('../templates/annotation-action-button.html'), onClick={onClick}
disabled={isDisabled}
aria-label={label}
h-tooltip
>
<i className={classnames(icon, 'btn-icon')} />
</button>
);
}
AnnotationActionButton.propTypes = {
/** A CSS classname corresponding to an `h` icon */
icon: propTypes.string.isRequired,
isDisabled: propTypes.bool.isRequired,
label: propTypes.string.isRequired,
onClick: propTypes.func.isRequired,
}; };
module.exports = AnnotationActionButton;
...@@ -155,7 +155,12 @@ describe('annotation', function() { ...@@ -155,7 +155,12 @@ describe('annotation', function() {
.module('h', []) .module('h', [])
.component('annotation', annotationComponent()) .component('annotation', annotationComponent())
.component('annotationActionButton', { .component('annotationActionButton', {
bindings: require('../annotation-action-button').bindings, bindings: {
icon: '<',
isDisabled: '<',
label: '<',
onClick: '&',
},
}) })
.component('markdown', { .component('markdown', {
bindings: require('../markdown').bindings, bindings: require('../markdown').bindings,
......
...@@ -141,7 +141,7 @@ function startAngularApp(config) { ...@@ -141,7 +141,7 @@ function startAngularApp(config) {
.component('annotationHeader', require('./components/annotation-header')) .component('annotationHeader', require('./components/annotation-header'))
.component( .component(
'annotationActionButton', 'annotationActionButton',
require('./components/annotation-action-button') wrapReactComponent(require('./components/annotation-action-button'))
) )
.component( .component(
'annotationShareDialog', 'annotationShareDialog',
......
<button class="btn btn-clean annotation-action-btn"
ng-click="vm.onClick()"
ng-disabled="vm.isDisabled"
aria-label="{{ vm.label }}"
h-tooltip>
<i class="{{ vm.icon }} btn-icon"></i>
</button>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment