diff --git a/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap b/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap index 0739815b..03a95e79 100644 --- a/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +++ b/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap @@ -189,13 +189,13 @@ exports[`Test Banner Components Banner Snapshot 1`] = ` style={ [ { - "fontFamily": "Readex Pro", + "fontFamily": "Titillium Web", "fontSize": 16, "fontStyle": "normal", - "fontWeight": "400", + "fontWeight": "700", }, { - "color": "#0B3EE3", + "color": "#0073E6", }, { "color": undefined, diff --git a/src/components/buttons/ButtonLink.tsx b/src/components/buttons/ButtonLink.tsx index 000f0ac9..1093bc4c 100644 --- a/src/components/buttons/ButtonLink.tsx +++ b/src/components/buttons/ButtonLink.tsx @@ -1,4 +1,4 @@ -import React, { useCallback } from "react"; +import React, { useCallback, useMemo } from "react"; import { GestureResponderEvent, Pressable, StyleSheet } from "react-native"; import Animated, { Extrapolate, @@ -14,14 +14,15 @@ import { IOButtonStyles, IOColors, IOScaleValues, - IOSpringValues + IOSpringValues, + useIOExperimentalDesign } from "../../core"; import { makeFontStyleObject } from "../../utils/fonts"; import { WithTestID } from "../../utils/types"; import { AnimatedIcon, IOIcons, IconClassComponent } from "../icons/Icon"; import { HSpacer } from "../spacer/Spacer"; -type ColorButtonLink = "primary" | "error" | "warning" | "success" | "info"; +type ColorButtonLink = "primary"; export type ButtonLink = WithTestID<{ color?: ColorButtonLink; label: string; @@ -52,32 +53,19 @@ const mapColorStates: Record, ColorStates> = { pressed: IOColors["blueIO-600"], disabled: IOColors["grey-700"] } - }, - error: { - label: { - default: IOColors["error-850"], - pressed: IOColors["error-850"], - disabled: IOColors["grey-700"] - } - }, - warning: { - label: { - default: IOColors["warning-850"], - pressed: IOColors["warning-850"], - disabled: IOColors["grey-700"] - } - }, - success: { - label: { - default: IOColors["success-850"], - pressed: IOColors["success-850"], - disabled: IOColors["grey-700"] - } - }, - info: { + } +}; + +// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153 +const mapLegacyColorStates: Record< + NonNullable, + ColorStates +> = { + // Primary button + primary: { label: { - default: IOColors["info-850"], - pressed: IOColors["info-850"], + default: IOColors.blue, + pressed: IOColors["blue-600"], disabled: IOColors["grey-700"] } } @@ -91,6 +79,14 @@ const IOButtonStylesLocal = StyleSheet.create({ } }); +// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153 +const IOButtonLegacyStylesLocal = StyleSheet.create({ + label: { + fontSize: 16, + ...makeFontStyleObject("Bold", false, "TitilliumWeb") + } +}); + export const ButtonLink = React.memo( ({ color = "primary", @@ -104,6 +100,16 @@ export const ButtonLink = React.memo( testID }: ButtonLink) => { const isPressed = useSharedValue(0); + const { isExperimental } = useIOExperimentalDesign(); + + const colorMap = useMemo( + () => (isExperimental ? mapColorStates : mapLegacyColorStates), + [isExperimental] + ); + const buttonStylesLocal = useMemo( + () => (isExperimental ? IOButtonStylesLocal : IOButtonLegacyStylesLocal), + [isExperimental] + ); // Scaling transformation applied when the button is pressed const animationScaleValue = IOScaleValues?.basicButton?.pressedState; @@ -136,10 +142,7 @@ export const ButtonLink = React.memo( const labelColor = interpolateColor( progressPressed.value, [0, 1], - [ - mapColorStates[color].label.default, - mapColorStates[color].label.pressed - ] + [colorMap[color].label.default, colorMap[color].label.pressed] ); return { @@ -152,10 +155,7 @@ export const ButtonLink = React.memo( const iconColor = interpolateColor( progressPressed.value, [0, 1], - [ - mapColorStates[color].label.default, - mapColorStates[color].label.pressed - ] + [colorMap[color].label.default, colorMap[color].label.pressed] ); return { color: iconColor }; @@ -207,13 +207,13 @@ export const ButtonLink = React.memo( ) : ( )} @@ -222,10 +222,10 @@ export const ButtonLink = React.memo( )} , + ColorStates +> = { + // Primary button + primary: { + border: { + default: IOColors.blue, + pressed: IOColors.blue, + disabled: IOColors.bluegreyLight + }, + background: { + default: hexToRgba(IOColors.blue, 0), + pressed: hexToRgba(IOColors.blue, 0.15), + disabled: "transparent" + }, + label: { + default: IOColors.blue, + pressed: IOColors.blue, + disabled: IOColors.grey + } + }, + // Neutral button + neutral: { + border: { + default: IOColors.grey, + pressed: IOColors.bluegrey, + disabled: IOColors.bluegreyLight + }, + background: { + default: IOColors.white, + pressed: IOColors.greyUltraLight, + disabled: "transparent" + }, + label: { + default: IOColors.bluegrey, + pressed: IOColors.bluegreyDark, + disabled: IOColors.grey + } + }, + // Contrast button + contrast: { + border: { + default: IOColors.white, + pressed: IOColors.white, + disabled: hexToRgba(IOColors.white, 0.5) + }, + background: { + default: hexToRgba(IOColors.white, 0), + pressed: hexToRgba(IOColors.white, 0.2), + disabled: "transparent" + }, + label: { + default: IOColors.white, + pressed: IOColors.white, + disabled: hexToRgba(IOColors.white, 0.5) + } + }, + // Danger button + danger: { + border: { + default: IOColors.red, + pressed: IOColors.red, + disabled: IOColors.bluegreyLight + }, + background: { + default: hexToRgba(IOColors.red, 0), + pressed: hexToRgba(IOColors.red, 0.15), + disabled: "transparent" + }, + label: { + default: IOColors.red, + pressed: IOColors.red, + disabled: IOColors.grey + } + } +}; + +// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153 +const IOButtonLegacyStylesLocal = StyleSheet.create({ + // eslint-disable-next-line react-native/no-unused-styles + label: { + ...makeFontStyleObject("Bold") + }, + // eslint-disable-next-line react-native/no-unused-styles + buttonWithBorder: { + borderWidth: 1 + } +}); + const DISABLED_OPACITY = 0.5; const IOButtonStylesLocal = StyleSheet.create({ + // eslint-disable-next-line react-native/no-unused-styles label: { ...makeFontStyleObject("Regular", false, "ReadexPro") }, + // eslint-disable-next-line react-native/no-unused-styles buttonWithBorder: { borderWidth: 2 } @@ -158,8 +258,23 @@ export const ButtonOutline = ({ accessibilityHint, testID }: ButtonOutline) => { + const { isExperimental } = useIOExperimentalDesign(); const isPressed: Animated.SharedValue = useSharedValue(0); + const colorMap = React.useMemo( + () => (isExperimental ? mapColorStates : mapLegacyColorStates), + [isExperimental] + ); + + const buttonStyles = React.useMemo( + () => (isExperimental ? IOButtonStyles : IOButtonLegacyStyles), + [isExperimental] + ); + + const buttonStylesLocal = React.useMemo( + () => (isExperimental ? IOButtonStylesLocal : IOButtonLegacyStylesLocal), + [isExperimental] + ); // Scaling transformation applied when the button is pressed const animationScaleValue = IOScaleValues?.basicButton?.pressedState; @@ -174,19 +289,13 @@ export const ButtonOutline = ({ const backgroundColor = interpolateColor( progressPressed.value, [0, 1], - [ - mapColorStates[color].background.default, - mapColorStates[color].background.pressed - ] + [colorMap[color].background.default, colorMap[color].background.pressed] ); const borderColor = interpolateColor( progressPressed.value, [0, 1], - [ - mapColorStates[color].border.default, - mapColorStates[color].border.pressed - ] + [colorMap[color].border.default, colorMap[color].border.pressed] ); // Scale down button slightly when pressed @@ -210,10 +319,7 @@ export const ButtonOutline = ({ const labelColor = interpolateColor( progressPressed.value, [0, 1], - [ - mapColorStates[color].border.default, - mapColorStates[color].border.pressed - ] + [colorMap[color].border.default, colorMap[color].border.pressed] ); return { @@ -226,7 +332,7 @@ export const ButtonOutline = ({ const iconColor = interpolateColor( progressPressed.value, [0, 1], - [mapColorStates[color].label.default, mapColorStates[color].label.pressed] + [colorMap[color].label.default, colorMap[color].label.pressed] ); return { color: iconColor }; }); @@ -243,7 +349,10 @@ export const ButtonOutline = ({ isPressed.value = 0; }, [isPressed]); - const Button = () => ( + // Icon size + const iconSize: IOIconSizeScale = small ? 16 : 20; + + return ( ) : ( )} @@ -298,14 +407,12 @@ export const ButtonOutline = ({ )} ); - - return