Skip to content
This repository was archived by the owner on Apr 7, 2020. It is now read-only.

Commit

Permalink
Fix(elevation): Fix depth
Browse files Browse the repository at this point in the history
Fixes the function to add elevation depth, which was
broken by eslint.
  • Loading branch information
martahj committed Aug 7, 2018
1 parent 4ff222c commit 1212c1f
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/mixins/elevation.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,12 @@ export const elevationTransition = css`
cubic-bezier(0.4, 0, 0.2, 1);
`;

// helper to generate box shadow setting
const addDepth = (
type: "ambient" | "penumbra" | "umbra",
z: number
): string => css`
${props => {
const lastValidDepth = depth[type].length - 1;
let effectiveZ = z;
if (lastValidDepth < z) {
// eslint-disable-next-line no-console
console.warn(
`${type} of depth ${z} is invalid and will resolve to the maximum value of ${lastValidDepth}`
);
effectiveZ = lastValidDepth;
}
return `${depth[type][effectiveZ]} ${props.theme.elevation.colors[type]}`;
}};
// prettier wants to add a semicolon inside the css, which causes it to not work
/* eslint-disable prettier/prettier */
const addDepth = (type: "ambient" | "penumbra" | "umbra", z: number) => css`
${props => `${depth[type][z]} ${props.theme.elevation.colors[type]}`}
`;
/* eslint-enable */

const elevationMixin = (z: number): string => css`
${props => props.theme.elevation.property}: ${addDepth("umbra", z)},
Expand Down

0 comments on commit 1212c1f

Please sign in to comment.