Skip to content

Commit

Permalink
[material-ui] Fix getOverlayAlpha type (#41995)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Apr 23, 2024
1 parent 59bf4fc commit bfeb493
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ describe('experimental_extendTheme', () => {

expect(theme.colorSchemes.dark.overlays[0]).to.equal(undefined);
expect(theme.colorSchemes.dark.overlays[24]).to.equal(
'linear-gradient(rgba(255 255 255 / 0.16), rgba(255 255 255 / 0.16))',
'linear-gradient(rgba(255 255 255 / 0.165), rgba(255 255 255 / 0.165))',
);
});

Expand Down
8 changes: 3 additions & 5 deletions packages/mui-material/src/styles/getOverlayAlpha.ts
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;
}

0 comments on commit bfeb493

Please sign in to comment.