office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
32 lines • 1.49 kB
JavaScript
import * as tslib_1 from "tslib";
import * as React from 'react';
import { Rating } from 'office-ui-fabric-react/lib/Rating';
import { PrimaryButton } from 'office-ui-fabric-react/lib/Button';
var RatingButtonControlledExample = /** @class */ (function (_super) {
tslib_1.__extends(RatingButtonControlledExample, _super);
function RatingButtonControlledExample(props) {
var _this = _super.call(this, props) || this;
_this.state = {
rating: 0
};
return _this;
}
// tslint:disable:jsx-no-lambda
RatingButtonControlledExample.prototype.render = function () {
var _this = this;
var maxrating = 5;
return (React.createElement("div", { className: "ms-RatingButtonControlledExample" },
React.createElement(Rating, { rating: this.state.rating, max: 5, readOnly: true, allowZeroStars: true }),
React.createElement(PrimaryButton, { text: 'Click to change rating to ' + (maxrating - this.state.rating), onClick: function (e) {
if (_this.state.rating === 0) {
_this.setState({ rating: 5 });
}
else {
_this.setState({ rating: 0 });
}
} })));
};
return RatingButtonControlledExample;
}(React.Component));
export { RatingButtonControlledExample };
//# sourceMappingURL=Rating.ButtonControlled.Example.js.map