-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[material-ui] Fix getOverlayAlpha type (#41995)
- Loading branch information
1 parent
59bf4fc
commit bfeb493
Showing
2 changed files
with
4 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
// Inspired by https://github.com/material-components/material-components-ios/blob/bca36107405594d5b7b16265a5b0ed698f85a5ee/components/Elevation/src/UIColor%2BMaterialElevation.m#L61 | ||
const getOverlayAlpha = (elevation: number) => { | ||
export default function getOverlayAlpha(elevation: number): number { | ||
let alphaValue; | ||
if (elevation < 1) { | ||
alphaValue = 5.11916 * elevation ** 2; | ||
} else { | ||
alphaValue = 4.5 * Math.log(elevation + 1) + 2; | ||
} | ||
return (alphaValue / 100).toFixed(2); | ||
}; | ||
|
||
export default getOverlayAlpha; | ||
return Math.round(alphaValue * 10) / 1000; | ||
} |