Skip to content

Bugfix/box shadow #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 4, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
box-shadow transform: always set shadowOpacity to 1
  • Loading branch information
kristerkari committed Feb 4, 2018
commit fad10399fb9ef4f9da6fa796427ff11266d2b389
8 changes: 8 additions & 0 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ it('transforms box-shadow into shadow- properties', () => runTest([
shadowOffset: { width: 10, height: 20 },
shadowRadius: 30,
shadowColor: 'red',
shadowOpacity: 1,
}));

it('transforms box-shadow without blur-radius', () => runTest([
Expand All @@ -472,6 +473,7 @@ it('transforms box-shadow without blur-radius', () => runTest([
shadowOffset: { width: 10, height: 20 },
shadowRadius: 0,
shadowColor: 'red',
shadowOpacity: 1,
}));

it('transforms box-shadow without color', () => runTest([
Expand All @@ -480,6 +482,7 @@ it('transforms box-shadow without color', () => runTest([
shadowOffset: { width: 10, height: 20 },
shadowRadius: 30,
shadowColor: 'black',
shadowOpacity: 1,
}));

it('transforms box-shadow without blur-radius, color', () => runTest([
Expand All @@ -488,6 +491,7 @@ it('transforms box-shadow without blur-radius, color', () => runTest([
shadowOffset: { width: 10, height: 20 },
shadowRadius: 0,
shadowColor: 'black',
shadowOpacity: 1,
}));

it('transforms box-shadow with rgb color', () => runTest([
Expand All @@ -496,6 +500,7 @@ it('transforms box-shadow with rgb color', () => runTest([
shadowOffset: { width: 10, height: 20 },
shadowRadius: 0,
shadowColor: 'rgb(100, 100, 100)',
shadowOpacity: 1,
}));

it('transforms box-shadow with rgba color', () => runTest([
Expand All @@ -504,6 +509,7 @@ it('transforms box-shadow with rgba color', () => runTest([
shadowOffset: { width: 10, height: 20 },
shadowRadius: 0,
shadowColor: 'rgba(100, 100, 100, 0.5)',
shadowOpacity: 1,
}));

it('transforms box-shadow with hsl color', () => runTest([
Expand All @@ -512,6 +518,7 @@ it('transforms box-shadow with hsl color', () => runTest([
shadowOffset: { width: 10, height: 20 },
shadowRadius: 0,
shadowColor: 'hsl(120, 100%, 50%)',
shadowOpacity: 1,
}));

it('transforms box-shadow with hsla color', () => runTest([
Expand All @@ -520,6 +527,7 @@ it('transforms box-shadow with hsla color', () => runTest([
shadowOffset: { width: 10, height: 20 },
shadowRadius: 0,
shadowColor: 'hsla(120, 100%, 50%, 0.7)',
shadowOpacity: 1,
}));

it('transforms box-shadow enforces offset to be present', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/transforms/boxShadow.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = (tokenStream) => {
if (tokenStream.matches(NONE)) {
tokenStream.expectEmpty();
return {
$merge: { shadowOffset: { width: 0, height: 0 }, shadowRadius: 0, shadowColor: 'black' },
$merge: { shadowOffset: { width: 0, height: 0 }, shadowRadius: 0, shadowColor: 'black', shadowOpacity: 1 },
};
}

Expand Down Expand Up @@ -43,6 +43,7 @@ module.exports = (tokenStream) => {
shadowOffset: { width: offsetX, height: offsetY },
shadowRadius: blurRadius !== undefined ? blurRadius : 0,
shadowColor: color !== undefined ? color : 'black',
shadowOpacity: 1,
};
return { $merge };
};