Skip to content

Commit

Permalink
refactor: correct elevated bg color, elevation const renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewalczak committed Mar 26, 2022
1 parent 2290028 commit 17d618c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,22 @@ const Button = ({
const { roundness, isV3 } = theme;

const isElevationEntitled = isV3 ? isMode('elevated') : isMode('contained');
const containedInitialElevation = theme.isV3 ? 1 : 2;
const containedActiveElevation = theme.isV3 ? 2 : 8;
const initialElevation = theme.isV3 ? 1 : 2;
const activeElevation = theme.isV3 ? 2 : 8;

const { current: elevation } = React.useRef<Animated.Value>(
new Animated.Value(isElevationEntitled ? containedInitialElevation : 0)
new Animated.Value(isElevationEntitled ? initialElevation : 0)
);

React.useEffect(() => {
elevation.setValue(isElevationEntitled ? containedInitialElevation : 0);
}, [isElevationEntitled, elevation, containedInitialElevation]);
elevation.setValue(isElevationEntitled ? initialElevation : 0);
}, [isElevationEntitled, elevation, initialElevation]);

const handlePressIn = () => {
if (isMode('contained')) {
const { scale } = theme.animation;
Animated.timing(elevation, {
toValue: containedActiveElevation,
toValue: activeElevation,
duration: 200 * scale,
useNativeDriver: false,
}).start();
Expand All @@ -172,7 +172,7 @@ const Button = ({
if (isMode('contained')) {
const { scale } = theme.animation;
Animated.timing(elevation, {
toValue: containedInitialElevation,
toValue: initialElevation,
duration: 150 * scale,
useNativeDriver: false,
}).start();
Expand All @@ -181,7 +181,7 @@ const Button = ({

const font = theme.fonts.medium;

const borderRadius = isV3 ? 20 : roundness;
const borderRadius = (isV3 ? 5 : 1) * roundness;
const iconSize = isV3 ? 18 : 16;

const { backgroundColor, borderColor, textColor, borderWidth } =
Expand Down
2 changes: 1 addition & 1 deletion src/components/Button/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const getButtonColors = ({
textColor = buttonColor || theme.colors.primary;
} else if (isMode('elevated')) {
textColor = theme.colors.primary;
backgroundColor = buttonColor || theme.colors.surface;
backgroundColor = buttonColor || theme.colors.elevation.level1;
} else if (isMode('contained')) {
textColor = theme.colors.onPrimary;
backgroundColor = buttonColor || theme.colors.primary;
Expand Down

0 comments on commit 17d618c

Please sign in to comment.