Some checks failed
CI/CD Pipeline / unit-tests (push) Failing after 1m16s
CI/CD Pipeline / integration-tests (push) Failing after 2m32s
CI/CD Pipeline / lint (push) Successful in 5m22s
CI/CD Pipeline / e2e-tests (push) Has been skipped
CI/CD Pipeline / build (push) Has been skipped
11 lines
447 B
JavaScript
11 lines
447 B
JavaScript
// Inspired by https://github.com/material-components/material-components-ios/blob/bca36107405594d5b7b16265a5b0ed698f85a5ee/components/Elevation/src/UIColor%2BMaterialElevation.m#L61
|
|
const getOverlayAlpha = elevation => {
|
|
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; |