[fix] shadow style props resolution

This commit is contained in:
Nicolas Gallagher
2018-05-23 13:32:39 -07:00
parent f62ed22a14
commit a40521f485
2 changed files with 9 additions and 9 deletions

View File

@@ -177,11 +177,15 @@ describe('StyleSheet/createReactDOMStyle', () => {
});
test('shadowOffset only', () => {
expect(createReactDOMStyle({ shadowOffset: { width: 1, height: 2 } })).toEqual({});
expect(createReactDOMStyle({ shadowOffset: { width: 1, height: 2 } })).toEqual({
boxShadow: '1px 2px 0px rgba(0,0,0,1.00)'
});
});
test('shadowRadius only', () => {
expect(createReactDOMStyle({ shadowRadius: 5 })).toEqual({});
expect(createReactDOMStyle({ shadowRadius: 5 })).toEqual({
boxShadow: '0px 0px 5px rgba(0,0,0,1.00)'
});
});
test('shadowOffset, shadowRadius, shadowColor', () => {

View File

@@ -89,14 +89,10 @@ const resolveShadow = (resolvedStyle, style) => {
const offsetX = normalizeValue(null, width);
const offsetY = normalizeValue(null, height);
const blurRadius = normalizeValue(null, shadowRadius || 0);
const color = normalizeColor(shadowColor, shadowOpacity);
const color = normalizeColor(shadowColor || 'black', shadowOpacity);
if (color) {
const shadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`;
resolvedStyle.boxShadow = boxShadow ? `${boxShadow}, ${shadow}` : shadow;
} else if (boxShadow) {
resolvedStyle.boxShadow = boxShadow;
}
const shadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`;
resolvedStyle.boxShadow = boxShadow ? `${boxShadow}, ${shadow}` : shadow;
};
/**