@instructure/quiz-interactions
Version:
A React UI component Library for quiz interaction types.
89 lines • 3.54 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
var _dec, _class, _Pill;
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 = _getPrototypeOf(derived);
return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args));
}
/** @jsx jsx */
import { Component } from 'react';
import PropTypes from 'prop-types';
import { IconDragHandleLine } from '@instructure/ui-icons';
import { Text } from '@instructure/ui-text';
import { jsx } from '@instructure/emotion';
import Card from '../../../common/components/Card';
import generateStyle from './styles';
import generateComponentTheme from './theme';
import { withStyleOverrides } from '@instructure/quiz-common';
var Pill = (_dec = withStyleOverrides(generateStyle, generateComponentTheme), _dec(_class = (_Pill = /*#__PURE__*/function (_Component) {
function Pill() {
_classCallCheck(this, Pill);
return _callSuper(this, Pill, arguments);
}
_inherits(Pill, _Component);
return _createClass(Pill, [{
key: "renderActions",
value: function renderActions() {
if (this.props.actionsContent) {
return this.props.actionsContent(this.props.id);
}
return jsx("div", {
css: this.props.styles.actionsContentIconWrapper
}, jsx(IconDragHandleLine, null));
}
}, {
key: "render",
value: function render() {
if (this.props.isDraggable) {
return jsx(Card, {
id: this.props.id,
onDropOut: this.props.onDropOut
}, jsx("div", {
css: this.props.styles.choice
}, jsx("div", {
css: this.props.styles.choice.choiceActions
}, this.renderActions()), jsx("div", {
css: this.props.styles.choice.choiceBody
}, jsx(Text, {
color: "primary"
}, this.props.itemBody))));
}
return jsx("div", {
id: this.props.id,
css: this.props.styles.choice
}, jsx("div", {
css: this.props.styles.choice.choiceActions
}, this.renderActions()), jsx("div", {
css: this.props.styles.choice.choiceBody
}, jsx(Text, {
color: "primary"
}, this.props.itemBody)));
}
}]);
}(Component), _defineProperty(_Pill, "displayName", 'Pill'), _defineProperty(_Pill, "componentId", "Quizzes".concat(_Pill.displayName)), _defineProperty(_Pill, "propTypes", {
actionsContent: PropTypes.func,
isDraggable: PropTypes.bool,
id: PropTypes.string.isRequired,
itemBody: PropTypes.string.isRequired,
onDropOut: PropTypes.func,
styles: PropTypes.object
}), _defineProperty(_Pill, "defaultProps", {
actionsContent: void 0,
isDraggable: void 0,
onDropOut: void 0
}), _Pill)) || _class);
export { Pill as default };