Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
label?: React.ReactNode;
/**
* Size and position of the banner
*/
variant?: BannerVariant;
/**
* Color of the banner based on the type of the error
*/
error?: ErrorType;
/**
* Text on the right, call to action
*/
actionText?: string;
}
const BannerWrapper = styled('button')(
{
...type.body2,
backgroundColor: colors.cantaloupe400,
boxSizing: 'border-box',
color: colors.blackPepper400,
fontSize: 14,
fontWeight: 500,
padding: `${spacing.xxs} ${spacing.s}`,
textAlign: 'left',
border: 0,
display: 'flex',
alignItems: 'center',
transition: 'background-color 120ms',
'&:focus': {
outline: 'none',
...focusRing(2, 2),
width: variant === BannerVariant.Sticky ? '222px' : '328px',
'&:hover': {
backgroundColor: error === ErrorType.Error ? colors.cinnamon600 : colors.cantaloupe500,
},
})
);
const BannerIcon = styled(SystemIcon)({
marginRight: spacing.xs,
});
const BannerLabel = styled('div')({
flex: 1,
});
const BannerViewAll = styled('span')(
{
textDecoration: 'underline',
},
({variant}) => ({
display: variant === BannerVariant.Sticky ? 'none' : undefined,
})
);
export default class Banner extends React.Component {
static Variant = BannerVariant;
static ErrorType = ErrorType;
public static defaultProps = {
actionText: 'View All',
error: ErrorType.Alert,
variant: BannerVariant.Full,
cursor: 'pointer',
},
},
({error, variant}) => ({
backgroundColor: error === ErrorType.Error ? colors.cinnamon500 : colors.cantaloupe400,
color: error === ErrorType.Error ? colors.frenchVanilla100 : colors.blackPepper400,
borderRadius:
variant === BannerVariant.Sticky ? `${borderRadius.m} 0 0 ${borderRadius.m}` : borderRadius.m,
width: variant === BannerVariant.Sticky ? '222px' : '328px',
'&:hover': {
backgroundColor: error === ErrorType.Error ? colors.cinnamon600 : colors.cantaloupe500,
},
})
);
const BannerIcon = styled(SystemIcon)({
marginRight: spacing.xs,
});
const BannerLabel = styled('div')({
flex: 1,
});
const BannerViewAll = styled('span')(
{
textDecoration: 'underline',
},
({variant}) => ({
display: variant === BannerVariant.Sticky ? 'none' : undefined,
})
);
backgroundColor: error === ErrorType.Error ? colors.cinnamon500 : colors.cantaloupe400,
color: error === ErrorType.Error ? colors.frenchVanilla100 : colors.blackPepper400,
borderRadius:
variant === BannerVariant.Sticky ? `${borderRadius.m} 0 0 ${borderRadius.m}` : borderRadius.m,
width: variant === BannerVariant.Sticky ? '222px' : '328px',
'&:hover': {
backgroundColor: error === ErrorType.Error ? colors.cinnamon600 : colors.cantaloupe500,
},
})
);
const BannerIcon = styled(SystemIcon)({
marginRight: spacing.xs,
});
const BannerLabel = styled('div')({
flex: 1,
});
const BannerViewAll = styled('span')(
{
textDecoration: 'underline',
},
({variant}) => ({
display: variant === BannerVariant.Sticky ? 'none' : undefined,
})
);
export default class Banner extends React.Component {
static Variant = BannerVariant;
static ErrorType = ErrorType;
export interface MenuItemProps extends React.LiHTMLAttributes {
onClick?: (event: React.SyntheticEvent) => void;
children?: React.ReactNode;
id?: string;
icon?: CanvasSystemIcon;
secondaryIcon?: CanvasSystemIcon;
hasDivider?: boolean;
isDisabled?: boolean;
isFocused?: boolean;
role: string;
shouldClose?: boolean;
}
const Item = styled('li')>(
{
...type.body2,
padding: `${spacing.xxs} ${spacing.s}`,
height: spacing.xl,
boxSizing: 'border-box',
cursor: 'pointer',
color: colors.blackPepper300,
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
transition: 'background-color 80ms, color 80ms',
'&:focus': {
outline: 'none',
},
},
({isFocused, isDisabled}) => {
if (!isFocused && !isDisabled) {
return {