Skip to content

Commit

Permalink
correcciones - componente toast
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Morales committed Jun 27, 2024
1 parent 235e16a commit 75321d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions src/components/Toast/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import Text from '../Text';
const props1 = {
showIcon: true,
customIcon: 'iso_janis',
showClose: true,
link: 'Open',
showCloseIcon: true,
actionTitle: 'Open',
iconStyle: {color: 'red'},
};

const props2 = {
...props1,
onCloseCb: jest.fn(),
linkCb: jest.fn(),
actionCb: jest.fn(),
};

const validProps = {
Expand Down Expand Up @@ -68,8 +68,8 @@ describe('Toast', () => {
props={props1}
/>
);
const [link, close] = root.findAllByType(TouchableOpacity);
const {onPress: linkOnPress} = link.props;
const [actionTitle, close] = root.findAllByType(TouchableOpacity);
const {onPress: linkOnPress} = actionTitle.props;
const {onPress: closeOnPress} = close.props;
linkOnPress();
closeOnPress();
Expand Down
22 changes: 11 additions & 11 deletions src/components/Toast/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export interface ToastProps extends BaseToastProps {
props?: {
showIcon?: boolean;
customIcon?: string;
showClose?: boolean;
link?: string;
showCloseIcon?: boolean;
actionTitle?: string;
onCloseCb?: () => void;
linkCb?: () => void;
actionCb?: () => void;
iconStyle?: TextStyle;
};
}
Expand All @@ -32,10 +32,10 @@ const Toast: FC<ToastProps> = ({type, text1, text2, style, props}) => {
const {
showIcon = false,
customIcon = null,
showClose = false,
link = null,
showCloseIcon = false,
actionTitle = null,
onCloseCb = () => {},
linkCb = () => {},
actionCb = () => {},
iconStyle = {},
} = props || {};

Expand Down Expand Up @@ -82,7 +82,7 @@ const Toast: FC<ToastProps> = ({type, text1, text2, style, props}) => {
closeIcon: {
paddingLeft: scaledForDevice(10, moderateScale),
},
link: {
actionTitle: {
marginRight: scaledForDevice(5, moderateScale),
marginLeft: scaledForDevice(10, moderateScale),
fontFamily: 'Roboto-Medium',
Expand All @@ -108,12 +108,12 @@ const Toast: FC<ToastProps> = ({type, text1, text2, style, props}) => {
</View>

<View style={styles.feedbackWrapper}>
{link && (
<TouchableOpacity onPress={linkCb} activeOpacity={0.6}>
<Text style={styles.link}>{link}</Text>
{actionTitle && (
<TouchableOpacity onPress={actionCb} activeOpacity={0.6}>
<Text style={styles.actionTitle}>{actionTitle}</Text>
</TouchableOpacity>
)}
{showClose && (
{showCloseIcon && (
<TouchableOpacity onPress={onCloseCb} activeOpacity={0.6}>
<Icon name="cross_light" color={validColor} size={24} style={styles.closeIcon} />
</TouchableOpacity>
Expand Down
10 changes: 5 additions & 5 deletions storybook/stories/Toast/Toast.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default {
Janis: 'iso_janis',
},
},
link: {
actionTitle: {
control: {type: 'select'},
options: {
None: null,
Expand Down Expand Up @@ -51,10 +51,10 @@ export const DefaultProps = (props) => (
text2: props.text2,
autoHide: props.autoHide,
props: {
link: props.link,
actionTitle: props.actionTitle,
showIcon: props.showIcon,
customIcon: props.customIcon,
showClose: props.showClose,
showCloseIcon: props.showCloseIcon,
iconStyle: props.iconStyle,
onCloseCb: Toast.hide,
},
Expand All @@ -72,8 +72,8 @@ DefaultProps.args = {
'Lorem ipsum dolor sit amet, consectetur adipiscingsed ipsum dolorrrrdfds ipsum dolor sit amet.',
autoHide: true,
showIcon: true,
showClose: true,
showCloseIcon: true,
customIcon: null,
link: null,
actionTitle: null,
iconStyle: {},
};

0 comments on commit 75321d9

Please sign in to comment.