Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 43 additions & 39 deletions src/components/Banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,53 +45,57 @@ const defaultProps = {
shouldRenderHTML: false,
shouldShowIcon: false,
shouldShowCloseButton: false,
onClose: () => {},
onPress: () => {},
onClose: undefined,
onPress: undefined,
Comment thread
arosiclair marked this conversation as resolved.
containerStyles: [],
textStyles: [],
};

const Banner = props => (
<Hoverable>
{isHovered => (
<View style={[
styles.flexRow,
styles.alignItemsCenter,
styles.p5,
styles.borderRadiusNormal,
isHovered ? styles.activeComponentBG : styles.hoveredComponentBG,
styles.breakAll,
...props.containerStyles,
]}
>
<View style={[styles.flexRow, styles.flexGrow1, styles.mw100, styles.alignItemsCenter]}>
{props.shouldShowIcon && (
<View style={[styles.mr3]}>
<Icon
src={Expensicons.Exclamation}
fill={StyleUtils.getIconFillColor(getButtonState(isHovered))}
/>
</View>
{(isHovered) => {
const isClickable = props.onClose || props.onPress;
const shouldHighlight = isClickable && isHovered;
return (
<View style={[
styles.flexRow,
styles.alignItemsCenter,
styles.p5,
styles.borderRadiusNormal,
shouldHighlight ? styles.activeComponentBG : styles.hoveredComponentBG,
styles.breakAll,
...props.containerStyles,
]}
>
<View style={[styles.flexRow, styles.flexGrow1, styles.mw100, styles.alignItemsCenter]}>
{props.shouldShowIcon && (
<View style={[styles.mr3]}>
<Icon
src={Expensicons.Exclamation}
fill={StyleUtils.getIconFillColor(getButtonState(shouldHighlight))}
/>
</View>
)}
{
props.shouldRenderHTML
? <RenderHTML html={props.text} />
: <Text style={[...props.textStyles]} onPress={props.onPress}>{props.text}</Text>
}
</View>
{props.shouldShowCloseButton && (
<Tooltip text={props.translate('common.close')}>
<Pressable
onPress={props.onClose}
accessibilityRole="button"
accessibilityLabel={props.translate('common.close')}
>
<Icon src={Expensicons.Close} />
</Pressable>
</Tooltip>
)}
{
props.shouldRenderHTML
? <RenderHTML html={props.text} />
: <Text style={[...props.textStyles]} onPress={props.onPress}>{props.text}</Text>
}
</View>
{props.shouldShowCloseButton && (
<Tooltip text={props.translate('common.close')}>
<Pressable
onPress={props.onClose}
accessibilityRole="button"
accessibilityLabel={props.translate('common.close')}
>
<Icon src={Expensicons.Close} />
</Pressable>
</Tooltip>
)}
</View>
)}
);
}}
</Hoverable>
);

Expand Down