@instructure/quiz-interactions
Version:
A React UI component Library for quiz interaction types.
116 lines (115 loc) • 4.14 kB
JavaScript
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _object_spread(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === "function") {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function(key) {
_define_property(target, key, source[key]);
});
}
return target;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) {
symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
}
keys.push.apply(keys, symbols);
}
return keys;
}
function _object_spread_props(target, source) {
source = source != null ? source : {};
if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
var generateStyle = function(componentTheme, props) {
var printMq = '@media print';
var paragraphContainer = _define_property({
display: 'flex',
flexWrap: 'wrap',
marginTop: componentTheme.paragraphContainerMargin,
paddingBottom: componentTheme.paragraphContainerPadding,
paddingLeft: componentTheme.paragraphContainerPadding,
backgroundColor: componentTheme.paragraphContainerColor
}, printMq, {
display: 'block'
});
var fullWidthStyles = {
flex: 1,
display: 'flex',
alignItems: 'center'
};
return {
/* LABELS */ topLabel: {
paddingTop: componentTheme.bottomLabelPadding
},
bottomLabel: {
paddingTop: componentTheme.bottomLabelPadding
},
/* CHOICES */ container: props.displayAnswersParagraph ? paragraphContainer : {},
/* CHOICE */ choiceContainer: {
display: 'flex',
alignItems: 'center',
marginTop: componentTheme.choiceContainerMargin
},
choiceContainerContent: _object_spread_props(_object_spread({
padding: componentTheme.choiceContainerContentPadding,
backgroundColor: componentTheme.choiceContainerContentColor,
width: '100%'
}, !props.displayAnswersParagraph && fullWidthStyles), _define_property({}, printMq, fullWidthStyles)),
choicePosition: _define_property({
width: componentTheme.choicePositionWidth,
textAlign: 'center'
}, printMq, {
display: 'none'
}),
choice: {
flex: 1,
display: 'flex',
alignItems: 'center',
padding: componentTheme.choicePadding,
border: "".concat(componentTheme.choiceBorder, " solid ").concat(componentTheme.choiceBorderColor),
borderRadius: componentTheme.choiceBorderRadius,
backgroundColor: componentTheme.choiceColor
},
choiceBody: {
paddingLeft: componentTheme.choiceBodyPadding,
paddingRight: componentTheme.choiceBodyPadding
},
printedPositionInput: _define_property({
display: 'none'
}, printMq, {
display: 'flex',
marginRight: componentTheme.printedPositionInputMargin
})
};
};
export default generateStyle;