@instructure/quiz-interactions
Version:
A React UI component Library for quiz interaction types.
95 lines (94 loc) • 4.4 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = require("react");
var _propTypes = _interopRequireDefault(require("prop-types"));
var _uiIcons = require("@instructure/ui-icons");
var _uiText = require("@instructure/ui-text");
var _emotion = require("@instructure/emotion");
var _Card = _interopRequireDefault(require("../../../common/components/Card"));
var _styles = _interopRequireDefault(require("./styles"));
var _theme = _interopRequireDefault(require("./theme"));
var _quizCommon = require("@instructure/quiz-common");
var _dec, _class, _Pill;
/** @jsx jsx */
function _callSuper(_this, derived, args) {
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
} catch (e) {
return false;
}
}
derived = (0, _getPrototypeOf2["default"])(derived);
return (0, _possibleConstructorReturn2["default"])(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], (0, _getPrototypeOf2["default"])(_this).constructor) : derived.apply(_this, args));
}
var Pill = exports["default"] = (_dec = (0, _quizCommon.withStyleOverrides)(_styles["default"], _theme["default"]), _dec(_class = (_Pill = /*#__PURE__*/function (_Component) {
function Pill() {
(0, _classCallCheck2["default"])(this, Pill);
return _callSuper(this, Pill, arguments);
}
(0, _inherits2["default"])(Pill, _Component);
return (0, _createClass2["default"])(Pill, [{
key: "renderActions",
value: function renderActions() {
if (this.props.actionsContent) {
return this.props.actionsContent(this.props.id);
}
return (0, _emotion.jsx)("div", {
css: this.props.styles.actionsContentIconWrapper
}, (0, _emotion.jsx)(_uiIcons.IconDragHandleLine, null));
}
}, {
key: "render",
value: function render() {
if (this.props.isDraggable) {
return (0, _emotion.jsx)(_Card["default"], {
id: this.props.id,
onDropOut: this.props.onDropOut
}, (0, _emotion.jsx)("div", {
css: this.props.styles.choice
}, (0, _emotion.jsx)("div", {
css: this.props.styles.choice.choiceActions
}, this.renderActions()), (0, _emotion.jsx)("div", {
css: this.props.styles.choice.choiceBody
}, (0, _emotion.jsx)(_uiText.Text, {
color: "primary"
}, this.props.itemBody))));
}
return (0, _emotion.jsx)("div", {
id: this.props.id,
css: this.props.styles.choice
}, (0, _emotion.jsx)("div", {
css: this.props.styles.choice.choiceActions
}, this.renderActions()), (0, _emotion.jsx)("div", {
css: this.props.styles.choice.choiceBody
}, (0, _emotion.jsx)(_uiText.Text, {
color: "primary"
}, this.props.itemBody)));
}
}]);
}(_react.Component), (0, _defineProperty2["default"])(_Pill, "displayName", 'Pill'), (0, _defineProperty2["default"])(_Pill, "componentId", "Quizzes".concat(_Pill.displayName)), (0, _defineProperty2["default"])(_Pill, "propTypes", {
actionsContent: _propTypes["default"].func,
isDraggable: _propTypes["default"].bool,
id: _propTypes["default"].string.isRequired,
itemBody: _propTypes["default"].string.isRequired,
onDropOut: _propTypes["default"].func,
styles: _propTypes["default"].object
}), (0, _defineProperty2["default"])(_Pill, "defaultProps", {
actionsContent: void 0,
isDraggable: void 0,
onDropOut: void 0
}), _Pill)) || _class);