create-expo-cljs-app
Version:
Create a react native application with Expo and Shadow-CLJS!
71 lines (54 loc) • 2.79 kB
JavaScript
"use strict";
exports.__esModule = true;
exports.default = void 0;
var _normalizeValueWithProperty = _interopRequireDefault(require("./normalizeValueWithProperty"));
var _resolveShadowValue = _interopRequireDefault(require("./resolveShadowValue"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var defaultOffset = {
height: 0,
width: 0
};
function boxShadowReducer(resolvedStyle, style) {
var boxShadow = style.boxShadow;
var shadow = (0, _resolveShadowValue.default)(style);
if (shadow != null) {
resolvedStyle.boxShadow = boxShadow ? boxShadow + ", " + shadow : shadow;
}
}
function textShadowReducer(resolvedStyle, style) {
var textShadowColor = style.textShadowColor,
textShadowOffset = style.textShadowOffset,
textShadowRadius = style.textShadowRadius;
var _ref = textShadowOffset || defaultOffset,
height = _ref.height,
width = _ref.width;
var radius = textShadowRadius || 0;
var offsetX = (0, _normalizeValueWithProperty.default)(width);
var offsetY = (0, _normalizeValueWithProperty.default)(height);
var blurRadius = (0, _normalizeValueWithProperty.default)(radius);
var color = (0, _normalizeValueWithProperty.default)(textShadowColor, 'textShadowColor');
if (color && (height !== 0 || width !== 0 || radius !== 0) && offsetX != null && offsetY != null && blurRadius != null) {
resolvedStyle.textShadow = offsetX + " " + offsetY + " " + blurRadius + " " + color;
}
}
var createCompileableStyle = function createCompileableStyle(styles) {
var shadowColor = styles.shadowColor,
shadowOffset = styles.shadowOffset,
shadowOpacity = styles.shadowOpacity,
shadowRadius = styles.shadowRadius,
textShadowColor = styles.textShadowColor,
textShadowOffset = styles.textShadowOffset,
textShadowRadius = styles.textShadowRadius,
nextStyles = _objectWithoutPropertiesLoose(styles, ["shadowColor", "shadowOffset", "shadowOpacity", "shadowRadius", "textShadowColor", "textShadowOffset", "textShadowRadius"]);
if (shadowColor != null || shadowOffset != null || shadowOpacity != null || shadowRadius != null) {
boxShadowReducer(nextStyles, styles);
}
if (textShadowColor != null || textShadowOffset != null || textShadowRadius != null) {
textShadowReducer(nextStyles, styles);
}
return nextStyles;
};
var _default = createCompileableStyle;
exports.default = _default;
module.exports = exports.default;