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

convert component to React

parent 05f003d3
'use strict';
module.exports = {
controllerAs: 'vm',
bindings: {
icon: '<',
isDisabled: '<',
label: '<',
onClick: '&',
},
template: require('../templates/annotation-action-button.html'),
const classnames = require('classnames');
const propTypes = require('prop-types');
const { createElement } = require('preact');
function AnnotationActionButton({ icon, isDisabled, label, onClick }) {
return (
<button
className="btn btn-clean annotation-action-btn"
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() {
.module('h', [])
.component('annotation', annotationComponent())
.component('annotationActionButton', {
bindings: require('../annotation-action-button').bindings,
bindings: {
icon: '<',
isDisabled: '<',
label: '<',
onClick: '&',
},
})
.component('markdown', {
bindings: require('../markdown').bindings,
......
......@@ -141,7 +141,7 @@ function startAngularApp(config) {
.component('annotationHeader', require('./components/annotation-header'))
.component(
'annotationActionButton',
require('./components/annotation-action-button')
wrapReactComponent(require('./components/annotation-action-button'))
)
.component(
'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