Skip to content

Commit

Permalink
adds the legacy variant for colorMap specs
Browse files Browse the repository at this point in the history
  • Loading branch information
CrisTofani committed Nov 6, 2023
1 parent 3bd5bba commit d684d67
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/components/numberpad/NumberButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
IOColors,
IONumberPadButtonStyles,
IOScaleValues,
IOSpringValues
IOSpringValues,
useIOExperimentalDesign
} from "../../core";
import { H3 } from "../typography";

Expand Down Expand Up @@ -44,12 +45,30 @@ const colorMap: Record<NumberButtonVariantType, ColorMapVariant> = {
}
};

const legacyColorMap: Record<NumberButtonVariantType, ColorMapVariant> = {
light: {
background: "grey-50",
pressed: "grey-200",
foreground: "blue"
},
dark: {
background: "blue",
pressed: "blue-600",
foreground: "white"
}
};

export const NumberButton = ({
number,
variant,
onPress
}: NumberButtonProps) => {
const colors = useMemo(() => colorMap[variant], [variant]);
const { isExperimental } = useIOExperimentalDesign();

const colors = useMemo(
() => (isExperimental ? colorMap[variant] : legacyColorMap[variant]),
[variant, isExperimental]
);
const isPressed = useSharedValue(0);
// Scaling transformation applied when the button is pressed
const animationScaleValue = IOScaleValues?.basicButton?.pressedState;
Expand Down

0 comments on commit d684d67

Please sign in to comment.